hal_simplicity/actions/keypair.rs
1use elements::bitcoin::secp256k1::{self, rand};
2
3#[derive(serde::Serialize)]
4pub struct KeypairInfo {
5 pub secret: secp256k1::SecretKey,
6 pub x_only: secp256k1::XOnlyPublicKey,
7 pub parity: secp256k1::Parity,
8}
9
10/// Generate a random keypair.
11pub fn keypair_generate() -> KeypairInfo {
12 let (secret, public) = secp256k1::generate_keypair(&mut rand::thread_rng());
13 let (x_only, parity) = public.x_only_public_key();
14
15 KeypairInfo {
16 secret,
17 x_only,
18 parity,
19 }
20}