mirror of
https://github.com/arnaucube/miden-crypto.git
synced 2026-01-09 15:41:30 +01:00
fix: clippy warnings
This commit is contained in:
@@ -280,12 +280,12 @@ impl SecretKey {
|
|||||||
.expect("The number of coefficients should be equal to N");
|
.expect("The number of coefficients should be equal to N");
|
||||||
|
|
||||||
if let Ok(s2) = SignaturePoly::try_from(&s2_coef) {
|
if let Ok(s2) = SignaturePoly::try_from(&s2_coef) {
|
||||||
return Some(s2);
|
Some(s2)
|
||||||
} else {
|
} else {
|
||||||
return None;
|
None
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return None;
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ fn approx_exp(x: f64, ccs: f64) -> u64 {
|
|||||||
|
|
||||||
/// A random bool that is true with probability ≈ ccs · exp(-x).
|
/// A random bool that is true with probability ≈ ccs · exp(-x).
|
||||||
fn ber_exp<R: Rng>(x: f64, ccs: f64, rng: &mut R) -> bool {
|
fn ber_exp<R: Rng>(x: f64, ccs: f64, rng: &mut R) -> bool {
|
||||||
const LN2: f64 = std::f64::consts::LN_2;
|
const LN2: f64 = core::f64::consts::LN_2;
|
||||||
const ILN2: f64 = 1.0 / LN2;
|
const ILN2: f64 = 1.0 / LN2;
|
||||||
let s = f64::floor(x * ILN2);
|
let s = f64::floor(x * ILN2);
|
||||||
let r = x - s * LN2;
|
let r = x - s * LN2;
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ fn test_signature_gen_reference_impl() {
|
|||||||
// we compare the encoded signature including the nonce
|
// we compare the encoded signature including the nonce
|
||||||
let sig_bytes = signature.to_bytes();
|
let sig_bytes = signature.to_bytes();
|
||||||
let expected_sig_bytes = EXPECTED_SIG[i];
|
let expected_sig_bytes = EXPECTED_SIG[i];
|
||||||
let hex_expected_sig_bytes = hex::decode(&expected_sig_bytes).unwrap();
|
let hex_expected_sig_bytes = hex::decode(expected_sig_bytes).unwrap();
|
||||||
|
|
||||||
// we remove the headers when comparing as RPO_FALCON512 uses a different header format.
|
// we remove the headers when comparing as RPO_FALCON512 uses a different header format.
|
||||||
// we also remove the public key from the RPO_FALCON512 signature as this is not part of
|
// we also remove the public key from the RPO_FALCON512 signature as this is not part of
|
||||||
@@ -220,12 +220,12 @@ impl ChaCha {
|
|||||||
self.qround(3, 4, 9, 14);
|
self.qround(3, 4, 9, 14);
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in 0..16 {
|
for (i, s) in self.state.iter_mut().enumerate().take(16) {
|
||||||
self.state[i] = self.state[i].wrapping_add(state[i]);
|
*s = (*s).wrapping_add(state[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.ctr += 1;
|
self.ctr += 1;
|
||||||
return self.state.clone();
|
self.state.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn block_update(&mut self) -> Vec<u32> {
|
fn block_update(&mut self) -> Vec<u32> {
|
||||||
@@ -254,7 +254,7 @@ impl ChaCha {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn roll(x: u32, n: usize) -> u32 {
|
fn roll(x: u32, n: usize) -> u32 {
|
||||||
((x << n) & 0xffffffff) ^ (x >> (32 - n))
|
(x << n) ^ (x >> (32 - n))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user