From d6bf04c9f81e20655e4aa58efc6bac9d5ce16ed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Leegwater=20Sim=C3=B5es?= Date: Sun, 7 Jul 2024 16:37:35 +0200 Subject: [PATCH] core: impl `Eq` for `TxSkeleton` and `StealthAddress` --- core/CHANGELOG.md | 5 +++++ core/src/keys/public.rs | 4 +--- core/src/keys/view.rs | 4 +--- core/src/note.rs | 4 +--- core/src/stealth_address.rs | 2 +- core/src/transaction.rs | 2 +- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index d32fa2b..4932db0 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- impl `Eq` for `StealthAddress` +- impl `Eq` for `TxSkeleton` + ## [0.30.0] - 2024-07-03 ### Added diff --git a/core/src/keys/public.rs b/core/src/keys/public.rs index ad0f19f..ac4ecd7 100644 --- a/core/src/keys/public.rs +++ b/core/src/keys/public.rs @@ -16,7 +16,7 @@ use dusk_jubjub::GENERATOR_EXTENDED; use subtle::{Choice, ConstantTimeEq}; /// Public pair of `a·G` and `b·G` defining a [`PublicKey`] -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, Eq)] #[cfg_attr( feature = "rkyv-impl", derive(Archive, Serialize, Deserialize), @@ -72,8 +72,6 @@ impl PartialEq for PublicKey { } } -impl Eq for PublicKey {} - impl From<&SecretKey> for PublicKey { fn from(sk: &SecretKey) -> Self { let A = GENERATOR_EXTENDED * sk.a(); diff --git a/core/src/keys/view.rs b/core/src/keys/view.rs index 1130e51..73f57d7 100644 --- a/core/src/keys/view.rs +++ b/core/src/keys/view.rs @@ -19,7 +19,7 @@ use rkyv::{Archive, Deserialize, Serialize}; /// /// The notes are encrypted against secret a, so this is used to decrypt the /// blinding factor and value -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Eq)] #[cfg_attr( feature = "rkyv-impl", derive(Archive, Serialize, Deserialize), @@ -43,8 +43,6 @@ impl PartialEq for ViewKey { } } -impl Eq for ViewKey {} - impl ViewKey { /// This method is used to construct a new `ViewKey` from the given /// pair of secret `a` and public `b·G`. diff --git a/core/src/note.rs b/core/src/note.rs index 7bbe6f5..181f52f 100644 --- a/core/src/note.rs +++ b/core/src/note.rs @@ -66,7 +66,7 @@ impl TryFrom for NoteType { } /// A note that does not encrypt its value -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Eq)] #[cfg_attr( feature = "rkyv-impl", derive(Archive, Serialize, Deserialize), @@ -89,8 +89,6 @@ impl PartialEq for Note { } } -impl Eq for Note {} - impl Note { /// Creates a new phoenix output note pub fn new( diff --git a/core/src/stealth_address.rs b/core/src/stealth_address.rs index d6e5479..e4a47a4 100644 --- a/core/src/stealth_address.rs +++ b/core/src/stealth_address.rs @@ -18,7 +18,7 @@ use rkyv::{Archive, Deserialize, Serialize}; /// system. /// A `StealthAddress` is composed by a one-time note-public-key (the actual /// address) and a random point `R`. -#[derive(Default, Debug, Clone, Copy)] +#[derive(Default, Debug, Clone, Copy, Eq)] #[cfg_attr( feature = "rkyv-impl", derive(Archive, Serialize, Deserialize), diff --git a/core/src/transaction.rs b/core/src/transaction.rs index ef7b32c..d37400d 100644 --- a/core/src/transaction.rs +++ b/core/src/transaction.rs @@ -19,7 +19,7 @@ use dusk_bytes::{DeserializableSlice, Error as BytesError, Serializable}; use crate::{Note, OUTPUT_NOTES}; /// A phoenix transaction, referred to as tx-skeleton in the specs. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] #[cfg_attr( feature = "rkyv-impl", derive(Archive, Serialize, Deserialize),