No Pod IDs (#394)

- middleware:
  - Add `Statement::Intro`
  - Add `SignedBy` native predicate and operation.  The signature is auxiliary data to the operation
  - Rename `PodSigner` to `Signer` with a new API (just for signing `RawValue`)
  - Removed `NewEntry` operation.  Use `ContainsFromEntries` instead
  - Remove `KEY_SIGNER` and `KEY_TYPE` which are no longer used
  - Merge `RecursivePod` and `Pod` traits
  - Change the `Pod::deserialize_data` method to use `Self` instead of `Box<dyn Pod>` 
  - Extend `Pod` trait with these methods:
    - `is_main`: when the pod is Main, in a (recursive) verification its vk will be checked to exist in the vd_set but not if it's intro pod
    - `is_mock`: skip some verifications in the recursive mock MainPod verification
    - `verifier_data_hash`
    - `pod_id` renamed to `statements_hash`
  - AnchoredKeys are now a pair of dictionary root and key
  - Entry statements are now defined as Contains with literal arguments
    - Operations that take Entries now use Contains statements with literal arguments
- frontend:
  - Rename `SignedPod` to `SignedDict` (which now contains the dict, public key and signature, and can still `verify(self)`ed)
  - The `SignedDict` keeps the method `get_statement` for convenience but now it returns a `Contains` statement that proves the existence of the key in the dict
  - The `MainPodBuilder` automatically inserts a `Contains` statement when an operation is added that uses an entry as argument that was not yet "opened".
  - Removed the `literal` methods from the `MainPodBuilder` that were loading literals to anchored keys: that was no longer needed after we introduced literal arguments
- backend
  - Only verify inclusion of the verifying key into the vd_set if the pod is MainPod.  A pod is not MainPod if the first statement is Intro.
  - Reject intro pods that have non-intro statements
  - Empty pod now returns an intro statement
  - Don't insert a type statement automatically in MainPod and MockMainPod.  We get rid of the type entry.
  - Implement `SignedBy` operation, which uses the muxed table to store signature verifications
- Rename `PodId` to `statements_hash` or `sts_hash` for short.  Now this is only used as a hash of the statements for the circuits public inputs.
- Refactor normalization of `self` statements:
  - Before: replace values that contain `SELF` by the given pod_id
  - After: place the verifying key hash into the Intro predicates
This commit is contained in:
Eduard S. 2025-08-27 13:19:40 +02:00 committed by GitHub
parent 122f9c3cac
commit 0e2f7b756e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 2127 additions and 3064 deletions

View file

@ -33,7 +33,7 @@ impl fmt::Display for Wildcard {
impl ToFields for Wildcard {
fn to_fields(&self, _params: &Params) -> Vec<F> {
vec![F::from_canonical_u64(self.index as u64 + 1)]
vec![F::from_canonical_u64(self.index as u64)]
}
}
@ -110,8 +110,8 @@ impl fmt::Display for StatementTmplArg {
match self {
Self::None => write!(f, "none"),
Self::Literal(v) => v.fmt(f),
Self::AnchoredKey(pod_id, key) => {
pod_id.fmt(f)?;
Self::AnchoredKey(root, key) => {
root.fmt(f)?;
write!(f, "[")?;
key.fmt(f)?;
write!(f, "]")
@ -451,10 +451,13 @@ impl CustomPredicateRef {
#[cfg(test)]
mod tests {
use super::*;
use crate::middleware::{
AnchoredKey, CustomPredicate, CustomPredicateBatch, CustomPredicateRef, Key,
NativePredicate, Operation, Params, PodType, Predicate, Statement, StatementTmpl,
StatementTmplArg, SELF,
use crate::{
dict,
middleware::{
AnchoredKey, CustomPredicate, CustomPredicateBatch, CustomPredicateRef, Key,
NativePredicate, Operation, Params, Predicate, Statement, StatementTmpl,
StatementTmplArg,
},
};
fn st(p: Predicate, args: Vec<StatementTmplArg>) -> StatementTmpl {
@ -513,18 +516,25 @@ mod tests {
)?],
);
let d0 = dict!(32, {
"a" => 10,
})?;
let d1 = dict!(32, {
"b" => 15,
"c" => 17,
})?;
let custom_statement = Statement::Custom(
CustomPredicateRef::new(cust_pred_batch.clone(), 0),
vec![Value::from(SELF)],
vec![Value::from(d0.clone())],
);
let custom_deduction = Operation::Custom(
CustomPredicateRef::new(cust_pred_batch, 0),
vec![
Statement::equal(AnchoredKey::from((SELF, "c")), 2),
Statement::equal(AnchoredKey::from((&d1, "c")), 2),
Statement::product_of(
AnchoredKey::from((SELF, "a")),
AnchoredKey::from((SELF, "b")),
AnchoredKey::from((&d0, "a")),
AnchoredKey::from((&d1, "b")),
Value::from(3),
),
],
@ -548,18 +558,8 @@ mod tests {
"eth_friend".into(),
vec![
st(
P::Native(NP::Equal),
vec![
STA::AnchoredKey(wc(2), Key::from("_type")),
STA::Literal(PodType::Signed.into()),
],
),
st(
P::Native(NP::Equal),
vec![
STA::AnchoredKey(wc(2), Key::from("_signer")),
STA::Wildcard(wc(0)),
],
P::Native(NP::SignedBy),
vec![STA::Wildcard(wc(2)), STA::Wildcard(wc(0))],
),
st(
P::Native(NP::Equal),