From 19039d92813d2b1b720ea920e06957df3a3f10b1 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Tue, 22 Nov 2022 09:58:19 +1100 Subject: [PATCH] Remove `Ord`/`Hash` traits from SecretKey The current trait implementations of `Ord` and `PartialOrd` for `SecretKey` leak data when doing the comparison i.e., they are not constant time. Since there is no real usecase for ordering secret keys remove the trait implementations all together. Remove `Hash` at the same time because it does not make sense to implement it if `Ord`/`PartialOrd` are not implemented. --- src/key.rs | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/key.rs b/src/key.rs index d480e00..9bbf8c7 100644 --- a/src/key.rs +++ b/src/key.rs @@ -69,26 +69,6 @@ impl PartialEq for SecretKey { impl Eq for SecretKey {} -impl core::hash::Hash for SecretKey { - fn hash(&self, state: &mut H) { - self[..].hash(state) - } -} - -impl PartialOrd for SecretKey { - #[inline] - fn partial_cmp(&self, other: &SecretKey) -> Option { - self[..].partial_cmp(&other[..]) - } -} - -impl Ord for SecretKey { - #[inline] - fn cmp(&self, other: &SecretKey) -> core::cmp::Ordering { - self[..].cmp(&other[..]) - } -} - impl AsRef<[u8; constants::SECRET_KEY_SIZE]> for SecretKey { /// Gets a reference to the underlying array #[inline]