Generate test vectors for Sapling generators

This commit is contained in:
Jack Grigg 2018-05-18 18:28:00 +12:00
parent 6786564447
commit fb07e639b9
1 changed files with 46 additions and 0 deletions

View File

@ -1,7 +1,9 @@
#!/usr/bin/env python3
from binascii import hexlify
from pyblake2 import blake2s
from sapling_jubjub import Point, JUBJUB_COFACTOR
from sapling_utils 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
@ -46,3 +48,47 @@ NOTE_POSITION_BASE = find_group_hash(b'Zcash_J_', b'')
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')
def main():
print('''
struct SaplingGenerators {
skb: [u8; 32],
pkb: [u8; 32],
npb: [u8; 32],
wprb: [u8; 32],
vcvb: [u8; 32],
vcrb: [u8; 32],
};
let sapling_generators = SaplingGenerators {
skb: [
%s
],
pkb: [
%s
],
npb: [
%s
],
wprb: [
%s
],
vcvb: [
%s
],
vcrb: [
%s
],
};''' % (
chunk(hexlify(bytes(SPENDING_KEY_BASE))),
chunk(hexlify(bytes(PROVING_KEY_BASE))),
chunk(hexlify(bytes(NOTE_POSITION_BASE))),
chunk(hexlify(bytes(WINDOWED_PEDERSEN_RANDOMNESS_BASE))),
chunk(hexlify(bytes(VALUE_COMMITMENT_VALUE_BASE))),
chunk(hexlify(bytes(VALUE_COMMITMENT_RANDOMNESS_BASE))),
))
if __name__ == '__main__':
main()