pub struct PublicKey(/* private fields */);Expand description
A 65-byte uncompressed P-256 public key: 0x04 || X(32) || Y(32).
Implementations§
Source§impl PublicKey
impl PublicKey
Sourcepub fn new(bytes: [u8; 65]) -> Result<Self>
pub fn new(bytes: [u8; 65]) -> Result<Self>
Construct from raw bytes. Validates the 0x04 uncompressed-point
prefix; rejects compressed or hybrid encodings.
§Errors
Returns Error::BadPublicKeyPrefix if bytes[0] != 0x04.
Sourcepub fn from_slice(slice: &[u8]) -> Result<Self>
pub fn from_slice(slice: &[u8]) -> Result<Self>
Construct from a byte slice. Rejects wrong-length input.
§Errors
Returns Error::WrongPublicKeyLength if slice.len() != 65,
or Error::BadPublicKeyPrefix if the first byte is not 0x04.
Sourcepub fn verify(&self, message: &[u8], signature: &Signature) -> Result<()>
pub fn verify(&self, message: &[u8], signature: &Signature) -> Result<()>
Verify an ECDSA-P256-SHA256 signature against a message.
The signature is the 64-byte raw r || s form; ring’s
ECDSA_P256_SHA256_FIXED algorithm consumes exactly this layout
and computes the SHA-256 hash internally.
§Errors
Returns Error::SignatureVerificationFailed if the signature
is not a valid signature over message by the private key
corresponding to this public key. The error variant does NOT
distinguish between malformed signatures, wrong-key signatures,
and signatures over different messages — ring deliberately
keeps this opaque to avoid side-channel leaks.