Struct ed25519_dalek::Keypair [] [src]

pub struct Keypair {
    pub public: PublicKey,
    pub secret: SecretKey,
}

An ed25519 keypair.

Fields

The public half of this keypair.

The secret half of this keypair.

Methods

impl Keypair
[src]

Generate an ed25519 keypair.

Example

extern crate rand;
extern crate sha2;
extern crate ed25519_dalek;


use rand::Rng;
use rand::OsRng;
use sha2::Sha512;
use ed25519_dalek::Keypair;
use ed25519_dalek::Signature;

let mut cspring: OsRng = OsRng::new().unwrap();
let keypair: Keypair = Keypair::generate::<Sha512>(&mut cspring);

Input

A CSPRING with a fill_bytes() method, e.g. the one returned from rand::OsRng::new() (in the rand crate).

The caller must also supply a hash function which implements the Digest and Default traits, and which returns 512 bits of output. The standard hash function used for most ed25519 libraries is SHA-512, which is available with use sha2::Sha512 as in the example above. Other suitable hash functions include Keccak-512 and Blake2b-512.

Sign a message with this keypair's secret key.

Verify a signature on a message with this keypair's public key.

Trait Implementations

impl Debug for Keypair
[src]

Formats the value using the given formatter.