|
|
|
@ -101,25 +101,25 @@ pub struct State0 {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl State0 {
|
|
|
|
|
#[allow(clippy::too_many_arguments)]
|
|
|
|
|
pub fn new<R>(
|
|
|
|
|
a: bitcoin::SecretKey,
|
|
|
|
|
s_a: cross_curve_dleq::Scalar,
|
|
|
|
|
v_a: monero::PrivateViewKey,
|
|
|
|
|
pub async fn new<R>(
|
|
|
|
|
btc: bitcoin::Amount,
|
|
|
|
|
xmr: monero::Amount,
|
|
|
|
|
cancel_timelock: Timelock,
|
|
|
|
|
punish_timelock: Timelock,
|
|
|
|
|
redeem_address: bitcoin::Address,
|
|
|
|
|
punish_address: bitcoin::Address,
|
|
|
|
|
bitcoin_wallet: &bitcoin::Wallet,
|
|
|
|
|
rng: &mut R,
|
|
|
|
|
) -> Self
|
|
|
|
|
) -> Result<Self>
|
|
|
|
|
where
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
Self {
|
|
|
|
|
Ok(Self {
|
|
|
|
|
a,
|
|
|
|
|
s_a,
|
|
|
|
|
v_a,
|
|
|
|
@ -130,7 +130,7 @@ impl State0 {
|
|
|
|
|
xmr,
|
|
|
|
|
cancel_timelock,
|
|
|
|
|
punish_timelock,
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn receive(self, msg: Message0) -> Result<State1> {
|
|
|
|
|