From fc2d8d3861393028c360bff20a99cc2192202e81 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 4 Feb 2021 12:05:48 +1100 Subject: [PATCH] Rename alice::Message0 to Message0 There is now only one message0 --- swap/src/network/request_response.rs | 4 ++-- swap/src/protocol/alice/execution_setup.rs | 7 +++---- swap/src/protocol/alice/state.rs | 5 ++--- swap/src/protocol/bob/state.rs | 7 +++---- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/swap/src/network/request_response.rs b/swap/src/network/request_response.rs index e7641e22..88f7c491 100644 --- a/swap/src/network/request_response.rs +++ b/swap/src/network/request_response.rs @@ -2,7 +2,7 @@ use crate::protocol::{ alice, alice::{Message1, Message3, TransferProof}, bob, - bob::{EncryptedSignature, Message2, Message4}, + bob::{EncryptedSignature, Message0, Message2, Message4}, }; use async_trait::async_trait; use futures::prelude::*; @@ -26,7 +26,7 @@ pub const BUF_SIZE: usize = 1024 * 1024; #[derive(Clone, Debug, Serialize, Deserialize)] pub enum BobToAlice { SwapRequest(Box), - Message0(Box), + Message0(Box), Message2(Box), Message4(Box), } diff --git a/swap/src/protocol/alice/execution_setup.rs b/swap/src/protocol/alice/execution_setup.rs index cfdfce68..df3b6538 100644 --- a/swap/src/protocol/alice/execution_setup.rs +++ b/swap/src/protocol/alice/execution_setup.rs @@ -5,8 +5,7 @@ use crate::{ network::request_response::BUF_SIZE, protocol::{ alice::{State0, State3}, - bob, - bob::{Message2, Message4}, + bob::{Message0, Message2, Message4}, }, }; use anyhow::{Context, Error, Result}; @@ -67,11 +66,11 @@ impl Behaviour { let message1 = state0.next_message(); let state1 = { - let bob_message0 = serde_cbor::from_slice::( + let message0 = serde_cbor::from_slice::( &substream.read_message(BUF_SIZE).await?, ) .context("failed to deserialize message0")?; - state0.receive(bob_message0)? + state0.receive(message0)? }; substream diff --git a/swap/src/protocol/alice/state.rs b/swap/src/protocol/alice/state.rs index f64703e9..55ebc741 100644 --- a/swap/src/protocol/alice/state.rs +++ b/swap/src/protocol/alice/state.rs @@ -9,8 +9,7 @@ use crate::{ monero, protocol::{ alice::{Message1, Message3, TransferProof}, - bob, - bob::{EncryptedSignature, Message2, Message4}, + bob::{EncryptedSignature, Message0, Message2, Message4}, SwapAmounts, }, }; @@ -148,7 +147,7 @@ impl State0 { } } - pub fn receive(self, msg: bob::Message0) -> Result { + pub fn receive(self, msg: Message0) -> Result { msg.dleq_proof_s_b.verify( msg.S_b_bitcoin.clone().into(), msg.S_b_monero diff --git a/swap/src/protocol/bob/state.rs b/swap/src/protocol/bob/state.rs index b8144fe6..66c8c4eb 100644 --- a/swap/src/protocol/bob/state.rs +++ b/swap/src/protocol/bob/state.rs @@ -11,8 +11,7 @@ use crate::{ monero::{monero_private_key, TransferProof}, protocol::{ alice::{Message1, Message3}, - bob, - bob::{EncryptedSignature, Message2, Message4}, + bob::{EncryptedSignature, Message0, Message2, Message4}, SwapAmounts, }, }; @@ -119,8 +118,8 @@ impl State0 { } } - pub fn next_message(&self) -> bob::Message0 { - bob::Message0 { + pub fn next_message(&self) -> Message0 { + Message0 { B: self.b.public(), S_b_monero: monero::PublicKey::from_private_key(&monero::PrivateKey { scalar: self.s_b.into_ed25519(),