Skip to main content
Version: v3.x

Minimal Anti Collusion Infrastructure (MACI) / PrivateKey

Class: PrivateKey

Defined in: privateKey.ts:14

Notice

PrivateKey is a TS Class representing a MACI PrivateKey which is a seed to be used to generate a public key (point on the curve) This is a MACI private key, which is not to be confused with an Ethereum private key. A serialized MACI private key is prefixed by 'macisk.'

Constructors

Constructor

new PrivateKey(raw): PrivateKey

Defined in: privateKey.ts:21

Generate a new Private key object

Parameters

raw

SnarkBigNumber

the raw private key (a bigint)

Returns

PrivateKey

Properties

raw

raw: SnarkBigNumber

Defined in: privateKey.ts:15

Methods

asCircuitInputs()

asCircuitInputs(): string

Defined in: privateKey.ts:35

Return this Private key as a circuit input

Returns

string

the Private key as a circuit input


copy()

copy(): PrivateKey

Defined in: privateKey.ts:29

Create a copy of this Private key

Returns

PrivateKey

a copy of the Private key


serialize()

serialize(): string

Defined in: privateKey.ts:41

Serialize the private key

Returns

string

the serialized private key


toJSON()

toJSON(): IJsonPrivateKey

Defined in: privateKey.ts:75

Serialize this object

Returns

IJsonPrivateKey


deserialize()

static deserialize(s): PrivateKey

Defined in: privateKey.ts:55

Deserialize the private key

Parameters

s

string

the serialized private key

Returns

PrivateKey

the deserialized private key


fromJSON()

static fromJSON(json): PrivateKey

Defined in: privateKey.ts:86

Deserialize this object from a JSON object

Parameters

json

IJsonPrivateKey

the json object

Returns

PrivateKey

the deserialized object as a PrivateKey instance


isValidSerialized()

static isValidSerialized(serialized): boolean

Defined in: privateKey.ts:65

Check if the serialized private key is valid

Parameters

serialized

string

the serialized private key

Returns

boolean

whether it is a valid serialized private key