From c4cd541e6c9ca657fa33fdd686d70d81bf3e4e65 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sat, 12 Feb 2022 02:04:52 +0000 Subject: [PATCH] Add `Clone` impls to various structs This enables `InProgress: Clone`, which allows the bundle returned by `Builder::build` to be cloned. In pure-Rust wallets this should not be necessary, but it is required for `zcashd` due to FFI-crossing. --- src/builder.rs | 10 +++++----- src/circuit.rs | 2 +- src/keys.rs | 2 +- src/note/commitment.rs | 2 +- src/primitives/redpallas.rs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index 37a2768c..54b9a1ef 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -367,7 +367,7 @@ pub trait InProgressSignatures { } /// Marker for a bundle in the process of being built. -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct InProgress { proof: P, sigs: S, @@ -380,7 +380,7 @@ impl Authorization for InProgress { /// Marker for a bundle without a proof. /// /// This struct contains the private data needed to create a [`Proof`] for a [`Bundle`]. -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct Unproven { circuits: Vec, } @@ -419,7 +419,7 @@ impl Bundle, V> { } /// The parts needed to sign an [`Action`]. -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct SigningParts { /// The spend validating key for this action. Used to match spend authorizing keys to /// actions they can create signatures for. @@ -429,7 +429,7 @@ pub struct SigningParts { } /// Marker for an unauthorized bundle with no signatures. -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct Unauthorized { bsk: redpallas::SigningKey, } @@ -439,7 +439,7 @@ impl InProgressSignatures for Unauthorized { } /// Container for metadata needed to sign an [`Action`]. -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct SigningMetadata { /// If this action is spending a dummy note, this field holds that note's spend /// authorizing key. diff --git a/src/circuit.rs b/src/circuit.rs index 594a49f2..5d201a2f 100644 --- a/src/circuit.rs +++ b/src/circuit.rs @@ -96,7 +96,7 @@ pub struct Config { } /// The Orchard Action circuit. -#[derive(Debug, Default)] +#[derive(Clone, Debug, Default)] pub struct Circuit { pub(crate) path: Option<[MerkleHashOrchard; MERKLE_DEPTH_ORCHARD]>, pub(crate) pos: Option, diff --git a/src/keys.rs b/src/keys.rs index 2f4a9521..636d0332 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -101,7 +101,7 @@ impl SpendingKey { /// Defined in [Zcash Protocol Spec ยง 4.2.3: Orchard Key Components][orchardkeycomponents]. /// /// [orchardkeycomponents]: https://zips.z.cash/protocol/nu5.pdf#orchardkeycomponents -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct SpendAuthorizingKey(redpallas::SigningKey); impl SpendAuthorizingKey { diff --git a/src/note/commitment.rs b/src/note/commitment.rs index d3a7dff8..e27f8236 100644 --- a/src/note/commitment.rs +++ b/src/note/commitment.rs @@ -12,7 +12,7 @@ use crate::{ value::NoteValue, }; -#[derive(Debug)] +#[derive(Clone, Debug)] pub(crate) struct NoteCommitTrapdoor(pub(super) pallas::Scalar); impl NoteCommitTrapdoor { diff --git a/src/primitives/redpallas.rs b/src/primitives/redpallas.rs index 7314dfdd..cbdae803 100644 --- a/src/primitives/redpallas.rs +++ b/src/primitives/redpallas.rs @@ -23,7 +23,7 @@ pub type Binding = reddsa::orchard::Binding; impl SigType for Binding {} /// A RedPallas signing key. -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct SigningKey(reddsa::SigningKey); impl From> for [u8; 32] {