Merge pull request #6 from daira/daira-misc-improvements
Additions to .gitignore; rename CRS to URS; add test vectors for Pedersen generators
This commit is contained in:
commit
cbdb16ed55
|
@ -1 +1,8 @@
|
||||||
env
|
env/
|
||||||
|
__pycache__/
|
||||||
|
|
||||||
|
.*.swp
|
||||||
|
*.*~*
|
||||||
|
*.bak
|
||||||
|
*.pyc
|
||||||
|
*.pyo
|
||||||
|
|
|
@ -3,12 +3,13 @@ from pyblake2 import blake2s
|
||||||
|
|
||||||
from sapling_jubjub import Point, JUBJUB_COFACTOR
|
from sapling_jubjub import Point, JUBJUB_COFACTOR
|
||||||
from tv_output import render_args, render_tv
|
from tv_output import render_args, render_tv
|
||||||
|
from sapling_utils import i2leosp
|
||||||
|
|
||||||
# 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
|
||||||
# anticipated when we designed the algorithm, for rigidity purposes.
|
# anticipated when we designed the algorithm, for rigidity purposes.
|
||||||
# We deliberately use an ASCII hex string of 32 bytes here.
|
# We deliberately use an ASCII hex string of 32 bytes here.
|
||||||
CRS = b'096b36a5804bfacef1691e173c366a47ff5ba84a44f26ddd7e8d9f79d5b42df0'
|
URS = b'096b36a5804bfacef1691e173c366a47ff5ba84a44f26ddd7e8d9f79d5b42df0'
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -17,7 +18,7 @@ CRS = b'096b36a5804bfacef1691e173c366a47ff5ba84a44f26ddd7e8d9f79d5b42df0'
|
||||||
|
|
||||||
def group_hash(D, M):
|
def group_hash(D, M):
|
||||||
digest = blake2s(person=D)
|
digest = blake2s(person=D)
|
||||||
digest.update(CRS)
|
digest.update(URS)
|
||||||
digest.update(M)
|
digest.update(M)
|
||||||
p = Point.from_bytes(digest.digest())
|
p = Point.from_bytes(digest.digest())
|
||||||
if not p:
|
if not p:
|
||||||
|
@ -48,6 +49,9 @@ WINDOWED_PEDERSEN_RANDOMNESS_BASE = find_group_hash(b'Zcash_PH', b'r')
|
||||||
VALUE_COMMITMENT_VALUE_BASE = find_group_hash(b'Zcash_cv', b'v')
|
VALUE_COMMITMENT_VALUE_BASE = find_group_hash(b'Zcash_cv', b'v')
|
||||||
VALUE_COMMITMENT_RANDOMNESS_BASE = find_group_hash(b'Zcash_cv', b'r')
|
VALUE_COMMITMENT_RANDOMNESS_BASE = find_group_hash(b'Zcash_cv', b'r')
|
||||||
|
|
||||||
|
required_bases = 4
|
||||||
|
PEDERSEN_BASES = [find_group_hash(b'Zcash_PH', i2leosp(32, iminus1))
|
||||||
|
for iminus1 in range(0, required_bases)]
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
render_tv(
|
render_tv(
|
||||||
|
@ -60,6 +64,10 @@ def main():
|
||||||
('wprb', '[u8; 32]'),
|
('wprb', '[u8; 32]'),
|
||||||
('vcvb', '[u8; 32]'),
|
('vcvb', '[u8; 32]'),
|
||||||
('vcrb', '[u8; 32]'),
|
('vcrb', '[u8; 32]'),
|
||||||
|
('pb0', '[u8; 32]'),
|
||||||
|
('pb1', '[u8; 32]'),
|
||||||
|
('pb2', '[u8; 32]'),
|
||||||
|
('pb3', '[u8; 32]'),
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
'skb': bytes(SPENDING_KEY_BASE),
|
'skb': bytes(SPENDING_KEY_BASE),
|
||||||
|
@ -68,6 +76,10 @@ def main():
|
||||||
'wprb': bytes(WINDOWED_PEDERSEN_RANDOMNESS_BASE),
|
'wprb': bytes(WINDOWED_PEDERSEN_RANDOMNESS_BASE),
|
||||||
'vcvb': bytes(VALUE_COMMITMENT_VALUE_BASE),
|
'vcvb': bytes(VALUE_COMMITMENT_VALUE_BASE),
|
||||||
'vcrb': bytes(VALUE_COMMITMENT_RANDOMNESS_BASE),
|
'vcrb': bytes(VALUE_COMMITMENT_RANDOMNESS_BASE),
|
||||||
|
'pb0': bytes(PEDERSEN_BASES[0]),
|
||||||
|
'pb1': bytes(PEDERSEN_BASES[1]),
|
||||||
|
'pb2': bytes(PEDERSEN_BASES[2]),
|
||||||
|
'pb3': bytes(PEDERSEN_BASES[3]),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ import json
|
||||||
|
|
||||||
|
|
||||||
def chunk(h):
|
def chunk(h):
|
||||||
h = str(h, 'utf-8')
|
hstr = str(h, 'utf-8')
|
||||||
return '0x' + ', 0x'.join([h[i:i+2] for i in range(0, len(h), 2)])
|
return '0x' + ', 0x'.join([hstr[i:i+2] for i in range(0, len(hstr), 2)])
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue