diff --git a/src/key.rs b/src/key.rs index 779436f51..308b93ada 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,14 +883,15 @@ 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]; match from_hex(s, &mut res) { Ok(constants::SECRET_KEY_SIZE) => Keypair::from_seckey_slice(secp, &res[0..constants::SECRET_KEY_SIZE]), - _ => Err(Error::InvalidPublicKey), + _ => Err(Error::InvalidSecretKey), } } @@ -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 {