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

Calculate incremental note commitment trees #2407

Merged
merged 18 commits into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
03c3ca9
Make sapling::tree::NoteCommitmentTree incrementally updateable
dconnolly Jun 28, 2021
9b7e855
Make orchard::tree::NoteCommitmentTree incrementally updateable
dconnolly Jun 28, 2021
3970358
Remove a commented out line, allow a clippy lint to match the spec ex…
dconnolly Jun 28, 2021
80b05ad
Apply suggestions from code review
conradoplg Jul 9, 2021
3887bfb
incrementalmerkletree proof of concept
conradoplg Jul 9, 2021
56d5dc9
Changed to incrementalmerkletree implementation; update MerkleCRH^Orc…
conradoplg Jul 12, 2021
4c50cca
Add Orchard note commitment tree test vector
conradoplg Jul 12, 2021
059ca96
Make Sapling and Orchard note commitment code more similar
conradoplg Jul 13, 2021
e8dbe60
Reverse EMPTY_ROOTS to make code clearer
conradoplg Jul 13, 2021
bd2a936
Add/move test vectors for Orchard note commitment tree
conradoplg Jul 13, 2021
a98979f
Organize note commitment tests and test vectors
conradoplg Jul 13, 2021
c3e556d
Documentation improvements
conradoplg Jul 13, 2021
294524f
Merge branch 'main' into incremental-note-commitment-trees
conradoplg Jul 13, 2021
0a352ad
Merge remote-tracking branch 'origin/main' into incremental-note-comm…
conradoplg Jul 14, 2021
97ec261
Improvemnts from review; organize file names (vectors.rs -> tree.rs)
conradoplg Jul 14, 2021
7f917ab
Merge branch 'main' into incremental-note-commitment-trees
teor2345 Jul 14, 2021
37482ec
Merge branch 'main' into incremental-note-commitment-trees
conradoplg Jul 15, 2021
ddc8967
Merge branch 'main' into incremental-note-commitment-trees
conradoplg Jul 15, 2021
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
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions zebra-chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ zcash_primitives = { git = "https://github.com/zcash/librustzcash.git", rev = "0
bigint = "4"
uint = "0.9.1"
bls12_381 = "0.5.0"
incrementalmerkletree = "0.1.0"

proptest = { version = "0.10", optional = true }
proptest-derive = { version = "0.3.0", optional = true }
Expand Down
3 changes: 2 additions & 1 deletion zebra-chain/src/orchard/tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod preallocate;
mod prop;
pub mod test_vectors;
mod test_vectors;
mod vectors;
352 changes: 352 additions & 0 deletions zebra-chain/src/orchard/tests/test_vectors.rs

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions zebra-chain/src/orchard/tests/vectors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
use halo2::arithmetic::FieldExt;
use halo2::pasta::pallas;

use crate::orchard::tests::test_vectors;
use crate::orchard::tree::*;

#[test]
fn empty_roots() {
zebra_test::init();

for i in 0..EMPTY_ROOTS.len() {
assert_eq!(
EMPTY_ROOTS[i].to_bytes(),
// The test vector is in reversed order.
test_vectors::EMPTY_ROOTS[MERKLE_DEPTH - i]
);
}
}

#[test]
fn incremental_roots() {
zebra_test::init();

let mut leaves = vec![];

let mut incremental_tree = NoteCommitmentTree::default();

for (i, commitment_set) in test_vectors::COMMITMENTS.iter().enumerate() {
for cm_x in commitment_set.iter() {
let cm_u = pallas::Base::from_bytes(&cm_x).unwrap();

leaves.push(cm_u);

let _ = incremental_tree.append(cm_u);
}

assert_eq!(
hex::encode(incremental_tree.hash()),
hex::encode(test_vectors::ROOTS[i].anchor)
);

assert_eq!(
hex::encode((NoteCommitmentTree::from(leaves.clone())).hash()),
hex::encode(test_vectors::ROOTS[i].anchor)
);
}
}
Loading