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
- asArray
- asCircuitInputs
- asContractParam
- copy
- equals
- hash
- serialize
- toJSON
- deserialize
- fromJSON
- isValidSerializedPubKey
Constructors
constructor
• new PubKey(rawPubKey
): PubKey
Create a new instance of a public key
Parameters
Name | Type | Description |
---|---|---|
rawPubKey | PubKey | the raw public key |
Returns
Defined in
Properties
rawPubKey
• rawPubKey: PubKey
Defined in
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
asCircuitInputs
▸ asCircuitInputs(): string
[]
Return this public key as circuit inputs
Returns
string
[]
an array of strings
Defined in
asContractParam
▸ asContractParam(): IG1ContractParams
Return this public key as smart contract parameters
Returns
the public key as smart contract parameters
Defined in
copy
▸ copy(): PubKey
Create a copy of the public key
Returns
a copy of the public key
Defined in
equals
▸ equals(p
): boolean
Check whether this public key equals to another public key
Parameters
Name | Type | Description |
---|---|---|
p | PubKey | the public key to compare with |
Returns
boolean
whether they match
Defined in
hash
▸ hash(): bigint
Hash the two baby jubjub coordinates
Returns
bigint
the hash of this public key
Defined in
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
toJSON
▸ toJSON(): IJsonPublicKey
Serialize this object
Returns
Defined in
deserialize
▸ deserialize(s
): PubKey
Deserialize a serialized public key
Parameters
Name | Type | Description |
---|---|---|
s | string | the serialized public key |
Returns
the deserialized public key
Defined in
fromJSON
▸ fromJSON(json
): PubKey
Deserialize a JSON object into a PubKey instance
Parameters
Name | Type | Description |
---|---|---|
json | IJsonPublicKey | the json object |
Returns
PubKey
Defined in
isValidSerializedPubKey
▸ isValidSerializedPubKey(s
): boolean
Check whether a serialized public key is serialized correctly
Parameters
Name | Type | Description |
---|---|---|
s | string | the serialized public key |
Returns
boolean
whether the serialized public key is valid