Integrate recursion into MainPod (#243)

* calculate MainPod id in a dynamic-friendly way

The MainPod id is now calculated with front padding and a fixed size
independent of max_public_statements so that introduction gadgets can be
verified by a MainPod while paying only for the number of statements
they use.  This is because with front padding of none-statements we can
precompute the poseidon state corresponding to absorbing all the padding
statements and only pay constraints for the non-padding statements.

The id is calculated as follows:
`id = hash(serialize(reverse(statements || none-statements)))`

* add time feature and disable timing by default

* apply suggestions from @arnaucube

* link issues in todos
This commit is contained in:
Eduard S. 2025-05-29 17:10:19 +02:00 committed by GitHub
parent d3fef8392e
commit 88a75986b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 1405 additions and 729 deletions

View file

@ -1,4 +1,4 @@
use std::fmt;
use std::{fmt, iter};
use serde::{Deserialize, Serialize};
@ -28,9 +28,15 @@ impl Statement {
}
impl ToFields for Statement {
fn to_fields(&self, _params: &Params) -> Vec<middleware::F> {
let mut fields = self.0.to_fields(_params);
fields.extend(self.1.iter().flat_map(|arg| arg.to_fields(_params)));
fn to_fields(&self, params: &Params) -> Vec<middleware::F> {
let mut fields = self.0.to_fields(params);
fields.extend(
self.1
.iter()
.chain(iter::repeat(&StatementArg::None))
.take(params.max_statement_args)
.flat_map(|arg| arg.to_fields(params)),
);
fields
}
}