From c33fd3253996725a8a3e6314b1c23d5408015f40 Mon Sep 17 00:00:00 2001 From: peg Date: Mon, 22 Jul 2024 16:42:58 +0200 Subject: [PATCH] Remove session hash from protocol message (#956) Remove session hash from protocol message and use internal session id from synedrion instead --- crates/protocol/src/execute_protocol.rs | 6 +++--- crates/protocol/src/protocol_message.rs | 4 ---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/crates/protocol/src/execute_protocol.rs b/crates/protocol/src/execute_protocol.rs index f45ac0f8c..3e46b02db 100644 --- a/crates/protocol/src/execute_protocol.rs +++ b/crates/protocol/src/execute_protocol.rs @@ -74,6 +74,7 @@ async fn execute_protocol_generic( session: Session, session_id_hash: [u8; 32], ) -> Result<(Res::Success, mpsc::Receiver), GenericProtocolError> { + let session_id = synedrion::SessionId::from_seed(&session_id_hash); let tx = &chans.0; let rx = &mut chans.1; @@ -90,7 +91,7 @@ async fn execute_protocol_generic( // 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)?; @@ -115,7 +116,7 @@ async fn execute_protocol_generic( })?; 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"); @@ -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)?; } diff --git a/crates/protocol/src/protocol_message.rs b/crates/protocol/src/protocol_message.rs index b197aaac6..c836fca49 100644 --- a/crates/protocol/src/protocol_message.rs +++ b/crates/protocol/src/protocol_message.rs @@ -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 @@ -60,13 +58,11 @@ impl ProtocolMessage { from: &PartyId, to: &PartyId, payload: MessageBundle, - session_id_hash: [u8; 32], ) -> Self { Self { from: from.clone(), to: to.clone(), payload: ProtocolMessagePayload::MessageBundle(Box::new(payload)), - session_id_hash, } } }