From 63a1e76fb96ea14042669675c5cf4bb411d78c74 Mon Sep 17 00:00:00 2001 From: therealyingtong Date: Mon, 10 May 2021 12:11:27 +0800 Subject: [PATCH] Add orchard_utils.py --- orchard_key_components.py | 14 ++------------ orchard_utils.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 orchard_utils.py diff --git a/orchard_key_components.py b/orchard_key_components.py index 36c10f6..c31da05 100644 --- a/orchard_key_components.py +++ b/orchard_key_components.py @@ -8,20 +8,10 @@ from orchard_generators import NULLIFIER_K_BASE, SPENDING_KEY_BASE, group_hash from orchard_pallas import Fp, Scalar, Point from orchard_poseidon_hash import poseidon_hash from orchard_commitments import commit_ivk, note_commit -from utils import leos2bsp, leos2ip, i2leosp, i2lebsp, lebs2osp +from utils import leos2bsp, i2leosp, i2lebsp, lebs2osp +from orchard_utils import to_base, to_scalar from tv_output import render_args, render_tv -# -# Utilities -# - -def to_scalar(buf): - return Scalar(leos2ip(buf)) - -def to_base(buf): - return Fp(leos2ip(buf)) - - # # PRFs and hashes # diff --git a/orchard_utils.py b/orchard_utils.py new file mode 100644 index 0000000..af8be00 --- /dev/null +++ b/orchard_utils.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 +import sys; assert sys.version_info[0] >= 3, "Python 3 required." + +from orchard_pallas import Fp, Scalar +from utils import leos2ip + +# +# Utilities +# + +def to_scalar(buf): + return Scalar(leos2ip(buf)) + +def to_base(buf): + return Fp(leos2ip(buf))