Giter VIP home page Giter VIP logo

bubbletrouble14 / react-native-bls-signatures Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 0.0 29.41 MB

React Native wrapper for BLS Signatures

Home Page: https://www.npmjs.com/package/react-native-bls-signatures

License: MIT License

CMake 0.17% C++ 7.84% Java 0.08% JavaScript 0.14% C 85.87% TypeScript 5.26% Objective-C 0.12% Objective-C++ 0.07% Swift 0.01% Ruby 0.34% Kotlin 0.12%
bls12-381 cpp jini jsi react react-native chia

react-native-bls-signatures's Introduction

React Native BLS Signatures

This is a React Native wrapper for BLS Signatures that offers quick and direct bindings to the native C++ library, accessible through a user-friendly TypeScript API.

Installation

To use this library in your React Native project run the following command:

yarn add react-native-bls-signatures

or

npm install react-native-bls-signatures

Example

const seed = Uint8Array.from([
  0, 50, 6, 244, 24, 199, 1, 25, 52, 88, 192, 19, 18, 12, 89, 6, 220, 18, 102,
  58, 209, 82, 12, 62, 89, 110, 182, 9, 44, 20, 254, 22,
]).buffer;

const sk = AugSchemeMPL.keyGen(seed);
const pk = sk.getG1();

const message = Uint8Array.from([1, 2, 3, 4, 5]).buffer;
const signature = AugSchemeMPL.sign(sk, message);

const ok = AugSchemeMPL.verify(pk, message, signature);
console.log(ok); // true

Documentation

AugSchemeMPL

Static Methods:

  • skToG1(sk: PrivateKey) -> G1Element
  • keyGen(seed: ArrayBuffer) -> PrivateKey
  • sign(sk: PrivateKey, msg: ArrayBuffer) -> G2Element
  • signPrepend(sk: PrivateKey, msg: ArrayBuffer, prependPk: G1Element) -> G2Element
  • verify(pk: G1Element, msg: ArrayBuffer, sig: G2Element) -> boolean
  • aggregate(g2Elements: G2Element[]) -> G2Element
  • aggregateVerify(pks: G1Element[], msgs: ArrayBuffer[], sig: G2Element) -> boolean
  • deriveChildSk(sk: PrivateKey, index: number) -> PrivateKey
  • deriveChildSkUnhardened(sk: PrivateKey, index: number) -> PrivateKey
  • deriveChildPkUnhardened(pk: G1Element, index: number) -> G1Element

BasicSchemeMPL

Static Methods:

  • skToG1(sk: PrivateKey) -> G1Element
  • keyGen(seed: ArrayBuffer) -> PrivateKey
  • sign(sk: PrivateKey, msg: ArrayBuffer) -> G2Element
  • verify(pk: G1Element, msg: ArrayBuffer, sig: G2Element) -> boolean
  • aggregate(g2Elements: G2Element[]) -> G2Element
  • aggregateVerify(pks: G1Element[], msgs: ArrayBuffer[], sig: G2Element) -> boolean
  • deriveChildSk(sk: PrivateKey, index: number) -> PrivateKey
  • deriveChildSkUnhardened(sk: PrivateKey, index: number) -> PrivateKey
  • deriveChildPkUnhardened(pk: G1Element, index: number) -> G1Element

PopSchemeMPL

Static Methods:

  • skToG1(sk: PrivateKey) -> G1Element
  • keyGen(seed: ArrayBuffer) -> PrivateKey
  • sign(sk: PrivateKey, msg: ArrayBuffer) -> G2Element
  • verify(pk: G1Element, msg: ArrayBuffer, sig: G2Element) -> boolean
  • aggregate(g2Elements: G2Element[]) -> G2Element
  • aggregateVerify(pks: G1Element[], msgs: ArrayBuffer[], sig: G2Element) -> boolean
  • deriveChildSk(sk: PrivateKey, index: number) -> PrivateKey
  • deriveChildSkUnhardened(sk: PrivateKey, index: number) -> PrivateKey
  • deriveChildPkUnhardened(pk: G1Element, index: number) -> G1Element
  • popVerify(pk: G1Element, sigProof: G2Element) -> boolean
  • popProve(sk: PrivateKey) -> G2Element
  • fastAggregateVerify(pks: G1Element[], msg: ArrayBuffer, sig: G2Element) -> boolean

PrivateKey

Static Methods:

  • fromBytes(bytes: ArrayBuffer, modOrder?: boolean) -> PrivateKey
  • fromHex(hex: string) -> PrivateKey
  • aggregate(pks: PrivateKey[]) -> PrivateKey

Methods:

  • toBytes() -> ArrayBuffer
  • toHex() -> string
  • toString() -> string
  • equals(sk: PrivateKey) -> boolean
  • getG1() -> G1Element
  • getG2() -> G2Element

G1Element

Static Methods:

  • fromBytes(bytes: ArrayBuffer) -> G1Element
  • fromHex(hex: string) -> G1Element

Methods:

  • toBytes() -> ArrayBuffer
  • toHex() -> string
  • getFingerPrint() -> number
  • add(g1e: G1Element) -> G1Element
  • negate() -> G1Element
  • equals(g1e: G1Element) -> boolean

G2Element

Static Methods:

  • fromBytes(bytes: ArrayBuffer) -> G2Element
  • fromHex(hex: string) -> G2Element

Methods:

  • toBytes() -> ArrayBuffer
  • toHex() -> string
  • add(g2e: G2Element) -> G2Element
  • negate() -> G2Element
  • equals(g2e: G2Element) -> boolean

Utils

  • hash256(msg: ArrayBuffer) -> ArrayBuffer
  • toHex(bytes: ArrayBuffer) -> string
  • fromHex(hex: string) -> ArrayBuffer
  • getRandomSeed() -> ArrayBuffer Only use if sodium is enabled!

Libsodium license

The libsodium static library is licensed under the ISC license which requires the following copyright notice.

ISC License

Copyright (c) 2013-2020 Frank Denis <j at pureftpd dot org>

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

BLST license

BLST is used with the Apache 2.0 license

Resources

react-native-bls-signatures's People

Contributors

bubbletrouble14 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-native-bls-signatures's Issues

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.