Struct ecdsa::Signature [−][src]
pub struct Signature<C: Curve> where
SignatureSize<C>: ArrayLength<u8>, { /* fields omitted */ }
Expand description
ECDSA signature (fixed-size). Generic over elliptic curve types.
Serialized as fixed-sized big endian scalar values with no added framing:
r
: field element size for the given curve, big-endians
: field element size for the given curve, big-endian
For example, in a curve with a 256-bit modulus like NIST P-256 or
secp256k1, r
and s
will both be 32-bytes, resulting in a signature
with a total of 64-bytes.
ASN.1 DER-encoded signatures also supported via the
Signature::from_der
and Signature::to_der
methods.
Implementations
pub fn from_scalars(
r: impl Into<FieldBytes<C>>,
s: impl Into<FieldBytes<C>>
) -> Result<Self, Error>
pub fn from_scalars(
r: impl Into<FieldBytes<C>>,
s: impl Into<FieldBytes<C>>
) -> Result<Self, Error>
Create a Signature
from the serialized r
and s
scalar values
which comprise the signature.
This is supported on crate feature arithmetic
only.
arithmetic
only.Get the r
component of this signature
This is supported on crate feature arithmetic
only.
arithmetic
only.Get the s
component of this signature
This is supported on crate feature arithmetic
only.
arithmetic
only.Normalize signature into “low S” form as described in BIP 0062: Dealing with Malleability.
Trait Implementations
impl<C, D> DigestSigner<D, Signature<C>> for SigningKey<C> where
C: Curve + ProjectiveArithmetic,
D: FixedOutput<OutputSize = FieldSize<C>> + BlockInput + Clone + Default + Reset + Update,
Scalar<C>: FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
SignatureSize<C>: ArrayLength<u8>,
impl<C, D> DigestSigner<D, Signature<C>> for SigningKey<C> where
C: Curve + ProjectiveArithmetic,
D: FixedOutput<OutputSize = FieldSize<C>> + BlockInput + Clone + Default + Reset + Update,
Scalar<C>: FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
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
Sign the given prehashed message [Digest
], returning a signature. Read more
impl<C, D> DigestVerifier<D, Signature<C>> for VerifyingKey<C> where
C: Curve + ProjectiveArithmetic,
D: Digest<OutputSize = FieldSize<C>>,
AffinePoint<C>: VerifyPrimitive<C>,
Scalar<C>: FromDigest<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C, D> DigestVerifier<D, Signature<C>> for VerifyingKey<C> where
C: Curve + ProjectiveArithmetic,
D: Digest<OutputSize = FieldSize<C>>,
AffinePoint<C>: VerifyPrimitive<C>,
Scalar<C>: FromDigest<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> PrehashSignature for Signature<C> where
C: DigestPrimitive,
<FieldSize<C> as Add>::Output: ArrayLength<u8>,
This is supported on crate feature hazmat
only.
impl<C> PrehashSignature for Signature<C> where
C: DigestPrimitive,
<FieldSize<C> as Add>::Output: ArrayLength<u8>,
hazmat
only.impl<C, D> RandomizedDigestSigner<D, Signature<C>> for SigningKey<C> where
C: Curve + ProjectiveArithmetic,
D: FixedOutput<OutputSize = FieldSize<C>> + BlockInput + Clone + Default + Reset + Update,
Scalar<C>: FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
SignatureSize<C>: ArrayLength<u8>,
impl<C, D> RandomizedDigestSigner<D, Signature<C>> for SigningKey<C> where
C: Curve + ProjectiveArithmetic,
D: FixedOutput<OutputSize = FieldSize<C>> + BlockInput + Clone + Default + Reset + Update,
Scalar<C>: FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
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: Curve + ProjectiveArithmetic + DigestPrimitive,
Scalar<C>: FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
SignatureSize<C>: ArrayLength<u8>,
impl<C> RandomizedSigner<Signature<C>> for SigningKey<C> where
Self: RandomizedDigestSigner<C::Digest, Signature<C>>,
C: Curve + ProjectiveArithmetic + DigestPrimitive,
Scalar<C>: FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
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: Curve + ProjectiveArithmetic + DigestPrimitive,
Scalar<C>: FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
SignatureSize<C>: ArrayLength<u8>,
impl<C> Signer<Signature<C>> for SigningKey<C> where
Self: DigestSigner<C::Digest, Signature<C>>,
C: Curve + ProjectiveArithmetic + DigestPrimitive,
Scalar<C>: FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
SignatureSize<C>: ArrayLength<u8>,
impl<C> Verifier<Signature<C>> for VerifyingKey<C> where
C: Curve + ProjectiveArithmetic + DigestPrimitive,
C::Digest: Digest<OutputSize = FieldSize<C>>,
AffinePoint<C>: VerifyPrimitive<C>,
Scalar<C>: FromDigest<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> Verifier<Signature<C>> for VerifyingKey<C> where
C: Curve + ProjectiveArithmetic + DigestPrimitive,
C::Digest: Digest<OutputSize = FieldSize<C>>,
AffinePoint<C>: VerifyPrimitive<C>,
Scalar<C>: FromDigest<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C> Copy for Signature<C> where
C: Curve,
SignatureSize<C>: ArrayLength<u8>,
<SignatureSize<C> as ArrayLength<u8>>::ArrayType: Copy,
Auto Trait Implementations
impl<C> RefUnwindSafe for Signature<C> where
<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add<<<C as Curve>::UInt as ArrayEncoding>::ByteSize>>::Output as ArrayLength<u8>>::ArrayType: RefUnwindSafe,
impl<C> Unpin for Signature<C> where
<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add<<<C as Curve>::UInt as ArrayEncoding>::ByteSize>>::Output as ArrayLength<u8>>::ArrayType: Unpin,
impl<C> UnwindSafe for Signature<C> where
<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add<<<C as Curve>::UInt as ArrayEncoding>::ByteSize>>::Output as ArrayLength<u8>>::ArrayType: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self