2021-03-24 01:55:00 -04:00
|
|
|
use crate::{bitcoin, monero};
|
2021-02-18 20:22:55 -05:00
|
|
|
use conquer_once::Lazy;
|
|
|
|
use ecdsa_fun::fun::marker::Mark;
|
2021-03-24 01:55:00 -04:00
|
|
|
use serde::{Deserialize, Serialize};
|
2021-02-18 20:22:55 -05:00
|
|
|
use sha2::Sha256;
|
2021-03-24 01:55:00 -04:00
|
|
|
use sigma_fun::ext::dl_secp256k1_ed25519_eq::{CrossCurveDLEQ, CrossCurveDLEQProof};
|
2021-03-03 19:28:58 -05:00
|
|
|
use sigma_fun::HashTranscript;
|
2021-02-18 20:22:55 -05:00
|
|
|
|
2021-01-04 22:08:36 -05:00
|
|
|
pub mod alice;
|
|
|
|
pub mod bob;
|
2021-01-19 21:29:46 -05:00
|
|
|
|
2021-02-18 20:22:55 -05:00
|
|
|
pub static CROSS_CURVE_PROOF_SYSTEM: Lazy<
|
|
|
|
CrossCurveDLEQ<HashTranscript<Sha256, rand_chacha::ChaCha20Rng>>,
|
|
|
|
> = Lazy::new(|| {
|
|
|
|
CrossCurveDLEQ::<HashTranscript<Sha256, rand_chacha::ChaCha20Rng>>::new(
|
|
|
|
(*ecdsa_fun::fun::G).mark::<ecdsa_fun::fun::marker::Normal>(),
|
|
|
|
curve25519_dalek::constants::ED25519_BASEPOINT_POINT,
|
|
|
|
)
|
|
|
|
});
|
|
|
|
|
2021-01-20 22:00:37 -05:00
|
|
|
#[derive(Debug, Copy, Clone)]
|
2021-01-19 21:29:46 -05:00
|
|
|
pub struct StartingBalances {
|
2021-03-24 01:55:00 -04:00
|
|
|
pub xmr: monero::Amount,
|
2021-01-19 21:29:46 -05:00
|
|
|
pub btc: bitcoin::Amount,
|
|
|
|
}
|
2021-03-24 01:55:00 -04:00
|
|
|
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
|
|
pub struct Message0 {
|
|
|
|
B: bitcoin::PublicKey,
|
|
|
|
S_b_monero: monero::PublicKey,
|
|
|
|
S_b_bitcoin: bitcoin::PublicKey,
|
|
|
|
dleq_proof_s_b: CrossCurveDLEQProof,
|
|
|
|
v_b: monero::PrivateViewKey,
|
|
|
|
refund_address: bitcoin::Address,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
|
|
pub struct Message1 {
|
|
|
|
A: bitcoin::PublicKey,
|
|
|
|
S_a_monero: monero::PublicKey,
|
|
|
|
S_a_bitcoin: bitcoin::PublicKey,
|
|
|
|
dleq_proof_s_a: CrossCurveDLEQProof,
|
|
|
|
v_a: monero::PrivateViewKey,
|
|
|
|
redeem_address: bitcoin::Address,
|
|
|
|
punish_address: bitcoin::Address,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
|
|
pub struct Message2 {
|
2021-03-24 03:30:55 -04:00
|
|
|
psbt: bitcoin::PartiallySignedTransaction,
|
2021-03-24 01:55:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
|
|
pub struct Message3 {
|
|
|
|
tx_cancel_sig: bitcoin::Signature,
|
|
|
|
tx_refund_encsig: bitcoin::EncryptedSignature,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
|
|
pub struct Message4 {
|
|
|
|
tx_punish_sig: bitcoin::Signature,
|
|
|
|
tx_cancel_sig: bitcoin::Signature,
|
|
|
|
}
|