ecdsa::der

Struct Signature

Source
pub struct Signature<C>
where C: PrimeCurve, MaxSize<C>: ArrayLength<u8>, <FieldSize<C> as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,
{ /* private fields */ }
Expand description

ASN.1 DER-encoded signature.

Generic over the scalar size of the elliptic curve.

Implementations§

Source§

impl<C> Signature<C>
where C: PrimeCurve, MaxSize<C>: ArrayLength<u8>, <FieldSize<C> as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,

Source

pub fn len(&self) -> usize

Get the length of the signature in bytes

Source

pub fn as_bytes(&self) -> &[u8]

Borrow this signature as a byte slice

Source

pub fn to_bytes(&self) -> Box<[u8]>

Serialize this signature as a boxed byte slice

Trait Implementations§

Source§

impl<C> AsRef<[u8]> for Signature<C>
where C: PrimeCurve, MaxSize<C>: ArrayLength<u8>, <FieldSize<C> as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<C> Debug for Signature<C>
where C: PrimeCurve, MaxSize<C>: ArrayLength<u8>, <FieldSize<C> as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, C> Deserialize<'de> for Signature<C>
where C: PrimeCurve, MaxSize<C>: ArrayLength<u8>, <FieldSize<C> as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<C> PrehashSignature for Signature<C>
where C: PrimeCurve + DigestPrimitive, MaxSize<C>: ArrayLength<u8>, <FieldSize<C> as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,

Source§

type Digest = <C as DigestPrimitive>::Digest

Preferred Digest algorithm to use when computing this signature type.
Source§

impl<C> Serialize for Signature<C>
where C: PrimeCurve, MaxSize<C>: ArrayLength<u8>, <FieldSize<C> as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<C> Signature for Signature<C>
where C: PrimeCurve, MaxSize<C>: ArrayLength<u8>, <FieldSize<C> as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self>

Parse an ASN.1 DER-encoded ECDSA signature from a byte slice

§

fn as_bytes(&self) -> &[u8]

Borrow a byte slice representing the serialized form of this signature
Source§

impl<C> TryFrom<&[u8]> for Signature<C>
where C: PrimeCurve, MaxSize<C>: ArrayLength<u8>, <FieldSize<C> as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(input: &[u8]) -> Result<Self>

Performs the conversion.
Source§

impl<C> TryFrom<Signature<C>> for Signature<C>
where C: PrimeCurve, MaxSize<C>: ArrayLength<u8>, <FieldSize<C> as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(sig: Signature<C>) -> Result<Signature<C>>

Performs the conversion.

Auto Trait Implementations§

§

impl<C> Freeze for Signature<C>
where <<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Sized, <<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>>::Output: Sized, <<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>>::Output as ArrayLength<u8>>::ArrayType: Freeze,

§

impl<C> RefUnwindSafe for Signature<C>
where <<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Sized, <<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>>::Output: Sized, <<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>>::Output as ArrayLength<u8>>::ArrayType: RefUnwindSafe,

§

impl<C> Send for Signature<C>
where <<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Sized, <<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>>::Output: Sized,

§

impl<C> Sync for Signature<C>
where <<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Sized, <<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>>::Output: Sized,

§

impl<C> Unpin for Signature<C>
where <<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Sized, <<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>>::Output: Sized, <<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>>::Output as ArrayLength<u8>>::ArrayType: Unpin,

§

impl<C> UnwindSafe for Signature<C>
where <<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output: Sized, <<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>>::Output: Sized, <<<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as Add>::Output as Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>>::Output as ArrayLength<u8>>::ArrayType: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,