Reputation: 3667
I'm trying to use the secp256k1 library in Rust. I have a simple test program that fails to compile because it cannot find generate_keypair
:
extern crate secp256k1;
extern crate rand;
use secp256k1::{Secp256k1, ContextFlag};
use rand::{thread_rng};
fn main() {
let full = Secp256k1::with_caps(ContextFlag::Full);
let (sk, pk) = full.generate_keypair(&mut thread_rng()).unwrap();
}
This fails to compile with the error:
error[E0599]: no method named `generate_keypair` found for type `secp256k1::Secp256k1` in the current scope
--> src/main.rs:9:25
|
9 | let (sk, pk) = full.generate_keypair(&mut thread_rng()).unwrap();
| ^^^^^^^^^^^^^^^^
As far as I can tell, I'm using the library similarly to how its used in the library's tests.
I've rolled back rand to 0.3 and secp256k1 to 0.6 and now it works. I'miInterested in any thoughts as to why this is now broken.
Upvotes: 1
Views: 841
Reputation: 430368
The documentation for secp256k1 version 0.8.1 on docs.rs does not list any method generate_keypair
.
If you look at the source, you see:
/// Generates a random keypair. Convenience function for `key::SecretKey::new`
/// and `key::PublicKey::from_secret_key`; call those functions directly for
/// batch key generation. Requires a signing-capable context.
#[inline]
#[cfg(any(test, feature = "rand"))]
pub fn generate_keypair<R: Rng>(&self, rng: &mut R)
The generate_keypair
function is only available when you enable the optional rand
dependency. This was introduced in commit 29892960. Unfortunately, the maintainer of this crate does not publish version tags to the git repository, so it's very difficult to tell what version this change happened in.
Upvotes: 5