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:
Jack Grigg 2019-04-16 08:40:38 +01:00
parent e67560b154
commit 79006ecbdf
No known key found for this signature in database
GPG Key ID: 9E8255172BBF9898
2 changed files with 4 additions and 4 deletions

View File

@ -1,7 +1,6 @@
//! Implementation of a Merkle tree of commitments used to prove the existence of notes.
use byteorder::{LittleEndian, ReadBytesExt};
use sapling_crypto::circuit::sapling::TREE_DEPTH;
use std::collections::VecDeque;
use std::io::{self, Read, Write};
use std::iter;
@ -435,10 +434,10 @@ impl<Node: Hashable> CommitmentTreeWitness<Node> {
/// Reads a witness from its serialized form.
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
// the following vector of Pedersen hashes.
if witness[0] != depth as u8 {

View File

@ -14,7 +14,8 @@ use std::io::{self, Read, Write};
use crate::merkle_tree::Hashable;
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.
pub fn merkle_hash(depth: usize, lhs: &FrRepr, rhs: &FrRepr) -> FrRepr {