0.0.5 • Published 4 years ago

vrf.js v0.0.5

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

Install

$ yarn add vrf.js

Usage

ECVRF

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

VRF Sortition

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
}

more examples

APIs

  • utils.generatePair
  • utils.B
  • utils.N
  • ecvrf.vrf
  • ecvrf.prove
  • ecvrf.verify
  • ecvrf.proofToHash
  • ecvrf.hashToCurve
  • sortition.sortition
  • sortition.verifySort

TODOs

  • browser support
  • web examples
  • visualization
  • RSA-FDH-VRF