Remove max_depth in native MerkleTree (#442)
This simplifies the MerkleTree (and container) API. Defer the max depth check when assigning the witness (merkle proof siblings) to the merkle tree circuit. In this implementation the native Merkle Tree branches grow as much as they needed. There are no checks of max depth in the merkle tree. All keys are 256 bits (I added a debug_assert for this); so in the worst case a path will have depth 256. It can't have a longer depth because the `insert` method calls `prove_nonexistence` which errors if the key already exists; another one may exist which must be different and thus require a path <= 256 depth. Resolve #436
This commit is contained in:
parent
32dc85471d
commit
813a86c670
18 changed files with 266 additions and 462 deletions
|
|
@ -5,7 +5,7 @@ use std::{collections::HashSet, sync::LazyLock};
|
|||
use custom::eth_dos_batch;
|
||||
use num::BigUint;
|
||||
|
||||
pub static MOCK_VD_SET: LazyLock<VDSet> = LazyLock::new(|| VDSet::new(6, &[]).unwrap());
|
||||
pub static MOCK_VD_SET: LazyLock<VDSet> = LazyLock::new(|| VDSet::new(&[]));
|
||||
|
||||
use crate::{
|
||||
backends::plonky2::{primitives::ec::schnorr::SecretKey, signer::Signer},
|
||||
|
|
@ -50,8 +50,7 @@ pub fn zu_kyc_pod_builder(
|
|||
.iter()
|
||||
.map(|s| Value::from(*s))
|
||||
.collect();
|
||||
let sanction_set =
|
||||
Value::from(Set::new(params.max_depth_mt_containers, sanctions_values).unwrap());
|
||||
let sanction_set = Value::from(Set::new(sanctions_values));
|
||||
|
||||
let mut kyc = MainPodBuilder::new(params, vd_set);
|
||||
kyc.pub_op(Operation::dict_signed_by(gov_id))?;
|
||||
|
|
@ -72,13 +71,11 @@ pub fn zu_kyc_pod_builder(
|
|||
}
|
||||
|
||||
pub fn zu_kyc_pod_request(gov_signer: &Value, pay_signer: &Value) -> Result<PodRequest> {
|
||||
let params = Params::default();
|
||||
let sanctions_values: HashSet<Value> = ZU_KYC_SANCTION_LIST
|
||||
.iter()
|
||||
.map(|s| Value::from(*s))
|
||||
.collect();
|
||||
let sanction_set =
|
||||
Value::from(Set::new(params.max_depth_mt_containers, sanctions_values).unwrap());
|
||||
let sanction_set = Value::from(Set::new(sanctions_values));
|
||||
let input = format!(
|
||||
r#"
|
||||
REQUEST(
|
||||
|
|
@ -347,9 +344,8 @@ pub fn great_boy_pod_full_flow() -> Result<MainPodBuilder> {
|
|||
alice_friend_pods.push(friend.sign(&charlie_signer).unwrap());
|
||||
|
||||
let good_boy_issuers = Value::from(Set::new(
|
||||
params.max_depth_mt_containers,
|
||||
good_boy_issuers.into_iter().map(Value::from).collect(),
|
||||
)?);
|
||||
));
|
||||
|
||||
let builder = great_boy_pod_builder(
|
||||
¶ms,
|
||||
|
|
@ -433,6 +429,6 @@ pub fn tickets_pod_full_flow(params: &Params, vd_set: &VDSet) -> Result<MainPodB
|
|||
&signed_dict,
|
||||
123,
|
||||
true,
|
||||
&Set::new(params.max_depth_mt_containers, HashSet::new())?,
|
||||
&Set::new(HashSet::new()),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue