diff --git a/Cargo.toml b/Cargo.toml index efe0a6de..21dc48cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,3 +84,4 @@ debug = true [patch.crates-io] halo2_gadgets = { git = "https://github.com/zcash/halo2.git", rev = "0c33fa4e6e41464884765c8fb4cefebafd300ca2" } halo2_proofs = { git = "https://github.com/zcash/halo2.git", rev = "0c33fa4e6e41464884765c8fb4cefebafd300ca2" } +incrementalmerkletree = { git = "https://github.com/zcash/incrementalmerkletree.git", rev = "f23e3d89507849a24543121839eea6f40b141aff" } diff --git a/src/builder.rs b/src/builder.rs index f85d08a2..4bfdd843 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -590,8 +590,7 @@ impl Bundle, V> { #[cfg_attr(docsrs, doc(cfg(feature = "test-dependencies")))] pub mod testing { use core::fmt::Debug; - - use incrementalmerkletree::{bridgetree::BridgeTree, Frontier, Tree}; + use incrementalmerkletree::{bridgetree::BridgeTree, Tree}; use rand::{rngs::StdRng, CryptoRng, SeedableRng}; use proptest::collection::vec; @@ -666,6 +665,7 @@ pub mod testing { ( n_notes in 1usize..30, n_recipients in 1..30, + ) ( // generate note values that we're certain won't exceed MAX_NOTE_VALUE in total @@ -691,14 +691,15 @@ pub mod testing { tree.append(&leaf); let position = tree.witness().expect("tree is not empty"); - let path = MerklePath::from((position, tree.authentication_path(position).expect("we just witnessed the path"))); + let root = tree.root(0).unwrap(); + let path = MerklePath::from((position, tree.authentication_path(position, &root).expect("we just witnessed the path"))); notes_and_auth_paths.push((*note, path)); } ArbitraryBundleInputs { rng: StdRng::from_seed(rng_seed), sk, - anchor: tree.root().into(), + anchor: tree.root(0).unwrap().into(), notes: notes_and_auth_paths, recipient_amounts } diff --git a/src/tree.rs b/src/tree.rs index 92ca0344..2dfd4fae 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -284,14 +284,15 @@ pub mod testing { let position = tree.witness().expect("tree is not empty"); assert_eq!(position, i.into()); - assert_eq!(tree.root().0, pallas::Base::from_repr(tv.root).unwrap()); + let root = tree.root(0).unwrap(); + assert_eq!(root.0, pallas::Base::from_repr(tv.root).unwrap()); // Check paths for all leaves up to this point. The test vectors include paths // for not-yet-appended leaves (using UNCOMMITTED_ORCHARD as the leaf value), // but BridgeTree doesn't encode these. for j in 0..=i { assert_eq!( - tree.authentication_path(j.try_into().unwrap()), + tree.authentication_path(j.try_into().unwrap(), &root), Some( tv.paths[j] .iter() diff --git a/tests/builder.rs b/tests/builder.rs index ee1656f0..35c53976 100644 --- a/tests/builder.rs +++ b/tests/builder.rs @@ -1,4 +1,4 @@ -use incrementalmerkletree::{bridgetree::BridgeTree, Frontier, Hashable, Tree}; +use incrementalmerkletree::{bridgetree::BridgeTree, Hashable, Tree}; use orchard::{ builder::Builder, bundle::{Authorized, Flags}, @@ -73,12 +73,13 @@ fn bundle_chain() { let mut tree = BridgeTree::::new(0); tree.append(&leaf); let position = tree.witness().unwrap(); - let auth_path = tree.authentication_path(position).unwrap(); + let root = tree.root(0).unwrap(); + let auth_path = tree.authentication_path(position, &root).unwrap(); let merkle_path = MerklePath::from_parts( u64::from(position).try_into().unwrap(), auth_path[..].try_into().unwrap(), ); - let anchor = tree.root().into(); + let anchor = root.into(); assert_eq!(anchor, merkle_path.root(cmx)); let mut builder = Builder::new(Flags::from_parts(true, true), anchor);