pub struct PrivateKey<C: Curve> { /* private fields */ }Expand description
An ECDSA private key over the given curve.
Implementations§
Source§impl<C: Curve> PrivateKey<C>
impl<C: Curve> PrivateKey<C>
Sourcepub fn from_big_endian(scalar: &[u8]) -> Option<Self>
pub fn from_big_endian(scalar: &[u8]) -> Option<Self>
Parse a PrivateKey from a zero-padded, big-endian representation of the secret scalar.
Sourcepub fn to_big_endian(&self) -> Buffer
pub fn to_big_endian(&self) -> Buffer
Return the private key as zero-padded, big-endian bytes.
Sourcepub fn from_der_ec_private_key(der: &[u8]) -> Option<Self>
pub fn from_der_ec_private_key(der: &[u8]) -> Option<Self>
Parse an ECPrivateKey structure (from RFC 5915). The key must be on the specified curve.
Sourcepub fn to_der_ec_private_key(&self) -> Buffer
pub fn to_der_ec_private_key(&self) -> Buffer
Serialize this private key as an ECPrivateKey structure (from RFC 5915).
Sourcepub fn from_der_private_key_info(der: &[u8]) -> Option<Self>
pub fn from_der_private_key_info(der: &[u8]) -> Option<Self>
Parse a PrivateKeyInfo structure (from RFC 5208), commonly called “PKCS#8 format”. The key must be on the specified curve.
Sourcepub fn to_der_private_key_info(&self) -> Buffer
pub fn to_der_private_key_info(&self) -> Buffer
Serialize this private key as a PrivateKeyInfo structure (from RFC 5208), commonly called “PKCS#8 format”.
Sourcepub fn to_x962_uncompressed(&self) -> Buffer
pub fn to_x962_uncompressed(&self) -> Buffer
Serialize the public part of this key in uncompressed X9.62 format.
Sourcepub fn to_x962_compressed(&self) -> Buffer
pub fn to_x962_compressed(&self) -> Buffer
Serialize the public part of this key in compressed X9.62 format.
WARNING: compressed form is rarely used and is not as well supported as the uncompressed form.
Sourcepub fn to_der_subject_public_key_info(&self) -> Buffer
pub fn to_der_subject_public_key_info(&self) -> Buffer
Serialize this key in SubjectPublicKeyInfo format.
Sourcepub fn to_public_key(&self) -> PublicKey<C>
pub fn to_public_key(&self) -> PublicKey<C>
Return the public key corresponding to this private key.
Sourcepub fn sign(&self, to_be_signed: &[u8]) -> Vec<u8>
pub fn sign(&self, to_be_signed: &[u8]) -> Vec<u8>
Sign a digest of to_be_signed using this key and return the
ASN.1-based signature. SHA-256 will be used to produce the digest if the
curve of this public key is P-256. SHA-384 will be used to produce the
digest if the curve of this public key is P-384.
Sourcepub fn sign_p1363(&self, to_be_signed: &[u8]) -> Vec<u8>
pub fn sign_p1363(&self, to_be_signed: &[u8]) -> Vec<u8>
Sign a digest of to_be_signed using this key and return the
P1363-based signature. SHA-256 will be used to produce the digest if
the curve of this public key is P-256. SHA-384 will be used to produce
the digest if the curve of this public key is P-384.