Add test vectors for the first 4 Pedersen hash generators.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2018-06-04 15:30:52 +01:00
parent 4806d8494b
commit 013efd4c87
1 changed files with 12 additions and 0 deletions

View File

@ -3,6 +3,7 @@ from pyblake2 import blake2s
from sapling_jubjub import Point, JUBJUB_COFACTOR
from tv_output import render_args, render_tv
from sapling_utils import i2leosp
# First 64 bytes of the BLAKE2s input during group hash.
# This is chosen to be some random string that we couldn't have
@ -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_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():
render_tv(
@ -60,6 +64,10 @@ def main():
('wprb', '[u8; 32]'),
('vcvb', '[u8; 32]'),
('vcrb', '[u8; 32]'),
('pb0', '[u8; 32]'),
('pb1', '[u8; 32]'),
('pb2', '[u8; 32]'),
('pb3', '[u8; 32]'),
),
{
'skb': bytes(SPENDING_KEY_BASE),
@ -68,6 +76,10 @@ def main():
'wprb': bytes(WINDOWED_PEDERSEN_RANDOMNESS_BASE),
'vcvb': bytes(VALUE_COMMITMENT_VALUE_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]),
},
)