Only write k in Params; calculate n when reading

Co-authored-by: Jack Grigg <jack@electriccoin.co>
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
therealyingtong 2021-01-22 12:31:27 +08:00
parent e0f9fe1dcf
commit ffdd739f85
4 changed files with 8 additions and 11 deletions

View File

@ -56,7 +56,7 @@ where
}
/// Assembly to be used in circuit synthesis.
#[derive(Clone, Debug)]
#[derive(Debug)]
pub struct Assembly<F: Field> {
fixed: Vec<Polynomial<F, LagrangeCoeff>>,
permutations: Vec<permutation::keygen::Assembly>,
@ -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

View File

@ -14,7 +14,7 @@ pub(crate) struct AssemblyHelper<C: CurveAffine> {
deltaomega: Vec<Vec<C::Scalar>>,
}
#[derive(Clone, Debug)]
#[derive(Debug)]
pub(crate) struct Assembly {
pub(crate) mapping: Vec<Vec<(usize, usize)>>,
aux: Vec<Vec<(usize, usize)>>,
@ -139,7 +139,7 @@ impl Assembly {
helper: &AssemblyHelper<C>,
p: &Argument,
) -> VerifyingKey<C> {
// 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

View File

@ -194,7 +194,6 @@ impl<C: CurveAffine> Params<C> {
/// Writes params to a buffer.
pub fn write<W: io::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<C: CurveAffine> Params<C> {
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::<Result<_, _>>()?;
let g_lagrange: Vec<_> = (0..n).map(|_| C::read(reader)).collect::<Result<_, _>>()?;

View File

@ -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<C: CurveAffine, T: TranscriptWrite<C>>(
params: &Params<C>,
@ -82,7 +82,7 @@ pub fn create_proof<C: CurveAffine, T: TranscriptWrite<C>>(
}
}
// 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();