pub struct PublicKey(/* private fields */);Expand description
Implementations§
Source§impl PublicKey
impl PublicKey
Sourcepub fn from_bytes(key: &[u8]) -> Result<PublicKey, EllipticCurveError>
pub fn from_bytes(key: &[u8]) -> Result<PublicKey, EllipticCurveError>
Parses a compressed (49-byte) or uncompressed (97-byte) SEC1 encoding.
Returns EllipticCurveError::InvalidKey when the encoding is not a
valid point on the P-384 curve.
Sourcepub fn from_x_y(
x_bytes: &[u8; 48],
y_bytes: &[u8; 48],
) -> Result<PublicKey, EllipticCurveError>
pub fn from_x_y( x_bytes: &[u8; 48], y_bytes: &[u8; 48], ) -> Result<PublicKey, EllipticCurveError>
Builds a public key from raw affine x and y coordinates (both
big-endian, 48 bytes each). Returns InvalidKey if the coordinates
are not a valid point on the P-384 curve.
This is useful when importing keys from formats like JWK where x
and y are available directly.
Sourcepub fn verify(
&self,
message: &[u8],
signature: &[u8; 96],
) -> Result<(), EllipticCurveError>
pub fn verify( &self, message: &[u8], signature: &[u8; 96], ) -> Result<(), EllipticCurveError>
Verifies an ECDSA signature over message using SHA-384.
Both canonical low-s and non-canonical high-s signatures are accepted,
matching typical ECDSA interoperability. Use Self::verify_strict to
additionally reject high-s signatures.
Sourcepub fn verify_strict(
&self,
message: &[u8],
signature: &[u8; 96],
) -> Result<(), EllipticCurveError>
pub fn verify_strict( &self, message: &[u8], signature: &[u8; 96], ) -> Result<(), EllipticCurveError>
Verifies an ECDSA signature over message using SHA-384, additionally
rejecting non-canonical high-s signatures (s > n / 2).
Use this when signature malleability must be excluded (Bitcoin/EIP-2
style). Note that some third-party signers emit high-s signatures, which
this method will reject; Self::verify accepts both forms.
Sourcepub fn to_bytes(&self) -> [u8; 97]
pub fn to_bytes(&self) -> [u8; 97]
Returns the 97-byte uncompressed SEC1 encoding (0x04 || x || y).
Sourcepub fn to_compressed_bytes(&self) -> [u8; 49]
pub fn to_compressed_bytes(&self) -> [u8; 49]
Returns the 49-byte compressed SEC1 encoding (0x02/0x03 || x).