Skip to content

Commit

Permalink
feat: derive Clone for KeyPair and XKey
Browse files Browse the repository at this point in the history
Allow KeyPair and XKey structs to be cloned. We have no technical reason
not to do this, since it is trivial to copy out a private key from
either key type and the underlying members of the struct are all already
Clone.
  • Loading branch information
protochron committed Sep 19, 2024
1 parent 9a14513 commit 9909938
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ type Result<T> = std::result::Result<T, crate::error::Error>;

/// The main interface used for reading and writing _nkey-encoded_ key pairs, including
/// seeds and public keys. Instances of this type cannot be cloned.
#[derive(Clone)]
pub struct KeyPair {
kp_type: KeyPairType,
sk: Option<SecretKey>, //rawkey_kind: RawKeyKind,
Expand Down
1 change: 1 addition & 0 deletions src/xkeys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use rand::{CryptoRng, Rng, RngCore};

/// The main interface used for reading and writing _nkey-encoded_ curve key
/// pairs. Instances of this type cannot be cloned.
#[derive(Clone)]
pub struct XKey {
public: PublicKey,
secret: Option<SecretKey>,
Expand Down

0 comments on commit 9909938

Please sign in to comment.