This library provides flexible and efficient implementations of Verifiable Random Functions with Additional Data (VRF-AD), a cryptographic construct that augments a standard VRF scheme by incorporating auxiliary information into its signature.
It leverages the Arkworks framework and supports customization of scheme parameters.
- IETF VRF: Complies with ECVRF described in RFC9381.
- Pedersen VRF: Described in BCHSV23.
- Ring VRF: A zero-knowledge-based inspired by BCHSV23.
The library includes the following pre-configured suites:
- Ed25519-SHA-512-TAI: Supports IETF and Pedersen VRFs.
- Secp256r1-SHA-256-TAI: Supports IETF and Pedersen VRFs.
- Bandersnatch (Edwards curve on BLS12-381): Supports IETF, Pedersen, and Ring VRFs.
- JubJub (Edwards curve on BLS12-381): Supports IETF, Pedersen, and Ring VRFs.
- Baby-JubJub (Edwards curve on BN254): Supports IETF, Pedersen, and Ring VRFs.
use ark_ec_vrfs::suites::bandersnatch::*;
let secret = Secret::from_seed(b"example seed");
let public = secret.public();
let input = Input::new(b"example input");
let output = secret.output(input);
let aux_data = b"optional aux data";
Prove
use ark_ec_vrfs::ietf::Prover;
let proof = secret.prove(input, output, aux_data);
Verify
use ark_ec_vrfs::ietf::Verifier;
let result = public.verify(input, output, aux_data, &proof);
Ring construction
const RING_SIZE: usize = 100;
let prover_key_index = 3;
// Construct an example ring with dummy keys
let mut ring = (0..RING_SIZE).map(|i| Secret::from_seed(&i.to_le_bytes()).public().0).collect();
// Patch the ring with the public key of the prover
ring[prover_key_index] = public.0;
// Any key can be replaced with the padding point
ring[0] = RingContext::padding_point();
Ring context construction
let ring_ctx = RingContext::from_seed(RING_SIZE, b"example seed");
Prove
use ark_ec_vrfs::ring::Prover;
let prover_key = ring_ctx.prover_key(&ring);
let prover = ring_ctx.prover(prover_key, prover_key_index);
let proof = secret.prove(input, output, aux_data, &prover);
Verify
use ark_ec_vrfs::ring::Verifier;
let verifier_key = ring_ctx.verifier_key(&ring);
let verifier = ring_ctx.verifier(verifier_key);
let result = Public::verify(input, output, aux_data, &proof, &verifier);
Verifier key from commitment
let ring_commitment = ring_ctx.verifier_key().commitment();
let verifier_key = ring_ctx.verifier_key_from_commitment(ring_commitment);
Distributed under the MIT License.