ITally
Complete Tally interface
TallyResult
Tally result
struct TallyResult {
uint256 value;
bool isSet;
}
AddTallyResultsArgs
tally result args
struct AddTallyResultsArgs {
uint256[] voteOptionIndices;
uint256[] tallyResults;
uint256[][][] tallyResultProofs;
uint256 totalSpent;
uint256 totalSpentSalt;
uint256 tallyResultSalt;
uint256 newResultsCommitment;
uint256 spentVoiceCreditsHash;
uint256 perVOSpentVoiceCreditsHash;
}
addTallyResults
function addTallyResults(struct ITally.AddTallyResultsArgs args) external
Add and verify tally results by batch.
Parameters
Name | Type | Description |
---|---|---|
args | struct ITally.AddTallyResultsArgs | add tally result args |
updateSbCommitment
function updateSbCommitment() external
Update the state and ballot root commitment
tallyVotes
function tallyVotes(uint256 _newTallyCommitment, uint256[8] _proof) external
Verify the result of a tally batch
Parameters
Name | Type | Description |
---|---|---|
_newTallyCommitment | uint256 | the new tally commitment to be verified |
_proof | uint256[8] | the proof generated after tallying this batch |
isTallied
function isTallied() external view returns (bool tallied)
Check if all ballots are tallied
Return Values
Name | Type | Description |
---|---|---|
tallied | bool | whether all ballots are tallied |
tallyCommitment
function tallyCommitment() external view returns (uint256)
Get the tally commitment
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The current tally commitment |
tallyBatchNum
function tallyBatchNum() external view returns (uint256)
Get the tally batch number
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The current tally batch number |
sbCommitment
function sbCommitment() external view returns (uint256)
Get the final state and ballot commitment
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The sb commitment |
getTallyResults
function getTallyResults(uint256 index) external view returns (struct ITally.TallyResult)
Get tally results for a specific index
Parameters
Name | Type | Description |
---|---|---|
index | uint256 | The index to query |
Return Values
Name | Type | Description |
---|---|---|
[0] | struct ITally.TallyResult | The tally result |
totalTallyResults
function totalTallyResults() external view returns (uint256)
Get the total number of tally results
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The total tally results count |
totalSpent
function totalSpent() external view returns (uint256)
Get the total spent voice credits
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The total spent amount |
getPublicCircuitInputs
function getPublicCircuitInputs(uint256 _batchStartIndex, uint256 _newTallyCommitment) external view returns (uint256[] publicInputs)
Get public circuit inputs.
Parameters
Name | Type | Description |
---|---|---|
_batchStartIndex | uint256 | the batch start index |
_newTallyCommitment | uint256 | the new tally commitment to be verified |
Return Values
Name | Type | Description |
---|---|---|
publicInputs | uint256[] | public circuit inputs |
verifyTallyProof
function verifyTallyProof(uint256 _batchStartIndex, uint256 _newTallyCommitment, uint256[8] _proof) external view returns (bool isValid)
Verify the tally proof using the verifying key
Parameters
Name | Type | Description |
---|---|---|
_batchStartIndex | uint256 | the batch start index |
_newTallyCommitment | uint256 | the new tally commitment to be verified |
_proof | uint256[8] | the proof generated after processing all messages |
Return Values
Name | Type | Description |
---|---|---|
isValid | bool | whether the proof is valid |
verifyPerVoteOptionSpentVoiceCredits
function verifyPerVoteOptionSpentVoiceCredits(uint256 _voteOptionIndex, uint256 _spent, uint256[][] _spentProof, uint256 _spentSalt, uint8 _voteOptionTreeDepth, uint256 _spentVoiceCreditsHash, uint256 _resultCommitment) external view returns (bool isValid)
Return Values
Name | Type | Description |
---|---|---|
isValid | bool | Whether the provided proof is valid |
verifySpentVoiceCredits
function verifySpentVoiceCredits(uint256 _totalSpent, uint256 _totalSpentSalt, uint256 _resultCommitment, uint256 _perVoteOptionSpentVoiceCreditsHash) external view returns (bool isValid)
Verify the number of spent voice credits from the tally.json
Parameters
Name | Type | Description |
---|---|---|
_totalSpent | uint256 | spent field retrieved in the totalSpentVoiceCredits object |
_totalSpentSalt | uint256 | the corresponding salt in the totalSpentVoiceCredit object |
_resultCommitment | uint256 | hashLeftRight(merkle root of the results.tally, results.salt) in tally.json file |
_perVoteOptionSpentVoiceCreditsHash | uint256 | only for QV - hashLeftRight(merkle root of the no spent voice credits, salt) |
Return Values
Name | Type | Description |
---|---|---|
isValid | bool | Whether the provided values are valid |
verifyTallyResult
function verifyTallyResult(uint256 _voteOptionIndex, uint256 _tallyResult, uint256[][] _tallyResultProof, uint256 _tallyResultSalt, uint8 _voteOptionTreeDepth, uint256 _spentVoiceCreditsHash, uint256 _perVoteOptionSpentVoiceCreditsHash) external view returns (bool isValid)
Verify the result generated from the tally.json
Parameters
Name | Type | Description |
---|---|---|
_voteOptionIndex | uint256 | the index of the vote option to verify the correctness of the tally |
_tallyResult | uint256 | Flattened array of the tally |
_tallyResultProof | uint256[][] | Corresponding proof of the tally result |
_tallyResultSalt | uint256 | the respective salt in the results object in the tally.json |
_voteOptionTreeDepth | uint8 | depth of the vote option tree |
_spentVoiceCreditsHash | uint256 | hashLeftRight(number of spent voice credits, spent salt) |
_perVoteOptionSpentVoiceCreditsHash | uint256 | hashLeftRight(merkle root of the no spent voice credits per vote option, perVoteOptionSpentVoiceCredits salt) |
Return Values
Name | Type | Description |
---|---|---|
isValid | bool | Whether the provided proof is valid |