From 3ed967bcf84b18e14747efd3a516e10cc945a21b Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Mon, 31 Aug 2020 13:05:09 -0700 Subject: [PATCH] deps: use x25519-dalek's new PartialEq, Eq methods --- Cargo.lock | 4 ++-- zebra-chain/Cargo.toml | 2 +- zebra-chain/src/sprout/address.rs | 2 +- zebra-chain/src/sprout/joinsplit.rs | 21 +-------------------- zebra-chain/src/sprout/note/mac.rs | 2 +- 5 files changed, 6 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b479fc90..1f527168 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3050,9 +3050,9 @@ dependencies = [ [[package]] name = "x25519-dalek" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00ffb05621d7d051df0f020edf3e5db20797a4e522bf1f9c5dfa20603f1c85f6" +checksum = "bc614d95359fd7afc321b66d2107ede58b246b844cf5d8a0adcca413e439f088" dependencies = [ "curve25519-dalek", "rand_core 0.5.1", diff --git a/zebra-chain/Cargo.toml b/zebra-chain/Cargo.toml index ef4754c6..9347b34b 100644 --- a/zebra-chain/Cargo.toml +++ b/zebra-chain/Cargo.toml @@ -27,7 +27,7 @@ serde = { version = "1", features = ["serde_derive", "rc"] } serde-big-array = "0.3.0" sha2 = { version = "0.9.1", features=["compress"] } thiserror = "1" -x25519-dalek = { version = "1", features = ["serde"] } +x25519-dalek = { version = "1.1", features = ["serde"] } # ZF deps displaydoc = "0.1.7" diff --git a/zebra-chain/src/sprout/address.rs b/zebra-chain/src/sprout/address.rs index ccdf2653..73c074cb 100644 --- a/zebra-chain/src/sprout/address.rs +++ b/zebra-chain/src/sprout/address.rs @@ -34,7 +34,7 @@ impl fmt::Debug for SproutShieldedAddress { f.debug_struct("SproutShieldedAddress") .field("network", &self.network) .field("paying_key", &self.paying_key) - // Because x25519_dalek::PublicKey doesn't impl Debug. + // Use hex formatting for the transmission key. .field( "transmission_key", &hex::encode(&self.transmission_key.as_bytes()), diff --git a/zebra-chain/src/sprout/joinsplit.rs b/zebra-chain/src/sprout/joinsplit.rs index 21cb82ba..de64e760 100644 --- a/zebra-chain/src/sprout/joinsplit.rs +++ b/zebra-chain/src/sprout/joinsplit.rs @@ -16,7 +16,7 @@ use super::{commitment, note, tree}; /// A _JoinSplit Description_, as described in [protocol specification §7.2][ps]. /// /// [ps]: https://zips.z.cash/protocol/protocol.pdf#joinsplitencoding -#[derive(Clone, Debug, Serialize, Deserialize)] +#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)] pub struct JoinSplit { /// A value that the JoinSplit transfer removes from the transparent value /// pool. @@ -49,25 +49,6 @@ pub struct JoinSplit { pub enc_ciphertexts: [note::EncryptedNote; 2], } -// Because x25519_dalek::PublicKey does not impl PartialEq -impl PartialEq for JoinSplit

{ - fn eq(&self, other: &Self) -> bool { - self.vpub_old == other.vpub_old - && self.vpub_new == other.vpub_new - && self.anchor == other.anchor - && self.nullifiers == other.nullifiers - && self.commitments == other.commitments - && self.ephemeral_key.as_bytes() == other.ephemeral_key.as_bytes() - && self.random_seed == other.random_seed - && self.vmacs == other.vmacs - && self.zkproof == other.zkproof - && self.enc_ciphertexts == other.enc_ciphertexts - } -} - -// Because x25519_dalek::PublicKey does not impl Eq -impl Eq for JoinSplit

{} - impl ZcashSerialize for JoinSplit

{ fn zcash_serialize(&self, mut writer: W) -> Result<(), io::Error> { writer.write_u64::(self.vpub_old.into())?; diff --git a/zebra-chain/src/sprout/note/mac.rs b/zebra-chain/src/sprout/note/mac.rs index 20474465..4c5bc3c9 100644 --- a/zebra-chain/src/sprout/note/mac.rs +++ b/zebra-chain/src/sprout/note/mac.rs @@ -5,7 +5,7 @@ use std::io::{self, Read}; /// /// binding h_sig to each a_sk of the JoinSplit description, computed as /// described in § 4.10 ‘Non-malleability (Sprout)’ on p. 37 -#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)] +#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)] #[cfg_attr(test, derive(proptest_derive::Arbitrary))] pub struct MAC([u8; 32]);