Skip to main content
Version: v3.x

VkRegistry

Stores verifying keys for the circuits. Each circuit has a signature which is its compile-time constants represented as a uint256.

processVks

mapping(enum DomainObjs.Mode => mapping(uint256 => struct SnarkCommon.VerifyingKey)) processVks

processVkSet

mapping(enum DomainObjs.Mode => mapping(uint256 => bool)) processVkSet

tallyVks

mapping(enum DomainObjs.Mode => mapping(uint256 => struct SnarkCommon.VerifyingKey)) tallyVks

tallyVkSet

mapping(enum DomainObjs.Mode => mapping(uint256 => bool)) tallyVkSet

pollJoiningVks

mapping(uint256 => struct SnarkCommon.VerifyingKey) pollJoiningVks

pollJoiningVkSet

mapping(uint256 => bool) pollJoiningVkSet

pollJoinedVks

mapping(uint256 => struct SnarkCommon.VerifyingKey) pollJoinedVks

pollJoinedVkSet

mapping(uint256 => bool) pollJoinedVkSet

PollJoiningVkSet

event PollJoiningVkSet(uint256 _sig)

PollJoinedVkSet

event PollJoinedVkSet(uint256 _sig)

ProcessVkSet

event ProcessVkSet(uint256 _sig, enum DomainObjs.Mode _mode)

TallyVkSet

event TallyVkSet(uint256 _sig, enum DomainObjs.Mode _mode)

VkAlreadySet

error VkAlreadySet()

VkNotSet

error VkNotSet()

InvalidKeysParams

error InvalidKeysParams()

constructor

constructor() public payable

Create a new instance of the VkRegistry contract

isPollJoiningVkSet

function isPollJoiningVkSet(uint256 _sig) public view returns (bool isSet)

Check if the poll joining verifying key is set

Parameters

NameTypeDescription
_siguint256The signature

Return Values

NameTypeDescription
isSetboolwhether the verifying key is set

isPollJoinedVkSet

function isPollJoinedVkSet(uint256 _sig) public view returns (bool isSet)

Check if the poll joined verifying key is set

Parameters

NameTypeDescription
_siguint256The signature

Return Values

NameTypeDescription
isSetboolwhether the verifying key is set

isProcessVkSet

function isProcessVkSet(uint256 _sig, enum DomainObjs.Mode _mode) public view returns (bool isSet)

Check if the process verifying key is set

Parameters

NameTypeDescription
_siguint256The signature
_modeenum DomainObjs.ModeQV or Non-QV

Return Values

NameTypeDescription
isSetboolwhether the verifying key is set

isTallyVkSet

function isTallyVkSet(uint256 _sig, enum DomainObjs.Mode _mode) public view returns (bool isSet)

Check if the tally verifying key is set

Parameters

NameTypeDescription
_siguint256The signature
_modeenum DomainObjs.ModeQV or Non-QV

Return Values

NameTypeDescription
isSetboolwhether the verifying key is set

genPollJoiningVkSig

function genPollJoiningVkSig(uint256 _stateTreeDepth) public pure returns (uint256 sig)

generate the signature for the poll joining verifying key

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth

genPollJoinedVkSig

function genPollJoinedVkSig(uint256 _stateTreeDepth) public pure returns (uint256 sig)

generate the signature for the poll joined verifying key

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth

genProcessVkSig

function genProcessVkSig(uint256 _stateTreeDepth, uint256 _voteOptionTreeDepth, uint8 _messageBatchSize) public pure returns (uint256 sig)

generate the signature for the process verifying key

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth
_voteOptionTreeDepthuint256The vote option tree depth
_messageBatchSizeuint8The message batch size

genTallyVkSig

function genTallyVkSig(uint256 _stateTreeDepth, uint256 _intStateTreeDepth, uint256 _voteOptionTreeDepth) public pure returns (uint256 sig)

generate the signature for the tally verifying key

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth
_intStateTreeDepthuint256The intermediate state tree depth
_voteOptionTreeDepthuint256The vote option tree depth

Return Values

NameTypeDescription
siguint256The signature

setVerifyingKeysBatch

function setVerifyingKeysBatch(struct IVkRegistry.SetVerifyingKeysBatchArgs _args) public

Set the process and tally verifying keys for a certain combination of parameters and modes

Parameters

NameTypeDescription
_argsstruct IVkRegistry.SetVerifyingKeysBatchArgsThe verifying keys arguments

setVerifyingKeys

function setVerifyingKeys(uint256 _stateTreeDepth, uint256 _intStateTreeDepth, uint256 _voteOptionTreeDepth, uint8 _messageBatchSize, enum DomainObjs.Mode _mode, struct SnarkCommon.VerifyingKey _processVk, struct SnarkCommon.VerifyingKey _tallyVk) public

Set the process and tally verifying keys for a certain combination

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth
_intStateTreeDepthuint256The intermediate state tree depth
_voteOptionTreeDepthuint256The vote option tree depth
_messageBatchSizeuint8The message batch size
_modeenum DomainObjs.ModeQV or Non-QV
_processVkstruct SnarkCommon.VerifyingKeyThe process verifying key
_tallyVkstruct SnarkCommon.VerifyingKeyThe tally verifying key

setProcessVkKey

function setProcessVkKey(uint256 _stateTreeDepth, uint256 _voteOptionTreeDepth, uint8 _messageBatchSize, enum DomainObjs.Mode _mode, struct SnarkCommon.VerifyingKey _processVk) public

Set the process verifying key for a certain combination of parameters

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth
_voteOptionTreeDepthuint256The vote option tree depth
_messageBatchSizeuint8The message batch size
_modeenum DomainObjs.ModeQV or Non-QV
_processVkstruct SnarkCommon.VerifyingKeyThe process verifying key

