Skip to content

Commit d1d4ff9

Browse files
committed
doc: Keypair constructors accept odd keys
Clarify the conditions for returning the InvalidSecretKey error. Fixes #758
1 parent e66bd11 commit d1d4ff9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/key.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -858,8 +858,8 @@ impl Keypair {
858858
///
859859
/// # Errors
860860
///
861-
/// [`Error::InvalidSecretKey`] if the provided data has an incorrect length, exceeds Secp256k1
862-
/// field `p` value or the corresponding public key is not even.
861+
/// [`Error::InvalidSecretKey`] if the slice is not exactly 32 bytes long,
862+
/// or if the encoded number exceeds the Secp256k1 field `p` value.
863863
#[inline]
864864
pub fn from_seckey_slice<C: Signing>(
865865
secp: &Secp256k1<C>,
@@ -883,7 +883,8 @@ impl Keypair {
883883
///
884884
/// # Errors
885885
///
886-
/// [`Error::InvalidSecretKey`] if corresponding public key for the provided secret key is not even.
886+
/// [`Error::InvalidSecretKey`] if the string does not consist of exactly 64 hex characters,
887+
/// or if the encoded number exceeds the Secp256k1 field `p` value.
887888
#[inline]
888889
pub fn from_seckey_str<C: Signing>(secp: &Secp256k1<C>, s: &str) -> Result<Keypair, Error> {
889890
let mut res = [0u8; constants::SECRET_KEY_SIZE];
@@ -898,7 +899,8 @@ impl Keypair {
898899
///
899900
/// # Errors
900901
///
901-
/// [`Error::InvalidSecretKey`] if corresponding public key for the provided secret key is not even.
902+
/// [`Error::InvalidSecretKey`] if the string does not consist of exactly 64 hex characters,
903+
/// or if the encoded number exceeds the Secp256k1 field `p` value.
902904
#[inline]
903905
#[cfg(feature = "global-context")]
904906
pub fn from_seckey_str_global(s: &str) -> Result<Keypair, Error> {

0 commit comments

Comments
 (0)