@@ -35,6 +35,12 @@ use crate::schnorr;
35
35
36
36
/// Secret 256-bit key used as `x` in an ECDSA signature.
37
37
///
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
+ ///
38
44
/// # Examples
39
45
///
40
46
/// Basic usage:
@@ -47,6 +53,8 @@ use crate::schnorr;
47
53
/// let secret_key = SecretKey::new(&mut rand::thread_rng());
48
54
/// # }
49
55
/// ```
56
+ /// [`bincode`]: https://docs.rs/bincode
57
+ /// [`cbor`]: https://docs.rs/cbor
50
58
pub struct SecretKey ( [ u8 ; constants:: SECRET_KEY_SIZE ] ) ;
51
59
impl_array_newtype ! ( SecretKey , u8 , constants:: SECRET_KEY_SIZE ) ;
52
60
impl_display_secret ! ( SecretKey ) ;
@@ -70,6 +78,12 @@ pub const ONE_KEY: SecretKey = SecretKey([0, 0, 0, 0, 0, 0, 0, 0,
70
78
71
79
/// A Secp256k1 public key, used for verification of signatures.
72
80
///
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
+ ///
73
87
/// # Examples
74
88
///
75
89
/// Basic usage:
@@ -83,6 +97,8 @@ pub const ONE_KEY: SecretKey = SecretKey([0, 0, 0, 0, 0, 0, 0, 0,
83
97
/// let public_key = PublicKey::from_secret_key(&secp, &secret_key);
84
98
/// # }
85
99
/// ```
100
+ /// [`bincode`]: https://docs.rs/bincode
101
+ /// [`cbor`]: https://docs.rs/cbor
86
102
#[ derive( Copy , Clone , PartialEq , Eq , Debug , Hash ) ]
87
103
#[ repr( transparent) ]
88
104
pub struct PublicKey ( ffi:: PublicKey ) ;
@@ -1029,6 +1045,12 @@ impl<'de> serde::Deserialize<'de> for KeyPair {
1029
1045
1030
1046
/// An x-only public key, used for verification of Schnorr signatures and serialized according to BIP-340.
1031
1047
///
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
+ ///
1032
1054
/// # Examples
1033
1055
///
1034
1056
/// Basic usage:
@@ -1042,6 +1064,8 @@ impl<'de> serde::Deserialize<'de> for KeyPair {
1042
1064
/// let xonly = XOnlyPublicKey::from_keypair(&key_pair);
1043
1065
/// # }
1044
1066
/// ```
1067
+ /// [`bincode`]: https://docs.rs/bincode
1068
+ /// [`cbor`]: https://docs.rs/cbor
1045
1069
#[ derive( Copy , Clone , PartialEq , Eq , Debug , PartialOrd , Ord , Hash ) ]
1046
1070
pub struct XOnlyPublicKey ( ffi:: XOnlyPublicKey ) ;
1047
1071
0 commit comments