@@ -35,6 +35,12 @@ use crate::schnorr;
3535
3636/// Secret 256-bit key used as `x` in an ECDSA signature.
3737///
38+ /// # Serde support
39+ ///
40+ /// Implements de/serialization with the `serde` feature enabled. We treat the byte value as a tuple
41+ /// of 32 `u8`s for non-human-readable formats. This representation is optimal for for some formats
42+ /// (e.g. [`bincode`]) however other formats may be less optimal (e.g. [`cbor`]).
43+ ///
3844/// # Examples
3945///
4046/// Basic usage:
@@ -47,6 +53,8 @@ use crate::schnorr;
4753/// let secret_key = SecretKey::new(&mut rand::thread_rng());
4854/// # }
4955/// ```
56+ /// [`bincode`]: https://docs.rs/bincode
57+ /// [`cbor`]: https://docs.rs/cbor
5058pub struct SecretKey ( [ u8 ; constants:: SECRET_KEY_SIZE ] ) ;
5159impl_array_newtype ! ( SecretKey , u8 , constants:: SECRET_KEY_SIZE ) ;
5260impl_display_secret ! ( SecretKey ) ;
@@ -70,6 +78,12 @@ pub const ONE_KEY: SecretKey = SecretKey([0, 0, 0, 0, 0, 0, 0, 0,
7078
7179/// A Secp256k1 public key, used for verification of signatures.
7280///
81+ /// # Serde support
82+ ///
83+ /// Implements de/serialization with the `serde` feature enabled. We treat the byte value as a tuple
84+ /// of 33 `u8`s for non-human-readable formats. This representation is optimal for for some formats
85+ /// (e.g. [`bincode`]) however other formats may be less optimal (e.g. [`cbor`]).
86+ ///
7387/// # Examples
7488///
7589/// Basic usage:
@@ -83,6 +97,8 @@ pub const ONE_KEY: SecretKey = SecretKey([0, 0, 0, 0, 0, 0, 0, 0,
8397/// let public_key = PublicKey::from_secret_key(&secp, &secret_key);
8498/// # }
8599/// ```
100+ /// [`bincode`]: https://docs.rs/bincode
101+ /// [`cbor`]: https://docs.rs/cbor
86102#[ derive( Copy , Clone , PartialEq , Eq , Debug , Hash ) ]
87103#[ repr( transparent) ]
88104pub struct PublicKey ( ffi:: PublicKey ) ;
@@ -1029,6 +1045,12 @@ impl<'de> serde::Deserialize<'de> for KeyPair {
10291045
10301046/// An x-only public key, used for verification of Schnorr signatures and serialized according to BIP-340.
10311047///
1048+ /// # Serde support
1049+ ///
1050+ /// Implements de/serialization with the `serde` feature enabled. We treat the byte value as a tuple
1051+ /// of 32 `u8`s for non-human-readable formats. This representation is optimal for for some formats
1052+ /// (e.g. [`bincode`]) however other formats may be less optimal (e.g. [`cbor`]).
1053+ ///
10321054/// # Examples
10331055///
10341056/// Basic usage:
@@ -1042,6 +1064,8 @@ impl<'de> serde::Deserialize<'de> for KeyPair {
10421064/// let xonly = XOnlyPublicKey::from_keypair(&key_pair);
10431065/// # }
10441066/// ```
1067+ /// [`bincode`]: https://docs.rs/bincode
1068+ /// [`cbor`]: https://docs.rs/cbor
10451069#[ derive( Copy , Clone , PartialEq , Eq , Debug , PartialOrd , Ord , Hash ) ]
10461070pub struct XOnlyPublicKey ( ffi:: XOnlyPublicKey ) ;
10471071
0 commit comments