Rename alice::Message0 to Message0

There is now only one message0
This commit is contained in:
Franck Royer 2021-02-04 12:05:48 +11:00
parent 88bf080dc0
commit fc2d8d3861
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
4 changed files with 10 additions and 13 deletions

View File

@ -2,7 +2,7 @@ use crate::protocol::{
alice, alice,
alice::{Message1, Message3, TransferProof}, alice::{Message1, Message3, TransferProof},
bob, bob,
bob::{EncryptedSignature, Message2, Message4}, bob::{EncryptedSignature, Message0, Message2, Message4},
}; };
use async_trait::async_trait; use async_trait::async_trait;
use futures::prelude::*; use futures::prelude::*;
@ -26,7 +26,7 @@ pub const BUF_SIZE: usize = 1024 * 1024;
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
pub enum BobToAlice { pub enum BobToAlice {
SwapRequest(Box<bob::SwapRequest>), SwapRequest(Box<bob::SwapRequest>),
Message0(Box<bob::Message0>), Message0(Box<Message0>),
Message2(Box<Message2>), Message2(Box<Message2>),
Message4(Box<Message4>), Message4(Box<Message4>),
} }

View File

@ -5,8 +5,7 @@ use crate::{
network::request_response::BUF_SIZE, network::request_response::BUF_SIZE,
protocol::{ protocol::{
alice::{State0, State3}, alice::{State0, State3},
bob, bob::{Message0, Message2, Message4},
bob::{Message2, Message4},
}, },
}; };
use anyhow::{Context, Error, Result}; use anyhow::{Context, Error, Result};
@ -67,11 +66,11 @@ impl Behaviour {
let message1 = state0.next_message(); let message1 = state0.next_message();
let state1 = { let state1 = {
let bob_message0 = serde_cbor::from_slice::<bob::Message0>( let message0 = serde_cbor::from_slice::<Message0>(
&substream.read_message(BUF_SIZE).await?, &substream.read_message(BUF_SIZE).await?,
) )
.context("failed to deserialize message0")?; .context("failed to deserialize message0")?;
state0.receive(bob_message0)? state0.receive(message0)?
}; };
substream substream

View File

@ -9,8 +9,7 @@ use crate::{
monero, monero,
protocol::{ protocol::{
alice::{Message1, Message3, TransferProof}, alice::{Message1, Message3, TransferProof},
bob, bob::{EncryptedSignature, Message0, Message2, Message4},
bob::{EncryptedSignature, Message2, Message4},
SwapAmounts, SwapAmounts,
}, },
}; };
@ -148,7 +147,7 @@ impl State0 {
} }
} }
pub fn receive(self, msg: bob::Message0) -> Result<State1> { pub fn receive(self, msg: Message0) -> Result<State1> {
msg.dleq_proof_s_b.verify( msg.dleq_proof_s_b.verify(
msg.S_b_bitcoin.clone().into(), msg.S_b_bitcoin.clone().into(),
msg.S_b_monero msg.S_b_monero

View File

@ -11,8 +11,7 @@ use crate::{
monero::{monero_private_key, TransferProof}, monero::{monero_private_key, TransferProof},
protocol::{ protocol::{
alice::{Message1, Message3}, alice::{Message1, Message3},
bob, bob::{EncryptedSignature, Message0, Message2, Message4},
bob::{EncryptedSignature, Message2, Message4},
SwapAmounts, SwapAmounts,
}, },
}; };
@ -119,8 +118,8 @@ impl State0 {
} }
} }
pub fn next_message(&self) -> bob::Message0 { pub fn next_message(&self) -> Message0 {
bob::Message0 { Message0 {
B: self.b.public(), B: self.b.public(),
S_b_monero: monero::PublicKey::from_private_key(&monero::PrivateKey { S_b_monero: monero::PublicKey::from_private_key(&monero::PrivateKey {
scalar: self.s_b.into_ed25519(), scalar: self.s_b.into_ed25519(),