Move chunk() into tv_output module
This commit is contained in:
parent
9edd16e17a
commit
7e37b8cc24
|
@ -3,7 +3,7 @@ from binascii import hexlify
|
||||||
from pyblake2 import blake2s
|
from pyblake2 import blake2s
|
||||||
|
|
||||||
from sapling_jubjub import Point, JUBJUB_COFACTOR
|
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.
|
# First 64 bytes of the BLAKE2s input during group hash.
|
||||||
# This is chosen to be some random string that we couldn't have
|
# This is chosen to be some random string that we couldn't have
|
||||||
|
|
|
@ -6,7 +6,8 @@ from sapling_generators import PROVING_KEY_BASE, SPENDING_KEY_BASE, group_hash
|
||||||
from sapling_jubjub import Fr
|
from sapling_jubjub import Fr
|
||||||
from sapling_merkle_tree import MERKLE_DEPTH
|
from sapling_merkle_tree import MERKLE_DEPTH
|
||||||
from sapling_notes import note_commit, note_nullifier
|
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
|
# Utilities
|
||||||
|
|
|
@ -6,7 +6,8 @@ from pyblake2 import blake2b
|
||||||
from sapling_generators import SPENDING_KEY_BASE
|
from sapling_generators import SPENDING_KEY_BASE
|
||||||
from sapling_jubjub import Fr, Point, r_j
|
from sapling_jubjub import Fr, Point, r_j
|
||||||
from sapling_key_components import to_scalar
|
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):
|
def H(x):
|
||||||
|
|
|
@ -3,10 +3,6 @@
|
||||||
def cldiv(n, divisor):
|
def cldiv(n, divisor):
|
||||||
return (n + (divisor - 1)) // 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):
|
def i2lebsp(l, x):
|
||||||
return [int(c) for c in format(x, '0%sb' % l)[::-1]]
|
return [int(c) for c in format(x, '0%sb' % l)[::-1]]
|
||||||
|
|
||||||
|
|
|
@ -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)])
|
Loading…
Reference in New Issue