allow SELF in st_tmpl (#240)
* allow SELF in st_tmpl * add some tests * 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
b4a4c72328
commit
82481e88d7
9 changed files with 178 additions and 87 deletions
|
|
@ -21,7 +21,7 @@ pub fn eth_friend_batch(params: &Params, mock: bool) -> Result<Arc<CustomPredica
|
|||
let _eth_friend = builder.predicate_and(
|
||||
"eth_friend",
|
||||
// arguments:
|
||||
&["src_ori", "src_key", "dst_ori", "dst_key"],
|
||||
&["src_key", "dst_key"],
|
||||
// private arguments:
|
||||
&["attestation_pod"],
|
||||
// statement templates:
|
||||
|
|
@ -33,11 +33,11 @@ pub fn eth_friend_batch(params: &Params, mock: bool) -> Result<Arc<CustomPredica
|
|||
// the attestation pod is signed by (src_or, src_key)
|
||||
STB::new(NP::Equal)
|
||||
.arg(("attestation_pod", key(KEY_SIGNER)))
|
||||
.arg(("src_ori", "src_key")),
|
||||
.arg(("SELF", "src_key")),
|
||||
// that same attestation pod has an "attestation"
|
||||
STB::new(NP::Equal)
|
||||
.arg(("attestation_pod", key("attestation")))
|
||||
.arg(("dst_ori", "dst_key")),
|
||||
.arg(("SELF", "dst_key")),
|
||||
],
|
||||
)?;
|
||||
|
||||
|
|
@ -59,11 +59,8 @@ pub fn eth_dos_batch(params: &Params, mock: bool) -> Result<Arc<CustomPredicateB
|
|||
"eth_dos_distance_base",
|
||||
&[
|
||||
// arguments:
|
||||
"src_ori",
|
||||
"src_key",
|
||||
"dst_ori",
|
||||
"dst_key",
|
||||
"distance_ori",
|
||||
"distance_key",
|
||||
],
|
||||
&[ // private arguments:
|
||||
|
|
@ -71,10 +68,10 @@ pub fn eth_dos_batch(params: &Params, mock: bool) -> Result<Arc<CustomPredicateB
|
|||
&[
|
||||
// statement templates:
|
||||
STB::new(NP::Equal)
|
||||
.arg(("src_ori", "src_key"))
|
||||
.arg(("dst_ori", "dst_key")),
|
||||
.arg(("SELF", "src_key"))
|
||||
.arg(("SELF", "dst_key")),
|
||||
STB::new(NP::ValueOf)
|
||||
.arg(("distance_ori", "distance_key"))
|
||||
.arg(("SELF", "distance_key"))
|
||||
.arg(literal(0)),
|
||||
],
|
||||
)?;
|
||||
|
|
@ -89,45 +86,32 @@ pub fn eth_dos_batch(params: &Params, mock: bool) -> Result<Arc<CustomPredicateB
|
|||
"eth_dos_distance_ind",
|
||||
&[
|
||||
// arguments:
|
||||
"src_ori",
|
||||
"src_key",
|
||||
"dst_ori",
|
||||
"dst_key",
|
||||
"distance_ori",
|
||||
"distance_key",
|
||||
],
|
||||
&[
|
||||
// private arguments:
|
||||
"one_ori",
|
||||
"one_key",
|
||||
"shorter_distance_ori",
|
||||
"shorter_distance_key",
|
||||
"intermed_ori",
|
||||
"intermed_key",
|
||||
],
|
||||
&[
|
||||
// statement templates:
|
||||
STB::new(eth_dos_distance)
|
||||
.arg("src_ori")
|
||||
.arg("src_key")
|
||||
.arg("intermed_ori")
|
||||
.arg("intermed_key")
|
||||
.arg("shorter_distance_ori")
|
||||
.arg("shorter_distance_key"),
|
||||
// distance == shorter_distance + 1
|
||||
STB::new(NP::ValueOf)
|
||||
.arg(("one_ori", "one_key"))
|
||||
.arg(("SELF", "one_key"))
|
||||
.arg(literal(1)),
|
||||
STB::new(NP::SumOf)
|
||||
.arg(("distance_ori", "distance_key"))
|
||||
.arg(("shorter_distance_ori", "shorter_distance_key"))
|
||||
.arg(("one_ori", "one_key")),
|
||||
.arg(("SELF", "distance_key"))
|
||||
.arg(("SELF", "shorter_distance_key"))
|
||||
.arg(("SELF", "one_key")),
|
||||
// intermed is a friend of dst
|
||||
STB::new(eth_friend)
|
||||
.arg("intermed_ori")
|
||||
.arg("intermed_key")
|
||||
.arg("dst_ori")
|
||||
.arg("dst_key"),
|
||||
STB::new(eth_friend).arg("intermed_key").arg("dst_key"),
|
||||
],
|
||||
)?;
|
||||
|
||||
|
|
@ -138,29 +122,16 @@ pub fn eth_dos_batch(params: &Params, mock: bool) -> Result<Arc<CustomPredicateB
|
|||
|
||||
let _eth_dos_distance = builder.predicate_or(
|
||||
"eth_dos_distance",
|
||||
&[
|
||||
"src_ori",
|
||||
"src_key",
|
||||
"dst_ori",
|
||||
"dst_key",
|
||||
"distance_ori",
|
||||
"distance_key",
|
||||
],
|
||||
&["src_key", "dst_key", "distance_key"],
|
||||
&[],
|
||||
&[
|
||||
STB::new(eth_dos_distance_base)
|
||||
.arg("src_ori")
|
||||
.arg("src_key")
|
||||
.arg("dst_ori")
|
||||
.arg("dst_key")
|
||||
.arg("distance_ori")
|
||||
.arg("distance_key"),
|
||||
STB::new(eth_dos_distance_ind)
|
||||
.arg("src_ori")
|
||||
.arg("src_key")
|
||||
.arg("dst_ori")
|
||||
.arg("dst_key")
|
||||
.arg("distance_ori")
|
||||
.arg("distance_key"),
|
||||
],
|
||||
)?;
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ pub fn eth_dos_pod_builder(
|
|||
let zero = alice_bob_ethdos.priv_literal(0)?;
|
||||
let alice_equals_alice = alice_bob_ethdos.priv_op(op!(
|
||||
eq,
|
||||
(alice_attestation, KEY_SIGNER),
|
||||
alice_pubkey_copy.clone(),
|
||||
alice_pubkey_copy.clone()
|
||||
))?;
|
||||
let ethdos_alice_alice_is_zero_base = alice_bob_ethdos.priv_op(op!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue