Trait core_crypto::KeyPairSchema[][src]

pub trait KeyPairSchema: Sized + PartialEq + Debug + Copy {
    type Crypto: BlockCipher;
    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; fn to_bytes(&self) -> [u8; 64] { ... } }
Expand description

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

Associated Types

Required methods

fn random() -> Self[src]

Create a new Keypair with cryptographically random content.

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

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

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

Construct a Keypair from a hex encoded private key string.

fn from_private_key(pk: PrivateKey) -> Self[src]

Construct a Keypair PrivateKey type.

fn private_key(&self) -> PrivateKey[src]

fn public_key(&self) -> PublicKey[src]

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

Signs a data bytes with a Keypair.

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

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

fn from_null_private_key(pk: PublicKey) -> Self[src]

Provided methods

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

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.

Implementors