bc_components/ec_key/ec_public_key_base.rs
1use crate::{ECKey, ECUncompressedPublicKey};
2
3/// A trait for elliptic curve public keys that can provide their uncompressed
4/// form.
5///
6/// This trait extends `ECKey` to provide a method for obtaining the
7/// uncompressed representation of a public key. Elliptic curve public keys can
8/// be represented in both compressed (33 bytes) and uncompressed (65 bytes)
9/// formats:
10///
11/// - Compressed format: Uses a single byte prefix (0x02 or 0x03) followed by
12/// the x-coordinate (32 bytes), with the prefix indicating the parity of the
13/// y-coordinate.
14///
15/// - Uncompressed format: Uses a byte prefix (0x04) followed by both x and y
16/// coordinates (32 bytes each), for a total of 65 bytes.
17///
18/// The compressed format is more space-efficient and is recommended for most
19/// applications, but some legacy systems require the uncompressed format.
20pub trait ECPublicKeyBase: ECKey {
21 /// Returns the uncompressed public key representation.
22 fn uncompressed_public_key(&self) -> ECUncompressedPublicKey;
23}