Skip to content

Commit

Permalink
utils/key-utils: revert changes, doesn't have to be changed in this PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Georges Palauqui committed Dec 7, 2024
1 parent da6e1c1 commit aa437f7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions utils/key-utils/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
use ::key_utils::{Secp256k1PublicKey, Secp256k1SecretKey};
use secp256k1::{rand, Keypair, Secp256k1};

fn generate_key<R: rand::Rng + ?Sized>(rng: &mut R) -> (Secp256k1SecretKey, Secp256k1PublicKey) {
fn generate_key() -> (Secp256k1SecretKey, Secp256k1PublicKey) {
let secp = Secp256k1::new();
let (secret_key, _) = secp.generate_keypair(rng);
let (secret_key, _) = secp.generate_keypair(&mut rand::thread_rng());
let kp = Keypair::from_secret_key(&secp, &secret_key);
if kp.x_only_public_key().1 == secp256k1::Parity::Even {
(
Secp256k1SecretKey(kp.secret_key()),
Secp256k1PublicKey(kp.x_only_public_key().0),
)
} else {
generate_key(rng)
generate_key()
}
}

fn main() {
let (secret, public) = generate_key(&mut rand::thread_rng());
let (secret, public) = generate_key();
let secret: String = secret.into();
let public: String = public.into();
println!("Secret Key: {}", secret);
Expand Down

0 comments on commit aa437f7

Please sign in to comment.