Trait ring_compat::signature::Signature[][src]

pub trait Signature: AsRef<[u8]> + Debug {
    pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>;

    pub fn as_bytes(&self) -> &[u8] { ... }
}
This is supported on crate feature signature only.

Trait impl’d by concrete types that represent digital signatures.

Signature types must (as mandated by the AsRef<[u8]> bound) be a thin wrapper around the “bag-of-bytes” serialized form of a signature which can be directly parsed from or written to the “wire”.

Inspiration for this approach comes from the Ed25519 signature system, which adopted it based on the observation that past signature systems were not prescriptive about how signatures should be represented on-the-wire, and that lead to a proliferation of different wire formats and confusion about which ones should be used.

The Signature trait aims to provide similar simplicity by minimizing the number of steps involved to obtain a serializable signature and ideally ensuring there is one signature type for any given signature system shared by all “provider” crates.

For signature systems which require a more advanced internal representation (e.g. involving decoded scalars or decompressed elliptic curve points) it’s recommended that “provider” libraries maintain their own internal signature type and use From bounds to provide automatic conversions.

Required methods

pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>[src]

Parse a signature from its byte representation

Loading content...

Provided methods

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

Borrow a byte slice representing the serialized form of this signature

Loading content...

Implementors

impl Signature for ring_compat::signature::ed25519::Signature[src]

impl<C> Signature for ring_compat::signature::ecdsa::der::Signature<C> where
    C: Curve + Order,
    <C as Curve>::FieldSize: Add<<C as Curve>::FieldSize>,
    <C as Curve>::FieldSize: ArrayLength<u8>,
    <C as Curve>::FieldSize: NonZero,
    <<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output as Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>>::Output: ArrayLength<u8>,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>, 
[src]

pub fn from_bytes(bytes: &[u8]) -> Result<Signature<C>, Error>[src]

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

impl<C> Signature for ring_compat::signature::ecdsa::Signature<C> where
    C: Curve + Order,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>, 
[src]

Loading content...