@@ -6,13 +6,13 @@ import "@zk-kit/incremental-merkle-tree.sol/IncrementalBinaryTree.sol";
6
6
import "@openzeppelin/contracts/utils/Context.sol " ;
7
7
8
8
/// @title Semaphore groups contract.
9
- /// @dev The following code allows you to create groups, add and remove members.
9
+ /// @dev This contract allows you to create groups, add, remove and update members.
10
10
/// You can use getters to obtain informations about groups (root, depth, number of leaves).
11
11
abstract contract SemaphoreGroups is Context , ISemaphoreGroups {
12
12
using IncrementalBinaryTree for IncrementalTreeData;
13
13
14
14
/// @dev Gets a group id and returns the tree data.
15
- mapping (uint256 => IncrementalTreeData) internal merkleTree ;
15
+ mapping (uint256 => IncrementalTreeData) internal merkleTrees ;
16
16
17
17
/// @dev Creates a new group by initializing the associated tree.
18
18
/// @param groupId: Id of the group.
@@ -22,12 +22,12 @@ abstract contract SemaphoreGroups is Context, ISemaphoreGroups {
22
22
revert Semaphore__GroupAlreadyExists ();
23
23
}
24
24
25
- // The zeroValue is in fact an implicit member of the group.
25
+ // The zeroValue is an implicit member of the group, or an implicit leaf of the Merkle tree .
26
26
// Although there is a remote possibility that the preimage of
27
- // the hash may be calculated, using this value minimizes the risk.
27
+ // the hash may be calculated, using this value we aim to minimize the risk.
28
28
uint256 zeroValue = uint256 (keccak256 (abi.encodePacked (groupId))) >> 8 ;
29
29
30
- merkleTree [groupId].init (merkleTreeDepth, zeroValue);
30
+ merkleTrees [groupId].init (merkleTreeDepth, zeroValue);
31
31
32
32
emit GroupCreated (groupId, merkleTreeDepth, zeroValue);
33
33
}
@@ -40,7 +40,7 @@ abstract contract SemaphoreGroups is Context, ISemaphoreGroups {
40
40
revert Semaphore__GroupDoesNotExist ();
41
41
}
42
42
43
- merkleTree [groupId].insert (identityCommitment);
43
+ merkleTrees [groupId].insert (identityCommitment);
44
44
45
45
uint256 merkleTreeRoot = getMerkleTreeRoot (groupId);
46
46
uint256 index = getNumberOfMerkleTreeLeaves (groupId) - 1 ;
@@ -66,7 +66,7 @@ abstract contract SemaphoreGroups is Context, ISemaphoreGroups {
66
66
revert Semaphore__GroupDoesNotExist ();
67
67
}
68
68
69
- merkleTree [groupId].update (identityCommitment, newIdentityCommitment, proofSiblings, proofPathIndices);
69
+ merkleTrees [groupId].update (identityCommitment, newIdentityCommitment, proofSiblings, proofPathIndices);
70
70
71
71
uint256 merkleTreeRoot = getMerkleTreeRoot (groupId);
72
72
uint256 index = proofPathIndicesToMemberIndex (proofPathIndices);
@@ -90,7 +90,7 @@ abstract contract SemaphoreGroups is Context, ISemaphoreGroups {
90
90
revert Semaphore__GroupDoesNotExist ();
91
91
}
92
92
93
- merkleTree [groupId].remove (identityCommitment, proofSiblings, proofPathIndices);
93
+ merkleTrees [groupId].remove (identityCommitment, proofSiblings, proofPathIndices);
94
94
95
95
uint256 merkleTreeRoot = getMerkleTreeRoot (groupId);
96
96
uint256 index = proofPathIndicesToMemberIndex (proofPathIndices);
@@ -100,17 +100,17 @@ abstract contract SemaphoreGroups is Context, ISemaphoreGroups {
100
100
101
101
/// @dev See {ISemaphoreGroups-getMerkleTreeRoot}.
102
102
function getMerkleTreeRoot (uint256 groupId ) public view virtual override returns (uint256 ) {
103
- return merkleTree [groupId].root;
103
+ return merkleTrees [groupId].root;
104
104
}
105
105
106
106
/// @dev See {ISemaphoreGroups-getMerkleTreeDepth}.
107
107
function getMerkleTreeDepth (uint256 groupId ) public view virtual override returns (uint256 ) {
108
- return merkleTree [groupId].depth;
108
+ return merkleTrees [groupId].depth;
109
109
}
110
110
111
111
/// @dev See {ISemaphoreGroups-getNumberOfMerkleTreeLeaves}.
112
112
function getNumberOfMerkleTreeLeaves (uint256 groupId ) public view virtual override returns (uint256 ) {
113
- return merkleTree [groupId].numberOfLeaves;
113
+ return merkleTrees [groupId].numberOfLeaves;
114
114
}
115
115
116
116
/// @dev Converts the path indices of a Merkle proof to the identity commitment index in the tree.
0 commit comments