Complete the verification in MainMockPod (#302)

- Update the `RecursivePod` trait to return `vd_set` instead of `vds_root`
  - A native verifier requires the entire set to reason about the circuits that have been used in the recursive tree
- Implement serialization/deserialization for `VDSet`
- Remove `DynError` and use `BackendError` instead for middleware functions that wrap or define trait functions implemented in the backend.  This is based on the fact that we will only have a single backend enabled at a time, so there's no need for a `dyn Error`
  - Move the implementations of `_verify` functions to `verify` and similarly for `_prove`
- Complete the verification of a MockMainPod: the verification of input pods was missing.  The inclusion of these input pods in the serialization was also missing.  With this change a `MockMainPod` will grow after each recursion.  This was expected from the design but was not the case because of the missing recursive native verification implementation.

* apply feedback from @arnaucube
This commit is contained in:
Eduard S. 2025-06-19 16:28:25 +02:00 committed by GitHub
parent df8fce76d6
commit 6249406cb2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 427 additions and 350 deletions

View file

@ -1,6 +1,6 @@
use std::{backtrace::Backtrace, fmt::Debug};
use crate::middleware::{DynError, Statement, StatementTmpl, Value};
use crate::middleware::{BackendError, Statement, StatementTmpl, Value};
pub type Result<T, E = Error> = core::result::Result<T, E>;
@ -41,7 +41,7 @@ pub enum Error {
#[error(transparent)]
Infallible(#[from] std::convert::Infallible),
#[error(transparent)]
Backend(#[from] Box<DynError>),
Backend(#[from] BackendError),
#[error(transparent)]
Middleware(#[from] crate::middleware::Error),
}

View file

@ -564,7 +564,7 @@ impl MainPodBuilder {
statements: &statements,
operations: &operations,
public_statements: &public_statements,
vds_set: self.vd_set.clone(),
vd_set: self.vd_set.clone(),
};
let pod = prover.prove(&self.params, &self.vd_set, inputs)?;

View file

@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
use super::Error;
use crate::{
frontend::{MainPod, SignedPod},
middleware::{deserialize_pod, deserialize_signed_pod, Hash, Params, PodId},
middleware::{deserialize_pod, deserialize_signed_pod, Params, PodId, VDSet},
};
#[derive(Serialize, Deserialize, JsonSchema)]
@ -29,7 +29,7 @@ pub struct SerializedMainPod {
params: Params,
pod_type: (usize, String),
id: PodId,
vds_root: Hash,
vd_set: VDSet,
data: serde_json::Value,
}
@ -62,7 +62,7 @@ impl From<MainPod> for SerializedMainPod {
SerializedMainPod {
pod_type: (pod_type, pod_type_name_str.to_string()),
id: pod.id(),
vds_root: pod.pod.vds_root(),
vd_set: pod.pod.vd_set().clone(),
params: pod.params.clone(),
data,
}
@ -77,7 +77,7 @@ impl TryFrom<SerializedMainPod> for MainPod {
serialized.pod_type.0,
serialized.params.clone(),
serialized.id,
serialized.vds_root,
serialized.vd_set,
serialized.data,
)?;
let public_statements = pod.pub_statements();