From 27a972f1cb109d1e01c3351f757419453dae0974 Mon Sep 17 00:00:00 2001 From: Arman Aurobindo <66505181+armanthepythonguy@users.noreply.github.com> Date: Wed, 2 Oct 2024 23:36:06 +0530 Subject: [PATCH] Added serialize and deserialize to starky proofs (#1630) * changed to web-time in circuit_builder * Rustfmt * lint * added serialize and deseralize to starky proofs * linting fix --------- Co-authored-by: Robin Salen <30937548+Nashtare@users.noreply.github.com> --- starky/Cargo.toml | 1 + starky/src/fibonacci_stark.rs | 3 ++- starky/src/permutation_stark.rs | 3 ++- starky/src/proof.rs | 10 +++++++--- starky/src/unconstrained_stark.rs | 3 ++- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/starky/Cargo.toml b/starky/Cargo.toml index 92fdf4759d..31bd5e6e9b 100644 --- a/starky/Cargo.toml +++ b/starky/Cargo.toml @@ -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 diff --git a/starky/src/fibonacci_stark.rs b/starky/src/fibonacci_stark.rs index fdbc081686..69dfc46d37 100644 --- a/starky/src/fibonacci_stark.rs +++ b/starky/src/fibonacci_stark.rs @@ -61,7 +61,8 @@ const FIBONACCI_COLUMNS: usize = 2; const FIBONACCI_PUBLIC_INPUTS: usize = 3; impl, const D: usize> Stark for FibonacciStark { - type EvaluationFrame = StarkFrame + type EvaluationFrame + = StarkFrame where FE: FieldExtension, P: PackedField; diff --git a/starky/src/permutation_stark.rs b/starky/src/permutation_stark.rs index 8a897d792b..ec7f2e41ef 100644 --- a/starky/src/permutation_stark.rs +++ b/starky/src/permutation_stark.rs @@ -55,7 +55,8 @@ const PERM_COLUMNS: usize = 3; const PERM_PUBLIC_INPUTS: usize = 1; impl, const D: usize> Stark for PermutationStark { - type EvaluationFrame = StarkFrame + type EvaluationFrame + = StarkFrame where FE: FieldExtension, P: PackedField; diff --git a/starky/src/proof.rs b/starky/src/proof.rs index 09d3822dd2..31151f1c3b 100644 --- a/starky/src/proof.rs +++ b/starky/src/proof.rs @@ -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, C: GenericConfig, const D: usize> { /// Merkle cap of LDEs of trace values. pub trace_cap: MerkleCap, @@ -120,7 +122,8 @@ impl StarkProofTarget { } /// 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, C: GenericConfig, @@ -217,7 +220,8 @@ pub struct MultiProofChallenges, 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, const D: usize> { /// Openings of trace polynomials at `zeta`. pub local_values: Vec, diff --git a/starky/src/unconstrained_stark.rs b/starky/src/unconstrained_stark.rs index c8ce633537..495123acf8 100644 --- a/starky/src/unconstrained_stark.rs +++ b/starky/src/unconstrained_stark.rs @@ -45,7 +45,8 @@ const COLUMNS: usize = 2; const PUBLIC_INPUTS: usize = 0; impl, const D: usize> Stark for UnconstrainedStark { - type EvaluationFrame = StarkFrame + type EvaluationFrame + = StarkFrame where FE: FieldExtension, P: PackedField;