add secp256k1

This commit is contained in:
2020-04-19 08:40:31 +08:00
parent 4314fcfca0
commit b1ab9bde74
3 changed files with 217 additions and 24 deletions

View File

@@ -1,3 +1,14 @@
use rand::rngs::OsRng;
use secp256k1::Secp256k1;
fn main() {
println!("Hello, world!");
let secp = Secp256k1::new();
let mut rng = OsRng::new().expect("OsRng");
let (secret_key, public_key) = secp.generate_keypair(&mut rng);
println!("{}", secret_key);
println!("{}", public_key);
println!("{}", hex::encode(public_key.serialize_uncompressed().to_vec()));
}