Move chunk() into tv_output module

This commit is contained in:
Jack Grigg 2018-06-05 16:10:43 +12:00
parent 9edd16e17a
commit 7e37b8cc24
No known key found for this signature in database
GPG Key ID: 1B8D649257DB0829
5 changed files with 8 additions and 7 deletions

View File

@ -3,7 +3,7 @@ from binascii import hexlify
from pyblake2 import blake2s
from sapling_jubjub import Point, JUBJUB_COFACTOR
from sapling_utils import chunk
from tv_output import chunk
# First 64 bytes of the BLAKE2s input during group hash.
# This is chosen to be some random string that we couldn't have

View File

@ -6,7 +6,8 @@ from sapling_generators import PROVING_KEY_BASE, SPENDING_KEY_BASE, group_hash
from sapling_jubjub import Fr
from sapling_merkle_tree import MERKLE_DEPTH
from sapling_notes import note_commit, note_nullifier
from sapling_utils import chunk, leos2bsp, leos2ip
from sapling_utils import leos2bsp, leos2ip
from tv_output import chunk
#
# Utilities

View File

@ -6,7 +6,8 @@ from pyblake2 import blake2b
from sapling_generators import SPENDING_KEY_BASE
from sapling_jubjub import Fr, Point, r_j
from sapling_key_components import to_scalar
from sapling_utils import cldiv, chunk, leos2ip
from sapling_utils import cldiv, leos2ip
from tv_output import chunk
def H(x):

View File

@ -3,10 +3,6 @@
def cldiv(n, divisor):
return (n + (divisor - 1)) // divisor
def chunk(h):
h = str(h, 'utf-8')
return '0x' + ', 0x'.join([h[i:i+2] for i in range(0, len(h), 2)])
def i2lebsp(l, x):
return [int(c) for c in format(x, '0%sb' % l)[::-1]]

3
tv_output.py Normal file
View File

@ -0,0 +1,3 @@
def chunk(h):
h = str(h, 'utf-8')
return '0x' + ', 0x'.join([h[i:i+2] for i in range(0, len(h), 2)])