From 2ff8175c4d5a26162a735e0c1252b6afcf66a13d Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Mon, 21 Sep 2020 11:36:13 -0700 Subject: [PATCH] k256: improve documentation for `sha256` feature (#197) --- k256/src/ecdsa.rs | 16 +++++++++++++++- k256/src/ecdsa/sign.rs | 4 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/k256/src/ecdsa.rs b/k256/src/ecdsa.rs index 88eb6a49..479c5cac 100644 --- a/k256/src/ecdsa.rs +++ b/k256/src/ecdsa.rs @@ -14,9 +14,23 @@ //! [`VerifyKey`] types which natively implement ECDSA/secp256k1 signing and //! verification. //! +//! Additionally, this crate contains support for computing ECDSA signatures +//! using either the SHA-256 (standard) or Keccak-256 (Ethereum) digest +//! functions, which are gated under the following Cargo features: +//! +//! - `sha256`: compute signatures using NIST's standard SHA-256 digest +//! function. Unless you are computing signatures for Ethereum, this is +//! almost certainly what you want. +//! - `keccak256`: compute signatures using the Keccak-256 digest function, +//! an incompatible variant of the SHA-3 algorithm used exclusively by +//! Ethereum. +//! +//! Most users of this library who want to sign/verify signatures will want to +//! enable the `ecdsa` and `sha256` Cargo features. +//! //! ## Signing/Verification Example //! -//! This example requires the `ecdsa` Cargo feature is enabled: +//! This example requires the `ecdsa` and `sha256` Cargo features are enabled: //! //! ``` //! # #[cfg(feature = "ecdsa")] diff --git a/k256/src/ecdsa/sign.rs b/k256/src/ecdsa/sign.rs index 351129b9..d52f5bcd 100644 --- a/k256/src/ecdsa/sign.rs +++ b/k256/src/ecdsa/sign.rs @@ -66,7 +66,7 @@ impl From<&SecretKey> for SigningKey { } } -#[cfg(feature = "sha256")] +#[cfg(any(feature = "keccak256", feature = "sha256"))] impl signature::Signer for SigningKey where S: PrehashSignature, @@ -77,7 +77,7 @@ where } } -#[cfg(feature = "sha256")] +#[cfg(any(feature = "keccak256", feature = "sha256"))] impl RandomizedSigner for SigningKey where S: PrehashSignature,