Skip to content

Commit

Permalink
Added serialize and deserialize to starky proofs (#1630)
Browse files Browse the repository at this point in the history
* changed to web-time in circuit_builder

* Rustfmt

* lint

* added serialize and deseralize to starky proofs

* linting fix

---------

Co-authored-by: Robin Salen <[email protected]>
  • Loading branch information
armanthepythonguy and Nashtare authored Oct 2, 2024
1 parent 41dc325 commit 27a972f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions starky/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ anyhow = { workspace = true }
hashbrown = { workspace = true }
itertools = { workspace = true }
log = { workspace = true }
serde = { workspace = true, features = ["rc"] }
num-bigint = { version = "0.4.3", default-features = false }

# Local dependencies
Expand Down
3 changes: 2 additions & 1 deletion starky/src/fibonacci_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ const FIBONACCI_COLUMNS: usize = 2;
const FIBONACCI_PUBLIC_INPUTS: usize = 3;

impl<F: RichField + Extendable<D>, const D: usize> Stark<F, D> for FibonacciStark<F, D> {
type EvaluationFrame<FE, P, const D2: usize> = StarkFrame<P, P::Scalar, FIBONACCI_COLUMNS, FIBONACCI_PUBLIC_INPUTS>
type EvaluationFrame<FE, P, const D2: usize>
= StarkFrame<P, P::Scalar, FIBONACCI_COLUMNS, FIBONACCI_PUBLIC_INPUTS>
where
FE: FieldExtension<D2, BaseField = F>,
P: PackedField<Scalar = FE>;
Expand Down
3 changes: 2 additions & 1 deletion starky/src/permutation_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ const PERM_COLUMNS: usize = 3;
const PERM_PUBLIC_INPUTS: usize = 1;

impl<F: RichField + Extendable<D>, const D: usize> Stark<F, D> for PermutationStark<F, D> {
type EvaluationFrame<FE, P, const D2: usize> = StarkFrame<P, P::Scalar, PERM_COLUMNS, PERM_PUBLIC_INPUTS>
type EvaluationFrame<FE, P, const D2: usize>
= StarkFrame<P, P::Scalar, PERM_COLUMNS, PERM_PUBLIC_INPUTS>
where
FE: FieldExtension<D2, BaseField = F>,
P: PackedField<Scalar = FE>;
Expand Down
10 changes: 7 additions & 3 deletions starky/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ use plonky2::iop::target::Target;
use plonky2::plonk::config::{GenericConfig, Hasher};
use plonky2::util::serialization::{Buffer, IoResult, Read, Write};
use plonky2_maybe_rayon::*;
use serde::{Deserialize, Serialize};

use crate::config::StarkConfig;
use crate::lookup::GrandProductChallengeSet;

/// Merkle caps and openings that form the proof of a single STARK.
#[derive(Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(bound = "")]
pub struct StarkProof<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize> {
/// Merkle cap of LDEs of trace values.
pub trace_cap: MerkleCap<F, C::Hasher>,
Expand Down Expand Up @@ -120,7 +122,8 @@ impl<const D: usize> StarkProofTarget<D> {
}

/// Merkle caps and openings that form the proof of a single STARK, along with its public inputs.
#[derive(Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(bound = "")]
pub struct StarkProofWithPublicInputs<
F: RichField + Extendable<D>,
C: GenericConfig<D, F = F>,
Expand Down Expand Up @@ -217,7 +220,8 @@ pub struct MultiProofChallenges<F: RichField + Extendable<D>, const D: usize, co
}

/// Purported values of each polynomial at the challenge point.
#[derive(Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(bound = "")]
pub struct StarkOpeningSet<F: RichField + Extendable<D>, const D: usize> {
/// Openings of trace polynomials at `zeta`.
pub local_values: Vec<F::Extension>,
Expand Down
3 changes: 2 additions & 1 deletion starky/src/unconstrained_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const COLUMNS: usize = 2;
const PUBLIC_INPUTS: usize = 0;

impl<F: RichField + Extendable<D>, const D: usize> Stark<F, D> for UnconstrainedStark<F, D> {
type EvaluationFrame<FE, P, const D2: usize> = StarkFrame<P, P::Scalar, COLUMNS, PUBLIC_INPUTS>
type EvaluationFrame<FE, P, const D2: usize>
= StarkFrame<P, P::Scalar, COLUMNS, PUBLIC_INPUTS>
where
FE: FieldExtension<D2, BaseField = F>,
P: PackedField<Scalar = FE>;
Expand Down

0 comments on commit 27a972f

Please sign in to comment.