crypto/keypair: Add methods to get x and y from PublicKey.

This commit is contained in:
parazyd
2022-07-28 16:03:13 +02:00
parent 651085cf90
commit 4d5e6fef10

View File

@@ -2,9 +2,10 @@ use std::{convert::TryFrom, io, str::FromStr};
use halo2_gadgets::ecc::chip::FixedPoint;
use pasta_curves::{
arithmetic::CurveAffine,
group::{
ff::{Field, PrimeField},
Group, GroupEncoding,
Curve, Group, GroupEncoding,
},
pallas,
};
@@ -82,6 +83,14 @@ impl PublicKey {
None => Err(Error::PublicKeyFromBytes),
}
}
pub fn x(&self) -> pallas::Base {
*self.0.to_affine().coordinates().unwrap().x()
}
pub fn y(&self) -> pallas::Base {
*self.0.to_affine().coordinates().unwrap().y()
}
}
impl FromStr for PublicKey {