calculate MainPod id in a dynamic-friendly way (#241)

* 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)))`

* fix test
This commit is contained in:
Eduard S. 2025-05-23 10:12:28 +02:00 committed by GitHub
parent 82481e88d7
commit d3fef8392e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 245 additions and 26 deletions

View file

@ -582,6 +582,9 @@ pub struct Params {
pub max_statements: usize,
pub max_signed_pod_values: usize,
pub max_public_statements: usize,
// Number of public statements to hash to calculate the id. Must be equal or greater than
// `max_public_statements`.
pub num_public_statements_id: usize,
pub max_statement_args: usize,
pub max_operation_args: usize,
// max number of custom predicates batches that a MainPod can use
@ -607,6 +610,7 @@ impl Default for Params {
max_statements: 20,
max_signed_pod_values: 8,
max_public_statements: 10,
num_public_statements_id: 16,
max_statement_args: 5,
max_operation_args: 5,
max_custom_predicate_batches: 2,