Skip to content

Commit 19039d9

Browse files
committed
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.
1 parent 4a0c7fc commit 19039d9

File tree

1 file changed

+0
-20
lines changed

1 file changed

+0
-20
lines changed

src/key.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,6 @@ impl PartialEq for SecretKey {
6969

7070
impl Eq for SecretKey {}
7171

72-
impl core::hash::Hash for SecretKey {
73-
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
74-
self[..].hash(state)
75-
}
76-
}
77-
78-
impl PartialOrd for SecretKey {
79-
#[inline]
80-
fn partial_cmp(&self, other: &SecretKey) -> Option<core::cmp::Ordering> {
81-
self[..].partial_cmp(&other[..])
82-
}
83-
}
84-
85-
impl Ord for SecretKey {
86-
#[inline]
87-
fn cmp(&self, other: &SecretKey) -> core::cmp::Ordering {
88-
self[..].cmp(&other[..])
89-
}
90-
}
91-
9272
impl AsRef<[u8; constants::SECRET_KEY_SIZE]> for SecretKey {
9373
/// Gets a reference to the underlying array
9474
#[inline]

0 commit comments

Comments
 (0)