Add Orchard generators
This commit is contained in:
parent
03157edaf2
commit
43de24d88c
|
@ -0,0 +1,61 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import sys; assert sys.version_info[0] >= 3, "Python 3 required."
|
||||||
|
|
||||||
|
from pyblake2 import blake2s
|
||||||
|
|
||||||
|
from tv_output import render_args, render_tv
|
||||||
|
from orchard_group_hash import group_hash
|
||||||
|
from orchard_sinsemilla import sinsemilla_hash_to_point
|
||||||
|
|
||||||
|
# https://zips.z.cash/protocol/nu5.pdf#concretespendauthsig
|
||||||
|
SPENDING_KEY_BASE = group_hash(b'z.cash:Orchard', b'G')
|
||||||
|
|
||||||
|
# https://zips.z.cash/protocol/nu5.pdf#commitmentsandnullifiers
|
||||||
|
NULLIFIER_K_BASE = group_hash(b'z.cash:Orchard', b'K')
|
||||||
|
|
||||||
|
# https://zips.z.cash/protocol/nu5.pdf#concretehomomorphiccommit
|
||||||
|
VALUE_COMMITMENT_VALUE_BASE = group_hash(b'z.cash:Orchard-cv', b'v')
|
||||||
|
VALUE_COMMITMENT_RANDOMNESS_BASE = group_hash(b'z.cash:Orchard-cv', b'r')
|
||||||
|
|
||||||
|
# Used in SinsemillaCommit (https://zips.z.cash/protocol/nu5.pdf#sinsemillacommitments)
|
||||||
|
NOTE_COMMITMENT_BASE = group_hash(b'z.cash:Orchard-NoteCommit-r', b'')
|
||||||
|
NOTE_COMMITMENT_Q = group_hash(b'z.cash:Orchard-NoteCommit-M', b'')
|
||||||
|
|
||||||
|
# Used in SinsemillaShortCommit (https://zips.z.cash/protocol/nu5.pdf#sinsemillacommitments)
|
||||||
|
IVK_COMMITMENT_BASE = group_hash(b'z.cash:Orchard-CommitIvk-r', b'')
|
||||||
|
IVK_COMMITMENT_Q = group_hash(b'z.cash:Orchard-CommitIvk-M', b'')
|
||||||
|
|
||||||
|
# Used in SinsemillaHash (https://zips.z.cash/protocol/nu5.pdf#orchardmerklecrh)
|
||||||
|
MERKLE_CRH_Q = group_hash(b'z.cash:Orchard-MerkleCRH', b'')
|
||||||
|
|
||||||
|
def main():
|
||||||
|
render_tv(
|
||||||
|
render_args(),
|
||||||
|
'orchard_generators',
|
||||||
|
(
|
||||||
|
('skb', '[u8; 32]'),
|
||||||
|
('nkb', '[u8; 32]'),
|
||||||
|
('vcvb', '[u8; 32]'),
|
||||||
|
('vcrb', '[u8; 32]'),
|
||||||
|
('cmb', '[u8; 32]'),
|
||||||
|
('cmq', '[u8; 32]'),
|
||||||
|
('ivkb', '[u8; 32]'),
|
||||||
|
('ivkq', '[u8; 32]'),
|
||||||
|
('mcq', '[u8; 32]'),
|
||||||
|
),
|
||||||
|
{
|
||||||
|
'skb': bytes(SPENDING_KEY_BASE),
|
||||||
|
'nkb': bytes(NULLIFIER_K_BASE),
|
||||||
|
'vcvb': bytes(VALUE_COMMITMENT_VALUE_BASE),
|
||||||
|
'vcrb': bytes(VALUE_COMMITMENT_RANDOMNESS_BASE),
|
||||||
|
'cmb': bytes(NOTE_COMMITMENT_BASE),
|
||||||
|
'cmq': bytes(NOTE_COMMITMENT_Q),
|
||||||
|
'ivkb': bytes(IVK_COMMITMENT_BASE),
|
||||||
|
'ivkq': bytes(IVK_COMMITMENT_Q),
|
||||||
|
'mcq': bytes(MERKLE_CRH_Q),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Loading…
Reference in New Issue