2019-10-28 20:09:18 +00:00
|
|
|
extern crate secp256k1;
|
|
|
|
|
|
|
|
use secp256k1::{PublicKey, Secp256k1, SecretKey};
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let secp = Secp256k1::new();
|
2022-11-17 23:00:23 +00:00
|
|
|
let mut rng = rand::thread_rng();
|
2019-10-28 20:09:18 +00:00
|
|
|
// First option:
|
|
|
|
let (seckey, pubkey) = secp.generate_keypair(&mut rng);
|
|
|
|
|
|
|
|
assert_eq!(pubkey, PublicKey::from_secret_key(&secp, &seckey));
|
|
|
|
|
|
|
|
// Second option:
|
|
|
|
let seckey = SecretKey::new(&mut rng);
|
|
|
|
let _pubkey = PublicKey::from_secret_key(&secp, &seckey);
|
|
|
|
}
|