New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@switchboard-xyz/ecvrf-wasm

Package Overview
Dependencies
Maintainers
5
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@switchboard-xyz/ecvrf-wasm

WASM tool for generating and verifying ECVRFs on the Ed25519 curve using the Ristretto group

  • 1.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-88.89%
Maintainers
5
Weekly downloads
 
Created
Source

ecvrf-wasm

A JS compatibile compiled web assembly module (WASM) to prove and verify a verifiable random function for use on Solana.

Install

npm i --save @switchboard-xyz/ecvrf-wasm

Usage

To calculate a VRF proof

import ecvrf from "@switchboard-xyz/ecvrf-wasm";
import { Keypair } from "@solana/web3.js";

// oracle's secret key
let producerKeypair: Keypair;
// sourced from vrf.currentRound.alpha as Buffer converted to hex string
let alphaHex: string; 
const secretHex: string = Buffer.from(
  producerKeypair.secretKey.slice(0, producerKeypair.secretKey.length - 32)
).toString("hex");

const proofHexString: string = ecvrf.ecvrf_prove(secretHex, alphaHex);
console.log(`PROOF = ${proofHexString}`);

To verify a VRF proof

import ecvrf from "@switchboard-xyz/ecvrf-wasm";
import { PublicKey } from "@solana/web3.js";

// oracle's public key
let producerPubkey: PublicKey;
// sourced from vrf.builders[0].reprProof as Buffer converted to hex string
let proofHex: string;
// sourced from vrf.currentRound.alpha as Buffer converted to hex string
let alphaHex: string;

const verified: boolean = ecvrf.ecvrf_verify(
  producerPubkey.toBuffer().toString("hex"),
  proofHex,
  alphaHex
);
if (!verified) {
  throw new Error(`VRF proof was not verified`);
}

Keywords

FAQs

Package last updated on 08 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc