add target types for custom predicates (#223)
* add target types for custom predicates * simplify * fix clippy * fix typo * don't use ref for NativePredicate * fix wrong len * apply feedback from @ax0
This commit is contained in:
parent
bf394eada3
commit
726f95483d
6 changed files with 527 additions and 123 deletions
|
|
@ -85,14 +85,14 @@ impl OperationVerifyGadget {
|
|||
op.args
|
||||
.iter()
|
||||
.flatten()
|
||||
.map(|&i| builder.vec_ref(prev_statements, i))
|
||||
.map(|&i| builder.vec_ref(&self.params, prev_statements, i))
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
// Certain operations (Contains/NotContains) will refer to one
|
||||
// of the provided Merkle proofs (if any). These proofs have already
|
||||
// been verified, so we need only look up the claim.
|
||||
let resolved_merkle_claim =
|
||||
(!merkle_claims.is_empty()).then(|| builder.vec_ref(merkle_claims, op.aux[0]));
|
||||
let resolved_merkle_claim = (!merkle_claims.is_empty())
|
||||
.then(|| builder.vec_ref(&self.params, merkle_claims, op.aux[0]));
|
||||
|
||||
// The verification may require aux data which needs to be stored in the
|
||||
// `OperationVerifyTarget` so that we can set during witness generation.
|
||||
|
|
@ -455,7 +455,7 @@ impl OperationVerifyGadget {
|
|||
let individual_checks = prev_statements
|
||||
.iter()
|
||||
.map(|ps| {
|
||||
let same_predicate = builder.is_equal_slice(&st.predicate, &ps.predicate);
|
||||
let same_predicate = builder.is_equal_flattenable(&st.predicate, &ps.predicate);
|
||||
let same_anchored_key =
|
||||
builder.is_equal_slice(&st.args[0].elements, &ps.args[0].elements);
|
||||
builder.and(same_predicate, same_anchored_key)
|
||||
|
|
@ -575,15 +575,7 @@ impl MainPodVerifyGadget {
|
|||
.collect();
|
||||
|
||||
// 2. Calculate the Pod Id from the public statements
|
||||
let pub_statements_flattened = pub_statements
|
||||
.iter()
|
||||
.flat_map(|s| {
|
||||
s.predicate
|
||||
.iter()
|
||||
.chain(s.args.iter().flat_map(|a| &a.elements))
|
||||
})
|
||||
.cloned()
|
||||
.collect();
|
||||
let pub_statements_flattened = pub_statements.iter().flat_map(|s| s.flatten()).collect();
|
||||
let id = builder.hash_n_to_hash_no_pad::<PoseidonHash>(pub_statements_flattened);
|
||||
|
||||
// 4. Verify type
|
||||
|
|
@ -591,6 +583,7 @@ impl MainPodVerifyGadget {
|
|||
// TODO: Store this hash in a global static with lazy init so that we don't have to
|
||||
// compute it every time.
|
||||
let expected_type_statement = StatementTarget::from_flattened(
|
||||
&self.params,
|
||||
&builder.constants(
|
||||
&Statement::ValueOf(
|
||||
AnchoredKey::from((SELF, KEY_TYPE)),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue