A pure Javascript Implementation of Verifiable Random Functions
$ yarn add vrf.js
const {utils, ecvrf, sortition} = require('vrf.js')
const X = Buffer.from('test')
const [publicKey, privateKey] = utils.generatePair()
const {value, proof} = ecvrf.vrf(publicKey, privateKey, X)
ecvrf.verify(publicKey, X, proof, value)
// true
const {utils, ecvrf, sortition} = require('vrf.js')
const seed = Buffer.from('sortition')
const role = Buffer.from('test')
const w = utils.N(100)
const W = utils.N(1000)
const tau = utils.N(10)
const [publicKey, privateKey] = utils.generatePair()
const [value, proof, j] = sortition.sortition(
privateKey, publicKey,
seed, tau, role, w, W
)
if (+j > 0) {
// next
}
- utils.generatePair
- utils.B
- utils.N
- ecvrf.vrf
- ecvrf.prove
- ecvrf.verify
- ecvrf.proofToHash
- ecvrf.hashToCurve
- sortition.sortition
- sortition.verifySort
- browser support
- web examples
- visualization
- RSA-FDH-VRF