Skip to content

Commit

Permalink
don't return err when malicious signer sends something, just warn and…
Browse files Browse the repository at this point in the history
… continue; complete insufficient signers test
  • Loading branch information
xoloki committed Oct 27, 2023
1 parent 82f2939 commit b96cf3f
Showing 1 changed file with 50 additions and 4 deletions.
54 changes: 50 additions & 4 deletions src/state_machine/coordinator/fire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,16 @@ impl<Aggregator: AggregatorTrait> Coordinator<Aggregator> {
.malicious_signer_ids
.contains(&nonce_response.signer_id)
{
info!(
warn!(
"Sign round {} iteration {} received malicious NonceResponse from signer {} ({}/{})",
nonce_response.sign_id,
nonce_response.sign_iter_id,
nonce_response.signer_id,
self.nonce_recv_key_ids.len(),
self.config.threshold,
);
return Err(Error::MaliciousSigner(nonce_response.signer_id));
//return Err(Error::MaliciousSigner(nonce_response.signer_id));
return Ok(());
}

self.public_nonces
Expand Down Expand Up @@ -1202,7 +1203,7 @@ pub mod test {
let mut malicious = Vec::new();
// now remove signers so the number is insufficient
for _ in 0..num_signers_to_remove {
malicious.push(insufficient_signers.pop());
malicious.push(insufficient_signers.pop().unwrap());
}

// Send the SignatureShareRequest message to all signers and share their responses with the coordinator and signers
Expand Down Expand Up @@ -1233,18 +1234,63 @@ pub mod test {
State::NonceGather(is_taproot, merkle_root)
);

// put the malicious signers back in
while !malicious.is_empty() {
insufficient_signers.push(malicious.pop().unwrap());
}

// Send the NonceRequest message to all signers and share their responses with the coordinator and signers
let (outbound_messages, operation_results) = feedback_messages(
&mut insufficient_coordinator,
&mut insufficient_signers,
&outbound_messages,
);
assert_eq!(outbound_messages.len(), 1);
assert_eq!(operation_results.len(), 0);

assert_eq!(
insufficient_coordinator.state,
State::SigShareGather(is_taproot, merkle_root)
);

// again remove signers so the number is insufficient
for _ in 0..num_signers_to_remove {
malicious.push(insufficient_signers.pop().unwrap());
}

// Send the SignatureShareRequest message to all signers and share their responses with the coordinator and signers
let (outbound_messages, operation_results) = feedback_messages(
&mut insufficient_coordinator,
&mut insufficient_signers,
&outbound_messages,
);
assert!(outbound_messages.is_empty());
assert!(operation_results.is_empty());

assert_eq!(
insufficient_coordinator.state,
State::NonceGather(is_taproot, merkle_root)
State::SigShareGather(is_taproot, merkle_root)
);

// Sleep long enough to hit the timeout
thread::sleep(Duration::from_millis(256));

let (outbound_messages, operation_results) = insufficient_coordinator
.process_inbound_messages(&[])
.unwrap();

assert_eq!(outbound_messages.len(), 0);
assert_eq!(operation_results.len(), 1);
assert_eq!(
insufficient_coordinator.state,
State::SigShareGather(is_taproot, merkle_root)
);
match &operation_results[0] {
OperationResult::SignError(sign_error) => match sign_error {
SignError::InsufficientSigners => {}
_ => panic!("Expected SignError::InsufficientSigners"),
},
_ => panic!("Expected OperationResult::SignError"),
}
}
}

0 comments on commit b96cf3f

Please sign in to comment.