Skip to main content
Version: v3.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

Constructor

new Keypair(privateKey?): Keypair

Defined in: keyPair.ts:26

Create a new instance of a Keypair

Parameters

privateKey?

PrivateKey

the private key (optional)

Returns

Keypair

Notice

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

Properties

privateKey

privateKey: PrivateKey

Defined in: keyPair.ts:17


publicKey

publicKey: PublicKey

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:74

Serialize into a JSON object

Returns

IJsonKeyPair


fromJSON()

static fromJSON(json): Keypair

Defined in: keyPair.ts:86

Deserialize into a Keypair instance

Parameters

json

IJsonKeyPair

Returns

Keypair

a keypair instance


generateEcdhSharedKey()

static generateEcdhSharedKey(privateKey, publicKey): EcdhSharedKey

Defined in: keyPair.ts:49

Generate a shared key

Parameters

privateKey

PrivateKey

publicKey

PublicKey

Returns

EcdhSharedKey