fix: use raw values for container keys and values (#312)

* Get rid of additional key/value hashing in container types

* Add test
This commit is contained in:
Ahmad Afuni 2025-06-25 22:41:52 +10:00 committed by GitHub
parent e1775d8578
commit 115c3c1152
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 42 additions and 32 deletions

View file

@ -732,11 +732,11 @@ pub mod tests {
},
examples::{attest_eth_friend, zu_kyc_pod_builder, zu_kyc_sign_pod_builders, EthDosHelper},
frontend::{
literal, CustomPredicateBatchBuilder, MainPodBuilder, StatementTmplBuilder as STB,
{self},
self, literal, CustomPredicateBatchBuilder, MainPodBuilder, StatementTmplBuilder as STB,
},
middleware::{
self, containers::Set, CustomPredicateRef, NativePredicate as NP, Value, DEFAULT_VD_SET,
},
middleware,
middleware::{CustomPredicateRef, NativePredicate as NP, Value, DEFAULT_VD_SET},
op,
};
@ -948,4 +948,25 @@ pub mod tests {
Ok(pod.verify()?)
}
#[test]
fn test_set_contains() -> frontend::Result<()> {
let params = Params::default();
let mut builder = MainPodBuilder::new(&params, &*DEFAULT_VD_SET);
let set = [1, 2, 3].into_iter().map(|n| n.into()).collect();
let st = builder
.pub_op(op!(
new_entry,
"entry",
Set::new(params.max_merkle_proofs_containers, set).unwrap()
))
.unwrap();
builder.pub_op(op!(set_contains, st, 1))?;
let mut prover = Prover {};
let proof = builder.prove(&mut prover, &params).unwrap();
let pod = (proof.pod as Box<dyn Any>).downcast::<MainPod>().unwrap();
Ok(pod.verify()?)
}
}