sinsemilla::merkle: Remove MERKLE_DEPTH constant.

This commit is contained in:
therealyingtong 2022-01-27 08:13:49 +08:00
parent 31259d089c
commit 85b481af35
3 changed files with 6 additions and 7 deletions

View File

@ -392,7 +392,7 @@ impl plonk::Circuit<pallas::Base> for Circuit {
// Merkle path validity check. // Merkle path validity check.
let anchor = { let anchor = {
let path = self.path.map(|typed_path| { let path: Option<[pallas::Base; MERKLE_DEPTH_ORCHARD]> = self.path.map(|typed_path| {
// TODO: Replace with array::map once MSRV is 1.55.0. // TODO: Replace with array::map once MSRV is 1.55.0.
gen_const_array(|i| typed_path[i].inner()) gen_const_array(|i| typed_path[i].inner())
}); });

View File

@ -16,9 +16,6 @@ pub(in crate::circuit) mod chip;
/// SWU hash-to-curve personalization for the Merkle CRH generator /// SWU hash-to-curve personalization for the Merkle CRH generator
pub const MERKLE_CRH_PERSONALIZATION: &str = "z.cash:Orchard-MerkleCRH"; pub const MERKLE_CRH_PERSONALIZATION: &str = "z.cash:Orchard-MerkleCRH";
/// Depth of Merkle tree
pub(crate) const MERKLE_DEPTH: usize = 32;
/// Instructions to check the validity of a Merkle path of a given `PATH_LENGTH`. /// Instructions to check the validity of a Merkle path of a given `PATH_LENGTH`.
/// The hash function used is a Sinsemilla instance with `K`-bit words. /// The hash function used is a Sinsemilla instance with `K`-bit words.
/// The hash function can process `MAX_WORDS` words. /// The hash function can process `MAX_WORDS` words.
@ -136,7 +133,7 @@ where
pub mod tests { pub mod tests {
use super::{ use super::{
chip::{MerkleChip, MerkleConfig}, chip::{MerkleChip, MerkleConfig},
MerklePath, MERKLE_DEPTH, MerklePath,
}; };
use crate::{ use crate::{
@ -160,6 +157,8 @@ pub mod tests {
use rand::{rngs::OsRng, RngCore}; use rand::{rngs::OsRng, RngCore};
use std::convert::TryInto; use std::convert::TryInto;
const MERKLE_DEPTH: usize = 32;
#[derive(Default)] #[derive(Default)]
struct MyCircuit { struct MyCircuit {
leaf: Option<pallas::Base>, leaf: Option<pallas::Base>,

View File

@ -5,7 +5,7 @@ use halo2::{
}; };
use pasta_curves::{arithmetic::FieldExt, pallas}; use pasta_curves::{arithmetic::FieldExt, pallas};
use super::{MerkleInstructions, MERKLE_DEPTH}; use super::MerkleInstructions;
use crate::{ use crate::{
circuit::gadget::{ circuit::gadget::{
@ -180,7 +180,7 @@ where
} }
} }
impl<Hash, Commit, F> impl<Hash, Commit, F, const MERKLE_DEPTH: usize>
MerkleInstructions<pallas::Affine, MERKLE_DEPTH, { sinsemilla::K }, { sinsemilla::C }> MerkleInstructions<pallas::Affine, MERKLE_DEPTH, { sinsemilla::K }, { sinsemilla::C }>
for MerkleChip<Hash, Commit, F> for MerkleChip<Hash, Commit, F>
where where