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 */ }
sign
only.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
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>,
Generate a cryptographically random SigningKey
.
Initialize signing key from a raw scalar serialized as a byte slice.
This is supported on crate feature verify
only.
verify
only.Get the VerifyingKey
which corresponds to this SigningKey
Serialize this SigningKey
as bytes
Trait Implementations
impl<C: Clone> Clone 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: Clone> Clone 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>,
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> 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>,
impl<C> DecodePrivateKey for SigningKey<C> where
C: PrimeCurve + AlgorithmParameters + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
This is supported on crate feature pkcs8
only.
impl<C> DecodePrivateKey for SigningKey<C> where
C: PrimeCurve + AlgorithmParameters + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
pkcs8
only.Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary format). Read more
Deserialize PKCS#8 private key from a PrivateKeyDocument
.
impl<C, D> DigestSigner<D, Signature<C>> for SigningKey<C> where
C: PrimeCurve + ProjectiveArithmetic,
D: CoreProxy + Digest + FixedOutput<OutputSize = FieldSize<C>>,
D::Core: BlockSizeUser + BufferKindUser<BufferKind = Eager> + Clone + Default + FixedOutputCore + HashMarker + OutputSizeUser<OutputSize = D::OutputSize>,
<D::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<D::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
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,
D: CoreProxy + Digest + FixedOutput<OutputSize = FieldSize<C>>,
D::Core: BlockSizeUser + BufferKindUser<BufferKind = Eager> + Clone + Default + FixedOutputCore + HashMarker + OutputSizeUser<OutputSize = D::OutputSize>,
<D::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<D::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
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
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>,
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>,
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>,
Performs the conversion.
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>,
Performs the conversion.
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>,
impl<C> FromStr for SigningKey<C> where
C: PrimeCurve + AlgorithmParameters + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
This is supported on crate feature pem
only.
impl<C> FromStr for SigningKey<C> where
C: PrimeCurve + AlgorithmParameters + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
pem
only.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
impl<C, D> RandomizedDigestSigner<D, Signature<C>> for SigningKey<C> where
C: PrimeCurve + ProjectiveArithmetic,
D: CoreProxy + Digest + FixedOutput<OutputSize = FieldSize<C>>,
D::Core: BlockSizeUser + BufferKindUser<BufferKind = Eager> + Clone + Default + FixedOutputCore + HashMarker + OutputSizeUser<OutputSize = D::OutputSize>,
<D::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<D::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
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,
D: CoreProxy + Digest + FixedOutput<OutputSize = FieldSize<C>>,
D::Core: BlockSizeUser + BufferKindUser<BufferKind = Eager> + Clone + Default + FixedOutputCore + HashMarker + OutputSizeUser<OutputSize = D::OutputSize>,
<D::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<D::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
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.
Sign the given prehashed message Digest
, returning a signature. Read more
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>,
Attempt to sign the given message, returning a digital signature on success, or an error if something went wrong. Read more
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>,
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> TryFrom<PrivateKeyInfo<'_>> for SigningKey<C> where
C: PrimeCurve + AlgorithmParameters + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
This is supported on crate feature pkcs8
only.
impl<C> TryFrom<PrivateKeyInfo<'_>> for SigningKey<C> where
C: PrimeCurve + AlgorithmParameters + ProjectiveArithmetic,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
FieldSize<C>: ModulusSize,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
pkcs8
only.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
Auto Trait Implementations
impl<C> RefUnwindSafe for SigningKey<C> where
<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 ScalarArithmetic>::Scalar: Unpin,
impl<C> UnwindSafe for SigningKey<C> where
<C as ScalarArithmetic>::Scalar: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
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