From d1d4ff9f01695526c01198dee643d273f0c32b9d Mon Sep 17 00:00:00 2001 From: Christian Lewe Date: Fri, 14 Feb 2025 21:55:44 +0100 Subject: [PATCH] doc: Keypair constructors accept odd keys Clarify the conditions for returning the InvalidSecretKey error. Fixes #758 --- src/key.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/key.rs b/src/key.rs index 779436f51..f050dc797 100644 --- a/src/key.rs +++ b/src/key.rs @@ -858,8 +858,8 @@ impl Keypair { /// /// # Errors /// - /// [`Error::InvalidSecretKey`] if the provided data has an incorrect length, exceeds Secp256k1 - /// field `p` value or the corresponding public key is not even. + /// [`Error::InvalidSecretKey`] if the slice is not exactly 32 bytes long, + /// or if the encoded number exceeds the Secp256k1 field `p` value. #[inline] pub fn from_seckey_slice( secp: &Secp256k1, @@ -883,7 +883,8 @@ impl Keypair { /// /// # Errors /// - /// [`Error::InvalidSecretKey`] if corresponding public key for the provided secret key is not even. + /// [`Error::InvalidSecretKey`] if the string does not consist of exactly 64 hex characters, + /// or if the encoded number exceeds the Secp256k1 field `p` value. #[inline] pub fn from_seckey_str(secp: &Secp256k1, s: &str) -> Result { let mut res = [0u8; constants::SECRET_KEY_SIZE]; @@ -898,7 +899,8 @@ impl Keypair { /// /// # Errors /// - /// [`Error::InvalidSecretKey`] if corresponding public key for the provided secret key is not even. + /// [`Error::InvalidSecretKey`] if the string does not consist of exactly 64 hex characters, + /// or if the encoded number exceeds the Secp256k1 field `p` value. #[inline] #[cfg(feature = "global-context")] pub fn from_seckey_str_global(s: &str) -> Result {