Skip to main content
Version: v1.2

PubKey

Notice

A class representing a public key This is a MACI public key, which is not to be confused with an Ethereum public key. A serialized MACI public key is prefixed by 'macipk.' A raw MACI public key can be thought as a pair of BigIntegers (x, y) representing a point on the baby jubjub curve

Table of contents​

Constructors​

Properties​

Methods​

Constructors​

constructor​

• new PubKey(rawPubKey): PubKey

Create a new instance of a public key

Parameters​

NameTypeDescription
rawPubKeyPubKeythe raw public key

Returns​

PubKey

Defined in​

publicKey.ts:24

Properties​

rawPubKey​

• rawPubKey: PubKey

Defined in​

publicKey.ts:18

Methods​

asArray​

▸ asArray(): bigint[]

Return this public key as an array of bigints

Returns​

bigint[]

the public key as an array of bigints

Defined in​

publicKey.ts:59


asCircuitInputs​

▸ asCircuitInputs(): string[]

Return this public key as circuit inputs

Returns​

string[]

an array of strings

Defined in​

publicKey.ts:53


asContractParam​

▸ asContractParam(): IG1ContractParams

Return this public key as smart contract parameters

Returns​

IG1ContractParams

the public key as smart contract parameters

Defined in​

publicKey.ts:40


copy​

▸ copy(): PubKey

Create a copy of the public key

Returns​

PubKey

a copy of the public key

Defined in​

publicKey.ts:34


equals​

▸ equals(p): boolean

Check whether this public key equals to another public key

Parameters​

NameTypeDescription
pPubKeythe public key to compare with

Returns​

boolean

whether they match

Defined in​

publicKey.ts:92


hash​

▸ hash(): bigint

Hash the two baby jubjub coordinates

Returns​

bigint

the hash of this public key

Defined in​

publicKey.ts:85


serialize​

▸ serialize(): string

Generate a serialized public key from this public key object

Returns​

string

the string representation of a serialized public key

Defined in​

publicKey.ts:65


toJSON​

▸ toJSON(): IJsonPublicKey

Serialize this object

Returns​

IJsonPublicKey

Defined in​

publicKey.ts:128


deserialize​

▸ deserialize(s): PubKey

Deserialize a serialized public key

Parameters​

NameTypeDescription
sstringthe serialized public key

Returns​

PubKey

the deserialized public key

Defined in​

publicKey.ts:99


fromJSON​

▸ fromJSON(json): PubKey

Deserialize a JSON object into a PubKey instance

Parameters​

NameTypeDescription
jsonIJsonPublicKeythe json object

Returns​

PubKey

PubKey

Defined in​

publicKey.ts:139


isValidSerializedPubKey​

▸ isValidSerializedPubKey(s): boolean

Check whether a serialized public key is serialized correctly

Parameters​

NameTypeDescription
sstringthe serialized public key

Returns​

boolean

whether the serialized public key is valid

Defined in​

publicKey.ts:114