Fix custom predicate circuits and add tests for them (#235)
* add tests, fix custom predicates * wip * wip * fix custom predicates * modularize code * fix typos * remove scratch file * update * Update src/backends/plonky2/circuits/mainpod.rs Co-authored-by: Ahmad Afuni <root@ahmadafuni.com> --------- Co-authored-by: Ahmad Afuni <root@ahmadafuni.com>
This commit is contained in:
parent
f5a1aa7523
commit
def0730462
16 changed files with 629 additions and 153 deletions
|
|
@ -274,12 +274,12 @@ mod tests {
|
|||
params.print_serialized_sizes();
|
||||
|
||||
// ETH friend custom predicate batch
|
||||
let eth_friend = eth_friend_batch(¶ms)?;
|
||||
let eth_friend = eth_friend_batch(¶ms, true)?;
|
||||
|
||||
// This batch only has 1 predicate, so we pick it already for convenience
|
||||
let eth_friend = Predicate::Custom(CustomPredicateRef::new(eth_friend, 0));
|
||||
|
||||
let eth_dos_batch = eth_dos_batch(¶ms)?;
|
||||
let eth_dos_batch = eth_dos_batch(¶ms, true)?;
|
||||
let eth_dos_batch_mw: middleware::CustomPredicateBatch =
|
||||
Arc::unwrap_or_clone(eth_dos_batch);
|
||||
let fields = eth_dos_batch_mw.to_fields(¶ms);
|
||||
|
|
|
|||
|
|
@ -793,7 +793,7 @@ pub mod build_utils {
|
|||
(max_of, $($arg:expr),+) => { $crate::frontend::Operation(
|
||||
$crate::middleware::OperationType::Native($crate::middleware::NativeOperation::MaxOf),
|
||||
$crate::op_args!($($arg),*), $crate::middleware::OperationAux::None) };
|
||||
(custom, $op:expr, $($arg:expr),+) => { $crate::frontend::Operation(
|
||||
(custom, $op:expr, $($arg:expr),*) => { $crate::frontend::Operation(
|
||||
$crate::middleware::OperationType::Custom($op),
|
||||
$crate::op_args!($($arg),*), $crate::middleware::OperationAux::None) };
|
||||
(dict_contains, $dict:expr, $key:expr, $value:expr) => { $crate::frontend::Operation(
|
||||
|
|
@ -925,18 +925,19 @@ pub mod tests {
|
|||
// Alice attests that she is ETH friends with Charlie and Charlie
|
||||
// attests that he is ETH friends with Bob.
|
||||
let alice_attestation =
|
||||
eth_friend_signed_pod_builder(¶ms, charlie.pubkey().into()).sign(&mut alice)?;
|
||||
eth_friend_signed_pod_builder(¶ms, charlie.public_key().into()).sign(&mut alice)?;
|
||||
check_kvs(&alice_attestation)?;
|
||||
let charlie_attestation =
|
||||
eth_friend_signed_pod_builder(¶ms, bob.pubkey().into()).sign(&mut charlie)?;
|
||||
eth_friend_signed_pod_builder(¶ms, bob.public_key().into()).sign(&mut charlie)?;
|
||||
check_kvs(&charlie_attestation)?;
|
||||
|
||||
let mut prover = MockProver {};
|
||||
let alice_bob_ethdos = eth_dos_pod_builder(
|
||||
¶ms,
|
||||
true,
|
||||
&alice_attestation,
|
||||
&charlie_attestation,
|
||||
&bob.pubkey().into(),
|
||||
bob.public_key().into(),
|
||||
)?
|
||||
.prove(&mut prover, ¶ms)?;
|
||||
|
||||
|
|
|
|||
|
|
@ -276,16 +276,17 @@ mod tests {
|
|||
// Alice attests that she is ETH friends with Charlie and Charlie
|
||||
// attests that he is ETH friends with Bob.
|
||||
let alice_attestation =
|
||||
eth_friend_signed_pod_builder(¶ms, charlie.pubkey().into()).sign(&mut alice)?;
|
||||
eth_friend_signed_pod_builder(¶ms, charlie.public_key().into()).sign(&mut alice)?;
|
||||
let charlie_attestation =
|
||||
eth_friend_signed_pod_builder(¶ms, bob.pubkey().into()).sign(&mut charlie)?;
|
||||
eth_friend_signed_pod_builder(¶ms, bob.public_key().into()).sign(&mut charlie)?;
|
||||
|
||||
let mut prover = MockProver {};
|
||||
let alice_bob_ethdos = eth_dos_pod_builder(
|
||||
¶ms,
|
||||
true,
|
||||
&alice_attestation,
|
||||
&charlie_attestation,
|
||||
&bob.pubkey().into(),
|
||||
bob.public_key().into(),
|
||||
)?
|
||||
.prove(&mut prover, ¶ms)?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue