secp256k1 0.31.1

Rust wrapper library for Pieter Wuille's `libsecp256k1`. Implements ECDSA and BIP 340 signatures for the SECG elliptic curve group secp256k1 and related utilities.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
extern crate secp256k1;

use secp256k1::{PublicKey, Secp256k1, SecretKey};

fn main() {
    let secp = Secp256k1::new();
    let mut rng = rand::rng();
    // 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);
}