Struct ecdsa::SigningKey
source · pub struct SigningKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,{ /* private fields */ }
Expand description
ECDSA signing key. Generic over elliptic curves.
Requires an elliptic_curve::ProjectiveArithmetic
impl on the curve, and a
SignPrimitive
impl on its associated Scalar
type.
Implementations§
source§impl<C> SigningKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> SigningKey<C>where C: PrimeCurve + ProjectiveArithmetic, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
sourcepub fn random(rng: impl CryptoRng + RngCore) -> Self
pub fn random(rng: impl CryptoRng + RngCore) -> Self
Generate a cryptographically random SigningKey
.
sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Initialize signing key from a raw scalar serialized as a byte slice.
sourcepub fn to_bytes(&self) -> FieldBytes<C>
pub fn to_bytes(&self) -> FieldBytes<C>
Serialize this SigningKey
as bytes
sourcepub fn as_nonzero_scalar(&self) -> &NonZeroScalar<C>
pub fn as_nonzero_scalar(&self) -> &NonZeroScalar<C>
Borrow the secret NonZeroScalar
value for this key.
⚠️ Warning
This value is key material.
Please treat it with the care it deserves!
sourcepub fn verifying_key(&self) -> VerifyingKey<C>
pub fn verifying_key(&self) -> VerifyingKey<C>
Get the VerifyingKey
which corresponds to this SigningKey
Trait Implementations§
source§impl<C> AsRef<VerifyingKey<C>> for SigningKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> AsRef<VerifyingKey<C>> for SigningKey<C>where C: PrimeCurve + ProjectiveArithmetic, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
source§fn as_ref(&self) -> &VerifyingKey<C>
fn as_ref(&self) -> &VerifyingKey<C>
Converts this type into a shared reference of the (usually inferred) input type.
source§impl<C> Clone for SigningKey<C>where
C: PrimeCurve + ProjectiveArithmetic + Clone,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> Clone for SigningKey<C>where C: PrimeCurve + ProjectiveArithmetic + Clone, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
source§fn clone(&self) -> SigningKey<C>
fn clone(&self) -> SigningKey<C>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<C> ConstantTimeEq for SigningKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> ConstantTimeEq for SigningKey<C>where C: PrimeCurve + ProjectiveArithmetic, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
source§impl<C> Debug for SigningKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> Debug for SigningKey<C>where C: PrimeCurve + ProjectiveArithmetic, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
source§impl<C, D> DigestSigner<D, Signature<C>> for SigningKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
C::UInt: for<'a> From<&'a Scalar<C>>,
D: Digest + BlockSizeUser + FixedOutput<OutputSize = FieldSize<C>> + FixedOutputReset,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C, D> DigestSigner<D, Signature<C>> for SigningKey<C>where C: PrimeCurve + ProjectiveArithmetic, C::UInt: for<'a> From<&'a Scalar<C>>, D: Digest + BlockSizeUser + FixedOutput<OutputSize = FieldSize<C>> + FixedOutputReset, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
source§fn try_sign_digest(&self, msg_digest: D) -> Result<Signature<C>>
fn try_sign_digest(&self, msg_digest: D) -> Result<Signature<C>>
Sign message digest using a deterministic ephemeral scalar (k
)
computed using the algorithm described in RFC6979 § 3.2.
source§fn sign_digest(&self, digest: D) -> S
fn sign_digest(&self, digest: D) -> S
source§impl<C> Drop for SigningKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> Drop for SigningKey<C>where C: PrimeCurve + ProjectiveArithmetic, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
source§impl<C> From<&SecretKey<C>> for SigningKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> From<&SecretKey<C>> for SigningKey<C>where C: PrimeCurve + ProjectiveArithmetic, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
source§impl<C> From<&SigningKey<C>> for SecretKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> From<&SigningKey<C>> for SecretKey<C>where C: PrimeCurve + ProjectiveArithmetic, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
source§fn from(secret_key: &SigningKey<C>) -> Self
fn from(secret_key: &SigningKey<C>) -> Self
Converts to this type from the input type.
source§impl<C> From<&SigningKey<C>> for VerifyingKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> From<&SigningKey<C>> for VerifyingKey<C>where C: PrimeCurve + ProjectiveArithmetic, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
source§fn from(signing_key: &SigningKey<C>) -> VerifyingKey<C>
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>where
C: PrimeCurve + ProjectiveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> From<NonZeroScalar<C>> for SigningKey<C>where C: PrimeCurve + ProjectiveArithmetic, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
source§fn from(secret_scalar: NonZeroScalar<C>) -> Self
fn from(secret_scalar: NonZeroScalar<C>) -> Self
Converts to this type from the input type.
source§impl<C> From<SecretKey<C>> for SigningKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> From<SecretKey<C>> for SigningKey<C>where C: PrimeCurve + ProjectiveArithmetic, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
source§impl<C> From<SigningKey<C>> for SecretKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> From<SigningKey<C>> for SecretKey<C>where C: PrimeCurve + ProjectiveArithmetic, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
source§fn from(key: SigningKey<C>) -> Self
fn from(key: SigningKey<C>) -> Self
Converts to this type from the input type.
source§impl<C> Keypair<Signature<C>> for SigningKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> Keypair<Signature<C>> for SigningKey<C>where C: PrimeCurve + ProjectiveArithmetic, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
§type VerifyingKey = VerifyingKey<C>
type VerifyingKey = VerifyingKey<C>
Verifying key type for this keypair.
source§fn verifying_key(&self) -> &Self::VerifyingKey
fn verifying_key(&self) -> &Self::VerifyingKey
Get the verifying key which can verify signatures produced by the
signing key portion of this keypair.
source§impl<C> PartialEq<SigningKey<C>> for SigningKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> PartialEq<SigningKey<C>> for SigningKey<C>where C: PrimeCurve + ProjectiveArithmetic, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
Constant-time comparison
source§fn eq(&self, other: &SigningKey<C>) -> bool
fn eq(&self, other: &SigningKey<C>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<C> PrehashSigner<Signature<C>> for SigningKey<C>where
C: PrimeCurve + ProjectiveArithmetic + DigestPrimitive,
C::Digest: BlockSizeUser + FixedOutput<OutputSize = FieldSize<C>> + FixedOutputReset,
C::UInt: for<'a> From<&'a Scalar<C>>,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> PrehashSigner<Signature<C>> for SigningKey<C>where C: PrimeCurve + ProjectiveArithmetic + DigestPrimitive, C::Digest: BlockSizeUser + FixedOutput<OutputSize = FieldSize<C>> + FixedOutputReset, C::UInt: for<'a> From<&'a Scalar<C>>, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
source§impl<C, D> RandomizedDigestSigner<D, Signature<C>> for SigningKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
C::UInt: for<'a> From<&'a Scalar<C>>,
D: Digest + BlockSizeUser + FixedOutput<OutputSize = FieldSize<C>> + FixedOutputReset,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C, D> RandomizedDigestSigner<D, Signature<C>> for SigningKey<C>where C: PrimeCurve + ProjectiveArithmetic, C::UInt: for<'a> From<&'a Scalar<C>>, D: Digest + BlockSizeUser + FixedOutput<OutputSize = FieldSize<C>> + FixedOutputReset, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
source§impl<C> RandomizedSigner<Signature<C>> for SigningKey<C>where
Self: RandomizedDigestSigner<C::Digest, Signature<C>>,
C: PrimeCurve + ProjectiveArithmetic + DigestPrimitive,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> RandomizedSigner<Signature<C>> for SigningKey<C>where Self: RandomizedDigestSigner<C::Digest, Signature<C>>, C: PrimeCurve + ProjectiveArithmetic + DigestPrimitive, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
source§impl<C> Signer<Signature<C>> for SigningKey<C>where
Self: DigestSigner<C::Digest, Signature<C>>,
C: PrimeCurve + ProjectiveArithmetic + DigestPrimitive,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> Signer<Signature<C>> for SigningKey<C>where Self: DigestSigner<C::Digest, Signature<C>>, C: PrimeCurve + ProjectiveArithmetic + DigestPrimitive, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
source§impl<C> TryFrom<&[u8]> for SigningKey<C>where
C: PrimeCurve + ProjectiveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> TryFrom<&[u8]> for SigningKey<C>where C: PrimeCurve + ProjectiveArithmetic, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
impl<C> Eq for SigningKey<C>where C: PrimeCurve + ProjectiveArithmetic, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
Constant-time comparison
impl<C> ZeroizeOnDrop for SigningKey<C>where C: PrimeCurve + ProjectiveArithmetic, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,
Auto Trait Implementations§
impl<C> RefUnwindSafe for SigningKey<C>where <C as AffineArithmetic>::AffinePoint: RefUnwindSafe, <C as ScalarArithmetic>::Scalar: RefUnwindSafe,
impl<C> Send for SigningKey<C>
impl<C> Sync for SigningKey<C>
impl<C> Unpin for SigningKey<C>where <C as AffineArithmetic>::AffinePoint: Unpin, <C as ScalarArithmetic>::Scalar: Unpin,
impl<C> UnwindSafe for SigningKey<C>where <C as AffineArithmetic>::AffinePoint: UnwindSafe, <C as ScalarArithmetic>::Scalar: UnwindSafe,
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