PrivateVoting
Inherits: IPrivateVoting
Title: PrivateVoting
Author: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80)
Stateless Diamond facet for anonymous one-person-one-vote polling over Semaphore groups: a member casts an anonymous ballot with a Semaphore proof (scope = poll id, message = choice), and the scope-bound nullifier gives each member exactly one vote per poll.
All logic lives in PrivateVotingLib. Composes the ISemaphore module (must be present in the same diamond). 1-person-1-vote, not token-weighted.
Notes:
- lattice-version: 0.1.0
- lattice-source: Lattice original (composes Semaphore v4)
Functions
createPoll
Creates a poll over groupId. Only the group admin may create polls for it.
function createPoll(uint256 groupId, uint32 numChoices, uint64 startTime, uint64 endTime)
external
virtual
returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| groupId | uint256 | The Semaphore group whose members may vote. |
| numChoices | uint32 | Number of options (>= 2). |
| startTime | uint64 | Unix time voting opens (0 = immediately). |
| endTime | uint64 | Unix time voting closes (0 = never). |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 | The new poll id (1-based); voters must use this as the Semaphore scope. |
vote
Casts an anonymous ballot in pollId. proof.scope must equal pollId and
proof.message is the chosen option; the nullifier prevents a second ballot.
function vote(uint256 pollId, ISemaphore.SemaphoreProof calldata proof) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| pollId | uint256 | The poll to vote in. |
| proof | ISemaphore.SemaphoreProof | The Semaphore proof of membership binding the choice + poll. |
pollCount
Returns the number of polls created.
function pollCount() external view virtual returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
getPoll
Returns the public configuration of pollId.
function getPoll(uint256 pollId) external view virtual returns (PollView memory);Parameters
| Name | Type | Description |
|---|---|---|
| pollId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | PollView |
getVotes
Returns the vote count for choice in pollId.
function getVotes(uint256 pollId, uint256 choice) external view virtual returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| pollId | uint256 | |
| choice | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
hasVoted
Returns whether nullifier has already voted in pollId.
function hasVoted(uint256 pollId, uint256 nullifier) external view virtual returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| pollId | uint256 | |
| nullifier | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
exportSelectors
ERC-8153 selector export: this facet's cuttable selectors, tightly packed (4 bytes each).
Excludes exportSelectors() itself (0x0ef22643) - it is never cut into a diamond. Order matches
forge inspect PrivateVoting methodIdentifiers (alphabetical by signature); kept in exact parity by
ExportSelectorsParityTest. Chunks:
createPoll(uint256,uint32,uint64,uint64) 0x5fc5999b
getPoll(uint256) 0x1a8cbcaa
getVotes(uint256,uint256) 0x91f36633
hasVoted(uint256,uint256) 0x64390ff1
pollCount() 0x9207891d
vote(uint256,(uint256,uint256,uint256,uint256,uint256,uint256[8])) 0xd5d4738f
function exportSelectors() external pure virtual returns (bytes memory selectors);Returns
| Name | Type | Description |
|---|---|---|
| selectors | bytes |