Add workspace lints

This commit is contained in:
Luke Parker
2023-12-16 20:54:24 -05:00
parent c40ce00955
commit ea3af28139
122 changed files with 329 additions and 128 deletions

View File

@@ -13,6 +13,9 @@ rust-version = "1.74"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[lints]
workspace = true
[dependencies]
std-shims = { path = "../../common/std-shims", version = "^0.1.1", default-features = false, optional = true }

View File

@@ -13,6 +13,9 @@ rust-version = "1.65"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[lints]
workspace = true
[dependencies]
rustversion = "1"

View File

@@ -50,6 +50,7 @@ fn u8_from_bool(bit_ref: &mut bool) -> u8 {
let bit_ref = black_box(bit_ref);
let mut bit = black_box(*bit_ref);
#[allow(clippy::cast_lossless)]
let res = black_box(bit as u8);
bit.zeroize();
debug_assert!((res | 1) == 1);

View File

@@ -13,6 +13,9 @@ rust-version = "1.70"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[lints]
workspace = true
[dependencies]
thiserror = { version = "1", default-features = false, optional = true }

View File

@@ -226,7 +226,7 @@ impl<C: Ciphersuite, E: Encryptable> EncryptedMessage<C, E> {
use ciphersuite::group::ff::PrimeField;
let mut repr = <C::F as PrimeField>::Repr::default();
for b in repr.as_mut().iter_mut() {
for b in repr.as_mut() {
*b = 255;
}
// Tries to guarantee the above assumption.

View File

@@ -257,7 +257,7 @@ mod lib {
self.params.zeroize();
self.secret_share.zeroize();
self.group_key.zeroize();
for (_, share) in self.verification_shares.iter_mut() {
for share in self.verification_shares.values_mut() {
share.zeroize();
}
}
@@ -410,10 +410,10 @@ mod lib {
self.group_key.zeroize();
self.included.zeroize();
self.secret_share.zeroize();
for (_, share) in self.original_verification_shares.iter_mut() {
for share in self.original_verification_shares.values_mut() {
share.zeroize();
}
for (_, share) in self.verification_shares.iter_mut() {
for share in self.verification_shares.values_mut() {
share.zeroize();
}
}
@@ -484,7 +484,7 @@ mod lib {
);
let mut verification_shares = self.verification_shares();
for (i, share) in verification_shares.iter_mut() {
for (i, share) in &mut verification_shares {
*share *= lagrange::<C::F>(*i, &included);
}

View File

@@ -12,6 +12,9 @@ rust-version = "1.73"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[lints]
workspace = true
[dependencies]
rustversion = "1"

View File

@@ -240,7 +240,7 @@ where
}
let mut s = [(G0::Scalar::ZERO, G1::Scalar::ZERO); RING_LEN];
for s in s.iter_mut() {
for s in &mut s {
*s = (read_scalar(r)?, read_scalar(r)?);
}

View File

@@ -45,7 +45,7 @@ impl BitSignature {
}
}
pub(crate) const fn bits(&self) -> usize {
pub(crate) const fn bits(&self) -> u8 {
match self {
BitSignature::ClassicLinear => 1,
BitSignature::ConciseLinear => 2,

View File

@@ -42,6 +42,7 @@ fn u8_from_bool(bit_ref: &mut bool) -> u8 {
let bit_ref = black_box(bit_ref);
let mut bit = black_box(*bit_ref);
#[allow(clippy::cast_lossless)]
let res = black_box(bit as u8);
bit.zeroize();
debug_assert!((res | 1) == 1);
@@ -278,7 +279,7 @@ where
};
let capacity = usize::try_from(G0::Scalar::CAPACITY.min(G1::Scalar::CAPACITY)).unwrap();
let bits_per_group = BitSignature::from(SIGNATURE).bits();
let bits_per_group = usize::from(BitSignature::from(SIGNATURE).bits());
let mut pow_2 = (generators.0.primary, generators.1.primary);
@@ -391,7 +392,7 @@ where
generators: (Generators<G0>, Generators<G1>),
) -> Result<(G0, G1), DLEqError> {
let capacity = usize::try_from(G0::Scalar::CAPACITY.min(G1::Scalar::CAPACITY)).unwrap();
let bits_per_group = BitSignature::from(SIGNATURE).bits();
let bits_per_group = usize::from(BitSignature::from(SIGNATURE).bits());
let has_remainder = (capacity % bits_per_group) != 0;
// These shouldn't be possible, as locally created and deserialized proofs should be properly
@@ -449,7 +450,7 @@ where
#[cfg(feature = "serialize")]
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();
let bits_per_group = usize::from(BitSignature::from(SIGNATURE).bits());
let mut bits = Vec::with_capacity(capacity / bits_per_group);
for _ in 0 .. (capacity / bits_per_group) {

View File

@@ -29,7 +29,7 @@ pub fn scalar_normalize<F0: PrimeFieldBits + Zeroize, F1: PrimeFieldBits>(
let mut skip = bits.len() - usize::try_from(mutual_capacity).unwrap();
// Needed to zero out the bits
#[allow(unused_assignments)]
for mut bit in bits.iter_mut() {
for mut bit in &mut bits {
if skip > 0 {
bit.deref_mut().zeroize();
skip -= 1;

View File

@@ -13,6 +13,9 @@ rust-version = "1.65"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[lints]
workspace = true
[dependencies]
rustversion = "1"

View File

@@ -12,6 +12,7 @@ pub(crate) fn u8_from_bool(bit_ref: &mut bool) -> u8 {
let bit_ref = black_box(bit_ref);
let mut bit = black_box(*bit_ref);
#[allow(clippy::cast_lossless)]
let res = black_box(bit as u8);
bit.zeroize();
debug_assert!((res | 1) == 1);

View File

@@ -214,7 +214,7 @@ impl Sum<Point> for Point {
impl<'a> Sum<&'a Point> for Point {
fn sum<I: Iterator<Item = &'a Point>>(iter: I) -> Point {
Point::sum(iter.cloned())
Point::sum(iter.copied())
}
}

View File

@@ -13,6 +13,9 @@ rust-version = "1.60"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[lints]
workspace = true
[dependencies]
rand_core = "0.6"

View File

@@ -13,6 +13,9 @@ rust-version = "1.74"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[lints]
workspace = true
[dependencies]
thiserror = "1"

View File

@@ -184,7 +184,7 @@ impl<C: Curve, T: Sync + Clone + Debug + Transcript, H: Hram<C>> Algorithm<C> fo
&mut self,
_: &ThresholdView<C>,
_: Participant,
_: (),
(): (),
) -> Result<(), FrostError> {
Ok(())
}

View File

@@ -256,7 +256,7 @@ impl<C: Curve> BindingFactor<C> {
}
pub(crate) fn calculate_binding_factors<T: Clone + Transcript>(&mut self, transcript: &T) {
for (l, binding) in self.0.iter_mut() {
for (l, binding) in &mut self.0 {
let mut transcript = transcript.clone();
transcript.append_message(b"participant", C::F::from(u64::from(u16::from(*l))).to_repr());
// It *should* be perfectly fine to reuse a binding factor for multiple nonces

View File

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

View File

@@ -82,7 +82,7 @@ impl<C: Curve> Algorithm<C> for MultiNonce<C> {
&mut self,
_: &ThresholdView<C>,
_: Participant,
_: (),
(): (),
) -> Result<(), FrostError> {
Ok(())
}

View File

@@ -13,6 +13,9 @@ rust-version = "1.70"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[lints]
workspace = true
[dependencies]
rustversion = "1"

View File

@@ -38,6 +38,7 @@ fn u8_from_bool(bit_ref: &mut bool) -> u8 {
let bit_ref = black_box(bit_ref);
let mut bit = black_box(*bit_ref);
#[allow(clippy::cast_lossless)]
let res = black_box(bit as u8);
bit.zeroize();
debug_assert!((res | 1) == 1);

View File

@@ -13,6 +13,9 @@ rust-version = "1.74"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[lints]
workspace = true
[dependencies]
std-shims = { path = "../../common/std-shims", version = "^0.1.1", default-features = false }

View File

@@ -13,6 +13,9 @@ rust-version = "1.74"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[lints]
workspace = true
[dependencies]
rand_core = "0.6"
zeroize = "^1.5"

View File

@@ -99,7 +99,7 @@ impl Algorithm<Ristretto> for Schnorrkel {
&mut self,
_: &ThresholdView<Ristretto>,
_: Participant,
_: (),
(): (),
) -> Result<(), FrostError> {
Ok(())
}

View File

@@ -13,6 +13,9 @@ rust-version = "1.73"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[lints]
workspace = true
[dependencies]
rustversion = "1"