---
# System prepended metadata

title: Groups

---

---
sidebar_position: 1
---

# Groups

You can write the doc here. Before pushing your changes we'll remove the text below.

___

## Key points

### Merkle tree/groups relationship

Groups are actually incremental Merkle trees and group members are tree leaves. Since the Merkle tree implementation we are using now is a binary Merkle tree, the max number of members of a group is equal to `2 ^ treeDepth`. We will allow devs to use different tree depths (probably a range from 16 to 32). It could make sense to show the different group sizes a dev could use based on tree depths:

| Tree depth | Group max size | 
| -------- | -------- | 
| 16     | 2^16 = 65536     |
| 17     | 2^17 = 131072    |
| ...     | ...    |

Merkle trees are very useful when you want to prove that a leaf is part of the tree without sharing the whole data structure, but only the path from the leaf to the root. Merkle proofs are part the Semaphore zero-knowledge proofs.

### `SemaphoreGroup.sol` contract

Groups can be used by extending the `SemaphoreGroups.sol` contract. It contains 3 internal functions that must be called in the parent contract for group management (`_createGroup`, `_addMember`, `_removeMember`), and 3 public functions to get group information (`getRoot`, `getDepth`, `getNumberOfLeaves`).

The extension contracts are a good example to see how Semaphore groups can be used.

## Suggestions

* The guide could introduce the Semaphore groups by explaining what they are and why they are used.
* The guide could explain how developers can use the `SemaphoreGroup.sol` contract and its functions.

