Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deserialise trait #34

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions plonky2/src/fri/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

use serde::Serialize;
use serde::{Deserialize, Serialize};

use crate::fri::reduction_strategies::FriReductionStrategy;

Expand All @@ -22,7 +22,7 @@ pub mod verifier;
pub mod witness_util;

/// A configuration for the FRI protocol.
#[derive(Debug, Clone, Eq, PartialEq, Serialize)]
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct FriConfig {
/// `rate = 2^{-rate_bits}`.
pub rate_bits: usize,
Expand Down Expand Up @@ -67,7 +67,7 @@ impl FriConfig {

/// FRI parameters, including generated parameters which are specific to an instance size, in
/// contrast to `FriConfig` which is user-specified and independent of instance size.
#[derive(Debug, Clone, Eq, PartialEq, Serialize)]
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct FriParams {
/// User-specified FRI configuration.
pub config: FriConfig,
Expand Down
4 changes: 2 additions & 2 deletions plonky2/src/fri/reduction_strategies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
use alloc::{vec, vec::Vec};

use log::debug;
use serde::Serialize;
use serde::{Deserialize, Serialize};
#[cfg(feature = "timing")]
use web_time::Instant;

/// A method for deciding what arity to use at each reduction layer.
#[derive(Debug, Clone, Eq, PartialEq, Serialize)]
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub enum FriReductionStrategy {
/// Specifies the exact sequence of arities (expressed in bits) to use.
Fixed(Vec<usize>),
Expand Down
4 changes: 2 additions & 2 deletions plonky2/src/gates/selectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use alloc::{vec, vec::Vec};
use core::ops::Range;

use serde::Serialize;
use serde::{Deserialize, Serialize};

use crate::field::extension::Extendable;
use crate::field::polynomial::PolynomialValues;
Expand All @@ -13,7 +13,7 @@ use crate::plonk::circuit_builder::LookupWire;
/// Placeholder value to indicate that a gate doesn't use a selector polynomial.
pub(crate) const UNUSED_SELECTOR: usize = u32::MAX as usize;

#[derive(Debug, Clone, Eq, PartialEq, Serialize)]
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct SelectorsInfo {
pub selector_indices: Vec<usize>,
pub groups: Vec<Range<usize>>,
Expand Down
11 changes: 7 additions & 4 deletions plonky2/src/plonk/circuit_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use core::ops::{Range, RangeFrom};
use std::collections::BTreeMap;

use anyhow::Result;
use serde::Serialize;
use serde::{Deserialize, Serialize};

use crate::field::extension::Extendable;
use crate::field::fft::FftRootTable;
Expand Down Expand Up @@ -55,7 +55,7 @@ use crate::util::timing::TimingTree;
///
/// It supports a [`Default`] implementation tailored for recursion with Poseidon hash (of width 12)
/// as internal hash function and FRI rate of 1/8.
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct CircuitConfig {
/// The number of wires available at each row. This corresponds to the "width" of the circuit,
/// and consists in the sum of routed wires and advice wires.
Expand Down Expand Up @@ -388,7 +388,8 @@ impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
}

/// Circuit data required by the verifier, but not the prover.
#[derive(Debug, Clone, Eq, PartialEq, Serialize)]
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]

pub struct VerifierOnlyCircuitData<C: GenericConfig<D>, const D: usize> {
/// A commitment to each constant polynomial and each permutation polynomial.
pub constants_sigmas_cap: MerkleCap<C::F, C::Hasher>,
Expand All @@ -411,13 +412,15 @@ impl<C: GenericConfig<D>, const D: usize> VerifierOnlyCircuitData<C, D> {
}

/// Circuit data required by both the prover and the verifier.
#[derive(Debug, Clone, Eq, PartialEq, Serialize)]
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[serde(bound = "")]
pub struct CommonCircuitData<F: RichField + Extendable<D>, const D: usize> {
pub config: CircuitConfig,

pub fri_params: FriParams,

/// The types of gates used in this circuit, along with their prefixes.
#[serde(skip_deserializing, skip_serializing)]
pub gates: Vec<GateRef<F, D>>,

/// Information on the circuit's selector polynomials.
Expand Down
6 changes: 3 additions & 3 deletions plonky2/src/plonk/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use alloc::{vec, vec::Vec};
use core::fmt::Debug;

use serde::de::DeserializeOwned;
use serde::Serialize;
use serde::{Deserialize, Serialize};

use crate::field::extension::quadratic::QuadraticExtension;
use crate::field::extension::{Extendable, FieldExtension};
Expand Down Expand Up @@ -126,7 +126,7 @@ pub trait GenericConfig<const D: usize>:
}

/// Configuration using Poseidon over the Goldilocks field.
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Serialize)]
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Serialize, Deserialize)]
pub struct PoseidonGoldilocksConfig;
impl GenericConfig<2> for PoseidonGoldilocksConfig {
type F = GoldilocksField;
Expand All @@ -136,7 +136,7 @@ impl GenericConfig<2> for PoseidonGoldilocksConfig {
}

/// Configuration using Poseidon over the Goldilocks field.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct Poseidon2GoldilocksConfig;
impl GenericConfig<2> for Poseidon2GoldilocksConfig {
type F = GoldilocksField;
Expand Down