Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vector generation for bundle commitments. #39

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
297 changes: 291 additions & 6 deletions orchard_merkle_tree.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#!/usr/bin/env python3
import sys; assert sys.version_info[0] >= 3, "Python 3 required."
import math;

from binascii import unhexlify

from orchard_key_components import diversify_hash, prf_expand, FullViewingKey, SpendingKey
from orchard_note import OrchardNote, OrchardNotePlaintext
from orchard_pallas import Fp
from orchard_sinsemilla import sinsemilla_hash

from utils import i2lebsp, leos2bsp
from tv_output import render_args, render_tv
from tv_rand import Rand

# https://zips.z.cash/protocol/nu5.pdf#constants
MERKLE_DEPTH = 32
Expand All @@ -21,6 +26,42 @@ def merkle_crh(layer, left, right):
l = i2lebsp(10, MERKLE_DEPTH - 1 - layer)
return sinsemilla_hash(b"z.cash:Orchard-MerkleCRH", l + left + right)

def empty_roots():
empty_roots = [UNCOMMITTED_ORCHARD]
for layer in range(0, MERKLE_DEPTH)[::-1]:
bits = i2lebsp(L_MERKLE, empty_roots[-1].s)
empty_roots.append(merkle_crh(layer, bits, bits))
return empty_roots

EMPTY_ROOTS = empty_roots()

def anchor(leaves):
leaves0 = leaves.copy()
# pad with empty leaves to form a perfect tree
perfect_height = math.ceil(math.log2(len(leaves0)))
perfect_leaves = 1 << perfect_height
padding_len = perfect_leaves - len(leaves0)

for _ in range(0, padding_len):
leaves0.append(UNCOMMITTED_ORCHARD)

hashes = [leaves0]
for altitude in range(0, perfect_height):
layer = MERKLE_DEPTH - 1 - altitude
hashes.append([])
for pos in range(0, perfect_leaves >> (altitude + 1)):
left = hashes[altitude][pos * 2]
right = hashes[altitude][pos * 2 + 1]
hashes[altitude + 1].append(merkle_crh(layer, left.bits(L_MERKLE), right.bits(L_MERKLE)))

assert len(hashes[perfect_height]) == 1
root = hashes[perfect_height][0]
for altitude in range(perfect_height, MERKLE_DEPTH):
layer = MERKLE_DEPTH - 1 - altitude
root = merkle_crh(layer, root.bits(L_MERKLE), EMPTY_ROOTS[altitude].bits(L_MERKLE))

return root

left = unhexlify("87a086ae7d2252d58729b30263fb7b66308bf94ef59a76c9c86e7ea016536505")[::-1]
right = unhexlify("a75b84a125b2353da7e8d96ee2a15efe4de23df9601b9d9564ba59de57130406")[::-1]

Expand All @@ -32,9 +73,253 @@ def merkle_crh(layer, left, right):
assert merkle_crh(MERKLE_DEPTH - 1 - 25, left, right) == parent
assert merkle_crh(MERKLE_DEPTH - 1 - 26, left, right) != parent

def empty_roots():
empty_roots = [UNCOMMITTED_ORCHARD]
for layer in range(0, MERKLE_DEPTH)[::-1]:
bits = i2lebsp(L_MERKLE, empty_roots[-1].s)
empty_roots.append(merkle_crh(layer, bits, bits))
return empty_roots
def main():
args = render_args()

bundle_commitments = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be in this file (this is where #36 will go). These should go into a separate script file (they aren't really what this repo is for, but there isn't any better place to put them).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document how these were generated, in case they need to be regenerated.

[
[ 0x68, 0x13, 0x5c, 0xf4, 0x99, 0x33, 0x22, 0x90, 0x99, 0xa4, 0x4e,
0xc9, 0x9a, 0x75, 0xe1, 0xe1, 0xcb, 0x46, 0x40, 0xf9, 0xb5,
0xbd, 0xec, 0x6b, 0x32, 0x23, 0x85, 0x6f, 0xea, 0x16, 0x39,
0x0a ],
[ 0x78, 0x31, 0x50, 0x08, 0xfb, 0x29, 0x98, 0xb4, 0x30, 0xa5, 0x73,
0x1d, 0x67, 0x26, 0x20, 0x7d, 0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0x96, 0xcd,
0x0e, 0x8f, 0x52, 0xb2, 0x4b, 0x02, 0xec, 0x89, 0x5f, 0x3f,
0xce, 0x56, 0xa4, 0x67, 0x79, 0xb5, 0x03, 0x09, 0x83, 0x5a,
0x23 ],
[ 0xd9, 0xfe, 0x9f, 0x36, 0x08, 0xa6, 0xc6, 0xff, 0x09, 0x93, 0x58,
0xa6, 0x94, 0xf6, 0xae, 0xce, 0x4d, 0xa0, 0xc5, 0x35, 0x62,
0x8a, 0x88, 0x82, 0x43, 0x52, 0x9c, 0xa9, 0xb1, 0xf7, 0xa8,
0x10 ],
[ 0x1f, 0x01, 0xf1, 0xf8, 0xf4, 0xb5, 0x64, 0xd8, 0xb0, 0xff, 0xd3,
0x2a, 0xff, 0x11, 0x24, 0x3d, 0xee, 0x25, 0x82, 0xb4, 0xa3,
0xef, 0xbb, 0xce, 0xc9, 0x20, 0x02, 0x6c, 0x5e, 0x1f, 0x44,
0x1e ],
[ 0xa0, 0x65, 0x87, 0xcc, 0xc0, 0x3f, 0x14, 0x92, 0x94, 0x65, 0xcd,
0x3d, 0x93, 0x37, 0x90, 0xda, 0xb1, 0x23, 0xae, 0x4e, 0x57,
0x55, 0x8a, 0x7a, 0xf4, 0xfc, 0x06, 0x1e, 0x6b, 0x46, 0x7f,
0x1c ]
]
]

merkle_leaves = []
test_vectors = []
for note_commitments in bundle_commitments:
for c in note_commitments:
cmx = Fp.from_bytes(bytes(c))
merkle_leaves.append(cmx)

a = anchor(merkle_leaves)
test_vectors.append({
'anchor': bytes(a)
})

render_tv(
args,
'orchard_merkle_tree',
(
('anchor', '[u8; 32]'),
),
test_vectors,
)


if __name__ == '__main__':
main()