I simply tried to create a recoverable signature using the k256 crate documentation as a reference as follows, but for some reason I get a compile error regarding the sign
method to create the signature.
use k256::ecdsa::{recoverable, signature::Signer, SigningKey};
use rand_core::OsRng;
fn main() {
let signing_key = SigningKey::random(&mut OsRng);
let verifying_key = signing_key.verifying_key();
let message = b"ECDSA proves knowledge of a secret number in the context of a single message";
let signature: recoverable::Signature = signing_key.sign(message);
}
error[E0277]: the trait bound `k256::ecdsa::recoverable::Signature: PrehashSignature` is not satisfied
--> src/main.rs:9:57
|
9 | let signature: recoverable::Signature = signing_key.sign(message);
| ^^^^ the trait `PrehashSignature` is not implemented for `k256::ecdsa::recoverable::Signature`
|
= help: the following other types implement trait `PrehashSignature`:
ecdsa::Signature<C>
ecdsa::der::Signature<C>
k256::schnorr::Signature
= note: required because of the requirements on the impl of `Signer<k256::ecdsa::recoverable::Signature>` for `k256::ecdsa::SigningKey`
I have enabled the "ecdsa" features as follows:
k256 = { version = "0.11.3", features = ["ecdsa"] }
Is there any other setting I need to do?
As @isaactfa mentioned at the comment, I need to enable BOTH "ecdsa" and "keccak256" features:
k256 = { version = "0.11.3", features = ["ecdsa", "keccak256"] }