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
|
|
@ -11,7 +11,12 @@ use crate::{
|
|||
};
|
||||
|
||||
/// Instantiates an ETH friend batch
|
||||
pub fn eth_friend_batch(params: &Params) -> Result<Arc<CustomPredicateBatch>> {
|
||||
pub fn eth_friend_batch(params: &Params, mock: bool) -> Result<Arc<CustomPredicateBatch>> {
|
||||
let pod_type = if mock {
|
||||
PodType::MockSigned
|
||||
} else {
|
||||
PodType::Signed
|
||||
};
|
||||
let mut builder = CustomPredicateBatchBuilder::new(params.clone(), "eth_friend".into());
|
||||
let _eth_friend = builder.predicate_and(
|
||||
"eth_friend",
|
||||
|
|
@ -24,7 +29,7 @@ pub fn eth_friend_batch(params: &Params) -> Result<Arc<CustomPredicateBatch>> {
|
|||
// there is an attestation pod that's a SignedPod
|
||||
STB::new(NP::ValueOf)
|
||||
.arg(("attestation_pod", key(KEY_TYPE)))
|
||||
.arg(literal(PodType::MockSigned)), // TODO
|
||||
.arg(literal(pod_type)),
|
||||
// the attestation pod is signed by (src_or, src_key)
|
||||
STB::new(NP::Equal)
|
||||
.arg(("attestation_pod", key(KEY_SIGNER)))
|
||||
|
|
@ -41,8 +46,8 @@ pub fn eth_friend_batch(params: &Params) -> Result<Arc<CustomPredicateBatch>> {
|
|||
}
|
||||
|
||||
/// Instantiates an ETHDoS batch
|
||||
pub fn eth_dos_batch(params: &Params) -> Result<Arc<CustomPredicateBatch>> {
|
||||
let eth_friend = Predicate::Custom(CustomPredicateRef::new(eth_friend_batch(params)?, 0));
|
||||
pub fn eth_dos_batch(params: &Params, mock: bool) -> Result<Arc<CustomPredicateBatch>> {
|
||||
let eth_friend = Predicate::Custom(CustomPredicateRef::new(eth_friend_batch(params, mock)?, 0));
|
||||
let mut builder =
|
||||
CustomPredicateBatchBuilder::new(params.clone(), "eth_dos_distance_base".into());
|
||||
|
||||
|
|
|
|||
|
|
@ -69,10 +69,7 @@ pub fn zu_kyc_pod_builder(
|
|||
|
||||
// ETHDoS
|
||||
|
||||
pub fn eth_friend_signed_pod_builder(
|
||||
params: &Params,
|
||||
friend_pubkey: TypedValue,
|
||||
) -> SignedPodBuilder {
|
||||
pub fn eth_friend_signed_pod_builder(params: &Params, friend_pubkey: Value) -> SignedPodBuilder {
|
||||
let mut attestation = SignedPodBuilder::new(params);
|
||||
attestation.insert("attestation", friend_pubkey);
|
||||
|
||||
|
|
@ -81,13 +78,14 @@ pub fn eth_friend_signed_pod_builder(
|
|||
|
||||
pub fn eth_dos_pod_builder(
|
||||
params: &Params,
|
||||
mock: bool,
|
||||
alice_attestation: &SignedPod,
|
||||
charlie_attestation: &SignedPod,
|
||||
bob_pubkey: &TypedValue,
|
||||
bob_pubkey: Value,
|
||||
) -> Result<MainPodBuilder> {
|
||||
// Will need ETH friend and ETH DoS custom predicate batches.
|
||||
let eth_friend = CustomPredicateRef::new(eth_friend_batch(params)?, 0);
|
||||
let eth_dos_batch = eth_dos_batch(params)?;
|
||||
let eth_friend = CustomPredicateRef::new(eth_friend_batch(params, mock)?, 0);
|
||||
let eth_dos_batch = eth_dos_batch(params, mock)?;
|
||||
let eth_dos_base = CustomPredicateRef::new(eth_dos_batch.clone(), 0);
|
||||
let eth_dos_ind = CustomPredicateRef::new(eth_dos_batch.clone(), 1);
|
||||
let eth_dos = CustomPredicateRef::new(eth_dos_batch.clone(), 2);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue