Run latest nightly clippy

Also runs clippy on the tests and updates the CI accordingly
This commit is contained in:
Luke Parker
2023-01-01 04:18:23 -05:00
parent bff5f33616
commit 5599a052ad
23 changed files with 70 additions and 73 deletions

View File

@@ -328,7 +328,7 @@ impl<C: Ciphersuite> Zeroize for KeyMachine<C> {
fn exponential<C: Ciphersuite>(i: u16, values: &[C::G]) -> Vec<(C::F, C::G)> {
let i = C::F::from(i.into());
let mut res = Vec::with_capacity(values.len());
(0 .. values.len()).into_iter().fold(C::F::one(), |exp, l| {
(0 .. values.len()).fold(C::F::one(), |exp, l| {
res.push((exp, values[l]));
exp * i
});

View File

@@ -31,14 +31,14 @@ fn test_aos<const RING_LEN: usize>(default: Re<G0, G1>) {
ring[i] = (generators.0.alt * ring_keys[i].0, generators.1.alt * ring_keys[i].1);
}
for actual in 0 .. RING_LEN {
for (actual, key) in ring_keys.iter_mut().enumerate() {
let proof = Aos::<_, _, RING_LEN>::prove(
&mut OsRng,
transcript(),
generators,
&ring,
actual,
&mut ring_keys[actual],
key,
default.clone(),
);

View File

@@ -177,7 +177,7 @@ fn test_remainder() {
// This will ignore any unused bits, ensuring every remaining one is set
let keys = mutual_scalar_from_bytes::<Scalar, Scalar>(&[0xFF; 32]);
let keys = (Zeroizing::new(keys.0), Zeroizing::new(keys.1));
assert_eq!(Scalar::one() + keys.0.deref(), Scalar::from(2u64).pow_vartime(&[255]));
assert_eq!(Scalar::one() + keys.0.deref(), Scalar::from(2u64).pow_vartime([255]));
assert_eq!(keys.0, keys.1);
let (proof, res) = ConciseLinearDLEq::prove_without_bias(

View File

@@ -25,10 +25,10 @@ fn test_scalar() {
let (k, ed) = scalar_normalize::<_, DalekScalar>(initial);
// The initial scalar should equal the new scalar with Ed25519's capacity
let mut initial_bytes = (&initial.to_repr()).to_vec();
let mut initial_bytes = initial.to_repr().to_vec();
// Drop the first 4 bits to hit 252
initial_bytes[0] = initial_bytes[0] & 0b00001111;
let k_bytes = (&k.to_repr()).to_vec();
initial_bytes[0] &= 0b00001111;
let k_bytes = k.to_repr().to_vec();
assert_eq!(initial_bytes, k_bytes);
let mut ed_bytes = ed.to_repr().as_ref().to_vec();

View File

@@ -129,12 +129,11 @@ pub fn test_encoding<G: PrimeGroup>() {
let bytes = point.to_bytes();
let mut repr = G::Repr::default();
repr.as_mut().copy_from_slice(bytes.as_ref());
assert_eq!(point, G::from_bytes(&repr).unwrap(), "{} couldn't be encoded and decoded", msg);
assert_eq!(point, G::from_bytes(&repr).unwrap(), "{msg} couldn't be encoded and decoded");
assert_eq!(
point,
G::from_bytes_unchecked(&repr).unwrap(),
"{} couldn't be encoded and decoded",
msg
"{msg} couldn't be encoded and decoded",
);
};
test(G::identity(), "identity");

View File

@@ -43,12 +43,11 @@ pub fn test_encoding<F: PrimeField>() {
let bytes = scalar.to_repr();
let mut repr = F::Repr::default();
repr.as_mut().copy_from_slice(bytes.as_ref());
assert_eq!(scalar, F::from_repr(repr).unwrap(), "{} couldn't be encoded and decoded", msg);
assert_eq!(scalar, F::from_repr(repr).unwrap(), "{msg} couldn't be encoded and decoded");
assert_eq!(
scalar,
F::from_repr_vartime(repr).unwrap(),
"{} couldn't be encoded and decoded",
msg
"{msg} couldn't be encoded and decoded",
);
};
test(F::zero(), "0");

View File

@@ -155,7 +155,7 @@ pub fn sign<R: RngCore + CryptoRng, M: PreprocessMachine>(
machines,
|rng, machines| {
// Cache and rebuild half of the machines
let mut included = machines.keys().into_iter().cloned().collect::<Vec<_>>();
let mut included = machines.keys().cloned().collect::<Vec<_>>();
for i in included.drain(..) {
if (rng.next_u64() % 2) == 0 {
let cache = machines.remove(&i).unwrap().cache();

View File

@@ -56,7 +56,7 @@ impl From<serde_json::Value> for Vectors {
msg: to_str(&value["inputs"]["message"]),
included: to_str(&value["round_one_outputs"]["participant_list"])
.split(",")
.split(',')
.map(u16::from_str)
.collect::<Result<_, _>>()
.unwrap(),
@@ -134,7 +134,7 @@ pub fn test_with_vectors<R: RngCore + CryptoRng, C: Curve, H: Hram<C>>(
const MSG: &[u8] = b"Hello, World!";
let (mut machines, mut shares) = commit_and_shares(&mut *rng, machines, |_, _| {}, MSG);
let faulty = *shares.keys().into_iter().next().unwrap();
let faulty = *shares.keys().next().unwrap();
shares.get_mut(&faulty).unwrap().invalidate();
for (i, machine) in machines.drain() {