@@ -64,7 +64,7 @@ pub const ONE_KEY: SecretKey = SecretKey([0, 0, 0, 0, 0, 0, 0, 0,
6464 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 ] ) ;
6565
6666/// A Secp256k1 public key, used for verification of signatures
67- #[ derive( Copy , Clone , PartialEq , Eq , Debug , PartialOrd , Ord , Hash ) ]
67+ #[ derive( Copy , Clone , PartialEq , Eq , Debug , Hash ) ]
6868pub struct PublicKey ( ffi:: PublicKey ) ;
6969
7070impl fmt:: LowerHex for PublicKey {
@@ -470,6 +470,18 @@ impl<'de> ::serde::Deserialize<'de> for PublicKey {
470470 }
471471}
472472
473+ impl PartialOrd for PublicKey {
474+ fn partial_cmp ( & self , other : & PublicKey ) -> Option < :: core:: cmp:: Ordering > {
475+ self . serialize ( ) . partial_cmp ( & other. serialize ( ) )
476+ }
477+ }
478+
479+ impl Ord for PublicKey {
480+ fn cmp ( & self , other : & PublicKey ) -> :: core:: cmp:: Ordering {
481+ self . serialize ( ) . cmp ( & other. serialize ( ) )
482+ }
483+ }
484+
473485#[ cfg( test) ]
474486mod test {
475487 use Secp256k1 ;
@@ -860,10 +872,10 @@ mod test {
860872 assert ! ( !( pk2 < pk1) ) ;
861873 assert ! ( !( pk1 < pk2) ) ;
862874
863- assert ! ( pk3 < pk1) ;
864- assert ! ( pk1 > pk3) ;
865- assert ! ( pk3 < = pk1) ;
866- assert ! ( pk1 > = pk3) ;
875+ assert ! ( pk3 > pk1) ;
876+ assert ! ( pk1 < pk3) ;
877+ assert ! ( pk3 > = pk1) ;
878+ assert ! ( pk1 < = pk3) ;
867879 }
868880
869881 #[ cfg( feature = "serde" ) ]
0 commit comments