mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-07 05:52:31 -04:00
Move generation of keys inside State0::new
This commit is contained in:
parent
228da8015b
commit
256dd7de9f
2 changed files with 13 additions and 21 deletions
|
@ -182,23 +182,15 @@ impl Builder {
|
||||||
xmr: xmr_to_swap,
|
xmr: xmr_to_swap,
|
||||||
};
|
};
|
||||||
|
|
||||||
let a = bitcoin::SecretKey::new_random(rng);
|
|
||||||
let s_a = cross_curve_dleq::Scalar::random(rng);
|
|
||||||
let v_a = monero::PrivateViewKey::new_random(rng);
|
|
||||||
let redeem_address = self.bitcoin_wallet.new_address().await?;
|
|
||||||
let punish_address = redeem_address.clone();
|
|
||||||
let state0 = State0::new(
|
let state0 = State0::new(
|
||||||
a,
|
|
||||||
s_a,
|
|
||||||
v_a,
|
|
||||||
amounts.btc,
|
amounts.btc,
|
||||||
amounts.xmr,
|
amounts.xmr,
|
||||||
self.execution_params.bitcoin_cancel_timelock,
|
self.execution_params.bitcoin_cancel_timelock,
|
||||||
self.execution_params.bitcoin_punish_timelock,
|
self.execution_params.bitcoin_punish_timelock,
|
||||||
redeem_address,
|
self.bitcoin_wallet.as_ref(),
|
||||||
punish_address,
|
|
||||||
rng,
|
rng,
|
||||||
);
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(AliceState::Started { amounts, state0 })
|
Ok(AliceState::Started { amounts, state0 })
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,25 +101,25 @@ pub struct State0 {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl State0 {
|
impl State0 {
|
||||||
#[allow(clippy::too_many_arguments)]
|
pub async fn new<R>(
|
||||||
pub fn new<R>(
|
|
||||||
a: bitcoin::SecretKey,
|
|
||||||
s_a: cross_curve_dleq::Scalar,
|
|
||||||
v_a: monero::PrivateViewKey,
|
|
||||||
btc: bitcoin::Amount,
|
btc: bitcoin::Amount,
|
||||||
xmr: monero::Amount,
|
xmr: monero::Amount,
|
||||||
cancel_timelock: Timelock,
|
cancel_timelock: Timelock,
|
||||||
punish_timelock: Timelock,
|
punish_timelock: Timelock,
|
||||||
redeem_address: bitcoin::Address,
|
bitcoin_wallet: &bitcoin::Wallet,
|
||||||
punish_address: bitcoin::Address,
|
|
||||||
rng: &mut R,
|
rng: &mut R,
|
||||||
) -> Self
|
) -> Result<Self>
|
||||||
where
|
where
|
||||||
R: RngCore + CryptoRng,
|
R: RngCore + CryptoRng,
|
||||||
{
|
{
|
||||||
|
let a = bitcoin::SecretKey::new_random(rng);
|
||||||
|
let s_a = cross_curve_dleq::Scalar::random(rng);
|
||||||
|
let v_a = monero::PrivateViewKey::new_random(rng);
|
||||||
|
let redeem_address = bitcoin_wallet.new_address().await?;
|
||||||
|
let punish_address = redeem_address.clone();
|
||||||
let dleq_proof_s_a = cross_curve_dleq::Proof::new(rng, &s_a);
|
let dleq_proof_s_a = cross_curve_dleq::Proof::new(rng, &s_a);
|
||||||
|
|
||||||
Self {
|
Ok(Self {
|
||||||
a,
|
a,
|
||||||
s_a,
|
s_a,
|
||||||
v_a,
|
v_a,
|
||||||
|
@ -130,7 +130,7 @@ impl State0 {
|
||||||
xmr,
|
xmr,
|
||||||
cancel_timelock,
|
cancel_timelock,
|
||||||
punish_timelock,
|
punish_timelock,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_message(&self) -> Message1 {
|
pub fn next_message(&self) -> Message1 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue