aboutsummaryrefslogtreecommitdiff
path: root/src/account/public.rs
blob: c5d0aec49a875f95b9a54367f8d80b8f62231f0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Module implementing public key operations.

use k256::elliptic_curve::sec1::ToEncodedPoint as _;

/// A public key.
pub struct PublicKey(pub k256::PublicKey);

impl PublicKey {
    /// Returns an uncompressed encoded bytes for the public key.
    pub fn encode_uncompressed(&self) -> [u8; 65] {
        self.0
            .to_encoded_point(false)
            .as_bytes()
            .try_into()
            .expect("unexpected uncompressed private key length")
    }
}