Skip to main content
Version: v1.2

VkRegistry

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

processVks

mapping(uint256 => struct SnarkCommon.VerifyingKey) processVks

processVkSet

mapping(uint256 => bool) processVkSet

tallyVks

mapping(uint256 => struct SnarkCommon.VerifyingKey) tallyVks

tallyVkSet

mapping(uint256 => bool) tallyVkSet

subsidyVks

mapping(uint256 => struct SnarkCommon.VerifyingKey) subsidyVks

subsidyVkSet

mapping(uint256 => bool) subsidyVkSet

ProcessVkSet

event ProcessVkSet(uint256 _sig)

TallyVkSet

event TallyVkSet(uint256 _sig)

SubsidyVkSet

event SubsidyVkSet(uint256 _sig)

ProcessVkAlreadySet

error ProcessVkAlreadySet()

TallyVkAlreadySet

error TallyVkAlreadySet()

SubsidyVkAlreadySet

error SubsidyVkAlreadySet()

ProcessVkNotSet

error ProcessVkNotSet()

TallyVkNotSet

error TallyVkNotSet()

SubsidyVkNotSet

error SubsidyVkNotSet()

constructor

constructor() public payable

Create a new instance of the VkRegistry contract

isProcessVkSet

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

Check if the process verifying key is set

Parameters

NameTypeDescription
_siguint256The signature

Return Values

NameTypeDescription
isSetboolwhether the verifying key is set

isTallyVkSet

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

Check if the tally verifying key is set

Parameters

NameTypeDescription
_siguint256The signature

Return Values

NameTypeDescription
isSetboolwhether the verifying key is set

isSubsidyVkSet

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

Check if the subsidy verifying key is set

Parameters

NameTypeDescription
_siguint256The signature

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

genSubsidyVkSig

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

generate the signature for the subsidy verifying key

Parameters

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

Return Values

NameTypeDescription
siguint256The signature

setVerifyingKeys

function setVerifyingKeys(uint256 _stateTreeDepth, uint256 _intStateTreeDepth, uint256 _messageTreeDepth, uint256 _voteOptionTreeDepth, uint256 _messageBatchSize, 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
_processVkstruct SnarkCommon.VerifyingKeyThe process verifying key
_tallyVkstruct SnarkCommon.VerifyingKeyThe tally verifying key

setSubsidyKeys

function setSubsidyKeys(uint256 _stateTreeDepth, uint256 _intStateTreeDepth, uint256 _voteOptionTreeDepth, struct SnarkCommon.VerifyingKey _subsidyVk) public

Set the process verifying key for a certain combination of parameters

Parameters

NameTypeDescription
_stateTreeDepthuint256The state tree depth
_intStateTreeDepthuint256The intermediate state tree depth
_voteOptionTreeDepthuint256The vote option tree depth
_subsidyVkstruct SnarkCommon.VerifyingKeyThe verifying key

hasProcessVk

function hasProcessVk(uint256 _stateTreeDepth, uint256 _messageTreeDepth, uint256 _voteOptionTreeDepth, uint256 _messageBatchSize) 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

Return Values

NameTypeDescription
isSetboolwhether the verifying key is set

getProcessVkBySig

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

Get the process verifying key by signature

Parameters

NameTypeDescription
_siguint256The signature

Return Values

NameTypeDescription
vkstruct SnarkCommon.VerifyingKeyThe verifying key

getProcessVk

function getProcessVk(uint256 _stateTreeDepth, uint256 _messageTreeDepth, uint256 _voteOptionTreeDepth, uint256 _messageBatchSize) 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

Return Values

NameTypeDescription
vkstruct SnarkCommon.VerifyingKeyThe verifying key

hasTallyVk

function hasTallyVk(uint256 _stateTreeDepth, uint256 _intStateTreeDepth, uint256 _voteOptionTreeDepth) 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

Return Values

NameTypeDescription
isSetboolwhether the verifying key is set

getTallyVkBySig

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

Get the tally verifying key by signature

Parameters

NameTypeDescription
_siguint256The signature

Return Values

NameTypeDescription
vkstruct SnarkCommon.VerifyingKeyThe verifying key

getTallyVk

function getTallyVk(uint256 _stateTreeDepth, uint256 _intStateTreeDepth, uint256 _voteOptionTreeDepth) 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

Return Values

NameTypeDescription
vkstruct SnarkCommon.VerifyingKeyThe verifying key

hasSubsidyVk

function hasSubsidyVk(uint256 _stateTreeDepth, uint256 _intStateTreeDepth, uint256 _voteOptionTreeDepth) public view returns (bool isSet)

Check if the subsidy verifying key is set

Parameters

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

Return Values

NameTypeDescription
isSetboolwhether the verifying key is set

getSubsidyVkBySig

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

Get the subsidy verifying key by signature

Parameters

NameTypeDescription
_siguint256The signature

Return Values

NameTypeDescription
vkstruct SnarkCommon.VerifyingKeyThe verifying key

getSubsidyVk

function getSubsidyVk(uint256 _stateTreeDepth, uint256 _intStateTreeDepth, uint256 _voteOptionTreeDepth) public view returns (struct SnarkCommon.VerifyingKey vk)

Get the subsidy verifying key

Parameters

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

Return Values

NameTypeDescription
vkstruct SnarkCommon.VerifyingKeyThe verifying key