Struggle with Spec256k1

Hi everyone,
I have problem with function gerenate_keypair in Spec256k1 version 0.30.0
and I have this error when I want to generate public_key and secret_key
this is my function :slight_smile:

   let secp = Secp256k1::new();
   let (secret_key, public_key) = secp.generate_keypair(&mut OsRng);

and no method generate_key found in secp
and this is my toml
secp256k1 = "0.30.0"

Did you enable the rand feature on secp256k1?

~/secp_test> cat src/main.rs
use secp256k1::rand::rngs::OsRng;
use secp256k1::Secp256k1;

fn main() {
    let secp = Secp256k1::new();
    let (secret_key, public_key) = secp.generate_keypair(&mut OsRng);
}
~/secp_test> cat Cargo.toml
[package]
name = "secp_test"
version = "0.1.0"
edition = "2021"

[dependencies]
secp256k1 = { version = "0.30.0", features = ["rand"] }
1 Like

Thankfully about this and my problem solved
my issue is about
secp256k1 = { version = "0.30.0", features = ["rand"] }

on Cargo.tmol and I just use
secp256k1 = version = "0.30.0"
instead of top
Ty Schard

Welcome!

Please mark the reply that solved your problem as the solution. That way the top is marked solved, and others can easily see the solution.