### Table of Contents - [onModuleInit](#onmoduleinit) - [MCLBN_CURVE_FP254BNB](#mclbn_curve_fp254bnb) - [MCLBN_CURVE_FP382_1](#mclbn_curve_fp382_1) - [MCLBN_CURVE_FP382_2](#mclbn_curve_fp382_2) - [init](#init) - [secretKey](#secretkey) - [publicKey](#publickey) - [signature](#signature) - [free](#free) - [freeArray](#freearray) - [idSetInt](#idsetint) - [sign](#sign) - [verify](#verify) - [publicKeyExport](#publickeyexport) - [secretKeyExport](#secretkeyexport) - [signatureExport](#signatureexport) - [hashToSecretKey](#hashtosecretkey) - [secretKeyDeserialize](#secretkeydeserialize) - [secretKeyImport](#secretkeyimport) - [publicKeyDeserialize](#publickeydeserialize) - [publicKeyImport](#publickeyimport) - [signatureDeserialize](#signaturedeserialize) - [signatureImport](#signatureimport) - [secretKeyRecover](#secretkeyrecover) - [publicKeyRecover](#publickeyrecover) - [signatureRecover](#signaturerecover) - [secretKeyShare](#secretkeyshare) - [publicKeyShare](#publickeyshare) ## onModuleInit [index.js:13-20](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L13-L20 "Source code on GitHub") takes a callback that is called once the module is setup **Parameters** - `cb` ## MCLBN_CURVE_FP254BNB [index.js:25-25](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L25-L25 "Source code on GitHub") the FP254BNB curve ## MCLBN_CURVE_FP382_1 [index.js:30-30](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L30-L30 "Source code on GitHub") the FP382_1 curve ## MCLBN_CURVE_FP382_2 [index.js:35-35](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L35-L35 "Source code on GitHub") the FP382_2 curve ## init [index.js:52-54](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L52-L54 "Source code on GitHub") intailizes the libary to use a given curve **Parameters** - `curve` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the curves that can be used are MCLBN_CURVE_FP254BNB, MCLBN_CURVE_FP382_1 or MCLBN_CURVE_FP382_2 (optional, default `exports.MCLBN_CURVE_FP254BNB`) ## secretKey [index.js:60-62](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L60-L62 "Source code on GitHub") allocates a secret key Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the pointer to the key ## publicKey [index.js:68-70](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L68-L70 "Source code on GitHub") allocates a secret key Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the pointer to the key ## signature [index.js:76-78](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L76-L78 "Source code on GitHub") allocates a signature Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the pointer to the signture ## free [index.js:83-85](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L83-L85 "Source code on GitHub") frees a pointer **Parameters** - `x` ## freeArray [index.js:90-92](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L90-L92 "Source code on GitHub") frees an array of pointers **Parameters** - `a` ## idSetInt [index.js:99-104](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L99-L104 "Source code on GitHub") creates an ID to use in with threshold groups **Parameters** - `sk` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to the secret key, secret key stuct is used to hold the id - `n` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a int repsenting the ID. n cannot be zero. ## sign [index.js:112-112](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L112-L112 "Source code on GitHub") signs a message **Parameters** - `sig` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to the a signature - `sk` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to the secret key - `msg` **([TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) \| [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String))** the message to sign ## verify [index.js:120-120](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L120-L120 "Source code on GitHub") verifies a signature **Parameters** - `sig` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to the a signature - `pk` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to the secret key - `msg` **([TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) \| [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String))** the message that was signed ## publicKeyExport [index.js:127-127](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L127-L127 "Source code on GitHub") given a pointer to a public key this returns 64 byte Int8Array containing the key **Parameters** - `pk` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to the secret key Returns **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** ## secretKeyExport [index.js:134-134](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L134-L134 "Source code on GitHub") given a pointer to a secret key this returns 32 byte Int8Array containing the key **Parameters** - `pk` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to the secret key Returns **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** ## signatureExport [index.js:141-141](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L141-L141 "Source code on GitHub") given a pointer to a signature this returns 32 byte Int8Array containing the signature **Parameters** - `pk` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to the secret key Returns **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** ## hashToSecretKey [index.js:148-148](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L148-L148 "Source code on GitHub") generates a secret key given a seed phrase. **Parameters** - `sk` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a secret key - `seed` **([String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray))** the seed phrase ## secretKeyDeserialize [index.js:155-155](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L155-L155 "Source code on GitHub") write a secretKey to memory **Parameters** - `sk` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a secret key - `array` **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** the secret key as a 32 byte TypedArray ## secretKeyImport [index.js:163-167](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L163-L167 "Source code on GitHub") write a secretKey to memory and returns a pointer to it **Parameters** - `buf` - `sk` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a secret key - `array` **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** the secret key as a 32 byte TypedArray Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** ## publicKeyDeserialize [index.js:174-174](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L174-L174 "Source code on GitHub") write a publicKey to memory **Parameters** - `sk` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a public key - `array` **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** the secret key as a 64 byte TypedArray ## publicKeyImport [index.js:181-185](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L181-L185 "Source code on GitHub") write a publicKey to memory and returns a pointer to it **Parameters** - `buf` - `array` **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** the secret key as a 64 byte TypedArray Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** ## signatureDeserialize [index.js:192-192](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L192-L192 "Source code on GitHub") write a signature to memory **Parameters** - `sig` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a signature - `array` **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** the signature as a 32 byte TypedArray ## signatureImport [index.js:199-203](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L199-L203 "Source code on GitHub") write a signature to memory and returns a pointer to it **Parameters** - `buf` - `array` **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)** the signature as a 32 byte TypedArray Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** ## secretKeyRecover [index.js:211-211](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L211-L211 "Source code on GitHub") Recovers a secret key for a group given the groups secret keys shares and the groups ids **Parameters** - `sk` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a secret key that will be generated - `sksArray` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** an array of pointers to the groups secret key shares. The length of the array should be the threshold number for the group - `idArrah` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<numbers>** an array of pointers to ids in the groups. The length of the array should be the threshold number for the group ## publicKeyRecover [index.js:219-219](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L219-L219 "Source code on GitHub") Recovers a public key for a group given the groups public keys shares and the groups ids **Parameters** - `pk` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a secret key that will be generated - `pksArray` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** an array of pointers to the groups public key shares. The length of the array should be the threshold number for the group - `idArrah` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<numbers>** an array of pointers to ids in the groups. The length of the array should be the threshold number for the group ## signatureRecover [index.js:227-227](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L227-L227 "Source code on GitHub") Recovers a signature for a group given the groups public keys shares and the groups ids **Parameters** - `sig` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to the signature that will be generated - `sigArray` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** an array of pointers to signature shares. The length of the array should be the threshold number for the group - `idArrah` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<numbers>** an array of pointers to ids in the groups. The length of the array should be the threshold number for the group ## secretKeyShare [index.js:235-235](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L235-L235 "Source code on GitHub") Creates a secket key share for a group member given the groups members id (which is a the secret key) and array of master secret keys **Parameters** - `skshare` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a secret key that will be generated - `msk` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** an array of master secret keys. The number of keys is the threshould of the group. - `id` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the id of the member ## publicKeyShare [index.js:243-243](https://github.com/wanderer/bls-lib/blob/0e97e39f3b15ac41e2d87017b73dcad5b6950276/index.js#L243-L243 "Source code on GitHub") Creates a public key share for a group member given the groups members id (which is a the secret key) and array of master public keys **Parameters** - `pkshare` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a secret key that will be generated - `mpk` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** an array of master public keys. The number of keys is the threshould of the group. - `id` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the id of the member