Skip to content

Commit

Permalink
verifying key method on keyshare now returns option
Browse files Browse the repository at this point in the history
  • Loading branch information
ameba23 committed Nov 27, 2024
1 parent 404a95e commit 737e3b7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions crates/protocol/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ pub enum ProtocolExecutionErr {
ArcUnwrapError,
#[error("Message processing task panic or cancellation: {0}")]
JoinHandle(#[from] tokio::task::JoinError),
#[error("Could not get validating key from keyshare")]
NoValidatingKey,
}

#[derive(Debug, Error)]
Expand Down
3 changes: 2 additions & 1 deletion crates/protocol/src/execute_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ pub async fn execute_dkg(
tracing::info!("Finished key init protocol");

// Send verifying key
let verifying_key = init_keyshare.verifying_key();
let verifying_key =
init_keyshare.verifying_key().ok_or(ProtocolExecutionErr::NoValidatingKey)?;
for party_id in party_ids.iter() {
if !key_init_parties.contains(party_id) {
let message = ProtocolMessage {
Expand Down
6 changes: 3 additions & 3 deletions crates/protocol/tests/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async fn test_sign_with_parties(num_parties: usize) {
let (pairs, ids) = get_keypairs_and_ids(num_parties);
let keyshares = KeyShare::<KeyParams, PartyId>::new_centralized(&mut OsRng, &ids, None);
let aux_infos = AuxInfo::<KeyParams, PartyId>::new_centralized(&mut OsRng, &ids);
let verifying_key = keyshares[&PartyId::from(pairs[0].public())].verifying_key();
let verifying_key = keyshares[&PartyId::from(pairs[0].public())].verifying_key().unwrap();

let parties: Vec<_> = pairs
.iter()
Expand Down Expand Up @@ -114,7 +114,7 @@ async fn test_sign_with_parties(num_parties: usize) {
async fn test_refresh_with_parties(num_parties: usize) {
let (pairs, ids) = get_keypairs_and_ids(num_parties);
let keyshares = KeyShare::<KeyParams, PartyId>::new_centralized(&mut OsRng, &ids, None);
let verifying_key = keyshares[&PartyId::from(pairs[0].public())].verifying_key();
let verifying_key = keyshares[&PartyId::from(pairs[0].public())].verifying_key().unwrap();

let session_id = SessionId::Reshare {
verifying_key: verifying_key.to_encoded_point(true).as_bytes().to_vec(),
Expand Down Expand Up @@ -198,7 +198,7 @@ async fn test_dkg_and_sign_with_parties(num_parties: usize) {
})
.collect();

let verifying_key = parties[0].keyshare.clone().unwrap().verifying_key();
let verifying_key = parties[0].keyshare.clone().unwrap().verifying_key().unwrap();

let message_hash = [0u8; 32];
let session_id = SessionId::Sign(SigningSessionInfo {
Expand Down

0 comments on commit 737e3b7

Please sign in to comment.