mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
2c2fb7f350
- #1139 - #1140
21 lines
580 B
Rust
21 lines
580 B
Rust
use crate::bitcoin::Scalar;
|
|
use ecdsa_fun::fun::marker::{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")
|
|
.non_zero()
|
|
.expect("non-zero scalar")
|
|
}
|
|
}
|