Add From implementations for cylinder and splinter PublicKeys
It is common to have to convert between the two, so this commit
adds From implementations to make it easier.
use std::cmp::Ordering;
+use cylinder;
+
/// Local representation of a public key
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PublicKey {
@@ -50,3 +52,15 @@ impl PartialOrd for PublicKey {
Some(self.cmp(other))
}
}
+
+impl From<cylinder::PublicKey> for PublicKey {
+ fn from(public_key: cylinder::PublicKey) -> Self {
+ PublicKey::from_bytes(public_key.into_bytes())
+ }
+}
+
+impl From<PublicKey> for cylinder::PublicKey {
+ fn from(public_key: PublicKey) -> Self {
+ cylinder::PublicKey::new(public_key.into_bytes())
+ }
+}
