Constraints for custom predicates (#227)
* add target types for custom predicates * simplify * fix clippy * fix typo * don't use ref for NativePredicate * fix wrong len * precalculate CustomPredicateBatch id * wip * wip * move code back * great progress * wip * code complete, hopefully; missing tests * fill aux for custom predicate op * fix clippy warnings * fix typos * fix test import * fix missing assignment in lt_mask, test custom_operation_verify_gadget * fix mistake * wip * fix * debug revert except for let entry = CustomPredicateVerifyEntryTarget * fix batch_id calculation by fixing padding * oops * remove completed TODOs
This commit is contained in:
parent
4fa9e20ecd
commit
024ed8bd04
12 changed files with 1597 additions and 291 deletions
|
|
@ -38,15 +38,17 @@ impl OperationArg {
|
|||
pub enum OperationAux {
|
||||
None,
|
||||
MerkleProofIndex(usize),
|
||||
CustomPredVerifyIndex(usize),
|
||||
}
|
||||
|
||||
impl ToFields for OperationAux {
|
||||
fn to_fields(&self, _params: &Params) -> Vec<F> {
|
||||
let f = match self {
|
||||
Self::None => F::ZERO,
|
||||
Self::MerkleProofIndex(i) => F::from_canonical_usize(*i),
|
||||
let fs = match self {
|
||||
Self::None => [F::ZERO, F::ZERO],
|
||||
Self::MerkleProofIndex(i) => [F::from_canonical_usize(*i), F::ZERO],
|
||||
Self::CustomPredVerifyIndex(i) => [F::ZERO, F::from_canonical_usize(*i)],
|
||||
};
|
||||
vec![f]
|
||||
vec![fs[0], fs[1]]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -78,6 +80,7 @@ impl Operation {
|
|||
.collect::<Result<Vec<_>>>()?;
|
||||
let deref_aux = match self.2 {
|
||||
OperationAux::None => crate::middleware::OperationAux::None,
|
||||
OperationAux::CustomPredVerifyIndex(_) => crate::middleware::OperationAux::None,
|
||||
OperationAux::MerkleProofIndex(i) => crate::middleware::OperationAux::MerkleProof(
|
||||
merkle_proofs
|
||||
.get(i)
|
||||
|
|
@ -111,6 +114,7 @@ impl fmt::Display for Operation {
|
|||
match self.2 {
|
||||
OperationAux::None => (),
|
||||
OperationAux::MerkleProofIndex(i) => write!(f, " merkle_proof_{:02}", i)?,
|
||||
OperationAux::CustomPredVerifyIndex(i) => write!(f, " custom_pred_verify_{:02}", i)?,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue