From 9909938511f1b2755628913e5275a64dfdcd9157 Mon Sep 17 00:00:00 2001 From: Dan Norris Date: Thu, 19 Sep 2024 15:43:46 -0400 Subject: [PATCH] feat: derive Clone for KeyPair and XKey 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. --- src/lib.rs | 1 + src/xkeys.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 02b80c5..16c7ebc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -88,6 +88,7 @@ type Result = std::result::Result; /// 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, //rawkey_kind: RawKeyKind, diff --git a/src/xkeys.rs b/src/xkeys.rs index 8c9b370..8cfd874 100644 --- a/src/xkeys.rs +++ b/src/xkeys.rs @@ -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,