Skip to content

A pure Javascript Implementation of Verifiable Random Functions

License

Notifications You must be signed in to change notification settings

deepgitUT/vrf.js

This branch is 9 commits ahead of SuwakoKochiya/vrf.js:master.

Repository files navigation

A pure Javascript Implementation of Verifiable Random Functions

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

About

A pure Javascript Implementation of Verifiable Random Functions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 53.6%
  • TypeScript 46.4%