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.

Signed-off-by: Dan Norris <[email protected]>
  • Loading branch information
protochron committed Sep 19, 2024
1 parent 9a14513 commit 3e49a56
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ const PUBLIC_KEY_PREFIXES: [u8; 8] = [
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.
/// seeds and public keys.
#[derive(Clone)]
pub struct KeyPair {
kp_type: KeyPairType,
sk: Option<SecretKey>, //rawkey_kind: RawKeyKind,
Expand Down
3 changes: 2 additions & 1 deletion src/xkeys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ use crypto_box::{PublicKey, SecretKey};
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.
/// pairs.
#[derive(Clone)]
pub struct XKey {
public: PublicKey,
secret: Option<SecretKey>,
Expand Down

0 comments on commit 3e49a56

Please sign in to comment.