Add table multiplexer (and use it for container, custom pred & PublicKeyOf ops) (#376)

- Extend the `Flattenable` trait to include a `size` method that returns the number of `Target`s the type requires.  This is used in the table to figure out the max length of an array that must fit all entry types.
- Move the circuit methods to precalculate hash states and do hashes started from a precomputed state to a new module
- Introduce `MuxTableTarget` which allows easy multiplexing of tables where each sub-table may have entries of different lengths.  The table access is done via hashing + unhashing automatically (via use of a generator)
- Use the `MuxTableTarget` to access merkle tree claims and custom predicate verification, which where previously in different tables and accessed with independent random accesses each
- Move the public key derivation for the PublicKeyOf operation check to the same multiplexed table.  Now we can choose how many of those operations a circuit supports.

Resolve https://github.com/0xPARC/pod2/issues/357
Resolve https://github.com/0xPARC/pod2/issues/361
This commit is contained in:
Eduard S. 2025-08-05 19:09:41 -07:00 committed by GitHub
parent 0305a4de19
commit bcaef6c47a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 843 additions and 524 deletions

View file

@ -764,8 +764,11 @@ pub struct Params {
pub max_depth_mt_containers: usize,
// maximum depth of the merkle tree gadget used for verifier_data membership
// check. This allows creating verifying sets of pod circuits of size
// 2^max_depth_mt_vds.
// 2^max_depth_mt_vds. Limits the number of container operations of the type Contains,
// NotContains.
pub max_depth_mt_vds: usize,
// maximum number of public key derivations used for PublicKeyOf operation
pub max_public_key_of: usize,
//
// The following parameters define how a pod id is calculated. They need to be the same among
// different circuits to be compatible in their verification.
@ -803,6 +806,7 @@ impl Default for Params {
max_merkle_proofs_containers: 5,
max_depth_mt_containers: 32,
max_depth_mt_vds: 6, // up to 64 (2^6) different pod circuits
max_public_key_of: 2,
}
}
}
@ -828,10 +832,6 @@ impl Params {
Self::predicate_size() + STATEMENT_ARG_F_LEN * self.max_statement_args
}
pub fn operation_size(&self, operation_arg_f_len: usize) -> usize {
Self::operation_type_size() + operation_arg_f_len * self.max_operation_args
}
pub const fn statement_tmpl_size(&self) -> usize {
Self::predicate_size() + self.max_statement_args * Self::statement_tmpl_arg_size()
}