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.
This commit is contained in:
Tobin C. Harding 2022-11-22 09:58:19 +11:00
parent 4a0c7fca6a
commit 19039d9281
1 changed files with 0 additions and 20 deletions

View File

@ -69,26 +69,6 @@ impl PartialEq for SecretKey {
impl Eq for SecretKey {} impl Eq for SecretKey {}
impl core::hash::Hash for SecretKey {
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
self[..].hash(state)
}
}
impl PartialOrd for SecretKey {
#[inline]
fn partial_cmp(&self, other: &SecretKey) -> Option<core::cmp::Ordering> {
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 { impl AsRef<[u8; constants::SECRET_KEY_SIZE]> for SecretKey {
/// Gets a reference to the underlying array /// Gets a reference to the underlying array
#[inline] #[inline]