Struct SigningKey

Source
pub struct SigningKey<C>{ /* private fields */ }
Available on crate feature sign only.
Expand description

ECDSA signing key. Generic over elliptic curves.

Requires an elliptic_curve_flow::ProjectiveArithmetic impl on the curve, and a SignPrimitive impl on its associated Scalar type.

Implementations§

Source§

impl<C> SigningKey<C>

Source

pub fn random(rng: impl CryptoRng + RngCore) -> Self

Generate a cryptographically random SigningKey.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self>

Initialize signing key from a raw scalar serialized as a byte slice.

Source

pub fn verifying_key(&self) -> VerifyingKey<C>

Available on crate feature verify only.

Get the VerifyingKey which corresponds to this SigningKey

Source

pub fn to_bytes(&self) -> FieldBytes<C>

Serialize this SigningKey as bytes

Trait Implementations§

Source§

impl<C> Clone for SigningKey<C>

Source§

fn clone(&self) -> SigningKey<C>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C> ConstantTimeEq for SigningKey<C>

Source§

fn ct_eq(&self, other: &Self) -> Choice

Determine if two items are equal. Read more
Source§

impl<C> Debug for SigningKey<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C, D> DigestSigner<D, Signature<C>> for SigningKey<C>

Source§

fn try_sign_digest(&self, digest: D) -> Result<Signature<C>>

Sign message prehash using a deterministic ephemeral scalar (k) computed using the algorithm described in RFC 6979 (Section 3.2): https://tools.ietf.org/html/rfc6979#section-3

Source§

fn sign_digest(&self, digest: D) -> S

Sign the given prehashed message Digest, returning a signature. Read more
Source§

impl<C> Drop for SigningKey<C>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<C> From<&SecretKey<C>> for SigningKey<C>

Source§

fn from(secret_key: &SecretKey<C>) -> Self

Converts to this type from the input type.
Source§

impl<C> From<&SigningKey<C>> for VerifyingKey<C>

Source§

fn from(signing_key: &SigningKey<C>) -> VerifyingKey<C>

Converts to this type from the input type.
Source§

impl<C> From<NonZeroScalar<C>> for SigningKey<C>

Source§

fn from(secret_scalar: NonZeroScalar<C>) -> Self

Converts to this type from the input type.
Source§

impl<C> From<SecretKey<C>> for SigningKey<C>

Source§

fn from(secret_key: SecretKey<C>) -> Self

Converts to this type from the input type.
Source§

impl<C> FromPrivateKey for SigningKey<C>

Available on crate feature pkcs8 only.
Source§

fn from_pkcs8_private_key_info( private_key_info: PrivateKeyInfo<'_>, ) -> Result<Self>

Parse the PrivateKeyInfo from a PKCS#8-encoded document.
Source§

fn from_pkcs8_der(bytes: &[u8]) -> Result<Self, Error>

Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary format).
Source§

fn from_pkcs8_doc(doc: &PrivateKeyDocument) -> Result<Self, Error>

Deserialize PKCS#8 private key from a PrivateKeyDocument.
Source§

fn from_pkcs8_pem(s: &str) -> Result<Self, Error>

Deserialize PKCS#8-encoded private key from PEM. Read more
Source§

impl<C> FromStr for SigningKey<C>

Available on crate feature pem only.
Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more
Source§

impl<C> PartialEq for SigningKey<C>

Source§

fn eq(&self, other: &SigningKey<C>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<C, D> RandomizedDigestSigner<D, Signature<C>> for SigningKey<C>

Source§

fn try_sign_digest_with_rng( &self, rng: impl CryptoRng + RngCore, digest: D, ) -> Result<Signature<C>>

Sign message prehash using an ephemeral scalar (k) derived according to a variant of RFC 6979 (Section 3.6) which supplies additional entropy from an RNG.

Source§

fn sign_digest_with_rng(&self, rng: impl CryptoRng + RngCore, digest: D) -> S

Sign the given prehashed message Digest, returning a signature. Read more
Source§

impl<C> RandomizedSigner<Signature<C>> for SigningKey<C>

Source§

fn try_sign_with_rng( &self, rng: impl CryptoRng + RngCore, msg: &[u8], ) -> Result<Signature<C>>

Attempt to sign the given message, returning a digital signature on success, or an error if something went wrong. Read more
Source§

fn sign_with_rng(&self, rng: impl CryptoRng + RngCore, msg: &[u8]) -> S

Sign the given message and return a digital signature
Source§

impl<C> Signer<Signature<C>> for SigningKey<C>

Source§

fn try_sign(&self, msg: &[u8]) -> Result<Signature<C>>

Attempt to sign the given message, returning a digital signature on success, or an error if something went wrong. Read more
Source§

fn sign(&self, msg: &[u8]) -> S

Sign the given message and return a digital signature
Source§

impl<C> TryFrom<&[u8]> for SigningKey<C>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(bytes: &[u8]) -> Result<Self>

Performs the conversion.
Source§

impl<C> Eq for SigningKey<C>

Auto Trait Implementations§

§

impl<C> Freeze for SigningKey<C>

§

impl<C> RefUnwindSafe for SigningKey<C>

§

impl<C> Send for SigningKey<C>
where <<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Sized,

§

impl<C> Sync for SigningKey<C>
where <<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Sized,

§

impl<C> Unpin for SigningKey<C>

§

impl<C> UnwindSafe for SigningKey<C>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, S> SignerMut<S> for T
where T: Signer<S>, S: Signature,

Source§

fn try_sign(&mut self, msg: &[u8]) -> Result<S, Error>

Attempt to sign the given message, updating the state, and returning a digital signature on success, or an error if something went wrong. Read more
Source§

fn sign(&mut self, msg: &[u8]) -> S

Sign the given message, update the state, and return a digital signature
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.