Rename alice::Message1 to Message3

As per sequence diagram.
This commit is contained in:
Franck Royer 2021-02-04 11:45:54 +11:00
parent e74efd38b5
commit 0d1be52966
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
6 changed files with 19 additions and 17 deletions

View File

@ -1,6 +1,6 @@
use crate::protocol::{
alice,
alice::TransferProof,
alice::{Message3, TransferProof},
bob,
bob::{EncryptedSignature, Message4},
};
@ -36,7 +36,7 @@ pub enum BobToAlice {
pub enum AliceToBob {
SwapResponse(Box<alice::SwapResponse>),
Message0(Box<alice::Message0>),
Message1(Box<alice::Message1>),
Message3(Box<Message3>),
Message2,
}

View File

@ -31,7 +31,7 @@ pub use self::{
swap_response::*,
transfer_proof::TransferProof,
};
pub use execution_setup::Message1;
pub use execution_setup::Message3;
mod encrypted_signature;
pub mod event_loop;

View File

@ -26,7 +26,7 @@ pub struct Message0 {
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Message1 {
pub struct Message3 {
pub(crate) tx_cancel_sig: Signature,
pub(crate) tx_refund_encsig: EncryptedSignature,
}
@ -90,11 +90,11 @@ impl Behaviour {
};
{
let alice_message2 = state2.next_message();
let message3 = state2.next_message();
substream
.write_message(
&serde_cbor::to_vec(&alice_message2)
.context("failed to serialize Message2")?,
&serde_cbor::to_vec(&message3)
.context("failed to serialize message3")?,
)
.await?;
}

View File

@ -9,7 +9,7 @@ use crate::{
monero,
protocol::{
alice,
alice::TransferProof,
alice::{Message3, TransferProof},
bob,
bob::{EncryptedSignature, Message4},
SwapAmounts,
@ -237,7 +237,7 @@ pub struct State2 {
}
impl State2 {
pub fn next_message(&self) -> alice::Message1 {
pub fn next_message(&self) -> Message3 {
let tx_cancel =
bitcoin::TxCancel::new(&self.tx_lock, self.cancel_timelock, self.a.public(), self.B);
@ -250,7 +250,7 @@ impl State2 {
let tx_refund_encsig = self.a.encsign(self.S_b_bitcoin, tx_refund.digest());
let tx_cancel_sig = self.a.sign(tx_cancel.digest());
alice::Message1 {
Message3 {
tx_refund_encsig,
tx_cancel_sig,
}

View File

@ -3,6 +3,7 @@ use crate::{
network::request_response::BUF_SIZE,
protocol::{
alice,
alice::Message3,
bob::{State0, State2},
},
};
@ -98,11 +99,10 @@ impl Behaviour {
.await?;
}
let alice_message1 = serde_cbor::from_slice::<alice::Message1>(
&substream.read_message(BUF_SIZE).await?,
)
.context("failed to deserialize message1")?;
let state2 = state1.receive(alice_message1)?;
let message3 =
serde_cbor::from_slice::<Message3>(&substream.read_message(BUF_SIZE).await?)
.context("failed to deserialize message3")?;
let state2 = state1.receive(message3)?;
{
let message4 = state2.next_message();

View File

@ -10,7 +10,9 @@ use crate::{
monero,
monero::{monero_private_key, TransferProof},
protocol::{
alice, bob,
alice,
alice::Message3,
bob,
bob::{EncryptedSignature, Message4},
SwapAmounts,
},
@ -193,7 +195,7 @@ impl State1 {
}
}
pub fn receive(self, msg: alice::Message1) -> Result<State2> {
pub fn receive(self, msg: Message3) -> Result<State2> {
let tx_cancel = TxCancel::new(&self.tx_lock, self.cancel_timelock, self.A, self.b.public());
let tx_refund = bitcoin::TxRefund::new(&tx_cancel, &self.refund_address);