Make it possible to create random public keys

This is useful for tests.
This commit is contained in:
Thomas Eizinger 2021-03-24 18:19:58 +11:00
parent 3f56fe93e0
commit c539465925
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96

View File

@ -105,6 +105,13 @@ impl SecretKey {
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)]
pub struct PublicKey(Point);
impl PublicKey {
#[cfg(test)]
pub fn random() -> Self {
Self(Point::random(&mut rand::thread_rng()))
}
}
impl From<PublicKey> for Point {
fn from(from: PublicKey) -> Self {
from.0