Skip to content

Commit

Permalink
Update ChunkProof for serialization (#184)
Browse files Browse the repository at this point in the history
Update `ChunkProof` for serialization.
  • Loading branch information
silathdiir authored Aug 1, 2023
1 parent 1f1d1d9 commit b4945ce
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions prover/src/proof/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ use halo2_proofs::{halo2curves::bn256::G1Affine, plonk::ProvingKey};
use serde_derive::{Deserialize, Serialize};
use snark_verifier::Protocol;
use snark_verifier_sdk::Snark;
use types::eth::StorageTrace;
use types::{base64, eth::StorageTrace};

#[derive(Debug, Deserialize, Serialize)]
pub struct ChunkProof {
pub storage_trace: StorageTrace,
pub protocol: Protocol<G1Affine>,
#[serde(with = "base64")]
pub storage_trace: Vec<u8>,
#[serde(with = "base64")]
pub protocol: Vec<u8>,
pub proof: Proof,
}

Expand All @@ -19,7 +21,8 @@ impl ChunkProof {
storage_trace: StorageTrace,
pk: Option<&ProvingKey<G1Affine>>,
) -> Result<Self> {
let protocol = snark.protocol;
let storage_trace = serde_json::to_vec(&storage_trace)?;
let protocol = serde_json::to_vec(&snark.protocol)?;
let proof = Proof::new(snark.proof, &snark.instances, pk)?;

Ok(Self {
Expand All @@ -42,14 +45,16 @@ impl ChunkProof {

pub fn to_snark_and_storage_trace(self) -> (Snark, StorageTrace) {
let instances = self.proof.instances();
let storage_trace = serde_json::from_slice::<StorageTrace>(&self.storage_trace).unwrap();
let protocol = serde_json::from_slice::<Protocol<G1Affine>>(&self.protocol).unwrap();

(
Snark {
protocol: self.protocol,
protocol,
proof: self.proof.proof,
instances,
},
self.storage_trace,
storage_trace,
)
}
}
Expand Down

0 comments on commit b4945ce

Please sign in to comment.