Avoid carrying rng

This commit is contained in:
Franck Royer 2021-02-03 15:25:05 +11:00
parent 25bf5df122
commit e82383bcf6
No known key found for this signature in database
GPG key ID: A82ED75A8DFC50A4
5 changed files with 24 additions and 39 deletions

View file

@ -74,6 +74,7 @@ pub struct State0 {
b: bitcoin::SecretKey,
s_b: cross_curve_dleq::Scalar,
v_b: monero::PrivateViewKey,
dleq_proof_s_b: cross_curve_dleq::Proof,
#[serde(with = "::bitcoin::util::amount::serde::as_sat")]
btc: bitcoin::Amount,
xmr: monero::Amount,
@ -97,6 +98,7 @@ impl State0 {
let s_b = cross_curve_dleq::Scalar::random(rng);
let v_b = monero::PrivateViewKey::new_random(rng);
let dleq_proof_s_b = cross_curve_dleq::Proof::new(rng, &s_b);
Self {
b,
@ -104,6 +106,7 @@ impl State0 {
v_b,
btc,
xmr,
dleq_proof_s_b,
cancel_timelock,
punish_timelock,
refund_address,
@ -111,16 +114,14 @@ impl State0 {
}
}
pub fn next_message<R: RngCore + CryptoRng>(&self, rng: &mut R) -> bob::Message0 {
let dleq_proof_s_b = cross_curve_dleq::Proof::new(rng, &self.s_b);
pub fn next_message(&self) -> bob::Message0 {
bob::Message0 {
B: self.b.public(),
S_b_monero: monero::PublicKey::from_private_key(&monero::PrivateKey {
scalar: self.s_b.into_ed25519(),
}),
S_b_bitcoin: self.s_b.into_secp256k1().into(),
dleq_proof_s_b,
dleq_proof_s_b: self.dleq_proof_s_b.clone(),
v_b: self.v_b,
refund_address: self.refund_address.clone(),
}