No Description

cgeek 93696340cd Add vrfVerifySignature 1 year ago
.vscode 3f3725c027 Module is ready 1 year ago
addon a48a52b984 Remove logs 1 year ago
lib 935e276f7e Missing lib/ folder 1 year ago
nodejs 3a2bbb3121 Works with functions.cc 1 year ago
randombytes 3a2bbb3121 Works with functions.cc 1 year ago
src f6cab08f96 Missing libsignal-protocol-c.pc.in 1 year ago
test 93696340cd Add vrfVerifySignature 1 year ago
.gitignore 1c7ff51a5d .gitignore 1 year ago
CMakeLists.txt 3a2bbb3121 Works with functions.cc 1 year ago
LICENSE 3a2bbb3121 Works with functions.cc 1 year ago
README.md cf8715492f Update README example 1 year ago
index.ts 93696340cd Add vrfVerifySignature 1 year ago
package.json 1cbb957fe1 install/prepublish distinction 1 year ago
tsconfig.json 3f3725c027 Module is ready 1 year ago
yarn.lock 3f3725c027 Module is ready 1 year ago

README.md

Overview

This module is a NodeJS C++ addon relying WhisperSystems/libsignal-protocol-c library to provide VRF (Verifiable Random Function) facilities using VXEdDSA crypto scheme.

Installation

With NPM:

npm install --save https://dev.cgeek.fr/cgeek/vrf-duniter.git

Usage

Look at this Unit Test example:

import { decodeUTF8 } from '../lib/nacl-utils';
import { keypairFromSeed, vrfSign, vrfVerify } from '../index';
import * as assert from "assert";

// A message we want to be signed
const message = decodeUTF8("my public message")

// A random seed (this one is public, don't use it for production)
const seed = new Uint8Array([
  0x38, 0x61, 0x1d, 0x25, 0x3b, 0xea, 0x85, 0xa2,
  0x03, 0x80, 0x53, 0x43, 0xb7, 0x4a, 0x93, 0x6d,
  0x3b, 0x13, 0xb9, 0xe3, 0x12, 0x14, 0x53, 0xe9,
  0x74, 0x0b, 0x6b, 0x82, 0x7e, 0x33, 0x7e, 0x5d
])

// Get a valid VXEdDSA keypair from a random seed
const pair = keypairFromSeed(seed)

// Signs a message
const sign = vrfSign(message, pair.pub, pair.sec)

// Verifies the signature + hash
if(vrfVerify(message, sign.signature, sign.hash, pair.pub)) {
  console.log('Verified!')
} else {
  console.log('Verification failed.')
}