[][src]Module solana_libra_nextgen_crypto::vrf::ecvrf

This module implements an instantiation of a verifiable random function known as ECVRF-ED25519-SHA512-TAI.

Examples

use nextgen_crypto::{traits::Uniform, vrf::ecvrf::*};
use rand::{rngs::StdRng, SeedableRng};

let message = b"Test message";
let mut rng: StdRng = SeedableRng::from_seed([0; 32]);
let private_key = VRFPrivateKey::generate_for_testing(&mut rng);
let public_key: VRFPublicKey = (&private_key).into();

Note: The above example generates a private key using a private function intended only for testing purposes. Production code should find an alternate means for secure key generation.

Produce a proof for a message from a VRFPrivateKey, and verify the proof and message using a VRFPublicKey:

let proof = private_key.prove(message);
assert!(public_key.verify(&proof, message).is_ok());

Produce a pseudorandom output from a Proof:

let output: Output = (&proof).into();

Structs

Output

The ECVRF output produced from the proof

Proof

A VRF proof that can be used to validate an input with a public key

VRFExpandedPrivateKey

A longer private key which is slightly optimized for proof generation.

VRFPrivateKey

An ECVRF private key

VRFPublicKey

An ECVRF public key

Constants

OUTPUT_LENGTH

The number of bytes of Output

PROOF_LENGTH

The number of bytes of Proof