diff --git a/manul/src/session/echo.rs b/manul/src/session/echo.rs index 7b6d916..b3ac3da 100644 --- a/manul/src/session/echo.rs +++ b/manul/src/session/echo.rs @@ -31,7 +31,7 @@ pub(crate) enum EchoRoundError { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct EchoRoundMessage { - pub(crate) echo_messages: SerializableMap>, + pub(crate) echo_broadcasts: SerializableMap>, } /// Each protocol round can contain one `EchoRound` with "echo messages" that are sent to all @@ -40,7 +40,7 @@ pub struct EchoRoundMessage { #[derive(Debug)] pub struct EchoRound { verifier: SP::Verifier, - echo_messages: BTreeMap>, + echo_broadcasts: BTreeMap>, destinations: BTreeSet, expected_echos: BTreeSet, main_round: Box>, @@ -55,25 +55,25 @@ where { pub fn new( verifier: SP::Verifier, - my_echo_message: SignedMessage, - echo_messages: BTreeMap>, + my_echo_broadcast: SignedMessage, + echo_broadcasts: BTreeMap>, main_round: Box>, payloads: BTreeMap, artifacts: BTreeMap, ) -> Self { - let destinations = echo_messages.keys().cloned().collect::>(); + let destinations = echo_broadcasts.keys().cloned().collect::>(); // Add our own echo message because we expect it to be sent back from other nodes. let mut expected_echos = destinations.clone(); expected_echos.insert(verifier.clone()); - let mut echo_messages = echo_messages; - echo_messages.insert(verifier.clone(), my_echo_message); + let mut echo_broadcasts = echo_broadcasts; + echo_broadcasts.insert(verifier.clone(), my_echo_broadcast); debug!("{:?}: initialized echo round with {:?}", verifier, destinations); Self { verifier, - echo_messages, + echo_broadcasts, destinations, expected_echos, main_round, @@ -110,8 +110,8 @@ where debug!("{:?}: making echo round message for {:?}", self.verifier, destination); // Don't send our own message the second time - let mut echo_messages = self.echo_messages.clone(); - if echo_messages.remove(&self.verifier).is_none() { + let mut echo_broadcasts = self.echo_broadcasts.clone(); + if echo_broadcasts.remove(&self.verifier).is_none() { return Err(LocalError::new(format!( "Expected {:?} to be in the set of all echo messages", self.verifier @@ -119,7 +119,7 @@ where } let message = EchoRoundMessage:: { - echo_messages: echo_messages.into(), + echo_broadcasts: echo_broadcasts.into(), }; let dm = DirectMessage::new::(&message)?; Ok((dm, Artifact::empty())) @@ -150,7 +150,7 @@ where self.destinations ))); } - let message_keys = message.echo_messages.keys().cloned().collect::>(); + let message_keys = message.echo_broadcasts.keys().cloned().collect::>(); let missing_keys = expected_keys.difference(&message_keys).collect::>(); if !missing_keys.is_empty() { @@ -172,12 +172,12 @@ where // If there's a difference, it's a provable fault, // since we have both messages signed by `from`. - for (sender, echo) in message.echo_messages.iter() { + for (sender, echo) in message.echo_broadcasts.iter() { // We expect the key to be there since - // `message.echo_messages.keys()` is within `self.destinations` - // which was constructed as `self.echo_messages.keys()`. + // `message.echo_broadcasts.keys()` is within `self.destinations` + // which was constructed as `self.echo_broadcasts.keys()`. let previously_received_echo = self - .echo_messages + .echo_broadcasts .get(sender) .expect("the key is present by construction"); diff --git a/manul/src/session/evidence.rs b/manul/src/session/evidence.rs index 3ff13bc..2d8fa61 100644 --- a/manul/src/session/evidence.rs +++ b/manul/src/session/evidence.rs @@ -155,7 +155,7 @@ where .map_err(|error| { LocalError::new(format!("Failed to deserialize the given direct message: {:?}", error)) })?; - let echoed_to_us = deserialized.echo_messages.get(&from).ok_or_else(|| { + let echoed_to_us = deserialized.echo_broadcasts.get(&from).ok_or_else(|| { LocalError::new(format!( "The echo message from {from:?} is missing from the echo packet" )) @@ -248,7 +248,7 @@ where let verified = self.direct_message.clone().verify::(verifier)?; let deserialized = verified.payload().deserialize::>()?; let invalid_echo = deserialized - .echo_messages + .echo_broadcasts .get(&self.invalid_echo_sender) .ok_or_else(|| { EvidenceError::InvalidEvidence(format!( @@ -419,7 +419,7 @@ where let echo_set = DirectMessage::deserialize::>(verified_combined_echo.payload())?; let mut verified_echo_set = Vec::new(); - for (other_verifier, echo_broadcast) in echo_set.echo_messages.iter() { + for (other_verifier, echo_broadcast) in echo_set.echo_broadcasts.iter() { let verified_echo_broadcast = echo_broadcast.clone().verify::(other_verifier)?; let metadata = verified_echo_broadcast.metadata(); if metadata.session_id() != session_id || metadata.round_id() != *round_id { diff --git a/manul/src/session/session.rs b/manul/src/session/session.rs index 8552fbc..bd48c31 100644 --- a/manul/src/session/session.rs +++ b/manul/src/session/session.rs @@ -107,7 +107,7 @@ pub struct Session { verifier: SP::Verifier, round: Box>, message_destinations: BTreeSet, - echo_message: Option>, + echo_broadcast: Option>, possible_next_rounds: BTreeSet, transcript: Transcript, } @@ -159,14 +159,14 @@ where transcript: Transcript, ) -> Result { let verifier = signer.verifying_key(); - let echo_message = round + let echo_broadcast = round .make_echo_broadcast(rng) .transpose()? .map(|echo| SignedMessage::new::(rng, &signer, &session_id, round.id(), echo)) .transpose()?; let message_destinations = round.message_destinations().clone(); - let possible_next_rounds = if echo_message.is_none() { + let possible_next_rounds = if echo_broadcast.is_none() { round.possible_next_rounds() } else { BTreeSet::from([round.id().echo()]) @@ -177,7 +177,7 @@ where signer, verifier, round, - echo_message, + echo_broadcast, possible_next_rounds, message_destinations, transcript, @@ -215,7 +215,7 @@ where &self.session_id, self.round.id(), direct_message, - self.echo_message.clone(), + self.echo_broadcast.clone(), )?; Ok(( @@ -413,10 +413,10 @@ where accum.still_have_not_sent_messages, )?; - if let Some(echo_message) = self.echo_message { + if let Some(echo_broadcast) = self.echo_broadcast { let round = Box::new(ObjectSafeRoundWrapper::new(EchoRound::::new( verifier, - echo_message, + echo_broadcast, transcript.echo_broadcasts(round_id)?, self.round, accum.payloads,