Semaphore
Inherits: ISemaphore
Title: Semaphore
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from Semaphore (https://github.com/semaphore-protocol/semaphore)
Stateless Diamond facet for Semaphore anonymous membership / signaling: create groups, add identity commitments, and validate zero-knowledge membership + signaling proofs.
All logic lives in SemaphoreLib. Membership uses the Poseidon incremental Merkle tree; proof verification is delegated to the audited Semaphore v4 verifier (set via setVerifier); a per-group scope nullifier prevents double-signaling. logic over Lattice's own Poseidon Merkle + nullifier libraries.
Notes:
- lattice-version: 0.1.0
- lattice-source: Wraps the audited Semaphore v4 (PSE) Groth16 verifier; group / nullifier / root
Functions
createGroup
Creates a new group administered by the caller.
function createGroup() external virtual returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 | The new group id. |
createGroup
Creates a new group administered by admin.
function createGroup(address admin) external virtual returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| admin | address | The group admin (may add members). |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 | The new group id. |
addMember
Adds a member (identity commitment) to a group. Only the group admin.
function addMember(uint256 groupId, uint256 identityCommitment) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| groupId | uint256 | The group id. |
| identityCommitment | uint256 | The member's identity commitment. |
addMembers
Adds many members to a group. Only the group admin.
function addMembers(uint256 groupId, uint256[] calldata identityCommitments) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| groupId | uint256 | The group id. |
| identityCommitments | uint256[] | The members' identity commitments, in order. |
validateProof
Validates a proof against a group and consumes its nullifier (state-changing).
Reverts if the group/depth/root/nullifier checks fail or the proof is invalid.
function validateProof(uint256 groupId, SemaphoreProof calldata proof) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| groupId | uint256 | The group id. |
| proof | SemaphoreProof | The Semaphore proof. |
verifyProof
Verifies a proof against a group WITHOUT consuming the nullifier.
function verifyProof(uint256 groupId, SemaphoreProof calldata proof) external view virtual returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| groupId | uint256 | The group id. |
| proof | SemaphoreProof | The Semaphore proof. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool | True iff the proof is valid for the group. |
setVerifier
Sets the Semaphore verifier contract. Gated on the default admin role.
function setVerifier(address verifier_) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| verifier_ | address | The ISemaphoreVerifier address. |
groupCount
Returns the number of groups created.
function groupCount() external view virtual returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
groupAdmin
Returns the admin of groupId.
function groupAdmin(uint256 groupId) external view virtual returns (address);Parameters
| Name | Type | Description |
|---|---|---|
| groupId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
getMerkleTreeRoot
Returns the current Merkle root of groupId.
function getMerkleTreeRoot(uint256 groupId) external view virtual returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| groupId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
getMerkleTreeSize
Returns the number of members in groupId.
function getMerkleTreeSize(uint256 groupId) external view virtual returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| groupId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
hasMember
Returns whether identityCommitment is a member of groupId.
function hasMember(uint256 groupId, uint256 identityCommitment) external view virtual returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| groupId | uint256 | |
| identityCommitment | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
verifier
Returns the configured Semaphore verifier address.
function verifier() external view virtual returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
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 Semaphore methodIdentifiers (alphabetical by signature); kept in exact parity by
ExportSelectorsParityTest. Chunks:
addMember(uint256,uint256) 0x1783efc3
addMembers(uint256,uint256[]) 0x04245371
createGroup() 0x575185ed
createGroup(address) 0x5c3f3b60
getMerkleTreeRoot(uint256) 0xdabc4d51
getMerkleTreeSize(uint256) 0x7ee35a0c
groupAdmin(uint256) 0xbd883eb6
groupCount() 0x8f23b326
hasMember(uint256,uint256) 0x90509d44
setVerifier(address) 0x5437988d
validateProof(uint256,(uint256,uint256,uint256,uint256,uint256,uint256[8])) 0xd0d898dd
verifier() 0x2b7ac3f3
verifyProof(uint256,(uint256,uint256,uint256,uint256,uint256,uint256[8])) 0x456f4188
function exportSelectors() external pure virtual returns (bytes memory selectors);Returns
| Name | Type | Description |
|---|---|---|
| selectors | bytes |