Skip to main content
Version: v2.x

Minimal Anti Collusion Infrastructure (MACI) / Keypair

Class: Keypair

Defined in: keyPair.ts:16

Notice

A KeyPair is a pair of public and private keys This is a MACI keypair, which is not to be confused with an Ethereum public and private keypair. A MACI keypair is comprised of a MACI public key and a MACI private key

Constructors

new Keypair()

new Keypair(privKey?): Keypair

Defined in: keyPair.ts:26

Create a new instance of a Keypair

Parameters

privKey?

PrivKey

the private key (optional)

Returns

Keypair

Notice

if no privKey is passed, it will automatically generate a new private key

Properties

privKey

privKey: PrivKey

Defined in: keyPair.ts:17


pubKey

pubKey: PubKey

Defined in: keyPair.ts:19

Methods

copy()

copy(): Keypair

Defined in: keyPair.ts:41

Create a deep clone of this Keypair

Returns

Keypair

a copy of the Keypair


equals()

equals(keypair): boolean

Defined in: keyPair.ts:58

Check whether two Keypairs are equal

Parameters

keypair

Keypair

the keypair to compare with

Returns

boolean

whether they are equal or not


toJSON()

toJSON(): IJsonKeyPair

Defined in: keyPair.ts:75

Serialize into a JSON object

Returns

IJsonKeyPair


fromJSON()

static fromJSON(json): Keypair

Defined in: keyPair.ts:87

Deserialize into a Keypair instance

Parameters

json

IJsonKeyPair

Returns

Keypair

a keypair instance


genEcdhSharedKey()

static genEcdhSharedKey(privKey, pubKey): EcdhSharedKey

Defined in: keyPair.ts:49

Generate a shared key

Parameters

privKey

PrivKey

pubKey

PubKey

Returns

EcdhSharedKey