[−][src]Struct ecdsa::Signature
ECDSA signatures (fixed-size).
Generic over elliptic curve types.
These signatures are serialized as fixed-sized big endian scalar values with no additional 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 is also supported via the Signature::from_asn1
and
Signature::to_asn1
methods.
Implementations
impl<C: Curve> Signature<C> where
SignatureSize<C>: ArrayLength<u8>,
[src]
SignatureSize<C>: ArrayLength<u8>,
pub fn from_scalars(r: &ElementBytes<C>, s: &ElementBytes<C>) -> Self
[src]
Create a Signature
from the serialized r
and s
components
pub fn from_asn1(bytes: &[u8]) -> Result<Self, Error> where
C::ElementSize: Add + ArrayLength<u8>,
MaxSize<C>: ArrayLength<u8>,
<C::ElementSize as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,
[src]
C::ElementSize: Add + ArrayLength<u8>,
MaxSize<C>: ArrayLength<u8>,
<C::ElementSize as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,
Parse a signature from ASN.1 DER
pub fn to_asn1(&self) -> Signature<C> where
C::ElementSize: Add + ArrayLength<u8>,
MaxSize<C>: ArrayLength<u8>,
<C::ElementSize as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,
[src]
C::ElementSize: Add + ArrayLength<u8>,
MaxSize<C>: ArrayLength<u8>,
<C::ElementSize as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,
Serialize this signature as ASN.1 DER
pub fn r(&self) -> &ElementBytes<C>
[src]
Get the r
component of this signature
pub fn s(&self) -> &ElementBytes<C>
[src]
Get the s
component of this signature
impl<C> Signature<C> where
C: Curve + Arithmetic,
C::Scalar: NormalizeLow,
SignatureSize<C>: ArrayLength<u8>,
[src]
C: Curve + Arithmetic,
C::Scalar: NormalizeLow,
SignatureSize<C>: ArrayLength<u8>,
pub fn normalize_s(&mut self) -> Result<bool, Error>
[src]
Normalize signature into "low S" form as described in BIP 0062: Dealing with Malleability.
Trait Implementations
impl<C: Curve> AsRef<[u8]> for Signature<C> where
SignatureSize<C>: ArrayLength<u8>,
[src]
SignatureSize<C>: ArrayLength<u8>,
impl<C: Clone + Curve> Clone for Signature<C> where
SignatureSize<C>: ArrayLength<u8>,
[src]
SignatureSize<C>: ArrayLength<u8>,
impl<C: Curve> Copy for Signature<C> where
SignatureSize<C>: ArrayLength<u8>,
<SignatureSize<C> as ArrayLength<u8>>::ArrayType: Copy,
[src]
SignatureSize<C>: ArrayLength<u8>,
<SignatureSize<C> as ArrayLength<u8>>::ArrayType: Copy,
impl<C: Curve> Debug for Signature<C> where
SignatureSize<C>: ArrayLength<u8>,
[src]
SignatureSize<C>: ArrayLength<u8>,
impl<C, D> DigestVerifier<D, Signature<C>> for Verifier<C> where
C: Curve + Arithmetic,
D: Digest<OutputSize = C::ElementSize>,
C::AffinePoint: VerifyPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
[src]
C: Curve + Arithmetic,
D: Digest<OutputSize = C::ElementSize>,
C::AffinePoint: VerifyPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C: Eq + Curve> Eq for Signature<C> where
SignatureSize<C>: ArrayLength<u8>,
[src]
SignatureSize<C>: ArrayLength<u8>,
impl<C> From<Signature<C>> for Signature<C> where
C: Curve,
C::ElementSize: Add + ArrayLength<u8>,
MaxSize<C>: ArrayLength<u8>,
<C::ElementSize as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,
[src]
C: Curve,
C::ElementSize: Add + ArrayLength<u8>,
MaxSize<C>: ArrayLength<u8>,
<C::ElementSize as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,
impl<C: PartialEq + Curve> PartialEq<Signature<C>> for Signature<C> where
SignatureSize<C>: ArrayLength<u8>,
[src]
SignatureSize<C>: ArrayLength<u8>,
impl<C: DigestPrimitive> PrehashSignature for Signature<C> where
<C::ElementSize as Add>::Output: ArrayLength<u8>,
[src]
<C::ElementSize as Add>::Output: ArrayLength<u8>,
impl<C, D> RandomizedDigestSigner<D, Signature<C>> for Signer<C> where
C: Curve + Arithmetic,
D: Digest<OutputSize = C::ElementSize>,
C::Scalar: Invert<Output = C::Scalar> + Generate + SignPrimitive<C> + Zeroize,
SignatureSize<C>: ArrayLength<u8>,
[src]
C: Curve + Arithmetic,
D: Digest<OutputSize = C::ElementSize>,
C::Scalar: Invert<Output = C::Scalar> + Generate + SignPrimitive<C> + Zeroize,
SignatureSize<C>: ArrayLength<u8>,
fn try_sign_digest_with_rng(
&self,
rng: impl CryptoRng + RngCore,
digest: D
) -> Result<Signature<C>, Error>
[src]
&self,
rng: impl CryptoRng + RngCore,
digest: D
) -> Result<Signature<C>, Error>
fn sign_digest_with_rng(&self, rng: impl RngCore + CryptoRng, digest: D) -> S
[src]
impl<C> RandomizedSigner<Signature<C>> for Signer<C> where
C: Curve + Arithmetic + DigestPrimitive,
C::Digest: Digest<OutputSize = C::ElementSize>,
C::Scalar: Invert<Output = C::Scalar> + Generate + SignPrimitive<C> + Zeroize,
SignatureSize<C>: ArrayLength<u8>,
[src]
C: Curve + Arithmetic + DigestPrimitive,
C::Digest: Digest<OutputSize = C::ElementSize>,
C::Scalar: Invert<Output = C::Scalar> + Generate + SignPrimitive<C> + Zeroize,
SignatureSize<C>: ArrayLength<u8>,
fn try_sign_with_rng(
&self,
rng: impl CryptoRng + RngCore,
msg: &[u8]
) -> Result<Signature<C>, Error>
[src]
&self,
rng: impl CryptoRng + RngCore,
msg: &[u8]
) -> Result<Signature<C>, Error>
fn sign_with_rng(&self, rng: impl RngCore + CryptoRng, msg: &[u8]) -> S
[src]
impl<C: Curve> Signature for Signature<C> where
SignatureSize<C>: ArrayLength<u8>,
[src]
SignatureSize<C>: ArrayLength<u8>,
impl<C: Curve> StructuralEq for Signature<C> where
SignatureSize<C>: ArrayLength<u8>,
[src]
SignatureSize<C>: ArrayLength<u8>,
impl<C: Curve> StructuralPartialEq for Signature<C> where
SignatureSize<C>: ArrayLength<u8>,
[src]
SignatureSize<C>: ArrayLength<u8>,
impl<C: Curve, '_> TryFrom<&'_ [u8]> for Signature<C> where
SignatureSize<C>: ArrayLength<u8>,
[src]
SignatureSize<C>: ArrayLength<u8>,
type Error = Error
The type returned in the event of a conversion error.
fn try_from(bytes: &[u8]) -> Result<Self, Error>
[src]
impl<C> Verifier<Signature<C>> for Verifier<C> where
C: Curve + Arithmetic + DigestPrimitive,
C::AffinePoint: VerifyPrimitive<C>,
C::Digest: Digest<OutputSize = C::ElementSize>,
SignatureSize<C>: ArrayLength<u8>,
[src]
C: Curve + Arithmetic + DigestPrimitive,
C::AffinePoint: VerifyPrimitive<C>,
C::Digest: Digest<OutputSize = C::ElementSize>,
SignatureSize<C>: ArrayLength<u8>,
Auto Trait Implementations
impl<C> RefUnwindSafe for Signature<C> where
<<<C as Curve>::ElementSize as Add<<C as Curve>::ElementSize>>::Output as ArrayLength<u8>>::ArrayType: RefUnwindSafe,
<C as Curve>::ElementSize: Add<<C as Curve>::ElementSize>,
<<<C as Curve>::ElementSize as Add<<C as Curve>::ElementSize>>::Output as ArrayLength<u8>>::ArrayType: RefUnwindSafe,
<C as Curve>::ElementSize: Add<<C as Curve>::ElementSize>,
impl<C> Send for Signature<C> where
<C as Curve>::ElementSize: Add<<C as Curve>::ElementSize>,
<C as Curve>::ElementSize: Add<<C as Curve>::ElementSize>,
impl<C> Sync for Signature<C> where
<C as Curve>::ElementSize: Add<<C as Curve>::ElementSize>,
<C as Curve>::ElementSize: Add<<C as Curve>::ElementSize>,
impl<C> Unpin for Signature<C> where
<<<C as Curve>::ElementSize as Add<<C as Curve>::ElementSize>>::Output as ArrayLength<u8>>::ArrayType: Unpin,
<C as Curve>::ElementSize: Add<<C as Curve>::ElementSize>,
<<<C as Curve>::ElementSize as Add<<C as Curve>::ElementSize>>::Output as ArrayLength<u8>>::ArrayType: Unpin,
<C as Curve>::ElementSize: Add<<C as Curve>::ElementSize>,
impl<C> UnwindSafe for Signature<C> where
<<<C as Curve>::ElementSize as Add<<C as Curve>::ElementSize>>::Output as ArrayLength<u8>>::ArrayType: UnwindSafe,
<C as Curve>::ElementSize: Add<<C as Curve>::ElementSize>,
<<<C as Curve>::ElementSize as Add<<C as Curve>::ElementSize>>::Output as ArrayLength<u8>>::ArrayType: UnwindSafe,
<C as Curve>::ElementSize: Add<<C as Curve>::ElementSize>,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,