Skip to content

Latest commit

 

History

History
430 lines (248 loc) · 19.9 KB

File metadata and controls

430 lines (248 loc) · 19.9 KB

Table of Contents

onModuleInit

index.js:14-21

Takes a callback that is called once the module is setup

Parameters

  • cb

MCLBN_CURVE_FP254BNB

index.js:26-26

The FP254BNB curve

MCLBN_CURVE_FP382_1

index.js:31-31

The FP382_1 curve

MCLBN_CURVE_FP382_2

index.js:36-36

The FP382_2 curve

init

index.js:49-51

Initializes the library to use a given curve

Parameters

  • curve 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:57-59

Allocates a secret key

Returns number the pointer to the key

publicKey

index.js:65-67

Allocates a secret key

Returns number the pointer to the key

signature

index.js:73-75

Allocates a signature

Returns number the pointer to the signature

free

index.js:80-82

Frees a pointer

Parameters

  • x

freeArray

index.js:87-89

Frees an array of pointers

Parameters

  • a

idSetInt

index.js:96-101

Creates an ID from an int to use with threshold groups

Parameters

  • sk number a pointer to the secret key, secret key struct is used to hold the id
  • n number a int representing the ID. n cannot be zero.

idImportFromInt

index.js:108-112

Creates an ID from an int and returns a pointer to it

Parameters

  • n number a int representing the ID. n cannot be zero.

Returns number

idImport

index.js:119-127

Creates an ID from an int and returns a pointer to it

Parameters

  • n number a int representing the ID. n cannot be zero.

Returns number

sign

index.js:135-135

Signs a message

Parameters

verify

index.js:144-144

Verifies a signature

Parameters

Returns Boolean

publicKeyExport

index.js:151-151

Given a pointer to a public key, this returns a 64 byte Int8Array containing the key

Parameters

  • pk number a pointer to the secret key

Returns TypedArray

secretKeyExport

index.js:158-158

Given a pointer to a secret key, this returns a 32 byte Int8Array containing the key

Parameters

  • pk number a pointer to the secret key

Returns TypedArray

signatureExport

index.js:165-165

Given a pointer to a signature, this returns a 32 byte Int8Array containing the signature

Parameters

  • pk number a pointer to the secret key

Returns TypedArray

hashToSecretKey

index.js:172-172

Generates a secret key given a seed phrase

Parameters

secretKeyDeserialize

index.js:179-179

Writes a secretKey to memory

Parameters

  • sk number a pointer to a secret key
  • array TypedArray the secret key as a 32 byte TypedArray

secretKeyImport

index.js:187-191

Writes a secretKey to memory and returns a pointer to it

Parameters

  • buf
  • sk number a pointer to a secret key
  • array TypedArray the secret key as a 32 byte TypedArray

Returns Number

publicKeyDeserialize

index.js:198-198

Writes a publicKey to memory

Parameters

  • sk number a pointer to a public key
  • array TypedArray the secret key as a 64 byte TypedArray

publicKeyImport

index.js:205-209

Writes a publicKey to memory and returns a pointer to it

Parameters

  • buf
  • array TypedArray the secret key as a 64 byte TypedArray

Returns Number

signatureDeserialize

index.js:216-216

Writes a signature to memory

Parameters

  • sig number a pointer to a signature
  • array TypedArray the signature as a 32 byte TypedArray

signatureImport

index.js:223-227

Writes a signature to memory and returns a pointer to it

Parameters

  • buf
  • array TypedArray the signature as a 32 byte TypedArray

Returns Number

secretKeySetByCSPRNG

index.js:233-233

Initializes a secret key by a Cryptographically Secure Pseudo Random Number Generator

Parameters

getPublicKey

index.js:240-240

Creates a public key from the secret key

Parameters

secretKeyRecover

index.js:248-248

Recovers a secret key for a group given the groups secret keys shares and the groups ids

Parameters

  • sk number a pointer to a secret key that will be generated
  • sksArray Array<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<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:256-256

Recovers a public key for a group given the groups public keys shares and the groups ids

Parameters

  • pk number a pointer to a public key that will be generated
  • pksArray Array<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<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:264-264

Recovers a signature for a group given the groups public keys shares and the groups ids

Parameters

  • sig number a pointer to the signature that will be generated
  • sigArray Array<number> an array of pointers to signature shares. The length of the array should be the threshold number for the group
  • idArrah 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:272-272

Creates a secret key share for a group member given the groups members id (which is the secret key) and array of master secret keys

Parameters

  • skshare number a pointer to a secret key that will be generated
  • msk Array<number> an array of master secret keys. The number of keys is the threshold of the group.
  • id number the id of the member

publicKeyShare

index.js:280-280

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 a pointer to a secret key that will be generated
  • mpk Array<number> an array of master public keys. The number of keys is the threshold of the group.
  • id number the id of the member

publicKeyAdd

index.js:287-287

Takes two publicKeys and adds them together. pubkey1 = pubkey1 + pubkey2

Parameters

  • pubkey1 number a pointer to a public key
  • pubkey2 number a pointer to a public key

secretKeyAdd

index.js:294-294

Takes two secretKeys and adds them together. seckey1 = seckey1 + seckey2

Parameters

  • seckey1 number a pointer to a secret key
  • seckey2 number a pointer to a secret key

publicKeyIsEqual

index.js:302-302

Takes two publicKeys and tests their equality

Parameters

  • pubkey1 number a pointer to a public key
  • pubkey2 number a pointer to a public key return {Boolean}

dhKeyExchange

index.js:310-310

Does Diffie–Hellman key exchange

Parameters

  • sharedSecretKey number a pointer to a secretKey that will be populated with the shared secret
  • secretKey number a pointer to a secret key
  • pubkey number a pointer to a public key