@@ -3,34 +3,20 @@ pragma solidity 0.8.4;
3
3
4
4
/// @title Semaphore contract interface.
5
5
interface ISemaphore {
6
- error Semaphore__GroupDoesNotExist ();
7
- error Semaphore__GroupAlreadyExists ();
8
6
error Semaphore__GroupHasNoMembers ();
9
- error Semaphore__CallerIsNotTheGroupAdmin ();
10
7
error Semaphore__MerkleTreeDepthIsNotSupported ();
11
8
error Semaphore__MerkleTreeRootIsExpired ();
12
9
error Semaphore__MerkleTreeRootIsNotPartOfTheGroup ();
13
10
error Semaphore__YouAreUsingTheSameNillifierTwice ();
14
11
error Semaphore__InvalidProof ();
15
12
16
- /// It defines all the group parameters, in addition to those in the Merkle tree .
13
+ /// It defines all the group parameters used by Semaphore.sol .
17
14
struct Group {
18
- address admin;
19
15
uint256 merkleTreeDuration;
20
16
mapping (uint256 => uint256 ) merkleRootCreationDates;
21
17
mapping (uint256 => bool ) nullifiers;
22
18
}
23
19
24
- /// @dev Emitted when a new group is created.
25
- /// @param groupId: Id of the group.
26
- event GroupCreated (uint256 indexed groupId );
27
-
28
- /// @dev Emitted when an admin is assigned to a group.
29
- /// @param groupId: Id of the group.
30
- /// @param oldAdmin: Old admin of the group.
31
- /// @param newAdmin: New admin of the group.
32
- event GroupAdminUpdated (uint256 indexed groupId , address indexed oldAdmin , address indexed newAdmin );
33
-
34
20
/// @dev Emitted when the Merkle tree duration of a group is updated.
35
21
/// @param groupId: Id of the group.
36
22
/// @param oldMerkleTreeDuration: Old Merkle tree duration of the group.
@@ -57,71 +43,54 @@ interface ISemaphore {
57
43
uint256 [8 ] proof
58
44
);
59
45
60
- /// @dev Saves the nullifier hash to avoid double signaling and emits an event
61
- /// if the zero-knowledge proof is valid.
62
- /// @param groupId: Id of the group.
63
- /// @param merkleTreeRoot: Root of the Merkle tree.
64
- /// @param nullifier: Nullifier.
65
- /// @param message: Semaphore message.
66
- /// @param scope: Scope.
67
- /// @param proof: Zero-knowledge proof.
68
- function verifyProof (
69
- uint256 groupId ,
70
- uint256 merkleTreeRoot ,
71
- uint256 nullifier ,
72
- uint256 message ,
73
- uint256 scope ,
74
- uint256 [8 ] calldata proof
75
- ) external ;
76
-
77
- /// @dev Creates a new group. Only the admin will be able to add or remove members.
78
- /// @param groupId: Id of the group.
79
- /// @param admin: Admin of the group.
46
+ /// @dev See {SemaphoreGroups-_createGroup}.
80
47
function createGroup (uint256 groupId , address admin ) external ;
81
48
82
- /// @dev Creates a new group. Only the admin will be able to add or remove members .
49
+ /// @dev It creates a group with a custom Merkle tree duration .
83
50
/// @param groupId: Id of the group.
84
51
/// @param admin: Admin of the group.
85
- /// @param merkleTreeRootDuration: Time before the validity of a root expires .
86
- function createGroup (uint256 groupId , address admin , uint256 merkleTreeRootDuration ) external ;
52
+ /// @param merkleTreeDuration: Merkle tree duration .
53
+ function createGroup (uint256 groupId , address admin , uint256 merkleTreeDuration ) external ;
87
54
88
- /// @dev Updates the group admin.
89
- /// @param groupId: Id of the group.
90
- /// @param newAdmin: New admin of the group.
55
+ /// @dev See {SemaphoreGroups-_updateGroupAdmin}.
91
56
function updateGroupAdmin (uint256 groupId , address newAdmin ) external ;
92
57
93
58
/// @dev Updates the group Merkle tree duration.
94
59
/// @param groupId: Id of the group.
95
60
/// @param newMerkleTreeDuration: New Merkle tree duration.
96
61
function updateGroupMerkleTreeDuration (uint256 groupId , uint256 newMerkleTreeDuration ) external ;
97
62
98
- /// @dev Adds a new member to an existing group.
99
- /// @param groupId: Id of the group.
100
- /// @param identityCommitment: New identity commitment.
63
+ /// @dev See {SemaphoreGroups-_addMember}.
101
64
function addMember (uint256 groupId , uint256 identityCommitment ) external ;
102
65
103
- /// @dev Adds new members to an existing group.
104
- /// @param groupId: Id of the group.
105
- /// @param identityCommitments: New identity commitments.
66
+ /// @dev See {SemaphoreGroups-_addMembers}.
106
67
function addMembers (uint256 groupId , uint256 [] calldata identityCommitments ) external ;
107
68
108
- /// @dev Updates an identity commitment of an existing group. A proof of membership is
109
- /// needed to check if the node to be updated is part of the tree.
110
- /// @param groupId: Id of the group.
111
- /// @param oldIdentityCommitment: Existing identity commitment to be updated.
112
- /// @param newIdentityCommitment: New identity commitment.
113
- /// @param merkleProofSiblings: Array of the sibling nodes of the proof of membership.
69
+ /// @dev See {SemaphoreGroups-_updateMember}.
114
70
function updateMember (
115
71
uint256 groupId ,
116
72
uint256 oldIdentityCommitment ,
117
73
uint256 newIdentityCommitment ,
118
74
uint256 [] calldata merkleProofSiblings
119
75
) external ;
120
76
121
- /// @dev Removes a member from an existing group. A proof of membership is
122
- /// needed to check if the node to be removed is part of the tree.
123
- /// @param groupId: Id of the group.
124
- /// @param identityCommitment: Identity commitment to be removed.
125
- /// @param merkleProofSiblings: Array of the sibling nodes of the proof of membership.
77
+ /// @dev See {SemaphoreGroups-_removeMember}.
126
78
function removeMember (uint256 groupId , uint256 identityCommitment , uint256 [] calldata merkleProofSiblings ) external ;
79
+
80
+ /// @dev Saves the nullifier hash to avoid double signaling and emits an event
81
+ /// if the zero-knowledge proof is valid.
82
+ /// @param groupId: Id of the group.
83
+ /// @param merkleTreeRoot: Root of the Merkle tree.
84
+ /// @param nullifier: Nullifier.
85
+ /// @param message: Semaphore message.
86
+ /// @param scope: Scope.
87
+ /// @param proof: Zero-knowledge proof.
88
+ function verifyProof (
89
+ uint256 groupId ,
90
+ uint256 merkleTreeRoot ,
91
+ uint256 nullifier ,
92
+ uint256 message ,
93
+ uint256 scope ,
94
+ uint256 [8 ] calldata proof
95
+ ) external ;
127
96
}
0 commit comments