From 013efd4c8714bcc6912e1bd347f2220c35d884a8 Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Mon, 4 Jun 2018 15:30:52 +0100 Subject: [PATCH] Add test vectors for the first 4 Pedersen hash generators. Signed-off-by: Daira Hopwood --- sapling_generators.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sapling_generators.py b/sapling_generators.py index f002c25..1dc7e50 100644 --- a/sapling_generators.py +++ b/sapling_generators.py @@ -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]), }, )