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:
Eduard S. 2025-05-16 13:17:14 +02:00 committed by GitHub
parent f5a1aa7523
commit def0730462
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 629 additions and 153 deletions

View file

@ -57,11 +57,14 @@ impl fmt::Display for MockMainPod {
writeln!(f, "MockMainPod ({}):", self.id)?;
// TODO print input signed pods id and type
// TODO print input main pods id and type
let offset_input_signed_pods = Self::offset_input_signed_pods();
let offset_input_main_pods = self.offset_input_main_pods();
let offset_input_statements = self.offset_input_statements();
let offset_public_statements = self.offset_public_statements();
for (i, st) in self.statements.iter().enumerate() {
if (i < self.offset_input_main_pods()) && (i % self.params.max_signed_pod_values == 0) {
if (i >= offset_input_signed_pods && i < offset_input_main_pods)
&& ((i - offset_input_signed_pods) % self.params.max_signed_pod_values == 0)
{
writeln!(
f,
" from input SignedPod {}:",
@ -125,8 +128,12 @@ fn fmt_statement_index(
/// - private Statements
/// - public Statements
impl MockMainPod {
fn offset_input_signed_pods() -> usize {
1
}
fn offset_input_main_pods(&self) -> usize {
self.params.max_input_signed_pods * self.params.max_signed_pod_values
Self::offset_input_signed_pods()
+ self.params.max_input_signed_pods * self.params.max_signed_pod_values
}
fn offset_input_statements(&self) -> usize {
self.offset_input_main_pods()

View file

@ -19,7 +19,7 @@ pub struct MockSigner {
}
impl MockSigner {
pub fn pubkey(&self) -> Hash {
pub fn public_key(&self) -> Hash {
hash_str(&self.pk)
}
}
@ -27,7 +27,7 @@ impl MockSigner {
impl MockSigner {
fn _sign(&mut self, _params: &Params, kvs: &HashMap<Key, Value>) -> Result<MockSignedPod> {
let mut kvs = kvs.clone();
let pubkey = self.pubkey();
let pubkey = self.public_key();
kvs.insert(Key::from(KEY_SIGNER), Value::from(pubkey));
kvs.insert(Key::from(KEY_TYPE), Value::from(PodType::MockSigned));