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

Serialization #75

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion src/commitments.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use super::group::{GroupElement, VartimeMultiscalarMul, GROUP_BASEPOINT_COMPRESSED};
use super::scalar::Scalar;
use digest::{ExtendableOutput, Input, XofReader};
use serde::{Deserialize, Serialize};
use sha3::Shake256;

#[derive(Debug)]
#[derive(Debug, Serialize, Deserialize)]
pub struct MultiCommitGens {
pub n: usize,
pub G: Vec<GroupElement>,
Expand Down
3 changes: 2 additions & 1 deletion src/dense_mlpoly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ use serde::{Deserialize, Serialize};
#[cfg(feature = "multicore")]
use rayon::prelude::*;

#[derive(Debug)]
#[derive(Debug, Serialize, Deserialize)]
pub struct DensePolynomial {
num_vars: usize, // the number of variables in the multilinear polynomial
len: usize,
Z: Vec<Scalar>, // evaluations of the polynomial in all the 2^num_vars Boolean inputs
}

#[derive(Serialize, Deserialize)]
pub struct PolyCommitmentGens {
pub gens: DotProductProofGens,
}
Expand Down
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,19 @@ use timer::Timer;
use transcript::{AppendToTranscript, ProofTranscript};

/// `ComputationCommitment` holds a public preprocessed NP statement (e.g., R1CS)
#[derive(Serialize, Deserialize)]
pub struct ComputationCommitment {
comm: R1CSCommitment,
}

/// `ComputationDecommitment` holds information to decommit `ComputationCommitment`
#[derive(Serialize, Deserialize)]
pub struct ComputationDecommitment {
decomm: R1CSDecommitment,
}

/// `Assignment` holds an assignment of values to either the inputs or variables in an `Instance`
#[derive(Clone)]
#[derive(Clone, Serialize, Deserialize)]
pub struct Assignment {
assignment: Vec<Scalar>,
}
Expand Down Expand Up @@ -276,6 +278,7 @@ impl Instance {
}

/// `SNARKGens` holds public parameters for producing and verifying proofs with the Spartan SNARK
#[derive(Serialize, Deserialize)]
pub struct SNARKGens {
gens_r1cs_sat: R1CSGens,
gens_r1cs_eval: R1CSCommitmentGens,
Expand Down
1 change: 1 addition & 0 deletions src/nizk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ impl DotProductProof {
}
}

#[derive(Serialize, Deserialize)]
pub struct DotProductProofGens {
n: usize,
pub gens_n: MultiCommitGens,
Expand Down
2 changes: 2 additions & 0 deletions src/r1csinstance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct R1CSInstance {
C: SparseMatPolynomial,
}

#[derive(Serialize, Deserialize)]
pub struct R1CSCommitmentGens {
gens: SparseMatPolyCommitmentGens,
}
Expand Down Expand Up @@ -63,6 +64,7 @@ impl AppendToTranscript for R1CSCommitment {
}
}

#[derive(Serialize, Deserialize)]
pub struct R1CSDecommitment {
dense: MultiSparseMatPolynomialAsDense,
}
Expand Down
2 changes: 2 additions & 0 deletions src/r1csproof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub struct R1CSProof {
proof_eq_sc_phase2: EqualityProof,
}

#[derive(Serialize, Deserialize)]
pub struct R1CSSumcheckGens {
gens_1: MultiCommitGens,
gens_3: MultiCommitGens,
Expand All @@ -57,6 +58,7 @@ impl R1CSSumcheckGens {
}
}

#[derive(Serialize, Deserialize)]
pub struct R1CSGens {
gens_sc: R1CSSumcheckGens,
gens_pc: PolyCommitmentGens,
Expand Down
3 changes: 3 additions & 0 deletions src/sparse_mlpoly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ impl AppendToTranscript for DerefsCommitment {
}
}

#[derive(Serialize, Deserialize)]
struct AddrTimestamps {
ops_addr_usize: Vec<Vec<usize>>,
ops_addr: Vec<DensePolynomial>,
Expand Down Expand Up @@ -270,6 +271,7 @@ impl AddrTimestamps {
}
}

#[derive(Serialize, Deserialize)]
pub struct MultiSparseMatPolynomialAsDense {
batch_size: usize,
val: Vec<DensePolynomial>,
Expand All @@ -279,6 +281,7 @@ pub struct MultiSparseMatPolynomialAsDense {
comb_mem: DensePolynomial,
}

#[derive(Serialize, Deserialize)]
pub struct SparseMatPolyCommitmentGens {
gens_ops: PolyCommitmentGens,
gens_mem: PolyCommitmentGens,
Expand Down