Skip to content

Commit

Permalink
Remove session hash from protocol message (#956)
Browse files Browse the repository at this point in the history
Remove session hash from protocol message and use internal session id from synedrion instead
  • Loading branch information
ameba23 authored Jul 22, 2024
1 parent 66749eb commit c33fd32
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 3 additions & 3 deletions crates/protocol/src/execute_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ async fn execute_protocol_generic<Res: synedrion::ProtocolResult>(
session: Session<Res, sr25519::Signature, PairWrapper, PartyId>,
session_id_hash: [u8; 32],
) -> Result<(Res::Success, mpsc::Receiver<ProtocolMessage>), GenericProtocolError<Res>> {
let session_id = synedrion::SessionId::from_seed(&session_id_hash);
let tx = &chans.0;
let rx = &mut chans.1;

Expand All @@ -90,7 +91,7 @@ async fn execute_protocol_generic<Res: synedrion::ProtocolResult>(
// TODO (#641): this can happen in a spawned task
for destination in destinations.iter() {
let (message, artifact) = session.make_message(&mut OsRng, destination)?;
tx.send(ProtocolMessage::new(&my_id, destination, message, session_id_hash))?;
tx.send(ProtocolMessage::new(&my_id, destination, message))?;

// This will happen in a host task
accum.add_artifact(artifact)?;
Expand All @@ -115,7 +116,7 @@ async fn execute_protocol_generic<Res: synedrion::ProtocolResult>(
})?;

if let ProtocolMessagePayload::MessageBundle(payload) = message.payload.clone() {
if message.session_id_hash == session_id_hash {
if payload.session_id() == &session_id {
break (message.from, *payload);
} else {
tracing::warn!("Got protocol message with incorrect session ID - putting back in queue");
Expand Down Expand Up @@ -246,7 +247,6 @@ pub async fn execute_dkg(
payload: ProtocolMessagePayload::VerifyingKey(
verifying_key.to_encoded_point(true).as_bytes().to_vec(),
),
session_id_hash,
};
chans.0.send(message)?;
}
Expand Down
4 changes: 0 additions & 4 deletions crates/protocol/src/protocol_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ pub struct ProtocolMessage {
/// We need to send verifying keys during DKG to parties who were not present for the key init
/// session.
pub payload: ProtocolMessagePayload,
/// Identifier for this protocol session
pub session_id_hash: [u8; 32],
}

/// The payload of a message sent during one of the synedrion protocols
Expand All @@ -60,13 +58,11 @@ impl ProtocolMessage {
from: &PartyId,
to: &PartyId,
payload: MessageBundle<sr25519::Signature>,
session_id_hash: [u8; 32],
) -> Self {
Self {
from: from.clone(),
to: to.clone(),
payload: ProtocolMessagePayload::MessageBundle(Box::new(payload)),
session_id_hash,
}
}
}

0 comments on commit c33fd32

Please sign in to comment.