pub struct SecretKey {
pub bytes: Vec<u8>,
}Expand description
Secret key on a short Weierstrass curve: a scalar in [1, n-1]
encoded as felem_bytes big-endian octets (per the curve’s SEC1
octet length).
Shared between ECDSA and ECDH on the same curve.
Fields§
§bytes: Vec<u8>Big-endian encoding of the secret scalar d.
Implementations§
Source§impl SecretKey
impl SecretKey
Sourcepub fn to_sec1_der(
&self,
curve: EcCurve,
public_key: Option<&EcPublicKey>,
) -> Vec<u8> ⓘ
pub fn to_sec1_der( &self, curve: EcCurve, public_key: Option<&EcPublicKey>, ) -> Vec<u8> ⓘ
Encode as SEC1 DER (RFC 5915: ECPrivateKey).
Sourcepub fn from_sec1_der(der: &[u8]) -> Option<(Self, EcCurve, Option<EcPublicKey>)>
pub fn from_sec1_der(der: &[u8]) -> Option<(Self, EcCurve, Option<EcPublicKey>)>
Parse from SEC1 DER. Returns (secret_key, curve, optional_public_key).
Sourcepub fn to_pkcs8_der(
&self,
curve: EcCurve,
public_key: Option<&EcPublicKey>,
) -> Vec<u8> ⓘ
pub fn to_pkcs8_der( &self, curve: EcCurve, public_key: Option<&EcPublicKey>, ) -> Vec<u8> ⓘ
Encode as PKCS#8 DER (RFC 5958).
Sourcepub fn to_sec1_pem(
&self,
curve: EcCurve,
public_key: Option<&EcPublicKey>,
) -> String
pub fn to_sec1_pem( &self, curve: EcCurve, public_key: Option<&EcPublicKey>, ) -> String
Encode as SEC1 PEM.
Sourcepub fn to_pkcs8_pem(
&self,
curve: EcCurve,
public_key: Option<&EcPublicKey>,
) -> String
pub fn to_pkcs8_pem( &self, curve: EcCurve, public_key: Option<&EcPublicKey>, ) -> String
Encode as PKCS#8 PEM.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SecretKey
impl RefUnwindSafe for SecretKey
impl Send for SecretKey
impl Sync for SecretKey
impl Unpin for SecretKey
impl UnsafeUnpin for SecretKey
impl UnwindSafe for SecretKey
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