mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Replace usage of io::Error::new(io::ErrorKind::Other, with io::Error::other
Newly possible with Rust 1.74.
This commit is contained in:
@@ -93,7 +93,7 @@ pub trait Ciphersuite:
|
||||
|
||||
// ff mandates this is canonical
|
||||
let res = Option::<Self::F>::from(Self::F::from_repr(encoding))
|
||||
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "non-canonical scalar"));
|
||||
.ok_or_else(|| io::Error::other("non-canonical scalar"));
|
||||
encoding.as_mut().zeroize();
|
||||
res
|
||||
}
|
||||
@@ -106,9 +106,9 @@ pub trait Ciphersuite:
|
||||
reader.read_exact(encoding.as_mut())?;
|
||||
|
||||
let point = Option::<Self::G>::from(Self::G::from_bytes(&encoding))
|
||||
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "invalid point"))?;
|
||||
.ok_or_else(|| io::Error::other("invalid point"))?;
|
||||
if point.to_bytes().as_ref() != encoding.as_ref() {
|
||||
Err(io::Error::new(io::ErrorKind::Other, "non-canonical point"))?;
|
||||
Err(io::Error::other("non-canonical point"))?;
|
||||
}
|
||||
Ok(point)
|
||||
}
|
||||
|
||||
@@ -306,8 +306,7 @@ mod lib {
|
||||
/// Read keys from a type satisfying std::io::Read.
|
||||
pub fn read<R: io::Read>(reader: &mut R) -> io::Result<ThresholdCore<C>> {
|
||||
{
|
||||
let different =
|
||||
|| io::Error::new(io::ErrorKind::Other, "deserializing ThresholdCore for another curve");
|
||||
let different = || io::Error::other("deserializing ThresholdCore for another curve");
|
||||
|
||||
let mut id_len = [0; 4];
|
||||
reader.read_exact(&mut id_len)?;
|
||||
@@ -331,8 +330,7 @@ mod lib {
|
||||
(
|
||||
read_u16()?,
|
||||
read_u16()?,
|
||||
Participant::new(read_u16()?)
|
||||
.ok_or(io::Error::new(io::ErrorKind::Other, "invalid participant index"))?,
|
||||
Participant::new(read_u16()?).ok_or(io::Error::other("invalid participant index"))?,
|
||||
)
|
||||
};
|
||||
|
||||
@@ -344,8 +342,7 @@ mod lib {
|
||||
}
|
||||
|
||||
Ok(ThresholdCore::new(
|
||||
ThresholdParams::new(t, n, i)
|
||||
.map_err(|_| io::Error::new(io::ErrorKind::Other, "invalid parameters"))?,
|
||||
ThresholdParams::new(t, n, i).map_err(|_| io::Error::other("invalid parameters"))?,
|
||||
secret_share,
|
||||
verification_shares,
|
||||
))
|
||||
|
||||
@@ -55,11 +55,9 @@ 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(io::Error::new(io::ErrorKind::Other, "invalid point"))?
|
||||
};
|
||||
let Some(point) = Option::<G>::from(point) else { Err(io::Error::other("invalid point"))? };
|
||||
if point.to_bytes().as_ref() != repr.as_ref() {
|
||||
Err(io::Error::new(io::ErrorKind::Other, "non-canonical point"))?;
|
||||
Err(io::Error::other("non-canonical point"))?;
|
||||
}
|
||||
Ok(point)
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ use ff::{Field, PrimeField};
|
||||
use group::prime::PrimeGroup;
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
use std::io::{self, ErrorKind, Error, Read, Write};
|
||||
use std::io::{self, Error, Read, Write};
|
||||
|
||||
/// A cross-group DLEq proof capable of proving that two public keys, across two different curves,
|
||||
/// share a private key.
|
||||
@@ -91,7 +91,7 @@ fn read_scalar<R: Read, F: PrimeField>(r: &mut R) -> io::Result<F> {
|
||||
r.read_exact(repr.as_mut())?;
|
||||
let scalar = F::from_repr(repr);
|
||||
if scalar.is_none().into() {
|
||||
Err(Error::new(ErrorKind::Other, "invalid scalar"))?;
|
||||
Err(Error::other("invalid scalar"))?;
|
||||
}
|
||||
Ok(scalar.unwrap())
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ pub trait Curve: Ciphersuite {
|
||||
fn read_G<R: Read>(reader: &mut R) -> io::Result<Self::G> {
|
||||
let res = <Self as Ciphersuite>::read_G(reader)?;
|
||||
if res.is_identity().into() {
|
||||
Err(io::Error::new(io::ErrorKind::Other, "identity point"))?;
|
||||
Err(io::Error::other("identity point"))?;
|
||||
}
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ impl<C: Curve> Commitments<C> {
|
||||
let dleq = MultiDLEqProof::read(reader, dleq_generators.len())?;
|
||||
dleq
|
||||
.verify(&mut dleq_transcript::<T>(context), &dleq_generators, &dleq_nonces)
|
||||
.map_err(|_| io::Error::new(io::ErrorKind::Other, "invalid DLEq proof"))?;
|
||||
.map_err(|_| io::Error::other("invalid DLEq proof"))?;
|
||||
Some(dleq)
|
||||
} else {
|
||||
None
|
||||
|
||||
Reference in New Issue
Block a user