From d57fb6caebb03bb37da9980be689430969027009 Mon Sep 17 00:00:00 2001 From: Rui Morais Date: Tue, 25 Feb 2020 18:16:06 +0000 Subject: [PATCH 1/2] Derive of Hash trait to CompressedRistretto --- src/ristretto.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ristretto.rs b/src/ristretto.rs index c4b61700b..977f52f42 100644 --- a/src/ristretto.rs +++ b/src/ristretto.rs @@ -208,7 +208,7 @@ use backend::vector::scalar_mul; /// /// The Ristretto encoding is canonical, so two points are equal if and /// only if their encodings are equal. -#[derive(Copy, Clone, Eq, PartialEq)] +#[derive(Copy, Clone, Eq, PartialEq, Hash)] pub struct CompressedRistretto(pub [u8; 32]); impl ConstantTimeEq for CompressedRistretto { From 6a8e46606375a393332a2ceb2d3d4c2f17d3ce23 Mon Sep 17 00:00:00 2001 From: Rui Morais Date: Tue, 25 Feb 2020 22:39:19 +0000 Subject: [PATCH 2/2] add derive Hash to Scalar, MontgomeryPoint and CompressedEdwardsY --- src/edwards.rs | 2 +- src/montgomery.rs | 2 +- src/scalar.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/edwards.rs b/src/edwards.rs index 998af8dec..810bc20a3 100644 --- a/src/edwards.rs +++ b/src/edwards.rs @@ -150,7 +150,7 @@ use backend::vector::scalar_mul; /// /// The first 255 bits of a `CompressedEdwardsY` represent the /// \\(y\\)-coordinate. The high bit of the 32nd byte gives the sign of \\(x\\). -#[derive(Copy, Clone, Eq, PartialEq)] +#[derive(Copy, Clone, Eq, PartialEq, Hash)] pub struct CompressedEdwardsY(pub [u8; 32]); impl ConstantTimeEq for CompressedEdwardsY { diff --git a/src/montgomery.rs b/src/montgomery.rs index 4768451a6..c3676c2a5 100644 --- a/src/montgomery.rs +++ b/src/montgomery.rs @@ -65,7 +65,7 @@ use zeroize::Zeroize; /// Holds the \\(u\\)-coordinate of a point on the Montgomery form of /// Curve25519 or its twist. -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MontgomeryPoint(pub [u8; 32]); diff --git a/src/scalar.rs b/src/scalar.rs index d365d25f1..54da07ac8 100644 --- a/src/scalar.rs +++ b/src/scalar.rs @@ -182,7 +182,7 @@ type UnpackedScalar = backend::serial::u32::scalar::Scalar29; /// The `Scalar` struct holds an integer \\(s < 2\^{255} \\) which /// represents an element of \\(\mathbb Z / \ell\\). -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Hash)] pub struct Scalar { /// `bytes` is a little-endian byte encoding of an integer representing a scalar modulo the /// group order.