Skip to content

Commit 1889342

Browse files
committed
feat(key): make layout of {Keypair,XOnlyPublicKey,SecretKey} transparent
1 parent 049e07f commit 1889342

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/key/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ impl<'de> serde::Deserialize<'de> for PublicKey {
479479
/// ```
480480
/// [`bincode`]: https://docs.rs/bincode
481481
/// [`cbor`]: https://docs.rs/cbor
482+
#[repr(transparent)]
482483
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
483484
pub struct Keypair(ffi::Keypair);
484485
impl_fast_comparisons!(Keypair);
@@ -818,6 +819,7 @@ impl CPtr for Keypair {
818819
/// ```
819820
/// [`bincode`]: https://docs.rs/bincode
820821
/// [`cbor`]: https://docs.rs/cbor
822+
#[repr(transparent)]
821823
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
822824
pub struct XOnlyPublicKey(ffi::XOnlyPublicKey);
823825
impl_fast_comparisons!(XOnlyPublicKey);

src/key/secret.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ mod encapsulate {
4848
/// [`bincode`]: https://docs.rs/bincode
4949
/// [`cbor`]: https://docs.rs/cbor
5050
/// [cryptographically secure pseudorandom number generator]: https://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator
51+
#[repr(transparent)]
5152
#[derive(Copy, Clone)]
5253
pub struct SecretKey([u8; SECRET_KEY_SIZE]);
5354
// FIXME these two macro call should be moved outside of the encapsulate module

0 commit comments

Comments
 (0)