aboutsummaryrefslogtreecommitdiff
path: root/src/account/public.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/account/public.rs')
-rw-r--r--src/account/public.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/account/public.rs b/src/account/public.rs
new file mode 100644
index 0000000..c5d0aec
--- /dev/null
+++ b/src/account/public.rs
@@ -0,0 +1,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")
+ }
+}