Skip to main content
Version: v2.0_alpha

Keypair

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

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new Keypair(privKey?): Keypair

Create a new instance of a Keypair

Parameters

NameTypeDescription
privKey?PrivKeythe private key (optional)

Returns

Keypair

Notice

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

Defined in

keyPair.ts:26

Properties

privKey

privKey: PrivKey

Defined in

keyPair.ts:17


pubKey

pubKey: PubKey

Defined in

keyPair.ts:19

Methods

copy

copy(): Keypair

Create a deep clone of this Keypair

Returns

Keypair

a copy of the Keypair

Defined in

keyPair.ts:41


equals

equals(keypair): boolean

Check whether two Keypairs are equal

Parameters

NameTypeDescription
keypairKeypairthe keypair to compare with

Returns

boolean

whether they are equal or not

Defined in

keyPair.ts:58


toJSON

toJSON(): IJsonKeyPair

Serialize into a JSON object

Returns

IJsonKeyPair

Defined in

keyPair.ts:75


fromJSON

fromJSON(json): Keypair

Deserialize into a Keypair instance

Parameters

NameType
jsonIJsonKeyPair

Returns

Keypair

a keypair instance

Defined in

keyPair.ts:87


genEcdhSharedKey

genEcdhSharedKey(privKey, pubKey): EcdhSharedKey

Generate a shared key

Parameters

NameType
privKeyPrivKey
pubKeyPubKey

Returns

EcdhSharedKey

Defined in

keyPair.ts:49