Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
Implement Ord and PartialOrd for secret key type
Dr Maxim Orlovsky committed 3 years ago
commit ee17f352185f40e43874faece5a0e22c95a8d839
parent 2a6f3c4f556ed25008889587f621bff86711a70d
1 file changed +13 -0
modified radicle-crypto/src/lib.rs
@@ -1,3 +1,4 @@
+
use std::cmp::Ordering;
use std::{fmt, ops::Deref, str::FromStr};

use ed25519_compact as ed25519;
@@ -156,6 +157,18 @@ impl PublicKey {
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct SecretKey(ed25519::SecretKey);

+
impl PartialOrd for SecretKey {
+
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
+
        Some(self.cmp(other))
+
    }
+
}
+

+
impl Ord for SecretKey {
+
    fn cmp(&self, other: &Self) -> Ordering {
+
        self.0.cmp(&other.0)
+
    }
+
}
+

impl zeroize::Zeroize for SecretKey {
    fn zeroize(&mut self) {
        self.0.zeroize();