10 unstable releases (3 breaking)

0.4.3 Feb 4, 2021
0.4.2 Nov 16, 2020
0.4.0 Jun 18, 2020
0.3.3 Jun 12, 2020
0.1.1 May 12, 2019

#879 in Cryptography

Download history 28/week @ 2022-06-07 6/week @ 2022-06-14 9/week @ 2022-06-21 15/week @ 2022-06-28 15/week @ 2022-07-05 31/week @ 2022-07-12 14/week @ 2022-07-19 27/week @ 2022-07-26 30/week @ 2022-08-02 12/week @ 2022-08-09 7/week @ 2022-08-16 16/week @ 2022-08-23 5/week @ 2022-08-30 28/week @ 2022-09-06 20/week @ 2022-09-13 6/week @ 2022-09-20

59 downloads per month


190 lines


VRFs (Verifiable random functions) are great tools in decentralized systems because they can introduce random oracles into a protocol without the fear of data manipulation from a trusted party. These oracle functions are proven to be as hard to manipulate as breaking a particular cryptographic trapdoor.

See more in Micali's groundbreaking publication: https://people.csail.mit.edu/silvio/Selected%20Scientific%20Papers/Pseudo%20Randomness/Verifiable_Random_Functions.pdf

This elliptic curve instantiation was originally subject to exhaustive research in order to improve DNSSEC and proven to have the Trusted Uniqueness and Selective Pseudorandomness properties: https://eprint.iacr.org/2014/905.pdf

How is this different from traditional signatures?

An even more naive explanation of VRFs is that they are HMACs where the key is asymmetric. The parties agree on a pseudorandom function (SHA3) and exchange a proof with the same pseudorandomness that binds to the input but doesn't serve as the only witness (which is the case with simple SHA).

comparison table


use ecvrf::{VrfSk, VrfPk, VrfProof, keygen, prove, verify};
fn main() {
	let (privkey, pubkey): VrfSk = keygen()
						   let input = vec![0xde, 0xad, 0xbe, 0xef];
	let (output, proof) = ecvrf::prove(&input, privkey);
	assert!(ecvrf::verify(&input, &pubkey, output, proof));

You can serialize/deserialize each type with the corresponding to_bytes and from_bytes functions


This distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, possession, use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted. See http://www.wassenaar.org/ for more information.


~43K SLoC