mirror of https://github.com/zcash/orchard.git
Merge pull request #395 from nuttycom/update_bridgetree
Update the `incrementalmerkletree` and `bridgetree` patch versions.
This commit is contained in:
commit
11b6858ac8
|
@ -26,7 +26,6 @@ rustdoc-args = ["--cfg", "docsrs", "--html-in-header", "katex-header.html"]
|
|||
aes = "0.8"
|
||||
bitvec = "1"
|
||||
blake2b_simd = "1"
|
||||
bridgetree = { version = "0.2", optional = true }
|
||||
ff = "0.13"
|
||||
fpe = "0.6"
|
||||
group = { version = "0.13", features = ["wnaf-memuse"] }
|
||||
|
@ -72,7 +71,7 @@ bench = false
|
|||
default = ["multicore"]
|
||||
multicore = ["halo2_proofs/multicore"]
|
||||
dev-graph = ["halo2_proofs/dev-graph", "image", "plotters"]
|
||||
test-dependencies = ["bridgetree", "proptest"]
|
||||
test-dependencies = ["proptest"]
|
||||
|
||||
[[bench]]
|
||||
name = "note_decryption"
|
||||
|
@ -93,5 +92,5 @@ debug = true
|
|||
debug = true
|
||||
|
||||
[patch.crates-io]
|
||||
bridgetree = { git = "https://github.com/zcash/incrementalmerkletree.git", rev = "ea1686e8f8f6c1e41aa97251a7eb4fadfd33df47" }
|
||||
incrementalmerkletree = { git = "https://github.com/zcash/incrementalmerkletree.git", rev = "ea1686e8f8f6c1e41aa97251a7eb4fadfd33df47" }
|
||||
bridgetree = { git = "https://github.com/zcash/incrementalmerkletree.git", rev = "62f0c9039b0bee94c16c40c272e19c5922290664" }
|
||||
incrementalmerkletree = { git = "https://github.com/zcash/incrementalmerkletree.git", rev = "62f0c9039b0bee94c16c40c272e19c5922290664" }
|
||||
|
|
|
@ -759,8 +759,8 @@ impl OutputView for RecipientInfo {
|
|||
#[cfg(any(test, feature = "test-dependencies"))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "test-dependencies")))]
|
||||
pub mod testing {
|
||||
use bridgetree::BridgeTree;
|
||||
use core::fmt::Debug;
|
||||
use incrementalmerkletree::{frontier::Frontier, Hashable};
|
||||
use rand::{rngs::StdRng, CryptoRng, SeedableRng};
|
||||
|
||||
use proptest::collection::vec;
|
||||
|
@ -852,23 +852,26 @@ pub mod testing {
|
|||
),
|
||||
rng_seed in prop::array::uniform32(prop::num::u8::ANY)
|
||||
) -> ArbitraryBundleInputs<StdRng> {
|
||||
const MERKLE_DEPTH_ORCHARD: u8 = crate::constants::MERKLE_DEPTH_ORCHARD as u8;
|
||||
let mut tree = BridgeTree::<MerkleHashOrchard, u32, MERKLE_DEPTH_ORCHARD>::new(100, 0);
|
||||
use crate::constants::MERKLE_DEPTH_ORCHARD;
|
||||
let mut frontier = Frontier::<MerkleHashOrchard, { MERKLE_DEPTH_ORCHARD as u8 }>::empty();
|
||||
let mut notes_and_auth_paths: Vec<(Note, MerklePath)> = Vec::new();
|
||||
|
||||
for note in notes.iter() {
|
||||
let leaf = MerkleHashOrchard::from_cmx(¬e.commitment().into());
|
||||
tree.append(leaf);
|
||||
let position = tree.mark().expect("tree is not empty");
|
||||
frontier.append(leaf);
|
||||
|
||||
let path = MerklePath::from((position, tree.witness(position, 0).expect("we just witnessed the path")));
|
||||
notes_and_auth_paths.push((*note, path));
|
||||
let path = frontier
|
||||
.witness(|addr| Some(<MerkleHashOrchard as Hashable>::empty_root(addr.level())))
|
||||
.ok()
|
||||
.flatten()
|
||||
.expect("we can always construct a correct Merkle path");
|
||||
notes_and_auth_paths.push((*note, path.into()));
|
||||
}
|
||||
|
||||
ArbitraryBundleInputs {
|
||||
rng: StdRng::from_seed(rng_seed),
|
||||
sk,
|
||||
anchor: tree.root(0).unwrap().into(),
|
||||
anchor: frontier.root().into(),
|
||||
notes: notes_and_auth_paths,
|
||||
recipient_amounts
|
||||
}
|
||||
|
|
19
src/tree.rs
19
src/tree.rs
|
@ -95,6 +95,16 @@ impl From<(incrementalmerkletree::Position, Vec<MerkleHashOrchard>)> for MerkleP
|
|||
}
|
||||
}
|
||||
|
||||
impl From<incrementalmerkletree::MerklePath<MerkleHashOrchard, 32>> for MerklePath {
|
||||
fn from(path: incrementalmerkletree::MerklePath<MerkleHashOrchard, 32>) -> Self {
|
||||
let position: u64 = path.position().into();
|
||||
Self {
|
||||
position: position as u32,
|
||||
auth_path: path.path_elems().try_into().unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MerklePath {
|
||||
/// Generates a dummy Merkle path for use in dummy spent notes.
|
||||
pub(crate) fn dummy(mut rng: &mut impl RngCore) -> Self {
|
||||
|
@ -243,11 +253,8 @@ impl<'de> Deserialize<'de> for MerkleHashOrchard {
|
|||
}
|
||||
}
|
||||
|
||||
/// Generators for property testing.
|
||||
#[cfg(any(test, feature = "test-dependencies"))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "test-dependencies")))]
|
||||
pub mod testing {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use {
|
||||
crate::tree::{MerkleHashOrchard, EMPTY_ROOTS},
|
||||
bridgetree::{BridgeTree, Frontier as BridgeFrontier},
|
||||
|
@ -264,7 +271,7 @@ pub mod testing {
|
|||
assert_eq!(tv_empty_roots[height], root.to_bytes());
|
||||
}
|
||||
|
||||
let mut tree = BridgeTree::<MerkleHashOrchard, u32, 4>::new(100, 0);
|
||||
let mut tree = BridgeTree::<MerkleHashOrchard, u32, 4>::new(100);
|
||||
for (i, tv) in crate::test_vectors::merkle_path::test_vectors()
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
|
@ -272,7 +279,7 @@ pub mod testing {
|
|||
let cmx = MerkleHashOrchard::from_bytes(&tv.leaves[i]).unwrap();
|
||||
tree.append(cmx);
|
||||
let position = tree.mark().expect("tree is not empty");
|
||||
assert_eq!(position, i.into());
|
||||
assert_eq!(position, (i as u64).into());
|
||||
|
||||
let root = tree.root(0).unwrap();
|
||||
assert_eq!(root.0, pallas::Base::from_repr(tv.root).unwrap());
|
||||
|
|
|
@ -71,7 +71,7 @@ fn bundle_chain() {
|
|||
// Use the tree with a single leaf.
|
||||
let cmx: ExtractedNoteCommitment = note.commitment().into();
|
||||
let leaf = MerkleHashOrchard::from_cmx(&cmx);
|
||||
let mut tree = BridgeTree::<MerkleHashOrchard, u32, 32>::new(100, 0);
|
||||
let mut tree = BridgeTree::<MerkleHashOrchard, u32, 32>::new(100);
|
||||
tree.append(leaf);
|
||||
let position = tree.mark().unwrap();
|
||||
let root = tree.root(0).unwrap();
|
||||
|
|
Loading…
Reference in New Issue