mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 04:39:24 +00:00
Correct clippy warnings
Currently intended to be done with: cargo clippy --features "recommended merlin batch serialize experimental ed25519 ristretto p256 secp256k1 multisig" -- -A clippy::type_complexity -A dead_code
This commit is contained in:
@@ -34,17 +34,17 @@ pub async fn call_verify(
|
||||
contract: &schnorr_mod::Schnorr<SignerMiddleware<Provider<Http>, LocalWallet>>,
|
||||
params: &ProcessedSignature,
|
||||
) -> Result<()> {
|
||||
let ok = contract
|
||||
if contract
|
||||
.verify(
|
||||
params.parity + 27,
|
||||
params.px.to_bytes().into(),
|
||||
params.message.into(),
|
||||
params.message,
|
||||
params.s.to_bytes().into(),
|
||||
params.e.to_bytes().into(),
|
||||
)
|
||||
.call()
|
||||
.await?;
|
||||
if ok {
|
||||
.await?
|
||||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(eyre!(EthereumError::VerificationError))
|
||||
|
||||
@@ -41,7 +41,8 @@ pub fn ecrecover(message: Scalar, v: u8, r: Scalar, s: Scalar) -> Option<[u8; 20
|
||||
return Some(address(&key));
|
||||
}
|
||||
}
|
||||
return None;
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::{serialize::*, transaction::Transaction};
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct BlockHeader {
|
||||
pub major_version: u64,
|
||||
pub minor_version: u64,
|
||||
@@ -37,7 +37,7 @@ impl BlockHeader {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct Block {
|
||||
pub header: BlockHeader,
|
||||
pub miner_tx: Transaction,
|
||||
|
||||
@@ -38,7 +38,7 @@ lazy_static! {
|
||||
)
|
||||
.decompress()
|
||||
.unwrap();
|
||||
static ref H_TABLE: EdwardsBasepointTable = EdwardsBasepointTable::create(&*H);
|
||||
static ref H_TABLE: EdwardsBasepointTable = EdwardsBasepointTable::create(&H);
|
||||
}
|
||||
|
||||
// Function from libsodium our subsection of Monero relies on. Implementing it here means we don't
|
||||
@@ -98,5 +98,5 @@ pub fn hash(data: &[u8]) -> [u8; 32] {
|
||||
}
|
||||
|
||||
pub fn hash_to_scalar(data: &[u8]) -> Scalar {
|
||||
Scalar::from_bytes_mod_order(hash(&data))
|
||||
Scalar::from_bytes_mod_order(hash(data))
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::{Commitment, wallet::TransactionError, serialize::*};
|
||||
|
||||
pub(crate) const MAX_OUTPUTS: usize = 16;
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct Bulletproofs {
|
||||
pub A: EdwardsPoint,
|
||||
pub S: EdwardsPoint,
|
||||
|
||||
@@ -41,7 +41,7 @@ pub enum ClsagError {
|
||||
InvalidC1,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct ClsagInput {
|
||||
// The actual commitment for the true spend
|
||||
pub commitment: Commitment,
|
||||
@@ -69,6 +69,7 @@ impl ClsagInput {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
enum Mode {
|
||||
Sign(usize, EdwardsPoint, EdwardsPoint),
|
||||
#[cfg(feature = "experimental")]
|
||||
@@ -182,7 +183,7 @@ fn core(
|
||||
((D, c * mu_P, c * mu_C), c1.unwrap_or(c))
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct Clsag {
|
||||
pub D: EdwardsPoint,
|
||||
pub s: Vec<Scalar>,
|
||||
|
||||
@@ -65,7 +65,7 @@ impl ClsagDetails {
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
struct Interim {
|
||||
p: Scalar,
|
||||
c: Scalar,
|
||||
@@ -147,7 +147,7 @@ impl Algorithm<Ed25519> for ClsagMultisig {
|
||||
l: u16,
|
||||
serialized: &mut Re,
|
||||
) -> Result<(), FrostError> {
|
||||
if self.image.is_identity().into() {
|
||||
if self.image.is_identity() {
|
||||
self.transcript.domain_separate(b"CLSAG");
|
||||
self.input().transcript(&mut self.transcript);
|
||||
self.transcript.append_message(b"mask", &self.mask().to_bytes());
|
||||
@@ -189,15 +189,13 @@ impl Algorithm<Ed25519> for ClsagMultisig {
|
||||
&self.image,
|
||||
&self.input(),
|
||||
self.mask(),
|
||||
&self.msg.as_ref().unwrap(),
|
||||
self.msg.as_ref().unwrap(),
|
||||
nonce_sums[0][0].0,
|
||||
nonce_sums[0][1].0,
|
||||
);
|
||||
self.interim = Some(Interim { p, c, clsag, pseudo_out });
|
||||
|
||||
let share = dfg::Scalar(nonces[0].0 - (p * view.secret_share().0));
|
||||
|
||||
share
|
||||
dfg::Scalar(nonces[0].0 - (p * view.secret_share().0))
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
@@ -215,13 +213,13 @@ impl Algorithm<Ed25519> for ClsagMultisig {
|
||||
&self.input().decoys.ring,
|
||||
&self.image,
|
||||
&interim.pseudo_out,
|
||||
&self.msg.as_ref().unwrap(),
|
||||
self.msg.as_ref().unwrap(),
|
||||
)
|
||||
.is_ok()
|
||||
{
|
||||
return Some((clsag, interim.pseudo_out));
|
||||
}
|
||||
return None;
|
||||
None
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
@@ -232,7 +230,6 @@ impl Algorithm<Ed25519> for ClsagMultisig {
|
||||
share: dfg::Scalar,
|
||||
) -> bool {
|
||||
let interim = self.interim.as_ref().unwrap();
|
||||
return (&share.0 * &ED25519_BASEPOINT_TABLE) ==
|
||||
(nonces[0][0].0 - (interim.p * verification_share.0));
|
||||
(&share.0 * &ED25519_BASEPOINT_TABLE) == (nonces[0][0].0 - (interim.p * verification_share.0))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ pub(crate) fn rust_hash_to_point(key: EdwardsPoint) -> EdwardsPoint {
|
||||
#[allow(non_snake_case)]
|
||||
let mut Y = z - w;
|
||||
|
||||
Y = Y * Z.invert().unwrap();
|
||||
Y *= Z.invert().unwrap();
|
||||
let mut bytes = Y.to_repr();
|
||||
bytes[31] |= sign.unwrap_u8() << 7;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ pub fn generate_key_image(secret: Scalar) -> EdwardsPoint {
|
||||
secret * hash_to_point(&secret * &ED25519_BASEPOINT_TABLE)
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct RctBase {
|
||||
pub fee: u64,
|
||||
pub ecdh_info: Vec<[u8; 8]>,
|
||||
@@ -68,7 +68,7 @@ impl RctBase {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub enum RctPrunable {
|
||||
Null,
|
||||
Clsag { bulletproofs: Vec<Bulletproofs>, clsags: Vec<Clsag>, pseudo_outs: Vec<EdwardsPoint> },
|
||||
@@ -90,9 +90,9 @@ impl RctPrunable {
|
||||
match self {
|
||||
RctPrunable::Null => Ok(()),
|
||||
RctPrunable::Clsag { bulletproofs, clsags, pseudo_outs } => {
|
||||
write_vec(Bulletproofs::serialize, &bulletproofs, w)?;
|
||||
write_raw_vec(Clsag::serialize, &clsags, w)?;
|
||||
write_raw_vec(write_point, &pseudo_outs, w)
|
||||
write_vec(Bulletproofs::serialize, bulletproofs, w)?;
|
||||
write_raw_vec(Clsag::serialize, clsags, w)?;
|
||||
write_raw_vec(write_point, pseudo_outs, w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,13 +122,13 @@ impl RctPrunable {
|
||||
match self {
|
||||
RctPrunable::Null => panic!("Serializing RctPrunable::Null for a signature"),
|
||||
RctPrunable::Clsag { bulletproofs, .. } => {
|
||||
bulletproofs.iter().map(|bp| bp.signature_serialize(w)).collect()
|
||||
bulletproofs.iter().try_for_each(|bp| bp.signature_serialize(w))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct RctSignatures {
|
||||
pub base: RctBase,
|
||||
pub prunable: RctPrunable,
|
||||
|
||||
@@ -47,7 +47,7 @@ fn rpc_point(point: &str) -> Result<EdwardsPoint, RpcError> {
|
||||
rpc_hex(point)?.try_into().map_err(|_| RpcError::InvalidPoint(point.to_string()))?,
|
||||
)
|
||||
.decompress()
|
||||
.ok_or(RpcError::InvalidPoint(point.to_string()))
|
||||
.ok_or_else(|| RpcError::InvalidPoint(point.to_string()))
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@@ -110,7 +110,7 @@ impl Rpc {
|
||||
&self,
|
||||
hashes: &[[u8; 32]],
|
||||
) -> Result<(Vec<Result<Transaction, RpcError>>, Vec<[u8; 32]>), RpcError> {
|
||||
if hashes.len() == 0 {
|
||||
if hashes.is_empty() {
|
||||
return Ok((vec![], vec![]));
|
||||
}
|
||||
|
||||
@@ -142,14 +142,14 @@ impl Rpc {
|
||||
.iter()
|
||||
.map(|res| {
|
||||
let tx = Transaction::deserialize(&mut std::io::Cursor::new(
|
||||
rpc_hex(if res.as_hex.len() != 0 { &res.as_hex } else { &res.pruned_as_hex }).unwrap(),
|
||||
rpc_hex(if !res.as_hex.is_empty() { &res.as_hex } else { &res.pruned_as_hex }).unwrap(),
|
||||
))
|
||||
.map_err(|_| {
|
||||
RpcError::InvalidTransaction(hex::decode(&res.tx_hash).unwrap().try_into().unwrap())
|
||||
})?;
|
||||
|
||||
// https://github.com/monero-project/monero/issues/8311
|
||||
if res.as_hex.len() == 0 {
|
||||
if res.as_hex.is_empty() {
|
||||
match tx.prefix.inputs.get(0) {
|
||||
Some(Input::Gen { .. }) => (),
|
||||
_ => Err(RpcError::PrunedTransaction)?,
|
||||
@@ -165,7 +165,7 @@ impl Rpc {
|
||||
|
||||
pub async fn get_transactions(&self, hashes: &[[u8; 32]]) -> Result<Vec<Transaction>, RpcError> {
|
||||
let (txs, missed) = self.get_transactions_core(hashes).await?;
|
||||
if missed.len() != 0 {
|
||||
if !missed.is_empty() {
|
||||
Err(RpcError::TransactionsNotFound(missed))?;
|
||||
}
|
||||
// This will clone several KB and is accordingly inefficient
|
||||
|
||||
@@ -50,7 +50,7 @@ pub fn write_vec<T, W: io::Write, F: Fn(&T, &mut W) -> io::Result<()>>(
|
||||
w: &mut W,
|
||||
) -> io::Result<()> {
|
||||
write_varint(&values.len().try_into().unwrap(), w)?;
|
||||
write_raw_vec(f, &values, w)
|
||||
write_raw_vec(f, values, w)
|
||||
}
|
||||
|
||||
pub fn read_byte<R: io::Read>(r: &mut R) -> io::Result<u8> {
|
||||
@@ -81,14 +81,14 @@ pub fn read_32<R: io::Read>(r: &mut R) -> io::Result<[u8; 32]> {
|
||||
// TODO: https://github.com/serai-dex/serai/issues/25
|
||||
pub fn read_scalar<R: io::Read>(r: &mut R) -> io::Result<Scalar> {
|
||||
Scalar::from_canonical_bytes(read_32(r)?)
|
||||
.ok_or(io::Error::new(io::ErrorKind::Other, "unreduced scalar"))
|
||||
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "unreduced scalar"))
|
||||
}
|
||||
|
||||
pub fn read_point<R: io::Read>(r: &mut R) -> io::Result<EdwardsPoint> {
|
||||
CompressedEdwardsY(read_32(r)?)
|
||||
.decompress()
|
||||
.filter(|point| point.is_torsion_free())
|
||||
.ok_or(io::Error::new(io::ErrorKind::Other, "invalid point"))
|
||||
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "invalid point"))
|
||||
}
|
||||
|
||||
pub fn read_raw_vec<R: io::Read, T, F: Fn(&mut R) -> io::Result<T>>(
|
||||
@@ -96,9 +96,7 @@ pub fn read_raw_vec<R: io::Read, T, F: Fn(&mut R) -> io::Result<T>>(
|
||||
len: usize,
|
||||
r: &mut R,
|
||||
) -> io::Result<Vec<T>> {
|
||||
let mut res = Vec::with_capacity(
|
||||
len.try_into().map_err(|_| io::Error::new(io::ErrorKind::Other, "length exceeds usize"))?,
|
||||
);
|
||||
let mut res = Vec::with_capacity(len);
|
||||
for _ in 0 .. len {
|
||||
res.push(f(r)?);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ use crate::{
|
||||
|
||||
pub const RING_LEN: usize = 11;
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub enum Input {
|
||||
Gen(u64),
|
||||
|
||||
@@ -60,7 +60,7 @@ impl Input {
|
||||
}
|
||||
|
||||
// Doesn't bother moving to an enum for the unused Script classes
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct Output {
|
||||
pub amount: u64,
|
||||
pub key: EdwardsPoint,
|
||||
@@ -106,7 +106,7 @@ impl Output {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
pub enum Timelock {
|
||||
None,
|
||||
Block(usize),
|
||||
@@ -151,7 +151,7 @@ impl PartialOrd for Timelock {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct TransactionPrefix {
|
||||
pub version: u64,
|
||||
pub timelock: Timelock,
|
||||
@@ -198,7 +198,7 @@ impl TransactionPrefix {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct Transaction {
|
||||
pub prefix: TransactionPrefix,
|
||||
pub rct_signatures: RctSignatures,
|
||||
|
||||
@@ -57,6 +57,7 @@ pub enum AddressError {
|
||||
}
|
||||
|
||||
impl AddressMeta {
|
||||
#[allow(clippy::wrong_self_convention)]
|
||||
fn to_byte(&self) -> u8 {
|
||||
let bytes = AddressType::network_bytes(self.network);
|
||||
let byte = match self.kind {
|
||||
|
||||
@@ -94,7 +94,7 @@ fn offset(ring: &[u64]) -> Vec<u64> {
|
||||
res
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct Decoys {
|
||||
pub i: u8,
|
||||
pub offsets: Vec<u64>,
|
||||
|
||||
@@ -27,7 +27,7 @@ pub(crate) fn uniqueness(inputs: &[Input]) -> [u8; 32] {
|
||||
// If Gen, this should be the only input, making this loop somewhat pointless
|
||||
// This works and even if there were somehow multiple inputs, it'd be a false negative
|
||||
Input::Gen(height) => {
|
||||
write_varint(&(*height).try_into().unwrap(), &mut u).unwrap();
|
||||
write_varint(height, &mut u).unwrap();
|
||||
}
|
||||
Input::ToKey { key_image, .. } => u.extend(key_image.compress().to_bytes()),
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::{
|
||||
wallet::{ViewPair, uniqueness, shared_key, amount_decryption, commitment_mask},
|
||||
};
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct SpendableOutput {
|
||||
pub tx: [u8; 32],
|
||||
pub o: u8,
|
||||
@@ -92,7 +92,7 @@ impl Transaction {
|
||||
m_pubkeys.extend(&keys);
|
||||
}
|
||||
|
||||
pubkeys = m_pubkeys.iter().map(|key| key.point.decompress()).filter_map(|key| key).collect();
|
||||
pubkeys = m_pubkeys.iter().filter_map(|key| key.point.decompress()).collect();
|
||||
} else {
|
||||
return Timelocked(self.prefix.timelock, vec![]);
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ mod multisig;
|
||||
pub use multisig::TransactionMachine;
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
struct SendOutput {
|
||||
R: EdwardsPoint,
|
||||
dest: EdwardsPoint,
|
||||
@@ -61,7 +61,7 @@ impl SendOutput {
|
||||
AddressType::Integrated(_) => {
|
||||
unimplemented!("SendOutput::new doesn't support Integrated addresses")
|
||||
}
|
||||
AddressType::Subaddress => &r * spend,
|
||||
AddressType::Subaddress => r * spend,
|
||||
},
|
||||
dest: ((&shared_key * &ED25519_BASEPOINT_TABLE) + spend),
|
||||
commitment: Commitment::new(commitment_mask(shared_key), output.1),
|
||||
@@ -113,18 +113,17 @@ async fn prepare_inputs<R: RngCore + CryptoRng>(
|
||||
let decoys = Decoys::select(
|
||||
rng,
|
||||
rpc,
|
||||
rpc.get_height().await.map_err(|e| TransactionError::RpcError(e))? - 10,
|
||||
rpc.get_height().await.map_err(TransactionError::RpcError)? - 10,
|
||||
inputs,
|
||||
)
|
||||
.await
|
||||
.map_err(|e| TransactionError::RpcError(e))?;
|
||||
.map_err(TransactionError::RpcError)?;
|
||||
|
||||
for (i, input) in inputs.iter().enumerate() {
|
||||
signable.push((
|
||||
spend + input.key_offset,
|
||||
generate_key_image(spend + input.key_offset),
|
||||
ClsagInput::new(input.commitment, decoys[i].clone())
|
||||
.map_err(|e| TransactionError::ClsagError(e))?,
|
||||
ClsagInput::new(input.commitment, decoys[i].clone()).map_err(TransactionError::ClsagError)?,
|
||||
));
|
||||
|
||||
tx.prefix.inputs.push(Input::ToKey {
|
||||
@@ -158,7 +157,7 @@ impl Fee {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct SignableTransaction {
|
||||
inputs: Vec<SpendableOutput>,
|
||||
payments: Vec<(Address, u64)>,
|
||||
@@ -187,10 +186,10 @@ impl SignableTransaction {
|
||||
test(change)?;
|
||||
}
|
||||
|
||||
if inputs.len() == 0 {
|
||||
if inputs.is_empty() {
|
||||
Err(TransactionError::NoInputs)?;
|
||||
}
|
||||
if payments.len() == 0 {
|
||||
if payments.is_empty() {
|
||||
Err(TransactionError::NoOutputs)?;
|
||||
}
|
||||
|
||||
@@ -339,8 +338,7 @@ impl SignableTransaction {
|
||||
RctPrunable::Null => panic!("Signing for RctPrunable::Null"),
|
||||
RctPrunable::Clsag { ref mut clsags, ref mut pseudo_outs, .. } => {
|
||||
clsags.append(&mut clsag_pairs.iter().map(|clsag| clsag.0.clone()).collect::<Vec<_>>());
|
||||
pseudo_outs
|
||||
.append(&mut clsag_pairs.iter().map(|clsag| clsag.1.clone()).collect::<Vec<_>>());
|
||||
pseudo_outs.append(&mut clsag_pairs.iter().map(|clsag| clsag.1).collect::<Vec<_>>());
|
||||
}
|
||||
}
|
||||
Ok(tx)
|
||||
|
||||
@@ -108,7 +108,7 @@ impl SignableTransaction {
|
||||
transcript.append_message(b"input_shared_key", &input.key_offset.to_bytes());
|
||||
}
|
||||
for payment in &self.payments {
|
||||
transcript.append_message(b"payment_address", &payment.0.to_string().as_bytes());
|
||||
transcript.append_message(b"payment_address", payment.0.to_string().as_bytes());
|
||||
transcript.append_message(b"payment_amount", &payment.1.to_le_bytes());
|
||||
}
|
||||
|
||||
@@ -125,11 +125,11 @@ impl SignableTransaction {
|
||||
clsags.push(
|
||||
AlgorithmMachine::new(
|
||||
ClsagMultisig::new(transcript.clone(), input.key, inputs[i].clone())
|
||||
.map_err(|e| TransactionError::MultisigError(e))?,
|
||||
.map_err(TransactionError::MultisigError)?,
|
||||
Arc::new(offset),
|
||||
&included,
|
||||
)
|
||||
.map_err(|e| TransactionError::FrostError(e))?,
|
||||
.map_err(TransactionError::FrostError)?,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ impl SignableTransaction {
|
||||
&self.inputs,
|
||||
)
|
||||
.await
|
||||
.map_err(|e| TransactionError::RpcError(e))?;
|
||||
.map_err(TransactionError::RpcError)?;
|
||||
|
||||
Ok(TransactionMachine {
|
||||
signable: self,
|
||||
@@ -223,7 +223,7 @@ impl SignMachine<Transaction> for TransactionSignMachine {
|
||||
mut commitments: HashMap<u16, Re>,
|
||||
msg: &[u8],
|
||||
) -> Result<(TransactionSignatureMachine, Vec<u8>), FrostError> {
|
||||
if msg.len() != 0 {
|
||||
if !msg.is_empty() {
|
||||
Err(FrostError::InternalError(
|
||||
"message was passed to the TransactionMachine when it generates its own",
|
||||
))?;
|
||||
@@ -237,7 +237,8 @@ impl SignMachine<Transaction> for TransactionSignMachine {
|
||||
let mut commitments = (0 .. self.clsags.len())
|
||||
.map(|c| {
|
||||
let mut buf = [0; CLSAG_LEN];
|
||||
(&self.included)
|
||||
self
|
||||
.included
|
||||
.iter()
|
||||
.map(|l| {
|
||||
// Add all commitments to the transcript for their entropy
|
||||
@@ -310,7 +311,7 @@ impl SignMachine<Transaction> for TransactionSignMachine {
|
||||
|
||||
// Sort the inputs, as expected
|
||||
let mut sorted = Vec::with_capacity(self.clsags.len());
|
||||
while self.clsags.len() != 0 {
|
||||
while !self.clsags.is_empty() {
|
||||
sorted.push((
|
||||
images.swap_remove(0),
|
||||
self.signable.inputs.swap_remove(0),
|
||||
@@ -324,11 +325,11 @@ impl SignMachine<Transaction> for TransactionSignMachine {
|
||||
|
||||
let mut rng = ChaCha12Rng::from_seed(self.transcript.rng_seed(b"pseudo_out_masks"));
|
||||
let mut sum_pseudo_outs = Scalar::zero();
|
||||
while sorted.len() != 0 {
|
||||
while !sorted.is_empty() {
|
||||
let value = sorted.remove(0);
|
||||
|
||||
let mut mask = random_scalar(&mut rng);
|
||||
if sorted.len() == 0 {
|
||||
if sorted.is_empty() {
|
||||
mask = output_masks - sum_pseudo_outs;
|
||||
} else {
|
||||
sum_pseudo_outs += mask;
|
||||
|
||||
Reference in New Issue
Block a user