Skip to main content
Version: v2.0_alpha

SemaphoreGatekeeper

A gatekeeper contract which allows users to sign up to MACI only if they can prove they are part of a semaphore group.

Please note that once a identity is used to register, it cannot be used again. This is because we store the nullifier which is hash(secret, groupId)

groupId

uint256 groupId

The group id of the semaphore group

semaphoreContract

contract ISemaphore semaphoreContract

The semaphore contract

maci

address maci

The address of the MACI contract

registeredIdentities

mapping(uint256 => bool) registeredIdentities

The registered identities

ZeroAddress

error ZeroAddress()

Errors

OnlyMACI

error OnlyMACI()

AlreadyRegistered

error AlreadyRegistered()

InvalidGroup

error InvalidGroup()

InvalidProof

error InvalidProof()

constructor

constructor(address _semaphoreContract, uint256 _groupId) public payable

Create a new instance of the gatekeeper

Parameters

NameTypeDescription
_semaphoreContractaddressThe address of the semaphore contract
_groupIduint256The group id of the semaphore group

setMaciInstance

function setMaciInstance(address _maci) public

Adds an uninitialised MACI instance to allow for token signups

Parameters

NameTypeDescription
_maciaddressThe MACI contract interface to be stored

register

function register(address, bytes _data) public

Register an user if they can prove they belong to a semaphore group

Throw if the proof is not valid or just complete silently

Parameters

NameTypeDescription
address
_databytesThe ABI-encoded schemaId as a uint256.