Skip to main content

Signature

Trait Signature 

Source
pub trait Signature: Clone + Sized {
    type PublicKey: PublicKey;

    const LENGTH: usize;

    // Required methods
    fn from_bytes(bytes: &[u8]) -> AptosResult<Self>;
    fn to_bytes(&self) -> Vec<u8> ;

    // Provided method
    fn to_hex(&self) -> String { ... }
}
Expand description

A trait for signature types.

Required Associated Constants§

Source

const LENGTH: usize

The length of the signature in bytes.

Required Associated Types§

Source

type PublicKey: PublicKey

The public key type for this signature scheme.

Required Methods§

Source

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

Creates a signature from bytes.

§Errors

Returns an error if the bytes have an invalid length or format.

Source

fn to_bytes(&self) -> Vec<u8>

Returns the signature as bytes.

Provided Methods§

Source

fn to_hex(&self) -> String

Returns the signature as a hex string with 0x prefix.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Signature for Bls12381Signature

Available on crate feature bls only.
Source§

const LENGTH: usize = BLS12381_SIGNATURE_LENGTH

Source§

type PublicKey = Bls12381PublicKey

Source§

impl Signature for Ed25519Signature

Available on crate feature ed25519 only.
Source§

const LENGTH: usize = ED25519_SIGNATURE_LENGTH

Source§

type PublicKey = Ed25519PublicKey

Source§

impl Signature for MultiEd25519Signature

Available on crate feature ed25519 only.
Source§

impl Signature for Secp256k1Signature

Available on crate feature secp256k1 only.
Source§

const LENGTH: usize = SECP256K1_SIGNATURE_LENGTH

Source§

type PublicKey = Secp256k1PublicKey

Source§

impl Signature for Secp256r1Signature

Available on crate feature secp256r1 only.
Source§

const LENGTH: usize = SECP256R1_SIGNATURE_LENGTH

Source§

type PublicKey = Secp256r1PublicKey