Skip to content

Commit

Permalink
doc: Keypair constructors accept odd keys
Browse files Browse the repository at this point in the history
Clarify the conditions for returning the InvalidSecretKey error.

Fixes #758
  • Loading branch information
uncomputable committed Feb 14, 2025
1 parent e66bd11 commit d1d4ff9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<C: Signing>(
secp: &Secp256k1<C>,
Expand All @@ -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<C: Signing>(secp: &Secp256k1<C>, s: &str) -> Result<Keypair, Error> {
let mut res = [0u8; constants::SECRET_KEY_SIZE];
Expand All @@ -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<Keypair, Error> {
Expand Down

0 comments on commit d1d4ff9

Please sign in to comment.