move pod data's deserialization to RecursivePod trait (#294), expose get_common_data (#300)

This commit is contained in:
arnaucube 2025-06-18 11:13:29 +02:00 committed by GitHub
parent 6ab0bc52fc
commit 0541817116
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 87 additions and 81 deletions

View file

@ -46,14 +46,6 @@ impl MockEmptyPod {
}
Ok(())
}
pub(crate) fn deserialize(
params: Params,
id: PodId,
_vds_root: Hash,
_data: serde_json::Value,
) -> Result<Box<dyn RecursivePod>> {
Ok(Box::new(Self { params, id }))
}
}
impl Pod for MockEmptyPod {
@ -88,6 +80,14 @@ impl RecursivePod for MockEmptyPod {
fn vds_root(&self) -> Hash {
panic!("MockEmptyPod can't be verified in a recursive MainPod circuit");
}
fn deserialize_data(
params: Params,
_data: serde_json::Value,
_vds_root: Hash,
id: PodId,
) -> Result<Box<dyn RecursivePod>, Box<DynError>> {
Ok(Box::new(Self { params, id }))
}
}
#[cfg(test)]

View file

@ -190,32 +190,6 @@ impl MockMainPod {
})
}
// MockMainPods include some internal private state which is necessary
// for verification. In non-mock Pods, this state will not be necessary,
// as the public statements can be verified using a ZK proof.
pub(crate) fn deserialize(
params: Params,
id: PodId,
vds_root: Hash,
data: serde_json::Value,
) -> Result<Box<dyn RecursivePod>> {
let Data {
public_statements,
operations,
statements,
merkle_proofs,
} = serde_json::from_value(data)?;
Ok(Box::new(Self {
params,
id,
vds_root,
public_statements,
operations,
statements,
merkle_proofs,
}))
}
fn _verify(&self) -> Result<()> {
// 1. TODO: Verify input pods
@ -331,6 +305,31 @@ impl RecursivePod for MockMainPod {
fn vds_root(&self) -> Hash {
self.vds_root
}
// MockMainPods include some internal private state which is necessary
// for verification. In non-mock Pods, this state will not be necessary,
// as the public statements can be verified using a ZK proof.
fn deserialize_data(
params: Params,
data: serde_json::Value,
vds_root: Hash,
id: PodId,
) -> Result<Box<dyn RecursivePod>, Box<DynError>> {
let Data {
public_statements,
operations,
statements,
merkle_proofs,
} = serde_json::from_value(data)?;
Ok(Box::new(Self {
params,
id,
vds_root,
public_statements,
operations,
statements,
merkle_proofs,
}))
}
}
#[cfg(test)]