use vrf::{
openssl::{CipherSuite, ECVRF},
VRF,
};
fn main() {
let mut vrf = ECVRF::from_suite(CipherSuite::SECP256K1_SHA256_TAI).unwrap();
let secret_key =
hex::decode("c9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721").unwrap();
let public_key = vrf.derive_public_key(&secret_key).unwrap();
let message: &[u8] = b"sample";
let pi = vrf.prove(&secret_key, &message).unwrap();
let hash = vrf.proof_to_hash(&pi).unwrap();
println!("Generated VRF proof: {}", hex::encode(&pi));
let beta = vrf.verify(&public_key, &pi, &message);
match beta {
Ok(beta) => {
println!("VRF proof is valid!\nHash output: {}", hex::encode(&beta));
assert_eq!(hash, beta);
}
Err(e) => {
println!("VRF proof is not valid: {}", e);
}
}
}