GroupKeyManagement Cluster
Cluster ID: 0x003F |
Endpoint: Endpoint 0 (Root Endpoint)
GroupKeyManagement manages the encryption keys used for multicast communication in Matter networks. When you need to send commands to a group of devices simultaneously (e.g., "turn off all living room lights"), devices need to share a set of symmetric keys to encrypt and verify multicast messages. This Cluster is used to write, read, delete, and maintain these key sets.
GroupKeyManagement defines a CacheAndSync (CS) Feature.
When CS is enabled, the device supports caching and syncing trusted root certificates from the Distributed Compliance Ledger (DCL),
and allows the use of the CacheAndSync security policy. Devices without CS can only use the TrustFirst policy.
Commands
The GroupKeyManagement Cluster has 4 commands for managing the complete lifecycle of key sets (KeySets): write, read, delete, and enumerate. Click a command ID in the table below to jump to its detailed description.
| ID | Name | Direction | Description |
|---|---|---|---|
0x00 |
KeySetWrite | Client → Server | Write or update a key set |
0x01 |
KeySetRead | Client → Server | Read specified key set information |
0x03 |
KeySetRemove | Client → Server | Delete a key set |
0x04 |
KeySetReadAllIndices | Client → Server | List all key set IDs for the current Fabric |
KeySetWrite — Write Key Set(0x00)
Writes a complete key set (GroupKeySet) to the device. If the specified GroupKeySetID already exists, it is updated. Each key set contains up to three Epoch keys to support smooth transitions during key rotation.
| Parameter | Type | Description |
|---|---|---|
| GroupKeySet | GroupKeySetStruct | Complete key set structure, containing ID, security policy, and up to three groups of Epoch keys |
Written EpochKeys are sensitive data. The device will not return plaintext keys after storage —
when reading via KeySetRead, EpochKey fields return null, only EpochStartTime is visible.
Usage Scenarios
The Commissioner (e.g., phone App) needs to write shared keys to all devices participating in multicast via KeySetWrite before establishing multicast communication. Typically called after successful device commissioning and before joining a group.
KeySetRead — Read Key Set(0x01)
Reads key set information for the specified ID. Returns KeySetReadResponse, containing the key set's metadata (ID, security policy, Epoch start times) but not the plaintext keys.
| Parameter | Type | Description |
|---|---|---|
| GroupKeySetID | uint16 | Key set ID to read |
KeySetReadResponse
| Field | Type | Description |
|---|---|---|
| GroupKeySet | GroupKeySetStruct | Key set information (EpochKey fields are null, plaintext not returned) |
Usage Scenarios
Called when the management side needs to confirm whether a key set has been successfully written, or to check its security policy and Epoch time windows. Commonly used to check the current key set status before key rotation.
KeySetRemove — Delete Key Set(0x03)
Deletes the key set with the specified ID. Before deletion, ensure no GroupKeyMap entries still reference this key set, otherwise the associated groups will be unable to send or receive encrypted multicast messages properly.
| Parameter | Type | Description |
|---|---|---|
| GroupKeySetID | uint16 | Key set ID to delete (cannot be 0; ID 0 is the IPK key set and cannot be deleted) |
The key set with GroupKeySetID 0 is the Identity Protection Key (IPK),
automatically created when the Fabric is established. Attempting to delete ID 0 returns an INVALID_COMMAND error.
Usage Scenarios
After key rotation is complete, when old key sets are no longer referenced by any group, they can be cleaned up via KeySetRemove to free device storage space.
KeySetReadAllIndices — List All Key Sets(0x04)
Lists all stored key set IDs under the current Fabric. Returns KeySetReadAllIndicesResponse. No parameters required.
KeySetReadAllIndicesResponse
| Field | Type | Description |
|---|---|---|
| GroupKeySetIDs | list<uint16> | List of all key set IDs owned by the current Fabric |
Usage Scenarios
Before performing key audit or rotation, the management side calls this command to get all key set IDs on the device, then reviews details one by one via KeySetRead to decide which need updating or deletion.
Attributes
The GroupKeyManagement Cluster has 4 application attributes. Click an attribute ID in the summary table below to jump to its detailed description.
| ID | Name | Type | Writable | Description |
|---|---|---|---|---|
0x0000 |
GroupKeyMap | list<GroupKeyMapStruct> | Yes | Mapping of group IDs to key sets |
0x0001 |
GroupTable | list<GroupTableStruct> | No | Information table of all groups on the device |
0x0002 |
MaxGroupsPerFabric | uint16 | No | Maximum number of groups per Fabric |
0x0003 |
MaxGroupKeysPerFabric | uint16 | No | Maximum number of key sets per Fabric |
GroupKeyMap — Group Key Mapping(0x0000)
This is the most core attribute of this Cluster. It defines the mapping of "which group uses which key set." Each entry associates a GroupId with a GroupKeySetID, and the device uses this mapping to select the key for encrypting and decrypting multicast messages.
Writable attribute — the management side can write directly to establish or modify mappings. A key set can be shared by multiple groups, or each group can be assigned an independent key set.
GroupKeyMapStruct Structure
| Field | Type | Description |
|---|---|---|
| GroupId | group-id | Group ID (corresponding to a group registered in the Groups Cluster) |
| GroupKeySetID | uint16 | Associated key set ID (must be one already written via KeySetWrite) |
| FabricIndex | fabric-idx | Owning Fabric index (auto-filled, Fabric-isolated) |
GroupTable — Group Information Table(0x0001)
Read-only attribute displaying detailed information for all registered groups on the device. This table is automatically maintained by the device based on Groups Cluster operations and GroupKeyMap; it cannot be written to directly.
GroupTableStruct Structure
| Field | Type | Description |
|---|---|---|
| GroupId | group-id | Group ID |
| Endpoints | list<endpoint-no> | List of Endpoints included in this group |
| GroupName | string | Group name (max 16 bytes, optional) |
| FabricIndex | fabric-idx | Owning Fabric index |
MaxGroupsPerFabric — Max Groups(0x0002)
Read-only attribute indicating the maximum number of groups each Fabric can register. This is a hardware/firmware limit of the device; the management side should reference this value when planning multicast topology.
MaxGroupKeysPerFabric — Max Key Sets(0x0003)
Read-only attribute indicating the maximum number of key sets each Fabric can store. Including the IPK (ID = 0). If the value is 3, then besides the IPK, 2 custom key sets can be stored.
Before writing key sets or adding group mappings, first read MaxGroupsPerFabric and
MaxGroupKeysPerFabric to confirm the device has available space.
Write operations exceeding the limit return a RESOURCE_EXHAUSTED error.
Data Structures
GroupKeySetStruct (Key Set Structure)
Describes a complete multicast key set. Contains the key set ID, security policy, and up to three groups of Epoch keys with their start times. Three Epoch slots support key rotation — the device can hold both old and new keys simultaneously for seamless switching.
| Field | Type | Description |
|---|---|---|
| GroupKeySetID | uint16 | Key set unique identifier. 0 is IPK (Identity Protection Key), automatically managed by the Fabric |
| GroupKeySecurityPolicy | GroupKeySecurityPolicyEnum | Security policy — TrustFirst or CacheAndSync |
| EpochKey0 | octstr (16 bytes) / null | First Epoch key (128-bit AES key). Returns null when read |
| EpochStartTime0 | epoch-us / null | Effective time of EpochKey0 (microsecond-level UTC timestamp) |
| EpochKey1 | octstr (16 bytes) / null | Second Epoch key. Used during key rotation transition period |
| EpochStartTime1 | epoch-us / null | Effective time of EpochKey1 |
| EpochKey2 | octstr (16 bytes) / null | Third Epoch key. The final key after rotation is complete |
| EpochStartTime2 | epoch-us / null | Effective time of EpochKey2 |
Three Epoch slots are arranged in chronological order: EpochStartTime0 < EpochStartTime1 < EpochStartTime2. The device automatically switches to the new key when the current time reaches the corresponding EpochStartTime. During the transition window, the device can simultaneously decrypt received messages with the old key and encrypt sent messages with the new key, ensuring communication is not interrupted as devices in the group gradually update their keys.
Enum Types
GroupKeySecurityPolicyEnum (Security Policy)
Defines the security verification policy used by the key set. Determines how the device verifies the trustworthiness of multicast message sources.
Only after the CS bit is enabled in the device's FeatureMap
can the CacheAndSync policy be used in KeySetWrite.
Writing a CacheAndSync key set to a device that does not support CS returns INVALID_COMMAND.
Feature Bitmap
The GroupKeyManagement Cluster declares the device's supported advanced capabilities through FeatureMap (0xFFFC):
Example Data
Attribute read results of the GroupKeyManagement Cluster on a device with two configured groups:
{
// --- GroupKeyMap (Key Mapping Table) ---
"0x0000": [
{
"GroupId": 1,
"GroupKeySetID": 1,
"FabricIndex": 1
},
{
"GroupId": 2,
"GroupKeySetID": 1,
"FabricIndex": 1
}
],
// --- GroupTable (Group Info Table, Read-only) ---
"0x0001": [
{
"GroupId": 1,
"Endpoints": [1, 2],
"GroupName": "Living Room Lights",
"FabricIndex": 1
},
{
"GroupId": 2,
"Endpoints": [3],
"GroupName": "Bedroom Lights",
"FabricIndex": 1
}
],
// --- Capacity Limits ---
"0x0002": 4, // MaxGroupsPerFabric = 4
"0x0003": 3 // MaxGroupKeysPerFabric = 3
}
GroupKeyMap is the only writable attribute — write to it to bind groups and key sets. GroupTable is read-only, automatically calculated by the device based on Groups Cluster and GroupKeyMap. Key sets themselves are managed through KeySetWrite / KeySetRead commands, not through attribute read/write.
Common Scenarios
Scenario 1: Establishing Multicast Keys for a Group of Devices
When you need multiple devices to join the same group and support multicast communication:
- First read the target device's
MaxGroupKeysPerFabric (0x0003)to confirm key set quota availability - Write the same key set (same GroupKeySetID and EpochKey) to each target device via
KeySetWrite (0x00) - Write the
GroupKeyMap (0x0000)attribute on each device, mapping GroupId to the just-written GroupKeySetID - Add the device to the corresponding group via the Groups Cluster's AddGroup command
- Read
GroupTable (0x0001)to confirm group information and Endpoint mapping are correct - Now you can send multicast commands to the group, and all member devices can decrypt and execute using the shared key
Scenario 2: Key Rotation
Regularly rotating multicast keys is a security best practice. Matter's three-Epoch mechanism allows rotation to proceed seamlessly:
- List all current key set IDs via
KeySetReadAllIndices (0x04) - Read the target key set via
KeySetRead (0x01)and check the current Epoch time windows - Generate a new 128-bit AES key as the next Epoch key
- Update the key set via
KeySetWrite (0x00)— keep the currently active EpochKey, write the new key into the next Epoch slot, and set a future EpochStartTime - Write the same updated key set to each device in the group sequentially
- After all devices have been updated, when the new EpochStartTime arrives, they automatically switch to the new key
- After confirming all devices have switched, old Epoch keys no longer in use can be removed (overwritten in the next KeySetWrite)
The key to key rotation is write to all devices first, then let the new key take effect. If some devices still hold the old key while others have switched to the new key, multicast communication between these devices will be interrupted. Therefore, it is recommended to set EpochStartTime far enough in the future to ensure all devices have time to complete the update.