This commit is contained in:
parent
6ab0bc52fc
commit
0541817116
6 changed files with 87 additions and 81 deletions
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -581,7 +581,7 @@ pub struct MainPod {
|
|||
// a serialized proof. At some point in the future, this data may be available
|
||||
// as a constant or with static initialization, but in the meantime we can
|
||||
// generate it on-demand.
|
||||
fn get_common_data(params: &Params) -> Result<CommonCircuitData<F, D>, Error> {
|
||||
pub fn get_common_data(params: &Params) -> Result<CommonCircuitData<F, D>, Error> {
|
||||
// TODO: Cache this somehow
|
||||
// https://github.com/0xPARC/pod2/issues/247
|
||||
let rec_circuit_data = &*STANDARD_REC_MAIN_POD_CIRCUIT_DATA;
|
||||
|
|
@ -643,24 +643,6 @@ impl MainPod {
|
|||
pub fn params(&self) -> &Params {
|
||||
&self.params
|
||||
}
|
||||
|
||||
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 common = get_common_data(¶ms)?;
|
||||
let proof = deserialize_proof(&common, &data.proof)?;
|
||||
Ok(Box::new(Self {
|
||||
params,
|
||||
id,
|
||||
vds_root,
|
||||
proof,
|
||||
public_statements: data.public_statements,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
impl Pod for MainPod {
|
||||
|
|
@ -706,6 +688,23 @@ impl RecursivePod for MainPod {
|
|||
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 common = get_common_data(¶ms)?;
|
||||
let proof = deserialize_proof(&common, &data.proof)?;
|
||||
Ok(Box::new(Self {
|
||||
params,
|
||||
id,
|
||||
vds_root,
|
||||
proof,
|
||||
public_statements: data.public_statements,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue