mirror of
https://github.com/serai-dex/serai.git
synced 2024-11-16 17:07:35 +00:00
Remove must_use spam
This commit is contained in:
parent
f93106af6b
commit
286e96ccd8
11 changed files with 0 additions and 27 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<D: Digest<OutputSize = U64> + HashMarker>(hash: D) -> Self {
|
||||
let mut output = [0u8; 64];
|
||||
output.copy_from_slice(&hash.finalize());
|
||||
|
|
|
@ -94,7 +94,6 @@ impl<C: Ciphersuite> KeyGenMachine<C> {
|
|||
/// 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 }
|
||||
}
|
||||
|
|
|
@ -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<Self> {
|
||||
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<F: PrimeField>(i: Participant, included: &[Participant]) -> F {
|
||||
let i_f = F::from(u64::from(u16::from(i)));
|
||||
|
||||
|
@ -259,7 +253,6 @@ mod lib {
|
|||
}
|
||||
|
||||
impl<C: Ciphersuite> ThresholdCore<C> {
|
||||
#[must_use]
|
||||
pub(crate) fn new(
|
||||
params: ThresholdParams,
|
||||
secret_share: Zeroizing<C::F>,
|
||||
|
@ -420,7 +413,6 @@ mod lib {
|
|||
|
||||
impl<C: Ciphersuite> ThresholdKeys<C> {
|
||||
/// Create a new set of ThresholdKeys from a ThresholdCore.
|
||||
#[must_use]
|
||||
pub fn new(core: ThresholdCore<C>) -> Self {
|
||||
Self { core: Arc::new(core), offset: None }
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -147,7 +147,6 @@ pub type IetfSchnorr<C, H> = Schnorr<C, IetfTranscript, H>;
|
|||
|
||||
impl<C: Curve, T: Sync + Clone + Debug + Transcript, H: Hram<C>> Schnorr<C, T, H> {
|
||||
/// 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<C: Curve, H: Hram<C>> IetfSchnorr<C, H> {
|
|||
/// 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![]))
|
||||
}
|
||||
|
|
|
@ -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> {
|
||||
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 {
|
||||
<Self as Ciphersuite>::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::H> {
|
||||
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::H> {
|
||||
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 {
|
||||
<Self as Curve>::hash_to_F(b"rho", binding)
|
||||
}
|
||||
|
||||
/// Securely generate a random nonce. H3 from the IETF draft.
|
||||
#[must_use]
|
||||
fn random_nonce<R: RngCore + CryptoRng>(
|
||||
secret: &Zeroizing<Self::F>,
|
||||
rng: &mut R,
|
||||
|
|
|
@ -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<Id> {
|
||||
let mut slice = self.0.as_slice();
|
||||
while slice.len() > 1 {
|
||||
|
|
|
@ -155,7 +155,6 @@ impl<C: Ciphersuite> SchnorrAggregator<C> {
|
|||
///
|
||||
/// 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::<C::H>::new(dst), sigs: vec![] };
|
||||
res.digest.domain_separate(b"signatures");
|
||||
|
|
|
@ -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 }
|
||||
}
|
||||
|
|
|
@ -103,7 +103,6 @@ impl<D: Send + Clone + SecureDigest> DigestTranscript<D> {
|
|||
impl<D: Send + Clone + SecureDigest> Transcript for DigestTranscript<D> {
|
||||
type Challenge = Output<D>;
|
||||
|
||||
#[must_use]
|
||||
fn new(name: &'static [u8]) -> Self {
|
||||
let mut res = Self(D::new());
|
||||
res.append(DigestTranscriptMember::Name, name);
|
||||
|
|
Loading…
Reference in a new issue