Skip to content

Commit c28808c

Browse files
committed
Improve rustdocs for KeyPair
Currently the rustdocs for `KeyPair` are stale in regards to serde, we _do_ implement `Serialize` and `Deserialize` for `KeyPair`. Improve the rustdocs for `KeyPair` by removing stale docs and adding docs on fixed width binary serialization.
1 parent 6842383 commit c28808c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/key.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -715,13 +715,10 @@ impl Ord for PublicKey {
715715
///
716716
/// # Serde support
717717
///
718-
/// [`Serialize`] and [`Deserialize`] are not implemented for this type, even with the `serde`
719-
/// feature active. This is due to security considerations, see the [`serde_keypair`] documentation
720-
/// for details.
721-
///
722-
/// If the `serde` and `global-context` features are active `KeyPair`s can be serialized and
723-
/// deserialized by annotating them with `#[serde(with = "secp256k1::serde_keypair")]`
724-
/// inside structs or enums for which [`Serialize`] and [`Deserialize`] are being derived.
718+
/// Implements de/serialization with the `serde` and_`global-context` features enabled. Serializes
719+
/// the secret bytes only. We treat the byte value as a tuple of 32 `u8`s for non-human-readable
720+
/// formats. This representation is optimal for for some formats (e.g. [`bincode`]) however other
721+
/// formats may be less optimal (e.g. [`cbor`]). For human-readable formats we use a hex string.
725722
///
726723
/// # Examples
727724
///
@@ -736,8 +733,8 @@ impl Ord for PublicKey {
736733
/// let key_pair = KeyPair::from_secret_key(&secp, &secret_key);
737734
/// # }
738735
/// ```
739-
/// [`Deserialize`]: serde::Deserialize
740-
/// [`Serialize`]: serde::Serialize
736+
/// [`bincode`]: https://docs.rs/bincode
737+
/// [`cbor`]: https://docs.rs/cbor
741738
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
742739
pub struct KeyPair(ffi::KeyPair);
743740
impl_display_secret!(KeyPair);

0 commit comments

Comments
 (0)