pub struct PublicKey { /* private fields */ }Expand description
P-224 (secp224r1) ECDSA public key.
Supports signature verification and ECDH key agreement. Both compressed
(29-byte) and uncompressed (57-byte) SEC1 encodings are accepted on input;
use to_bytes to export uncompressed, and
to_compressed_bytes to export compressed.
§Verification
ⓘ
use crypto::p224::SecretKey;
let key = SecretKey::generate().unwrap();
let signature = key.sign(b"message").unwrap();
assert!(key.public_key().verify(b"message", &signature).is_ok());Implementations§
Source§impl PublicKey
impl PublicKey
pub fn from_bytes(key: &[u8]) -> Result<PublicKey, EllipticCurveError>
Sourcepub fn from_x_y(
x_bytes: &[u8; 28],
y_bytes: &[u8; 28],
) -> Result<PublicKey, EllipticCurveError>
pub fn from_x_y( x_bytes: &[u8; 28], y_bytes: &[u8; 28], ) -> Result<PublicKey, EllipticCurveError>
Build a public key from raw affine x and y coordinates (both
big-endian, 28 bytes each). Returns InvalidKey if the coordinates
are not a valid point on the P-224 curve.
This is useful when importing keys from formats like JWK where x
and y are available directly.
pub fn verify( &self, message: &[u8], signature: &[u8; 56], ) -> Result<(), EllipticCurveError>
pub fn to_bytes(&self) -> [u8; 57]
Sourcepub fn to_compressed_bytes(&self) -> [u8; 29]
pub fn to_compressed_bytes(&self) -> [u8; 29]
Returns the 29-byte compressed SEC1 encoding (0x02/0x03 || x).
§Errors
A valid PublicKey always has a compressed encoding, so this never
returns Err; the Result mirrors the other fallible key operations.
Trait Implementations§
impl Copy for PublicKey
impl Eq for PublicKey
impl StructuralPartialEq for PublicKey
Auto Trait Implementations§
impl Freeze for PublicKey
impl RefUnwindSafe for PublicKey
impl Send for PublicKey
impl Sync for PublicKey
impl Unpin for PublicKey
impl UnsafeUnpin for PublicKey
impl UnwindSafe for PublicKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more