Unify Sapling tree depth constants
When sapling-crypto is refactored, the zcash_primitives::sapling constant would become the canonical one.
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
//! Implementation of a Merkle tree of commitments used to prove the existence of notes.
|
//! Implementation of a Merkle tree of commitments used to prove the existence of notes.
|
||||||
|
|
||||||
use byteorder::{LittleEndian, ReadBytesExt};
|
use byteorder::{LittleEndian, ReadBytesExt};
|
||||||
use sapling_crypto::circuit::sapling::TREE_DEPTH;
|
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::io::{self, Read, Write};
|
use std::io::{self, Read, Write};
|
||||||
use std::iter;
|
use std::iter;
|
||||||
@@ -435,10 +434,10 @@ impl<Node: Hashable> CommitmentTreeWitness<Node> {
|
|||||||
|
|
||||||
/// Reads a witness from its serialized form.
|
/// Reads a witness from its serialized form.
|
||||||
pub fn from_slice(witness: &[u8]) -> Result<Self, ()> {
|
pub fn from_slice(witness: &[u8]) -> Result<Self, ()> {
|
||||||
Self::from_slice_with_depth(witness, TREE_DEPTH)
|
Self::from_slice_with_depth(witness, SAPLING_COMMITMENT_TREE_DEPTH)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_slice_with_depth(mut witness: &[u8], depth: usize) -> Result<Self, ()> {
|
fn from_slice_with_depth(mut witness: &[u8], depth: usize) -> Result<Self, ()> {
|
||||||
// Skip the first byte, which should be "depth" to signify the length of
|
// Skip the first byte, which should be "depth" to signify the length of
|
||||||
// the following vector of Pedersen hashes.
|
// the following vector of Pedersen hashes.
|
||||||
if witness[0] != depth as u8 {
|
if witness[0] != depth as u8 {
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ use std::io::{self, Read, Write};
|
|||||||
use crate::merkle_tree::Hashable;
|
use crate::merkle_tree::Hashable;
|
||||||
use JUBJUB;
|
use JUBJUB;
|
||||||
|
|
||||||
pub(crate) const SAPLING_COMMITMENT_TREE_DEPTH: usize = 32;
|
pub(crate) const SAPLING_COMMITMENT_TREE_DEPTH: usize =
|
||||||
|
sapling_crypto::circuit::sapling::TREE_DEPTH;
|
||||||
|
|
||||||
/// Compute a parent node in the Sapling commitment tree given its two children.
|
/// Compute a parent node in the Sapling commitment tree given its two children.
|
||||||
pub fn merkle_hash(depth: usize, lhs: &FrRepr, rhs: &FrRepr) -> FrRepr {
|
pub fn merkle_hash(depth: usize, lhs: &FrRepr, rhs: &FrRepr) -> FrRepr {
|
||||||
|
|||||||
Reference in New Issue
Block a user