Skip to main content
Version: v2.0_alpha

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

ProcessVkSet

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

TallyVkSet

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

ProcessVkAlreadySet

error ProcessVkAlreadySet()

TallyVkAlreadySet

error TallyVkAlreadySet()

ProcessVkNotSet

error ProcessVkNotSet()

TallyVkNotSet

error TallyVkNotSet()

SubsidyVkNotSet

error SubsidyVkNotSet()

InvalidKeysParams

error InvalidKeysParams()

constructor

constructor() public payable

Create a new instance of the VkRegistry contract

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

genProcessVkSig

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

generate the signature for the process verifying key

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth
_messageTreeDepthuint256The message tree depth
_voteOptionTreeDepthuint256The vote option tree depth
_messageBatchSizeuint256The 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(uint256 _stateTreeDepth, uint256 _intStateTreeDepth, uint256 _messageTreeDepth, uint256 _voteOptionTreeDepth, uint256 _messageBatchSize, enum DomainObjs.Mode[] _modes, struct SnarkCommon.VerifyingKey[] _processVks, struct SnarkCommon.VerifyingKey[] _tallyVks) public

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

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth
_intStateTreeDepthuint256The intermediate state tree depth
_messageTreeDepthuint256The message tree depth
_voteOptionTreeDepthuint256The vote option tree depth
_messageBatchSizeuint256The message batch size
_modesenum DomainObjs.Mode[]Array of QV or Non-QV modes (must have the same length as process and tally keys)
_processVksstruct SnarkCommon.VerifyingKey[]The process verifying keys (must have the same length as modes)
_tallyVksstruct SnarkCommon.VerifyingKey[]The tally verifying keys (must have the same length as modes)

setVerifyingKeys

function setVerifyingKeys(uint256 _stateTreeDepth, uint256 _intStateTreeDepth, uint256 _messageTreeDepth, uint256 _voteOptionTreeDepth, uint256 _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 of parameters

Parameters

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

hasProcessVk

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

Check if the process verifying key is set

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth
_messageTreeDepthuint256The message tree depth
_voteOptionTreeDepthuint256The vote option tree depth
_messageBatchSizeuint256The 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 _messageTreeDepth, uint256 _voteOptionTreeDepth, uint256 _messageBatchSize, enum DomainObjs.Mode _mode) public view returns (struct SnarkCommon.VerifyingKey vk)

Get the process verifying key

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth
_messageTreeDepthuint256The message tree depth
_voteOptionTreeDepthuint256The vote option tree depth
_messageBatchSizeuint256The 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