Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/examples/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use std::sync::Arc;
use anyhow::Result;

use crate::{
frontend::{literal, CustomPredicateBatchBuilder, StatementTmplBuilder},
middleware::{
CustomPredicateBatch, CustomPredicateRef, NativePredicate, Params, PodType, Predicate,
KEY_SIGNER, KEY_TYPE,
frontend::{
literal, CustomPredicateBatch, CustomPredicateBatchBuilder, CustomPredicateRef,
NativePredicate, Predicate, StatementTmplBuilder, Value,
},
middleware::{self, Params, PodType, KEY_SIGNER, KEY_TYPE},
};

use NativePredicate as NP;
Expand All @@ -27,7 +27,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", literal(KEY_TYPE)))
.arg(PodType::MockSigned), // TODO
.arg(middleware::Value::from(PodType::MockSigned)), // TODO
// the attestation pod is signed by (src_or, src_key)
STB::new(NP::Equal)
.arg(("attestation_pod", literal(KEY_SIGNER)))
Expand All @@ -37,6 +37,7 @@ pub fn eth_friend_batch(params: &Params) -> Result<Arc<CustomPredicateBatch>> {
.arg(("attestation_pod", literal("attestation")))
.arg(("dst_ori", "dst_key")),
],
"eth_friend",
)?;

println!("a.0. eth_friend = {}", builder.predicates.last().unwrap());
Expand All @@ -45,7 +46,7 @@ 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(eth_friend_batch(params)?, 0));
let eth_friend = Predicate::Custom(CustomPredicateRef::new(eth_friend_batch(params)?, 0));
let mut builder = CustomPredicateBatchBuilder::new("eth_dos_distance_base".into());

// eth_dos_distance_base(src_or, src_key, dst_or, dst_key, distance_or, distance_key) = and<
Expand Down Expand Up @@ -74,6 +75,7 @@ pub fn eth_dos_batch(params: &Params) -> Result<Arc<CustomPredicateBatch>> {
.arg(("distance_ori", "distance_key"))
.arg(0),
],
"eth_dos_distance_base",
)?;
println!(
"b.0. eth_dos_distance_base = {}",
Expand Down Expand Up @@ -119,6 +121,7 @@ pub fn eth_dos_batch(params: &Params) -> Result<Arc<CustomPredicateBatch>> {
.arg(("intermed_ori", "intermed_key"))
.arg(("dst_ori", "dst_key")),
],
"eth_dos_distance_ind",
)?;

println!(
Expand Down Expand Up @@ -147,6 +150,7 @@ pub fn eth_dos_batch(params: &Params) -> Result<Arc<CustomPredicateBatch>> {
.arg(("dst_ori", "dst_key"))
.arg(("distance_ori", "distance_key")),
],
"eth_dos_distance",
)?;

println!(
Expand Down
10 changes: 5 additions & 5 deletions src/examples/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use custom::{eth_dos_batch, eth_friend_batch};
use std::collections::HashMap;

use crate::backends::plonky2::mock::signedpod::MockSigner;
use crate::frontend::CustomPredicateRef;
use crate::frontend::{
containers::{Dictionary, Set},
MainPodBuilder, SignedPod, SignedPodBuilder, Statement, Value,
};
use crate::middleware::CustomPredicateRef;
use crate::middleware::{Params, PodType, KEY_SIGNER, KEY_TYPE};
use crate::op;

Expand Down Expand Up @@ -94,11 +94,11 @@ pub fn eth_dos_pod_builder(
bob_pubkey: &Value,
) -> Result<MainPodBuilder> {
// Will need ETH friend and ETH DoS custom predicate batches.
let eth_friend = CustomPredicateRef(eth_friend_batch(params)?, 0);
let eth_friend = CustomPredicateRef::new(eth_friend_batch(params)?, 0);
let eth_dos_batch = eth_dos_batch(params)?;
let eth_dos_base = CustomPredicateRef(eth_dos_batch.clone(), 0);
let eth_dos_ind = CustomPredicateRef(eth_dos_batch.clone(), 1);
let eth_dos = CustomPredicateRef(eth_dos_batch.clone(), 2);
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);

// ETHDoS POD builder
let mut alice_bob_ethdos = MainPodBuilder::new(params);
Expand Down
Loading
Loading