mirror of https://github.com/zcash/orchard.git
Add construction of OrchardIncrementalTreeDigest
This commit is contained in:
parent
4bb252eb0c
commit
ce4697aca5
|
@ -26,7 +26,7 @@ pub mod note;
|
||||||
mod note_encryption;
|
mod note_encryption;
|
||||||
pub mod primitives;
|
pub mod primitives;
|
||||||
mod spec;
|
mod spec;
|
||||||
mod tree;
|
pub mod tree;
|
||||||
pub mod value;
|
pub mod value;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
18
src/tree.rs
18
src/tree.rs
|
@ -1,3 +1,5 @@
|
||||||
|
//! Types related to Orchard note commitment trees and anchors.
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
constants::{
|
constants::{
|
||||||
util::gen_const_array, L_ORCHARD_MERKLE, MERKLE_CRH_PERSONALIZATION, MERKLE_DEPTH_ORCHARD,
|
util::gen_const_array, L_ORCHARD_MERKLE, MERKLE_CRH_PERSONALIZATION, MERKLE_DEPTH_ORCHARD,
|
||||||
|
@ -35,6 +37,8 @@ impl Anchor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The Merkle path from a leaf of the note commitment tree
|
||||||
|
/// to its anchor.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct MerklePath {
|
pub struct MerklePath {
|
||||||
position: u32,
|
position: u32,
|
||||||
|
@ -132,8 +136,18 @@ fn hash_layer(l_star: usize, pair: Pair) -> CtOption<pallas::Base> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
/// A newtype wrapper for leaves and internal nodes in the Orchard
|
||||||
struct OrchardIncrementalTreeDigest(CtOption<pallas::Base>);
|
/// incremental note commitment tree.
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct OrchardIncrementalTreeDigest(CtOption<pallas::Base>);
|
||||||
|
|
||||||
|
impl OrchardIncrementalTreeDigest {
|
||||||
|
/// Parses a incremental tree leaf digest from the bytes of
|
||||||
|
/// a note commitment.
|
||||||
|
pub fn from_bytes(bytes: &[u8; 32]) -> Self {
|
||||||
|
OrchardIncrementalTreeDigest(pallas::Base::from_bytes(bytes))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Hashable for OrchardIncrementalTreeDigest {
|
impl Hashable for OrchardIncrementalTreeDigest {
|
||||||
fn empty_leaf() -> Self {
|
fn empty_leaf() -> Self {
|
||||||
|
|
Loading…
Reference in New Issue