[][src]Trait tari_crypto::keys::SecretKey

pub trait SecretKey: ByteArray + Clone + PartialEq + Eq + Add<Output = Self> + Default {
    fn key_length() -> usize;
fn random<R: Rng + CryptoRng>(rng: &mut R) -> Self; }

A trait specifying common behaviour for representing SecretKeys. Specific elliptic curve implementations need to implement this trait for them to be used in Tari.

Example

Assuming there is a Ristretto implementation,

This code runs with edition 2018
let mut rng = rand::thread_rng();
let k = RistrettoSecretKey::random(&mut rng);
let p = RistrettoPublicKey::from_secret_key(&k);

Required methods

fn key_length() -> usize

fn random<R: Rng + CryptoRng>(rng: &mut R) -> Self

Loading content...

Implementors

impl SecretKey for RistrettoSecretKey[src]

fn random<R: Rng + CryptoRng>(rng: &mut R) -> Self[src]

Return a random secret key on the ristretto255 curve using the supplied CSPRNG.

Loading content...