From ffdd739f859b89ea412ef4ad844f332baea8410b Mon Sep 17 00:00:00 2001 From: therealyingtong Date: Fri, 22 Jan 2021 12:31:27 +0800 Subject: [PATCH] Only write k in Params; calculate n when reading Co-authored-by: Jack Grigg Co-authored-by: Daira Hopwood --- src/plonk/keygen.rs | 6 +++--- src/plonk/permutation/keygen.rs | 4 ++-- src/poly/commitment.rs | 5 +---- src/poly/commitment/prover.rs | 4 ++-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/plonk/keygen.rs b/src/plonk/keygen.rs index 8128934..8c99b7a 100644 --- a/src/plonk/keygen.rs +++ b/src/plonk/keygen.rs @@ -56,7 +56,7 @@ where } /// Assembly to be used in circuit synthesis. -#[derive(Clone, Debug)] +#[derive(Debug)] pub struct Assembly { fixed: Vec>, permutations: Vec, @@ -127,7 +127,7 @@ where _marker: std::marker::PhantomData, }; - // Synthesize the circuit to obtain SRS + // Synthesize the circuit to obtain URS circuit.synthesize(&mut assembly, config)?; let permutation_helper = permutation::keygen::Assembly::build_helper(params, &cs, &domain); @@ -177,7 +177,7 @@ where _marker: std::marker::PhantomData, }; - // Synthesize the circuit to obtain SRS + // Synthesize the circuit to obtain URS circuit.synthesize(&mut assembly, config)?; let fixed_polys: Vec<_> = assembly diff --git a/src/plonk/permutation/keygen.rs b/src/plonk/permutation/keygen.rs index d527725..072f6c5 100644 --- a/src/plonk/permutation/keygen.rs +++ b/src/plonk/permutation/keygen.rs @@ -14,7 +14,7 @@ pub(crate) struct AssemblyHelper { deltaomega: Vec>, } -#[derive(Clone, Debug)] +#[derive(Debug)] pub(crate) struct Assembly { pub(crate) mapping: Vec>, aux: Vec>, @@ -139,7 +139,7 @@ impl Assembly { helper: &AssemblyHelper, p: &Argument, ) -> VerifyingKey { - // Pre-compute commitments for the SRS. + // Pre-compute commitments for the URS. let mut commitments = vec![]; for i in 0..p.columns.len() { // Computes the permutation polynomial based on the permutation diff --git a/src/poly/commitment.rs b/src/poly/commitment.rs index 55517d3..f4098a8 100644 --- a/src/poly/commitment.rs +++ b/src/poly/commitment.rs @@ -194,7 +194,6 @@ impl Params { /// Writes params to a buffer. pub fn write(&self, writer: &mut W) -> io::Result<()> { writer.write_all(&self.k.to_le_bytes())?; - writer.write_all(&self.n.to_le_bytes())?; for g_element in &self.g { writer.write_all(&g_element.to_bytes())?; } @@ -213,9 +212,7 @@ impl Params { reader.read_exact(&mut k[..])?; let k = u32::from_le_bytes(k); - let mut n = [0u8; 8]; - reader.read_exact(&mut n[..])?; - let n = u64::from_le_bytes(n); + let n: u64 = 1 << k; let g: Vec<_> = (0..n).map(|_| C::read(reader)).collect::>()?; let g_lagrange: Vec<_> = (0..n).map(|_| C::read(reader)).collect::>()?; diff --git a/src/poly/commitment/prover.rs b/src/poly/commitment/prover.rs index 3f51865..4710821 100644 --- a/src/poly/commitment/prover.rs +++ b/src/poly/commitment/prover.rs @@ -20,7 +20,7 @@ use std::io; /// **Important:** This function assumes that the provided `transcript` has /// already seen the common inputs: the polynomial commitment P, the claimed /// opening v, and the point x. It's probably also nice for the transcript -/// to have seen the elliptic curve description and the SRS, if you want to +/// to have seen the elliptic curve description and the URS, if you want to /// be rigorous. pub fn create_proof>( params: &Params, @@ -82,7 +82,7 @@ pub fn create_proof>( } } - // Initialize the vector `G` from the SRS. We'll be progressively collapsing + // Initialize the vector `G` from the URS. We'll be progressively collapsing // this vector into smaller and smaller vectors until it is of length 1. let mut g = params.g.clone();