mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 04:39:24 +00:00
Meaningful changes from aggressive-clippy
I do want to enable a few specific lints, yet aggressive-clippy as a whole isn't worthwhile.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use core::ops::{Deref, DerefMut};
|
||||
#[cfg(feature = "serialize")]
|
||||
use std::io::{Read, Write};
|
||||
use std::io::{self, Read, Write};
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
@@ -51,15 +51,15 @@ fn u8_from_bool(bit_ref: &mut bool) -> u8 {
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
pub(crate) fn read_point<R: Read, G: PrimeGroup>(r: &mut R) -> std::io::Result<G> {
|
||||
pub(crate) fn read_point<R: Read, G: PrimeGroup>(r: &mut R) -> io::Result<G> {
|
||||
let mut repr = G::Repr::default();
|
||||
r.read_exact(repr.as_mut())?;
|
||||
let point = G::from_bytes(&repr);
|
||||
let Some(point) = Option::<G>::from(point) else {
|
||||
Err(std::io::Error::new(std::io::ErrorKind::Other, "invalid point"))?
|
||||
Err(io::Error::new(io::ErrorKind::Other, "invalid point"))?
|
||||
};
|
||||
if point.to_bytes().as_ref() != repr.as_ref() {
|
||||
Err(std::io::Error::new(std::io::ErrorKind::Other, "non-canonical point"))?;
|
||||
Err(io::Error::new(io::ErrorKind::Other, "non-canonical point"))?;
|
||||
}
|
||||
Ok(point)
|
||||
}
|
||||
@@ -439,7 +439,7 @@ where
|
||||
|
||||
/// Write a Cross-Group Discrete Log Equality proof to a type satisfying std::io::Write.
|
||||
#[cfg(feature = "serialize")]
|
||||
pub fn write<W: Write>(&self, w: &mut W) -> std::io::Result<()> {
|
||||
pub fn write<W: Write>(&self, w: &mut W) -> io::Result<()> {
|
||||
for bit in &self.bits {
|
||||
bit.write(w)?;
|
||||
}
|
||||
@@ -452,7 +452,7 @@ where
|
||||
|
||||
/// Read a Cross-Group Discrete Log Equality proof from a type satisfying std::io::Read.
|
||||
#[cfg(feature = "serialize")]
|
||||
pub fn read<R: Read>(r: &mut R) -> std::io::Result<Self> {
|
||||
pub fn read<R: Read>(r: &mut R) -> io::Result<Self> {
|
||||
let capacity = usize::try_from(G0::Scalar::CAPACITY.min(G1::Scalar::CAPACITY)).unwrap();
|
||||
let bits_per_group = BitSignature::from(SIGNATURE).bits();
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ fn test_dleq() {
|
||||
assert!(proof
|
||||
.verify(
|
||||
&mut transcript(),
|
||||
generators[.. i].iter().cloned().rev().collect::<Vec<_>>().as_ref(),
|
||||
generators[.. i].iter().copied().rev().collect::<Vec<_>>().as_ref(),
|
||||
&keys[.. i]
|
||||
)
|
||||
.is_err());
|
||||
@@ -86,7 +86,7 @@ fn test_dleq() {
|
||||
.verify(
|
||||
&mut transcript(),
|
||||
&generators[.. i],
|
||||
keys[.. i].iter().cloned().rev().collect::<Vec<_>>().as_ref()
|
||||
keys[.. i].iter().copied().rev().collect::<Vec<_>>().as_ref()
|
||||
)
|
||||
.is_err());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user