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.
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
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
- 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
- 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
- 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
- fromBytes(bytes:
ArrayBuffer
, modOrder?:boolean
) ->PrivateKey
- fromHex(hex:
string
) ->PrivateKey
- aggregate(pks:
PrivateKey[]
) ->PrivateKey
- toBytes() ->
ArrayBuffer
- toHex() ->
string
- toString() ->
string
- equals(sk:
PrivateKey
) ->boolean
- getG1() ->
G1Element
- getG2() ->
G2Element
- fromBytes(bytes:
ArrayBuffer
) ->G1Element
- fromHex(hex:
string
) ->G1Element
- toBytes() ->
ArrayBuffer
- toHex() ->
string
- getFingerPrint() ->
number
- add(g1e:
G1Element
) ->G1Element
- negate() ->
G1Element
- equals(g1e:
G1Element
) ->boolean
- fromBytes(bytes:
ArrayBuffer
) ->G2Element
- fromHex(hex:
string
) ->G2Element
- toBytes() ->
ArrayBuffer
- toHex() ->
string
- add(g2e:
G2Element
) ->G2Element
- negate() ->
G2Element
- equals(g2e:
G2Element
) ->boolean
- hash256(msg:
ArrayBuffer
) ->ArrayBuffer
- toHex(bytes:
ArrayBuffer
) ->string
- fromHex(hex:
string
) ->ArrayBuffer
- getRandomSeed() ->
ArrayBuffer
Only use if sodium is enabled!
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 is used with the Apache 2.0 license
- Chia-Network/bls-signatures code for bls
- Marc Rousavy thanks for all the examples
- animo/react-native-bbs-signatures also great example