mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-07 20:30:34 +00:00
Clippy fixes + address review comments
Co-authored-by: Jack Grigg <jack@electriccoin.co>
This commit is contained in:
parent
58479fbcc3
commit
e0f9fe1dcf
6 changed files with 20 additions and 33 deletions
|
|
@ -160,10 +160,8 @@ pub trait CurveAffine:
|
||||||
fn read<R: Read>(reader: &mut R) -> io::Result<Self> {
|
fn read<R: Read>(reader: &mut R) -> io::Result<Self> {
|
||||||
let mut compressed = [0u8; 32];
|
let mut compressed = [0u8; 32];
|
||||||
reader.read_exact(&mut compressed[..])?;
|
reader.read_exact(&mut compressed[..])?;
|
||||||
Option::from(Self::from_bytes(&compressed)).ok_or(io::Error::new(
|
Option::from(Self::from_bytes(&compressed))
|
||||||
io::ErrorKind::Other,
|
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "invalid point encoding in proof"))
|
||||||
"invalid point encoding in proof",
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Obtains the compressed, 32-byte little endian representation of this
|
/// Obtains the compressed, 32-byte little endian representation of this
|
||||||
|
|
|
||||||
|
|
@ -94,10 +94,8 @@ pub trait FieldExt:
|
||||||
fn read<R: Read>(reader: &mut R) -> io::Result<Self> {
|
fn read<R: Read>(reader: &mut R) -> io::Result<Self> {
|
||||||
let mut compressed = [0u8; 32];
|
let mut compressed = [0u8; 32];
|
||||||
reader.read_exact(&mut compressed[..])?;
|
reader.read_exact(&mut compressed[..])?;
|
||||||
Option::from(Self::from_bytes(&compressed)).ok_or(io::Error::new(
|
Option::from(Self::from_bytes(&compressed))
|
||||||
io::ErrorKind::Other,
|
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "invalid point encoding in proof"))
|
||||||
"invalid point encoding in proof",
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Obtains a field element that is congruent to the provided little endian
|
/// Obtains a field element that is congruent to the provided little endian
|
||||||
|
|
|
||||||
16
src/plonk.rs
16
src/plonk.rs
|
|
@ -57,15 +57,15 @@ impl<C: CurveAffine> VerifyingKey<C> {
|
||||||
) -> io::Result<Self> {
|
) -> io::Result<Self> {
|
||||||
let (domain, cs, _) = keygen::create_domain::<C, ConcreteCircuit>(params);
|
let (domain, cs, _) = keygen::create_domain::<C, ConcreteCircuit>(params);
|
||||||
|
|
||||||
let mut fixed_commitments = Vec::with_capacity(cs.num_fixed_columns);
|
let fixed_commitments: Vec<_> = (0..cs.num_fixed_columns)
|
||||||
for _ in 0..cs.num_fixed_columns {
|
.map(|_| C::read(reader))
|
||||||
fixed_commitments.push(C::read(reader)?);
|
.collect::<Result<_, _>>()?;
|
||||||
}
|
|
||||||
|
|
||||||
let mut permutations = Vec::with_capacity(cs.permutations.len());
|
let permutations: Vec<_> = cs
|
||||||
for argument in &cs.permutations {
|
.permutations
|
||||||
permutations.push(permutation::VerifyingKey::read(reader, argument)?);
|
.iter()
|
||||||
}
|
.map(|argument| permutation::VerifyingKey::read(reader, argument))
|
||||||
|
.collect::<Result<_, _>>()?;
|
||||||
|
|
||||||
Ok(VerifyingKey {
|
Ok(VerifyingKey {
|
||||||
domain,
|
domain,
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ where
|
||||||
let permutation_vks = cs
|
let permutation_vks = cs
|
||||||
.permutations
|
.permutations
|
||||||
.iter()
|
.iter()
|
||||||
.zip(assembly.clone().permutations.into_iter())
|
.zip(assembly.permutations.into_iter())
|
||||||
.map(|(p, assembly)| assembly.build_vk(params, &domain, &permutation_helper, p))
|
.map(|(p, assembly)| assembly.build_vk(params, &domain, &permutation_helper, p))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,11 +61,9 @@ impl<C: CurveAffine> VerifyingKey<C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn read<R: io::Read>(reader: &mut R, argument: &Argument) -> io::Result<Self> {
|
pub(crate) fn read<R: io::Read>(reader: &mut R, argument: &Argument) -> io::Result<Self> {
|
||||||
let mut commitments = Vec::with_capacity(argument.columns.len());
|
let commitments = (0..argument.columns.len())
|
||||||
for _ in 0..argument.columns.len() {
|
.map(|_| C::read(reader))
|
||||||
commitments.push(C::read(reader)?);
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
}
|
|
||||||
|
|
||||||
Ok(VerifyingKey { commitments })
|
Ok(VerifyingKey { commitments })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -201,8 +201,8 @@ impl<C: CurveAffine> Params<C> {
|
||||||
for g_lagrange_element in &self.g_lagrange {
|
for g_lagrange_element in &self.g_lagrange {
|
||||||
writer.write_all(&g_lagrange_element.to_bytes())?;
|
writer.write_all(&g_lagrange_element.to_bytes())?;
|
||||||
}
|
}
|
||||||
writer.write(&self.h.to_bytes())?;
|
writer.write_all(&self.h.to_bytes())?;
|
||||||
writer.write(&self.u.to_bytes())?;
|
writer.write_all(&self.u.to_bytes())?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -217,15 +217,8 @@ impl<C: CurveAffine> Params<C> {
|
||||||
reader.read_exact(&mut n[..])?;
|
reader.read_exact(&mut n[..])?;
|
||||||
let n = u64::from_le_bytes(n);
|
let n = u64::from_le_bytes(n);
|
||||||
|
|
||||||
let mut g = Vec::with_capacity(n as usize);
|
let g: Vec<_> = (0..n).map(|_| C::read(reader)).collect::<Result<_, _>>()?;
|
||||||
for _ in 0..n {
|
let g_lagrange: Vec<_> = (0..n).map(|_| C::read(reader)).collect::<Result<_, _>>()?;
|
||||||
g.push(C::read(reader)?);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut g_lagrange = Vec::with_capacity(n as usize);
|
|
||||||
for _ in 0..n {
|
|
||||||
g_lagrange.push(C::read(reader)?);
|
|
||||||
}
|
|
||||||
|
|
||||||
let h = C::read(reader)?;
|
let h = C::read(reader)?;
|
||||||
let u = C::read(reader)?;
|
let u = C::read(reader)?;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue