use std::cmp::Ordering;
use cylinder;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PublicKey {
bytes: Vec<u8>,
}
impl PublicKey {
pub fn from_bytes(bytes: Vec<u8>) -> Self {
PublicKey { bytes }
}
pub fn into_bytes(self) -> Vec<u8> {
self.bytes
}
pub fn as_slice(&self) -> &[u8] {
&self.bytes
}
}
impl Ord for PublicKey {
fn cmp(&self, other: &Self) -> Ordering {
self.bytes.cmp(&other.bytes)
}
}
impl PartialOrd for PublicKey {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
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())
}
}