KeyPairSchema

Trait KeyPairSchema 

Source
pub trait KeyPairSchema:
    Sized
    + PartialEq
    + Debug
    + Copy {
    type Crypto: BlockCipher;

    // Required methods
    fn random() -> Self;
    fn from_bytes(bytes: &[u8]) -> Result<Self>;
    fn from_hex_private_key<S: AsRef<str>>(hex: S) -> Result<Self>;
    fn from_private_key(pk: PrivateKey) -> Self;
    fn private_key(&self) -> PrivateKey;
    fn public_key(&self) -> PublicKey;
    fn sign(&self, data: &[u8]) -> Signature;
    fn verify(&self, data: &[u8], signature: Signature) -> Result<()>;
    fn from_null_private_key(pk: PublicKey) -> Self;

    // Provided method
    fn to_bytes(&self) -> [u8; 64] { ... }
}
Expand description

This trait defines a schema: an association of symbol or nis1 keypair type.

Required Associated Types§

Required Methods§

Source

fn random() -> Self

Create a new Keypair with cryptographically random content.

Source

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

Construct a Keypair from the bytes of a PublicKey and PrivateKey.

Source

fn from_hex_private_key<S: AsRef<str>>(hex: S) -> Result<Self>

Construct a Keypair from a hex encoded private key string.

Source

fn from_private_key(pk: PrivateKey) -> Self

Construct a Keypair PrivateKey type.

Source

fn private_key(&self) -> PrivateKey

Source

fn public_key(&self) -> PublicKey

Source

fn sign(&self, data: &[u8]) -> Signature

Signs a data bytes with a Keypair.

Source

fn verify(&self, data: &[u8], signature: Signature) -> Result<()>

Verify a Signature on a data with this Keypair public key.

Source

fn from_null_private_key(pk: PublicKey) -> Self

Provided Methods§

Source

fn to_bytes(&self) -> [u8; 64]

Convert this keypair to bytes.

§Returns

An array of bytes, [u8; KEYPAIR_LENGTH]. The first KEY_BYTES_SIZE of bytes is the PrivateKey, and the next KEY_BYTES_SIZE bytes is the PublicKey.

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§