mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-07 03:19:30 +00:00
fmt/clippy
This commit is contained in:
parent
fd6c58805f
commit
65c20638ce
11 changed files with 15 additions and 24 deletions
coins/monero/src
crypto
|
@ -71,7 +71,7 @@ impl Output {
|
|||
|
||||
pub fn serialize<W: std::io::Write>(&self, w: &mut W) -> std::io::Result<()> {
|
||||
write_varint(&self.amount, w)?;
|
||||
w.write_all(&[2 + (if self.view_tag.is_some() { 1 } else { 0 })])?;
|
||||
w.write_all(&[2 + u8::from(self.view_tag.is_some())])?;
|
||||
w.write_all(&self.key.to_bytes())?;
|
||||
if let Some(view_tag) = self.view_tag {
|
||||
w.write_all(&[view_tag])?;
|
||||
|
|
|
@ -133,9 +133,7 @@ impl ToString for Address {
|
|||
if let AddressType::Featured(subaddress, payment_id, guaranteed) = self.meta.kind {
|
||||
// Technically should be a VarInt, yet we don't have enough features it's needed
|
||||
data.push(
|
||||
(if subaddress { 1 } else { 0 }) +
|
||||
((if payment_id.is_some() { 1 } else { 0 }) << 1) +
|
||||
((if guaranteed { 1 } else { 0 }) << 2),
|
||||
u8::from(subaddress) + (u8::from(payment_id.is_some()) << 1) + (u8::from(guaranteed) << 2),
|
||||
);
|
||||
}
|
||||
if let Some(id) = self.meta.kind.payment_id() {
|
||||
|
|
|
@ -223,7 +223,7 @@ impl SignableTransaction {
|
|||
if change && change_address.is_none() {
|
||||
Err(TransactionError::NoChange)?;
|
||||
}
|
||||
let outputs = payments.len() + (if change { 1 } else { 0 });
|
||||
let outputs = payments.len() + usize::from(change);
|
||||
|
||||
// Calculate the extra length
|
||||
let extra = Extra::fee_weight(outputs, data.as_ref());
|
||||
|
|
|
@ -165,8 +165,7 @@ impl FieldElement {
|
|||
let mut bits = 0;
|
||||
for (i, bit) in other.to_le_bits().iter().rev().enumerate() {
|
||||
bits <<= 1;
|
||||
let bit = *bit as u8;
|
||||
assert_eq!(bit | 1, 1);
|
||||
let bit = u8::from(*bit);
|
||||
bits |= bit;
|
||||
|
||||
if ((i + 1) % 4) == 0 {
|
||||
|
|
|
@ -37,9 +37,7 @@ pub mod field;
|
|||
|
||||
// Convert a boolean to a Choice in a *presumably* constant time manner
|
||||
fn choice(value: bool) -> Choice {
|
||||
let bit = value as u8;
|
||||
debug_assert_eq!(bit | 1, 1);
|
||||
Choice::from(bit)
|
||||
Choice::from(u8::from(value))
|
||||
}
|
||||
|
||||
macro_rules! deref_borrow {
|
||||
|
|
|
@ -226,8 +226,7 @@ where
|
|||
break;
|
||||
}
|
||||
|
||||
let mut bit = *raw_bit as u8;
|
||||
debug_assert_eq!(bit | 1, 1);
|
||||
let mut bit = u8::from(*raw_bit);
|
||||
*raw_bit = false;
|
||||
|
||||
// Accumulate this bit
|
||||
|
@ -246,7 +245,7 @@ where
|
|||
these_bits,
|
||||
&mut blinding_key,
|
||||
));
|
||||
these_bits = 0;
|
||||
these_bits.zeroize();
|
||||
}
|
||||
}
|
||||
debug_assert_eq!(bits.len(), capacity / bits_per_group);
|
||||
|
|
|
@ -34,9 +34,8 @@ pub fn scalar_normalize<F0: PrimeFieldBits + Zeroize, F1: PrimeFieldBits>(
|
|||
res1 = res1.double();
|
||||
res2 = res2.double();
|
||||
|
||||
let mut bit = *raw_bit as u8;
|
||||
debug_assert_eq!(bit | 1, 1);
|
||||
*raw_bit = false;
|
||||
let mut bit = u8::from(*raw_bit);
|
||||
*raw_bit = 0;
|
||||
|
||||
res1 += F0::from(bit.into());
|
||||
res2 += F1::from(bit.into());
|
||||
|
|
|
@ -61,8 +61,7 @@ macro_rules! field {
|
|||
let mut bits = 0;
|
||||
for (i, bit) in other.to_le_bits().iter().rev().enumerate() {
|
||||
bits <<= 1;
|
||||
let bit = *bit as u8;
|
||||
assert_eq!(bit | 1, 1);
|
||||
let bit = u8::from(*bit);
|
||||
bits |= bit;
|
||||
|
||||
if ((i + 1) % 4) == 0 {
|
||||
|
|
|
@ -227,8 +227,7 @@ impl Mul<Scalar> for Point {
|
|||
let mut bits = 0;
|
||||
for (i, bit) in other.to_le_bits().iter().rev().enumerate() {
|
||||
bits <<= 1;
|
||||
let bit = *bit as u8;
|
||||
assert_eq!(bit | 1, 1);
|
||||
let bit = u8::from(*bit);
|
||||
bits |= bit;
|
||||
|
||||
if ((i + 1) % 4) == 0 {
|
||||
|
@ -320,7 +319,7 @@ fn addition_multiplication_serialization() {
|
|||
let mut accum = Point::identity();
|
||||
for x in 1 .. 10 {
|
||||
accum += Point::generator();
|
||||
let mul = Point::generator() * Scalar::from(x as u8);
|
||||
let mul = Point::generator() * Scalar::from(u8::try_from(x).unwrap());
|
||||
assert_eq!(accum, mul);
|
||||
assert_eq!(Point::from_bytes(&mul.to_bytes()).unwrap(), mul);
|
||||
}
|
||||
|
|
|
@ -128,7 +128,8 @@ fn ed448_non_ietf() {
|
|||
"e7c423399b36a33ece81aaa75e419a9dc4387edc99682f9e4742c9b1",
|
||||
"a9c2392cfe30510fd33f069a42dde987544dabd7ad307a62ae1c6b13",
|
||||
"00"
|
||||
).to_string()
|
||||
)
|
||||
.to_string(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
@ -31,8 +31,7 @@ where
|
|||
|
||||
#[allow(unused_assignments)]
|
||||
for (i, mut raw_bit) in bits.iter_mut().enumerate() {
|
||||
let mut bit = *raw_bit as u8;
|
||||
debug_assert_eq!(bit | 1, 1);
|
||||
let mut bit = u8::from(*raw_bit);
|
||||
*raw_bit = false;
|
||||
|
||||
groupings[p][i / w_usize] |= bit << (i % w_usize);
|
||||
|
|
Loading…
Reference in a new issue