Minimal Anti Collusion Infrastructure (MACI) / PublicKey
Class: PublicKey
Defined in: publicKey.ts:23
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
Constructors
Constructor
new PublicKey(
raw
,allowInvalid
):PublicKey
Defined in: publicKey.ts:36
Create a new instance of a public key
Parameters
raw
PublicKey
the raw public key
allowInvalid
boolean
= false
whether to allow invalid public keys
Returns
PublicKey
Dev
You might want to allow an invalid raw key, as when decrypting invalid messages, the public key data will be random, and likely not be a point on the curve. However we need to match keys to the circuit which does not perform such checks
Properties
raw
raw:
PublicKey
Defined in: publicKey.ts:24
Methods
asArray()
asArray():
bigint
[]
Defined in: publicKey.ts:72
Return this public key as an array of bigints
Returns
bigint
[]
the public key as an array of bigints
asCircuitInputs()
asCircuitInputs():
string
[]
Defined in: publicKey.ts:66
Return this public key as circuit inputs
Returns
string
[]
an array of strings
asContractParam()
asContractParam():
IG1ContractParams
Defined in: publicKey.ts:53
Return this public key as smart contract parameters
Returns
the public key as smart contract parameters
copy()
copy():
PublicKey
Defined in: publicKey.ts:47
Create a copy of the public key
Returns
PublicKey
a copy of the public key
equals()
equals(
key
):boolean
Defined in: publicKey.ts:99
Check whether this public key equals to another public key
Parameters
key
PublicKey
the public key to compare with
Returns
boolean
whether they match
hash()
hash():
bigint
Defined in: publicKey.ts:92
Hash the two baby jubjub coordinates
Returns
bigint
the hash of this public key
serialize()
serialize():
string
Defined in: publicKey.ts:78
Generate a serialized public key from this public key object
Returns
string
the string representation of a serialized public key
toJSON()
toJSON():
IJsonPublicKey
Defined in: publicKey.ts:130
Serialize this object
Returns
deserialize()
static
deserialize(s
):PublicKey
Defined in: publicKey.ts:106
Deserialize a serialized public key
Parameters
s
string
the serialized public key
Returns
PublicKey
the deserialized public key
fromJSON()
static
fromJSON(json
):PublicKey
Defined in: publicKey.ts:141
Deserialize a JSON object into a PublicKey instance
Parameters
json
the json object
Returns
PublicKey
PublicKey
genPadKey()
static
genPadKey():PublicKey
Defined in: publicKey.ts:149
Generate a default pad key
Returns
PublicKey
a default pad key
isValidSerialized()
static
isValidSerialized(s
):boolean
Defined in: publicKey.ts:116
Check whether a serialized public key is serialized correctly
Parameters
s
string
the serialized public key
Returns
boolean
whether the serialized public key is valid