setTallyVkKey

function setTallyVkKey(uint256 _stateTreeDepth, uint256 _intStateTreeDepth, uint256 _voteOptionTreeDepth, enum DomainObjs.Mode _mode, struct SnarkCommon.VerifyingKey _tallyVk) public

Set the tally verifying key for a certain combination of parameters

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth
_intStateTreeDepthuint256The intermediate state tree depth
_voteOptionTreeDepthuint256The vote option tree depth
_modeenum DomainObjs.ModeQV or Non-QV
_tallyVkstruct SnarkCommon.VerifyingKeyThe tally verifying key

setPollJoiningVkKey

function setPollJoiningVkKey(uint256 _stateTreeDepth, struct SnarkCommon.VerifyingKey _pollJoiningVk) public

Set the poll joining verifying key for a certain combination of parameters

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth
_pollJoiningVkstruct SnarkCommon.VerifyingKeyThe poll joining verifying key

setPollJoinedVkKey

function setPollJoinedVkKey(uint256 _stateTreeDepth, struct SnarkCommon.VerifyingKey _pollJoinedVk) public

Set the poll joined verifying key for a certain combination of parameters

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth
_pollJoinedVkstruct SnarkCommon.VerifyingKeyThe poll joined verifying key

hasProcessVk

function hasProcessVk(uint256 _stateTreeDepth, uint256 _voteOptionTreeDepth, uint8 _messageBatchSize, enum DomainObjs.Mode _mode) public view returns (bool isSet)

Check if the process verifying key is set

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth
_voteOptionTreeDepthuint256The vote option tree depth
_messageBatchSizeuint8The message batch size
_modeenum DomainObjs.ModeQV or Non-QV

Return Values

NameTypeDescription
isSetboolwhether the verifying key is set

getProcessVkBySig

function getProcessVkBySig(uint256 _sig, enum DomainObjs.Mode _mode) public view returns (struct SnarkCommon.VerifyingKey vk)

Get the process verifying key by signature

Parameters

NameTypeDescription
_siguint256The signature
_modeenum DomainObjs.ModeQV or Non-QV

Return Values

NameTypeDescription
vkstruct SnarkCommon.VerifyingKeyThe verifying key

getProcessVk

function getProcessVk(uint256 _stateTreeDepth, uint256 _voteOptionTreeDepth, uint8 _messageBatchSize, enum DomainObjs.Mode _mode) public view returns (struct SnarkCommon.VerifyingKey vk)

Get the process verifying key

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth
_voteOptionTreeDepthuint256The vote option tree depth
_messageBatchSizeuint8The message batch size
_modeenum DomainObjs.ModeQV or Non-QV

Return Values

NameTypeDescription
vkstruct SnarkCommon.VerifyingKeyThe verifying key

hasTallyVk

function hasTallyVk(uint256 _stateTreeDepth, uint256 _intStateTreeDepth, uint256 _voteOptionTreeDepth, enum DomainObjs.Mode _mode) public view returns (bool isSet)

Check if the tally verifying key is set

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth
_intStateTreeDepthuint256The intermediate state tree depth
_voteOptionTreeDepthuint256The vote option tree depth
_modeenum DomainObjs.ModeQV or Non-QV

Return Values

NameTypeDescription
isSetboolwhether the verifying key is set

getTallyVkBySig

function getTallyVkBySig(uint256 _sig, enum DomainObjs.Mode _mode) public view returns (struct SnarkCommon.VerifyingKey vk)

Get the tally verifying key by signature

Parameters

NameTypeDescription
_siguint256The signature
_modeenum DomainObjs.ModeQV or Non-QV

Return Values

NameTypeDescription
vkstruct SnarkCommon.VerifyingKeyThe verifying key

getTallyVk

function getTallyVk(uint256 _stateTreeDepth, uint256 _intStateTreeDepth, uint256 _voteOptionTreeDepth, enum DomainObjs.Mode _mode) public view returns (struct SnarkCommon.VerifyingKey vk)

Get the tally verifying key

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth
_intStateTreeDepthuint256The intermediate state tree depth
_voteOptionTreeDepthuint256The vote option tree depth
_modeenum DomainObjs.ModeQV or Non-QV

Return Values

NameTypeDescription
vkstruct SnarkCommon.VerifyingKeyThe verifying key

getPollJoiningVkBySig

function getPollJoiningVkBySig(uint256 _sig) public view returns (struct SnarkCommon.VerifyingKey vk)

Get the poll joining verifying key by signature

Parameters

NameTypeDescription
_siguint256The signature

Return Values

NameTypeDescription
vkstruct SnarkCommon.VerifyingKeyThe verifying key

getPollJoinedVkBySig

function getPollJoinedVkBySig(uint256 _sig) public view returns (struct SnarkCommon.VerifyingKey vk)

Get the poll joined verifying key by signature

Parameters

NameTypeDescription
_siguint256The signature

Return Values

NameTypeDescription
vkstruct SnarkCommon.VerifyingKeyThe verifying key

getPollJoiningVk

function getPollJoiningVk(uint256 _stateTreeDepth) public view returns (struct SnarkCommon.VerifyingKey vk)

Get the poll joining verifying key

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth

Return Values

NameTypeDescription
vkstruct SnarkCommon.VerifyingKeyThe verifying key

getPollJoinedVk

function getPollJoinedVk(uint256 _stateTreeDepth) public view returns (struct SnarkCommon.VerifyingKey vk)

Get the poll joined verifying key

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth

Return Values

NameTypeDescription
vkstruct SnarkCommon.VerifyingKeyThe verifying key