From 286e96ccd8973155843411532293719adf1d1538 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sat, 8 Jul 2023 01:06:38 -0400 Subject: [PATCH] Remove must_use spam --- crypto/dalek-ff-group/src/field.rs | 2 -- crypto/dalek-ff-group/src/lib.rs | 2 -- crypto/dkg/src/frost.rs | 1 - crypto/dkg/src/lib.rs | 8 -------- crypto/ed448/src/scalar.rs | 1 - crypto/frost/src/algorithm.rs | 2 -- crypto/frost/src/curve/mod.rs | 6 ------ crypto/multiexp/src/batch.rs | 2 -- crypto/schnorr/src/aggregate.rs | 1 - crypto/schnorrkel/src/lib.rs | 1 - crypto/transcript/src/lib.rs | 1 - 11 files changed, 27 deletions(-) diff --git a/crypto/dalek-ff-group/src/field.rs b/crypto/dalek-ff-group/src/field.rs index 0b952906..1b41d7cd 100644 --- a/crypto/dalek-ff-group/src/field.rs +++ b/crypto/dalek-ff-group/src/field.rs @@ -217,7 +217,6 @@ impl PrimeFieldBits for FieldElement { impl FieldElement { /// Interpret the value as a little-endian integer, square it, and reduce it into a FieldElement. - #[must_use] pub fn from_square(value: [u8; 32]) -> Self { let value = U256::from_le_bytes(value); Self(reduce(U512::from(value.mul_wide(&value)))) @@ -259,7 +258,6 @@ impl FieldElement { /// The result is only a valid square root if the Choice is true. /// RFC 8032 simply fails if there isn't a square root, leaving any return value undefined. /// Ristretto explicitly returns 0 or sqrt((SQRT_M1 * u) / v). - #[must_use] pub fn sqrt_ratio_i(u: Self, v: Self) -> (Choice, Self) { let i = SQRT_M1; diff --git a/crypto/dalek-ff-group/src/lib.rs b/crypto/dalek-ff-group/src/lib.rs index ac40b099..56a2fb90 100644 --- a/crypto/dalek-ff-group/src/lib.rs +++ b/crypto/dalek-ff-group/src/lib.rs @@ -223,13 +223,11 @@ impl Scalar { } /// Perform wide reduction on a 64-byte array to create a Scalar without bias. - #[must_use] pub fn from_bytes_mod_order_wide(bytes: &[u8; 64]) -> Self { Self(DScalar::from_bytes_mod_order_wide(bytes)) } /// Derive a Scalar without bias from a digest via wide reduction. - #[must_use] pub fn from_hash + HashMarker>(hash: D) -> Self { let mut output = [0u8; 64]; output.copy_from_slice(&hash.finalize()); diff --git a/crypto/dkg/src/frost.rs b/crypto/dkg/src/frost.rs index 40e8ef63..be1947a5 100644 --- a/crypto/dkg/src/frost.rs +++ b/crypto/dkg/src/frost.rs @@ -94,7 +94,6 @@ impl KeyGenMachine { /// Create a new machine to generate a key. /// /// The context string should be unique among multisigs. - #[must_use] pub const fn new(params: ThresholdParams, context: String) -> Self { Self { params, context, curve: PhantomData } } diff --git a/crypto/dkg/src/lib.rs b/crypto/dkg/src/lib.rs index 79ced53b..cfb5ee65 100644 --- a/crypto/dkg/src/lib.rs +++ b/crypto/dkg/src/lib.rs @@ -33,7 +33,6 @@ pub mod tests; pub struct Participant(pub(crate) u16); impl Participant { /// Create a new Participant identifier from a u16. - #[must_use] pub const fn new(i: u16) -> Option { if i == 0 { None @@ -44,7 +43,6 @@ impl Participant { /// Convert a Participant identifier to bytes. #[allow(clippy::wrong_self_convention)] - #[must_use] pub const fn to_bytes(&self) -> [u8; 2] { self.0.to_le_bytes() } @@ -183,24 +181,20 @@ mod lib { } /// Return the threshold for a multisig with these parameters. - #[must_use] pub const fn t(&self) -> u16 { self.t } /// Return the amount of participants for a multisig with these parameters. - #[must_use] pub const fn n(&self) -> u16 { self.n } /// Return the participant index of the share with these parameters. - #[must_use] pub const fn i(&self) -> Participant { self.i } } /// Calculate the lagrange coefficient for a signing set. - #[must_use] pub fn lagrange(i: Participant, included: &[Participant]) -> F { let i_f = F::from(u64::from(u16::from(i))); @@ -259,7 +253,6 @@ mod lib { } impl ThresholdCore { - #[must_use] pub(crate) fn new( params: ThresholdParams, secret_share: Zeroizing, @@ -420,7 +413,6 @@ mod lib { impl ThresholdKeys { /// Create a new set of ThresholdKeys from a ThresholdCore. - #[must_use] pub fn new(core: ThresholdCore) -> Self { Self { core: Arc::new(core), offset: None } } diff --git a/crypto/ed448/src/scalar.rs b/crypto/ed448/src/scalar.rs index 9f6adbe3..db988c5c 100644 --- a/crypto/ed448/src/scalar.rs +++ b/crypto/ed448/src/scalar.rs @@ -53,7 +53,6 @@ field!( impl Scalar { /// Perform a wide reduction to obtain a non-biased Scalar. - #[must_use] pub fn wide_reduce(bytes: [u8; 114]) -> Self { let wide = U1024::from_le_slice(&[bytes.as_ref(), &[0; 14]].concat()); Self(Residue::new(&U448::from_le_slice( diff --git a/crypto/frost/src/algorithm.rs b/crypto/frost/src/algorithm.rs index 541a06e2..76500512 100644 --- a/crypto/frost/src/algorithm.rs +++ b/crypto/frost/src/algorithm.rs @@ -147,7 +147,6 @@ pub type IetfSchnorr = Schnorr; impl> Schnorr { /// Construct a Schnorr algorithm continuing the specified transcript. - #[must_use] pub const fn new(transcript: T) -> Self { Self { transcript, c: None, _hram: PhantomData } } @@ -157,7 +156,6 @@ impl> IetfSchnorr { /// Construct a IETF-compatible Schnorr algorithm. /// /// Please see the `IetfSchnorr` documentation for the full details of this. - #[must_use] pub const fn ietf() -> Self { Self::new(IetfTranscript(vec![])) } diff --git a/crypto/frost/src/curve/mod.rs b/crypto/frost/src/curve/mod.rs index 0f3a3cc5..1fe0c22f 100644 --- a/crypto/frost/src/curve/mod.rs +++ b/crypto/frost/src/curve/mod.rs @@ -46,7 +46,6 @@ pub trait Curve: Ciphersuite { const CONTEXT: &'static [u8]; /// Hash the given dst and data to a byte vector. Used to instantiate H4 and H5. - #[must_use] fn hash(dst: &[u8], data: &[u8]) -> Output { Self::H::digest([Self::CONTEXT, dst, data].concat()) } @@ -54,31 +53,26 @@ pub trait Curve: Ciphersuite { /// Field element from hash. Used during key gen and by other crates under Serai as a general /// utility. Used to instantiate H1 and H3. #[allow(non_snake_case)] - #[must_use] fn hash_to_F(dst: &[u8], msg: &[u8]) -> Self::F { ::hash_to_F(&[Self::CONTEXT, dst].concat(), msg) } /// Hash the message for the binding factor. H4 from the IETF draft. - #[must_use] fn hash_msg(msg: &[u8]) -> Output { Self::hash(b"msg", msg) } /// Hash the commitments for the binding factor. H5 from the IETF draft. - #[must_use] fn hash_commitments(commitments: &[u8]) -> Output { Self::hash(b"com", commitments) } /// Hash the commitments and message to calculate the binding factor. H1 from the IETF draft. - #[must_use] fn hash_binding_factor(binding: &[u8]) -> Self::F { ::hash_to_F(b"rho", binding) } /// Securely generate a random nonce. H3 from the IETF draft. - #[must_use] fn random_nonce( secret: &Zeroizing, rng: &mut R, diff --git a/crypto/multiexp/src/batch.rs b/crypto/multiexp/src/batch.rs index 0d00a3a0..18facf2e 100644 --- a/crypto/multiexp/src/batch.rs +++ b/crypto/multiexp/src/batch.rs @@ -37,7 +37,6 @@ where /// Create a new batch verifier, expected to verify the following amount of statements. /// /// `capacity` is a size hint and is not required to be accurate. - #[must_use] pub fn new(capacity: usize) -> Self { Self(Zeroizing::new(Vec::with_capacity(capacity))) } @@ -112,7 +111,6 @@ where /// /// This function will only return the ID of one invalid statement, even if multiple are invalid. // A constant time variant may be beneficial for robust protocols - #[must_use] pub fn blame_vartime(&self) -> Option { let mut slice = self.0.as_slice(); while slice.len() > 1 { diff --git a/crypto/schnorr/src/aggregate.rs b/crypto/schnorr/src/aggregate.rs index 99d6f572..bf018b94 100644 --- a/crypto/schnorr/src/aggregate.rs +++ b/crypto/schnorr/src/aggregate.rs @@ -155,7 +155,6 @@ impl SchnorrAggregator { /// /// The DST used here must prevent a collision with whatever hash function produced the /// challenges. - #[must_use] pub fn new(dst: &'static [u8]) -> Self { let mut res = Self { digest: DigestTranscript::::new(dst), sigs: vec![] }; res.digest.domain_separate(b"signatures"); diff --git a/crypto/schnorrkel/src/lib.rs b/crypto/schnorrkel/src/lib.rs index e55a43ef..4bc5e409 100644 --- a/crypto/schnorrkel/src/lib.rs +++ b/crypto/schnorrkel/src/lib.rs @@ -62,7 +62,6 @@ impl Schnorrkel { /// Create a new algorithm with the specified context. /// /// If the context is greater than or equal to 4 GB in size, this will panic. - #[must_use] pub fn new(context: &'static [u8]) -> Self { Self { context, schnorr: Schnorr::new(MerlinTranscript::new(b"FROST Schnorrkel")), msg: None } } diff --git a/crypto/transcript/src/lib.rs b/crypto/transcript/src/lib.rs index 7f28ec11..660f0a97 100644 --- a/crypto/transcript/src/lib.rs +++ b/crypto/transcript/src/lib.rs @@ -103,7 +103,6 @@ impl DigestTranscript { impl Transcript for DigestTranscript { type Challenge = Output; - #[must_use] fn new(name: &'static [u8]) -> Self { let mut res = Self(D::new()); res.append(DigestTranscriptMember::Name, name);