Skip to content

Commit

Permalink
feat: receipt support Serialize (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
xander42280 authored Dec 29, 2024
1 parent 3167ad8 commit 8e7915d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions prover/src/generation/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use plonky2::field::extension::Extendable;
use plonky2::hash::hash_types::RichField;
use plonky2::plonk::config::GenericConfig;
use plonky2::plonk::proof::ProofWithPublicInputs;
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use std::{cell::RefCell, rc::Rc};

Expand All @@ -19,18 +20,19 @@ pub(crate) struct GenerationStateCheckpoint {
pub(crate) traces: TraceCheckpoint,
}

#[derive(Clone, Debug, Eq, Hash, PartialEq)]
#[derive(Clone, Debug, Serialize, Deserialize, Eq, Hash, PartialEq)]
pub struct Assumption {
pub claim: [u8; 32],
}

#[derive(Clone, Debug)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ReceiptClaim {
pub elf_id: Vec<u8>, // pre image id
pub commit: Vec<u8>, // commit info
}

#[derive(Clone, Debug)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(bound = "")]
pub struct InnerReceipt<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize> {
pub proof: ProofWithPublicInputs<F, C, D>,
pub values: PublicValues,
Expand All @@ -52,7 +54,8 @@ where
}
}

#[derive(Clone, Debug)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(bound = "")]
pub enum AssumptionReceipt<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
{
// A [Receipt] for a proven assumption.
Expand Down Expand Up @@ -102,7 +105,8 @@ where
}
}

#[derive(Clone, Debug)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(bound = "")]
pub struct CompositeReceipt<
F: RichField + Extendable<D>,
C: GenericConfig<D, F = F>,
Expand All @@ -127,7 +131,8 @@ where
}
}

#[derive(Clone, Debug)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(bound = "")]
pub enum Receipt<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize> {
Segments(InnerReceipt<F, C, D>),
Composite(CompositeReceipt<F, C, D>),
Expand Down

0 comments on commit 8e7915d

Please sign in to comment.