mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-04 20:03:39 +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> {
|
||||
let mut compressed = [0u8; 32];
|
||||
reader.read_exact(&mut compressed[..])?;
|
||||
Option::from(Self::from_bytes(&compressed)).ok_or(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"invalid point encoding in proof",
|
||||
))
|
||||
Option::from(Self::from_bytes(&compressed))
|
||||
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "invalid point encoding in proof"))
|
||||
}
|
||||
|
||||
/// 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> {
|
||||
let mut compressed = [0u8; 32];
|
||||
reader.read_exact(&mut compressed[..])?;
|
||||
Option::from(Self::from_bytes(&compressed)).ok_or(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"invalid point encoding in proof",
|
||||
))
|
||||
Option::from(Self::from_bytes(&compressed))
|
||||
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "invalid point encoding in proof"))
|
||||
}
|
||||
|
||||
/// 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> {
|
||||
let (domain, cs, _) = keygen::create_domain::<C, ConcreteCircuit>(params);
|
||||
|
||||
let mut fixed_commitments = Vec::with_capacity(cs.num_fixed_columns);
|
||||
for _ in 0..cs.num_fixed_columns {
|
||||
fixed_commitments.push(C::read(reader)?);
|
||||
}
|
||||
let fixed_commitments: Vec<_> = (0..cs.num_fixed_columns)
|
||||
.map(|_| C::read(reader))
|
||||
.collect::<Result<_, _>>()?;
|
||||
|
||||
let mut permutations = Vec::with_capacity(cs.permutations.len());
|
||||
for argument in &cs.permutations {
|
||||
permutations.push(permutation::VerifyingKey::read(reader, argument)?);
|
||||
}
|
||||
let permutations: Vec<_> = cs
|
||||
.permutations
|
||||
.iter()
|
||||
.map(|argument| permutation::VerifyingKey::read(reader, argument))
|
||||
.collect::<Result<_, _>>()?;
|
||||
|
||||
Ok(VerifyingKey {
|
||||
domain,
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ where
|
|||
let permutation_vks = cs
|
||||
.permutations
|
||||
.iter()
|
||||
.zip(assembly.clone().permutations.into_iter())
|
||||
.zip(assembly.permutations.into_iter())
|
||||
.map(|(p, assembly)| assembly.build_vk(params, &domain, &permutation_helper, p))
|
||||
.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> {
|
||||
let mut commitments = Vec::with_capacity(argument.columns.len());
|
||||
for _ in 0..argument.columns.len() {
|
||||
commitments.push(C::read(reader)?);
|
||||
}
|
||||
|
||||
let commitments = (0..argument.columns.len())
|
||||
.map(|_| C::read(reader))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
Ok(VerifyingKey { commitments })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,8 +201,8 @@ impl<C: CurveAffine> Params<C> {
|
|||
for g_lagrange_element in &self.g_lagrange {
|
||||
writer.write_all(&g_lagrange_element.to_bytes())?;
|
||||
}
|
||||
writer.write(&self.h.to_bytes())?;
|
||||
writer.write(&self.u.to_bytes())?;
|
||||
writer.write_all(&self.h.to_bytes())?;
|
||||
writer.write_all(&self.u.to_bytes())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -217,15 +217,8 @@ impl<C: CurveAffine> Params<C> {
|
|||
reader.read_exact(&mut n[..])?;
|
||||
let n = u64::from_le_bytes(n);
|
||||
|
||||
let mut g = Vec::with_capacity(n as usize);
|
||||
for _ in 0..n {
|
||||
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 g: Vec<_> = (0..n).map(|_| C::read(reader)).collect::<Result<_, _>>()?;
|
||||
let g_lagrange: Vec<_> = (0..n).map(|_| C::read(reader)).collect::<Result<_, _>>()?;
|
||||
|
||||
let h = C::read(reader)?;
|
||||
let u = C::read(reader)?;
|
||||
|
|
|
|||
Loading…
Reference in a new issue