Skip to content

Commit

Permalink
check for invalid NonceResponse in SignatureShareRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
xoloki committed Dec 17, 2024
1 parent c4c6e69 commit 6507e2a
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/state_machine/signer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use aes_gcm::Error as AesGcmError;
use hashbrown::{HashMap, HashSet};
use rand_core::{CryptoRng, RngCore};
use std::collections::BTreeMap;
use std::collections::{BTreeMap, BTreeSet};
use tracing::{debug, info, trace, warn};

use crate::{
Expand Down Expand Up @@ -577,7 +577,22 @@ impl<SignerType: SignerTrait> Signer<SignerType> {
.map(|nr| nr.signer_id)
.collect::<Vec<u32>>();

debug!("Got SignatureShareRequest for signer_ids {:?}", signer_ids);
let signer_id_set = sign_request
.nonce_responses
.iter()
.map(|nr| nr.signer_id)
.collect::<BTreeSet<u32>>();

if signer_ids.len() != signer_id_set.len()
|| signer_id_set.len() == 0

Check failure on line 587 in src/state_machine/signer/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

length comparison to zero
|| signer_id_set.len() > self.total_signers.try_into().unwrap()
|| signer_id_set.last().unwrap() > &self.total_signers
{
warn!(signer_ids = ?signer_ids, "Got SignatureShareRequest with invalid NonceResponse");
return Err(Error::InvalidNonceResponse);
} else {
debug!(signer_ids = ?signer_ids, "Got SignatureShareRequest");
}

for signer_id in &signer_ids {
if *signer_id == self.signer_id {
Expand Down

0 comments on commit 6507e2a

Please sign in to comment.