Browse Source

serialize pubkey

main
kilic 8 months ago
parent
commit
0a81df83b0
1 changed files with 11 additions and 0 deletions
  1. +11
    -0
      src/eddsa.rs

+ 11
- 0
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<u8> {
let mut bytes = Vec::new();
self.serialize_compressed(&mut bytes).unwrap();
bytes
}
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Box<dyn ark_std::error::Error>> {
let point = Affine::<TE>::deserialize_compressed(bytes)?;
Ok(Self(point))
}
}
impl<TE: TECurveConfig> From<Affine<TE>> for PublicKey<TE> {

Loading…
Cancel
Save