Skip to content

Commit

Permalink
test sign_schnorr in coordinators dkg_sign tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xoloki committed Oct 17, 2024
1 parent 3f9b193 commit be1d95d
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/state_machine/coordinator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,59 @@ pub mod test {
}
_ => panic!("Expected Signature Operation result"),
}

// Start a signing round
let msg = "It was many and many a year ago, in a kingdom by the sea"
.as_bytes()
.to_vec();
let signature_type = SignatureType::Schnorr;
let message = coordinators
.first_mut()
.unwrap()
.start_signing_round(&msg, signature_type.clone())
.unwrap();
assert_eq!(
coordinators.first_mut().unwrap().get_state(),
State::NonceGather(signature_type.clone())
);

// Send the message to all signers and gather responses by sharing with all other signers and coordinator
let (outbound_messages, operation_results) =
feedback_messages(&mut coordinators, &mut signers, &[message]);
assert!(operation_results.is_empty());
assert_eq!(
coordinators.first_mut().unwrap().get_state(),
State::SigShareGather(signature_type.clone())
);

assert_eq!(outbound_messages.len(), 1);
match &outbound_messages[0].msg {
Message::SignatureShareRequest(_) => {}
_ => {
panic!("Expected SignatureShareRequest message");
}
}

// Send the SignatureShareRequest message to all signers and share their responses with the coordinator and signers
let (outbound_messages, operation_results) =
feedback_messages(&mut coordinators, &mut signers, &outbound_messages);
assert!(outbound_messages.is_empty());
assert_eq!(operation_results.len(), 1);
match &operation_results[0] {
OperationResult::SignSchnorr(sig) => {
for coordinator in coordinators.iter() {
assert!(sig.verify(
&coordinator
.get_aggregate_public_key()
.expect("No aggregate public key set!")
.x(),
&msg
));
assert_eq!(coordinator.get_state(), State::Idle);
}
}
_ => panic!("Expected Signature Operation result"),
}
}

pub fn equal_after_save_load<Coordinator: CoordinatorTrait, SignerType: SignerTrait>(
Expand Down

0 comments on commit be1d95d

Please sign in to comment.