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

@ -158,23 +158,6 @@ impl EmptyPod {
})
.map_err(|e| Error::custom(format!("EmptyPod proof verification failure: {:?}", e)))
}
pub(crate) fn deserialize(
params: Params,
id: PodId,
vds_root: Hash,
data: serde_json::Value,
) -> Result<Box<dyn RecursivePod>> {
let data: Data = serde_json::from_value(data)?;
let circuit_data = &*STANDARD_REC_MAIN_POD_CIRCUIT_DATA;
let proof = deserialize_proof(&circuit_data.common, &data.proof)?;
Ok(Box::new(Self {
params,
id,
vds_root,
proof,
}))
}
}
#[derive(Serialize, Deserialize)]
@ -220,6 +203,22 @@ impl RecursivePod for EmptyPod {
fn vds_root(&self) -> Hash {
self.vds_root
}
fn deserialize_data(
params: Params,
data: serde_json::Value,
vds_root: Hash,
id: PodId,
) -> Result<Box<dyn RecursivePod>, Box<DynError>> {
let data: Data = serde_json::from_value(data)?;
let circuit_data = &*STANDARD_REC_MAIN_POD_CIRCUIT_DATA;
let proof = deserialize_proof(&circuit_data.common, &data.proof)?;
Ok(Box::new(Self {
params,
id,
vds_root,
proof,
}))
}
}
#[cfg(test)]