Giter Site home page Giter Site logo

jonnycrunch / node-bbs-signatures Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mattrglobal/node-bbs-signatures

0.0 1.0 0.0 277 KB

An implementation of BBS+ signatures using rust and typescript for node.js

License: Apache License 2.0

JavaScript 1.81% Rust 35.20% TypeScript 61.06% Shell 1.93%

node-bbs-signatures's Introduction

Mattr logo

Node BBS Signatures

Master Release

This repository is the home to a performant multi-message digital signature algorithm implementation which supports deriving zero knowledge proofs that enable selective disclosure from the originally signed message set.

BBS+ Signatures are a digital signature algorithm originally born from the work on Short group signatures by Boneh, Boyen, and Shachum which was later improved on in Constant-Size Dynamic k-TAA as BBS+ and touched on again in section 4.3 in Anonymous Attestation Using the Strong Diffie Hellman Assumption Revisited .

BBS+ signatures require a pairing-friendly curve, this library includes support for BLS12-381.

BBS+ Signatures allow for multi-message signing whilst producing a single output signature. With a BBS signature, a proof of knowledge based proof can be produced where only some of the originally signed messages are revealed at the discretion of the prover.

For more details on the signature algorithm please refer to here

Getting started

To use this package within your project simply run

npm install @mattrglobal/node-bbs-signatures

Or with Yarn

yarn add @mattrglobal/node-bbs-signatures

Usage

The following is a short sample on how to use the API

import {
  generateBls12381KeyPair,
  blsSign,
  blsVerify,
  blsCreateProof,
  blsVerifyProof,
} from "@mattrglobal/node-bbs-signatures";

//Generate a new key pair
const keyPair = generateBls12381KeyPair();

//Set of messages we wish to sign
const messages = ["message1", "message2"];

//Create the signature
const signature = blsSign({
  keyPair,
  messages: messages,
});

//Verify the signature
const isVerified = blsVerify({
  publicKey: keyPair.publicKey,
  messages: messages,
  signature,
});

//Derive a proof from the signature revealing the first message
const proof = blsCreateProof({
  signature,
  publicKey: keyPair.publicKey,
  messages,
  nonce: "nonce",
  revealed: [0],
});

//Verify the created proof
const isProofVerified = blsVerifyProof({
  proof,
  publicKey: keyPair.publicKey,
  messageCount: messages.length,
  messages: messages.slice(0, 1),
  nonce: "nonce",
  revealed: [0],
});

Element Size

Within a digital signature there are several elements for which it is useful to know the size, the following table outlines the general equation for calculating element sizes in relation to BBS+ signatures as it is dependent on the pairing friendly curve used.

Element Size Equation
Private Key F
Public Key G2
Signature G1 + 2*F
Proof 5*G1 + (4 + no_of_hidden_messages)*F
  • F A field element
  • G1 A point in the field of G1
  • G2 A point in the field of G2
  • no_of_hidden_messages The number of the hidden messages

This library includes specific support for BLS12-381 keys with BBS+ signatures and hence gives rise to the following concrete sizes

Element Size with BLS12-381
Private Key 32 Bytes
Public Key 96 Bytes
Signature 112 Bytes
Proof 368 + (no_of_hidden_messages)*32 Bytes

Getting started as a contributor

The following describes how to get started as a contributor to this project

Prerequisites

The following is a list of dependencies you must install to build and contribute to this project

For more details see our contribution guidelines

Install

To install the package dependencies run:

yarn install --frozen-lockfile

Build

To build the project run:

yarn build

Test

To run the test in the project run:

yarn test

Benchmark

To benchmark the implementation locally run:

yarn benchmark

Dependencies

This library uses the bbs rust crate for the implementation of BBS+ signatures and BLS12-381 which is then wrapped and exposed in javascript/typescript using neon-bindings.

Relevant References

For those interested in more details, you might find the following resources helpful

node-bbs-signatures's People

Contributors

tplooker avatar mikelodder7 avatar liam-tait avatar kdenhartog avatar telegramsam avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.