xmr-btc-swap/swap/src/monero_ext.rs
Thomas Eizinger 84bc2c82b7
Upgrade to bdk 4.0
To achieve this we also:

- upgrade rust-bitcoin to 0.26
- upgrade bitcoin-harness to latest version (which also depends bitcoin 0.26)
- upgrade to latest edcsa-fun
- replace cross_curve_dleq proof with sigma_fun (to avoid an upgrade dance over there)
2021-02-19 15:18:37 +11:00

21 lines
593 B
Rust

use crate::bitcoin::Scalar;
use ecdsa_fun::fun::marker::{Mark, NonZero, Secret};
pub trait ScalarExt {
fn to_secpfun_scalar(&self) -> ecdsa_fun::fun::Scalar;
}
impl ScalarExt for crate::monero::Scalar {
fn to_secpfun_scalar(&self) -> Scalar<Secret, NonZero> {
let mut little_endian_bytes = self.to_bytes();
little_endian_bytes.reverse();
let big_endian_bytes = little_endian_bytes;
ecdsa_fun::fun::Scalar::from_bytes(big_endian_bytes)
.expect("valid scalar")
.mark::<NonZero>()
.expect("non-zero scalar")
}
}