[−][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> Signature<C> where
C: Curve + CheckSignatureBytes,
SignatureSize<C>: ArrayLength<u8>,
[src]
C: Curve + CheckSignatureBytes,
SignatureSize<C>: ArrayLength<u8>,
pub fn from_scalars(
r: impl Into<FieldBytes<C>>,
s: impl Into<FieldBytes<C>>
) -> Result<Self, Error>
[src]
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.
pub fn from_asn1(bytes: &[u8]) -> Result<Self, Error> where
C::FieldSize: Add + ArrayLength<u8>,
MaxSize<C>: ArrayLength<u8>,
<C::FieldSize as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,
[src]
C::FieldSize: Add + ArrayLength<u8>,
MaxSize<C>: ArrayLength<u8>,
<C::FieldSize as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,
Parse a signature from ASN.1 DER
pub fn to_asn1(&self) -> Signature<C> where
C::FieldSize: Add + ArrayLength<u8>,
MaxSize<C>: ArrayLength<u8>,
<C::FieldSize as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,
[src]
C::FieldSize: Add + ArrayLength<u8>,
MaxSize<C>: ArrayLength<u8>,
<C::FieldSize as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,
Serialize this signature as ASN.1 DER
impl<C> Signature<C> where
C: Curve + ProjectiveArithmetic,
Scalar<C>: PrimeField<Repr = FieldBytes<C>>,
<Scalar<C> as PrimeField>::Repr: From<Scalar<C>> + for<'a> From<&'a Scalar<C>>,
SignatureSize<C>: ArrayLength<u8>,
[src]
C: Curve + ProjectiveArithmetic,
Scalar<C>: PrimeField<Repr = FieldBytes<C>>,
<Scalar<C> as PrimeField>::Repr: From<Scalar<C>> + for<'a> From<&'a Scalar<C>>,
SignatureSize<C>: ArrayLength<u8>,
pub fn r(&self) -> NonZeroScalar<C>
[src]
arithmetic
only.Get the r
component of this signature
pub fn s(&self) -> NonZeroScalar<C>
[src]
arithmetic
only.Get the s
component of this signature
pub fn normalize_s(&mut self) -> Result<bool, Error> where
Scalar<C>: NormalizeLow,
[src]
Scalar<C>: NormalizeLow,
arithmetic
only.Normalize signature into "low S" form as described in BIP 0062: Dealing with Malleability.
Trait Implementations
impl<C> AsRef<[u8]> for Signature<C> where
C: Curve + CheckSignatureBytes,
SignatureSize<C>: ArrayLength<u8>,
[src]
C: Curve + CheckSignatureBytes,
SignatureSize<C>: ArrayLength<u8>,
impl<C: Clone + Curve + CheckSignatureBytes> Clone for Signature<C> where
SignatureSize<C>: ArrayLength<u8>,
[src]
SignatureSize<C>: ArrayLength<u8>,
impl<C> Copy for Signature<C> where
C: Curve + CheckSignatureBytes,
SignatureSize<C>: ArrayLength<u8>,
<SignatureSize<C> as ArrayLength<u8>>::ArrayType: Copy,
[src]
C: Curve + CheckSignatureBytes,
SignatureSize<C>: ArrayLength<u8>,
<SignatureSize<C> as ArrayLength<u8>>::ArrayType: Copy,
impl<C> Debug for Signature<C> where
C: Curve + CheckSignatureBytes,
SignatureSize<C>: ArrayLength<u8>,
[src]
C: Curve + CheckSignatureBytes,
SignatureSize<C>: ArrayLength<u8>,
impl<C, D> DigestSigner<D, Signature<C>> for SigningKey<C> where
C: Curve + ProjectiveArithmetic,
FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
Scalar<C>: PrimeField<Repr = FieldBytes<C>> + FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
D: FixedOutput<OutputSize = C::FieldSize> + BlockInput + Clone + Default + Reset + Update,
SignatureSize<C>: ArrayLength<u8>,
[src]
C: Curve + ProjectiveArithmetic,
FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
Scalar<C>: PrimeField<Repr = FieldBytes<C>> + FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
D: FixedOutput<OutputSize = C::FieldSize> + BlockInput + Clone + Default + Reset + Update,
SignatureSize<C>: ArrayLength<u8>,
fn try_sign_digest(&self, digest: D) -> Result<Signature<C>, Error>
[src]
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
fn sign_digest(&self, digest: D) -> S
[src]
impl<C, D> DigestVerifier<D, Signature<C>> for VerifyKey<C> where
C: Curve + ProjectiveArithmetic,
D: Digest<OutputSize = C::FieldSize>,
FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
Scalar<C>: PrimeField<Repr = FieldBytes<C>> + FromDigest<C>,
AffinePoint<C>: Clone + Debug + VerifyPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
[src]
C: Curve + ProjectiveArithmetic,
D: Digest<OutputSize = C::FieldSize>,
FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
Scalar<C>: PrimeField<Repr = FieldBytes<C>> + FromDigest<C>,
AffinePoint<C>: Clone + Debug + VerifyPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C: Eq + Curve + CheckSignatureBytes> Eq for Signature<C> where
SignatureSize<C>: ArrayLength<u8>,
[src]
SignatureSize<C>: ArrayLength<u8>,
impl<C: PartialEq + Curve + CheckSignatureBytes> PartialEq<Signature<C>> for Signature<C> where
SignatureSize<C>: ArrayLength<u8>,
[src]
SignatureSize<C>: ArrayLength<u8>,
impl<C> PrehashSignature for Signature<C> where
C: DigestPrimitive + CheckSignatureBytes,
<C::FieldSize as Add>::Output: ArrayLength<u8>,
[src]
C: DigestPrimitive + CheckSignatureBytes,
<C::FieldSize as Add>::Output: ArrayLength<u8>,
impl<C, D> RandomizedDigestSigner<D, Signature<C>> for SigningKey<C> where
C: Curve + ProjectiveArithmetic,
FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
Scalar<C>: PrimeField<Repr = FieldBytes<C>> + FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
D: FixedOutput<OutputSize = C::FieldSize> + BlockInput + Clone + Default + Reset + Update,
SignatureSize<C>: ArrayLength<u8>,
[src]
C: Curve + ProjectiveArithmetic,
FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
Scalar<C>: PrimeField<Repr = FieldBytes<C>> + FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
D: FixedOutput<OutputSize = C::FieldSize> + BlockInput + Clone + Default + Reset + Update,
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>
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.
fn sign_digest_with_rng(&self, rng: impl RngCore + CryptoRng, digest: D) -> S
[src]
impl<C> RandomizedSigner<Signature<C>> for SigningKey<C> where
C: Curve + ProjectiveArithmetic + DigestPrimitive,
FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
Scalar<C>: PrimeField<Repr = FieldBytes<C>> + FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
SignatureSize<C>: ArrayLength<u8>,
Self: RandomizedDigestSigner<C::Digest, Signature<C>>,
[src]
C: Curve + ProjectiveArithmetic + DigestPrimitive,
FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
Scalar<C>: PrimeField<Repr = FieldBytes<C>> + FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
SignatureSize<C>: ArrayLength<u8>,
Self: RandomizedDigestSigner<C::Digest, Signature<C>>,
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> Signature for Signature<C> where
C: Curve + CheckSignatureBytes,
SignatureSize<C>: ArrayLength<u8>,
[src]
C: Curve + CheckSignatureBytes,
SignatureSize<C>: ArrayLength<u8>,
impl<C> Signer<Signature<C>> for SigningKey<C> where
C: Curve + ProjectiveArithmetic + DigestPrimitive,
FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
Scalar<C>: PrimeField<Repr = FieldBytes<C>> + FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
SignatureSize<C>: ArrayLength<u8>,
Self: DigestSigner<C::Digest, Signature<C>>,
[src]
C: Curve + ProjectiveArithmetic + DigestPrimitive,
FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
Scalar<C>: PrimeField<Repr = FieldBytes<C>> + FromDigest<C> + Invert<Output = Scalar<C>> + SignPrimitive<C> + Zeroize,
SignatureSize<C>: ArrayLength<u8>,
Self: DigestSigner<C::Digest, Signature<C>>,
fn try_sign(&self, msg: &[u8]) -> Result<Signature<C>, Error>
[src]
fn sign(&self, msg: &[u8]) -> S
[src]
impl<C: Curve + CheckSignatureBytes> StructuralEq for Signature<C> where
SignatureSize<C>: ArrayLength<u8>,
[src]
SignatureSize<C>: ArrayLength<u8>,
impl<C: Curve + CheckSignatureBytes> StructuralPartialEq for Signature<C> where
SignatureSize<C>: ArrayLength<u8>,
[src]
SignatureSize<C>: ArrayLength<u8>,
impl<C, '_> TryFrom<&'_ [u8]> for Signature<C> where
C: Curve + CheckSignatureBytes,
SignatureSize<C>: ArrayLength<u8>,
[src]
C: Curve + CheckSignatureBytes,
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> TryFrom<Signature<C>> for Signature<C> where
C: Curve + CheckSignatureBytes,
C::FieldSize: Add + ArrayLength<u8>,
MaxSize<C>: ArrayLength<u8>,
<C::FieldSize as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,
[src]
C: Curve + CheckSignatureBytes,
C::FieldSize: Add + ArrayLength<u8>,
MaxSize<C>: ArrayLength<u8>,
<C::FieldSize as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,
type Error = Error
The type returned in the event of a conversion error.
fn try_from(doc: Signature<C>) -> Result<Signature<C>, Error>
[src]
impl<C> Verifier<Signature<C>> for VerifyKey<C> where
C: Curve + ProjectiveArithmetic + DigestPrimitive,
C::Digest: Digest<OutputSize = C::FieldSize>,
FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
Scalar<C>: PrimeField<Repr = FieldBytes<C>> + FromDigest<C>,
AffinePoint<C>: Clone + Debug + VerifyPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
[src]
C: Curve + ProjectiveArithmetic + DigestPrimitive,
C::Digest: Digest<OutputSize = C::FieldSize>,
FieldBytes<C>: From<Scalar<C>> + for<'r> From<&'r Scalar<C>>,
Scalar<C>: PrimeField<Repr = FieldBytes<C>> + FromDigest<C>,
AffinePoint<C>: Clone + Debug + VerifyPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
Auto Trait Implementations
impl<C> RefUnwindSafe for Signature<C> where
<<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output as ArrayLength<u8>>::ArrayType: RefUnwindSafe,
<C as Curve>::FieldSize: Add<<C as Curve>::FieldSize>,
<<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output as ArrayLength<u8>>::ArrayType: RefUnwindSafe,
<C as Curve>::FieldSize: Add<<C as Curve>::FieldSize>,
impl<C> Send for Signature<C> where
<C as Curve>::FieldSize: Add<<C as Curve>::FieldSize>,
<C as Curve>::FieldSize: Add<<C as Curve>::FieldSize>,
impl<C> Sync for Signature<C> where
<C as Curve>::FieldSize: Add<<C as Curve>::FieldSize>,
<C as Curve>::FieldSize: Add<<C as Curve>::FieldSize>,
impl<C> Unpin for Signature<C> where
<<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output as ArrayLength<u8>>::ArrayType: Unpin,
<C as Curve>::FieldSize: Add<<C as Curve>::FieldSize>,
<<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output as ArrayLength<u8>>::ArrayType: Unpin,
<C as Curve>::FieldSize: Add<<C as Curve>::FieldSize>,
impl<C> UnwindSafe for Signature<C> where
<<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output as ArrayLength<u8>>::ArrayType: UnwindSafe,
<C as Curve>::FieldSize: Add<<C as Curve>::FieldSize>,
<<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output as ArrayLength<u8>>::ArrayType: UnwindSafe,
<C as Curve>::FieldSize: Add<<C as Curve>::FieldSize>,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<A, T> AsBits<T> for A where
A: AsRef<[T]>,
T: BitStore + BitMemory,
A: AsRef<[T]>,
T: BitStore + BitMemory,
fn as_bits<O>(&self) -> &BitSlice<O, T> where
O: BitOrder,
O: BitOrder,
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> Conv for T
impl<T> FmtForward for T
fn fmt_binary(self) -> FmtBinary<Self> where
Self: Binary,
Self: Binary,
fn fmt_display(self) -> FmtDisplay<Self> where
Self: Display,
Self: Display,
fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp,
Self: LowerExp,
fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex,
Self: LowerHex,
fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal,
Self: Octal,
fn fmt_pointer(self) -> FmtPointer<Self> where
Self: Pointer,
Self: Pointer,
fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp,
Self: UpperExp,
fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex,
Self: UpperHex,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pipe for T
impl<T> PipeAsRef for T
fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
R: 'a,
Self: AsRef<T>,
T: 'a,
R: 'a,
Self: AsRef<T>,
T: 'a,
fn pipe_as_mut<'a, T, R>(&'a mut self, func: impl FnOnce(&'a mut T) -> R) -> R where
R: 'a,
Self: AsMut<T>,
T: 'a,
R: 'a,
Self: AsMut<T>,
T: 'a,
impl<T> PipeBorrow for T
fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
R: 'a,
Self: Borrow<T>,
T: 'a,
R: 'a,
Self: Borrow<T>,
T: 'a,
fn pipe_borrow_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
R: 'a,
Self: BorrowMut<T>,
T: 'a,
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
R: 'a,
Self: BorrowMut<T>,
T: 'a,
impl<T> PipeDeref for T
fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R where
R: 'a,
Self: Deref,
R: 'a,
Self: Deref,
fn pipe_deref_mut<'a, R>(
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
R: 'a,
Self: DerefMut,
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
R: 'a,
Self: DerefMut,
impl<T> PipeRef for T
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
R: 'a,
fn pipe_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a,
R: 'a,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> Tap for T
fn tap<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
F: FnOnce(&Self) -> R,
fn tap_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
F: FnOnce(&Self) -> R,
fn tap_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
F: FnOnce(&mut Self) -> R,
fn tap_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
F: FnOnce(&mut Self) -> R,
impl<T, U> TapAsRef<U> for T where
U: ?Sized,
U: ?Sized,
fn tap_ref<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: AsRef<T>,
F: FnOnce(&T) -> R,
Self: AsRef<T>,
fn tap_ref_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: AsRef<T>,
F: FnOnce(&T) -> R,
Self: AsRef<T>,
fn tap_ref_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
fn tap_ref_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
impl<T, U> TapBorrow<U> for T where
U: ?Sized,
U: ?Sized,
fn tap_borrow<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Self: Borrow<T>,
fn tap_borrow_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Self: Borrow<T>,
fn tap_borrow_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
impl<T> TapDeref for T
fn tap_deref<F, R>(self, func: F) -> Self where
F: FnOnce(&Self::Target) -> R,
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Self: Deref,
fn tap_deref_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&Self::Target) -> R,
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Self: Deref,
fn tap_deref_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
fn tap_deref_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
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> TryConv for T
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>,