diff --git a/src/eddsa.rs b/src/eddsa.rs index e83f68b..253d2ab 100644 --- a/src/eddsa.rs +++ b/src/eddsa.rs @@ -51,6 +51,17 @@ impl PublicKey { pub fn xy(&self) -> (&TE::BaseField, &TE::BaseField) { self.as_ref().xy().unwrap() } + + pub fn to_bytes(&self) -> Vec { + let mut bytes = Vec::new(); + self.serialize_compressed(&mut bytes).unwrap(); + bytes + } + + pub fn from_bytes(bytes: &[u8]) -> Result> { + let point = Affine::::deserialize_compressed(bytes)?; + Ok(Self(point)) + } } impl From> for PublicKey {