You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Motivation:**
Docs were out of date in some places. Redundant functions were present
**Modifications:**
- Clarify docs/natspec
- Remove `checkKey` in favor of `isKeyRegistered`
- Remove old test file
- Add sequence diagrams
- Add documentation on errors/events
**Result:**
Cleaner code
* @param pubkey Public key bytes. For ECDSA, this is the address of the key. For BN254, this is the G1 and G2 key combined (see `encodeBN254KeyData`)
65
+
* @param signature Signature proving ownership. For ECDSA this is a signature of the `getECDSAKeyRegistrationMessageHash`. For BN254 this is a signature of the `getBN254KeyRegistrationMessageHash`.
64
66
* @dev Can be called by operator directly or by addresses they've authorized via PermissionController
65
67
* @dev Reverts if key is already registered
68
+
* @dev There exist no restriction on the state of the operator with respect to the operatorSet. That is, an operator
69
+
* does not have to be registered for the operator in the `AllocationManager` to register a key for it
66
70
*/
67
71
function registerKey(
68
72
address operator,
@@ -72,11 +76,11 @@ function registerKey(
72
76
) external;
73
77
```
74
78
75
-
There are restrictions on the state of the operator with respect to the operatorSet. That is, an operator does not have to be registered for the operator in the `AllocationManager` to register a key for it.
79
+
There ARE NO restrictions on the state of the operator with respect to the operatorSet. That is, an operator does not have to be registered for the operator in the `AllocationManager` to register a key for it.
76
80
77
81
For ECDSA keys:
78
82
-`pubkey`: 20 bytes representing the Ethereum address
79
-
-`signature`: EIP-712 signature from the key's private key
83
+
-`signature`: EIP-712 signature from the key's private key. Signature is over [`getECDSAKeyRegistrationMessageHash`](#getecdsakeyregistrationmessagehash)
80
84
81
85
*Effects*:
82
86
* Registers the key for the operator in the specified operator set
@@ -201,7 +205,7 @@ Returns the message hash that must be signed over for BN254 key registration.
201
205
* @notice Deregisters a cryptographic key for an operator with a specific operator set
202
206
* @param operator Address of the operator to deregister key for
203
207
* @param operatorSet The operator set to deregister the key from
204
-
* @dev Can be called by avs directly or by addresses they've authorized via PermissionController
208
+
* @dev Can be called by operator directly or by addresses they've authorized via PermissionController
205
209
* @dev Reverts if key was not registered
206
210
* @dev Keys remain in global key registry to prevent reuse
207
211
*/
@@ -216,9 +220,46 @@ Removes an operator's key from the specified operator set. Note that the key rem
216
220
* The key remains in the global registry
217
221
218
222
*Requirements*:
219
-
* Caller MUST be authorized for the AVS (via PermissionController)
223
+
* Caller MUST be authorized for the operator (via PermissionController)
220
224
* The operator MUST not be slashable for the AVS, to prevent off-chain race conditions
221
225
* The operator set MUST be configured
222
226
* The operator MUST have a registered key for this operator set
223
227
224
228
---
229
+
230
+
## Usage patterns
231
+
The `KeyRegistrar` introduces new operator/avs registration patterns. Note that these registration patterns are **only for AVSs who have opted to use the new [middlewareV2](https://github.com/Layr-Labs/eigenlayer-middleware/tree/dev/docs/middlewareV2) contract architecture.**
232
+
233
+
### Operator/AVS Registration
234
+
235
+
```mermaid
236
+
sequenceDiagram
237
+
participant OP as Operator
238
+
participant KR as KeyRegistrar
239
+
participant AM as AllocationManager
240
+
participant AVR as AVSRegistrar
241
+
242
+
OP->>KR: Tx1: registerKey
243
+
OP->>AM: Tx2: registerForOperatorSets
244
+
AM-->>AVR: registerForOperatorSets
245
+
AVR-->>KR: isRegistered
246
+
```
247
+
248
+
249
+
### Deregistration/Key Rotation
250
+
251
+
Deregistration takes a dependency on the `AllocationManager`. In particular, operators are only allowed to deregister their key from an operatorSet if they are not slashable by said operatorSet.
252
+
253
+
To rotate a key, an operator must deregister from the operatorSet, wait until it is not slashable, deregister its key, and then register a new key. If the operator was not slashable, it can rotate its key without a delay.
254
+
255
+
```mermaid
256
+
sequenceDiagram
257
+
participant OP as Operator
258
+
participant AM as AllocationManager
259
+
participant KR as KeyRegistrar
260
+
261
+
OP->>AM: Tx1: deregisterFromOperatorSets
262
+
Note over OP: Wait 14 days<br>(if previously allocated)
* @param pubkey Public key bytes. For ECDSA, this is the address of the key. For BN254, this is the G1 and G2 key combined (see `encodeBN254KeyData`)
71
+
* @param signature Signature proving ownership. For ECDSA this is a signature of the `getECDSAKeyRegistrationMessageHash`. For BN254 this is a signature of the `getBN254KeyRegistrationMessageHash`.
59
72
* @dev Can be called by operator directly or by addresses they've authorized via PermissionController
60
73
* @dev Reverts if key is already registered
61
74
* @dev There exist no restriction on the state of the operator with respect to the operatorSet. That is, an operator
@@ -79,29 +92,19 @@ interface IKeyRegistrar is IKeyRegistrarErrors, IKeyRegistrarEvents, ISemVerMixi
79
92
*/
80
93
function deregisterKey(addressoperator, OperatorSet memoryoperatorSet) external;
81
94
82
-
/**
83
-
* @notice Checks if an operator has a registered key
84
-
* @param operatorSet The operator set to check and update
85
-
* @param operator Address of the operator
86
-
* @return whether the operator has a registered key
87
-
* @dev This function is called by the AVSRegistrar when an operator registers for an AVS
88
-
* @dev Only authorized callers for the AVS can call this function
89
-
* @dev Reverts if operator doesn't have a registered key for this operator set
90
-
*/
91
-
function checkKey(OperatorSet memoryoperatorSet, addressoperator) externalviewreturns (bool);
92
-
93
95
/**
94
96
* @notice Checks if a key is registered for an operator with a specific operator set
95
97
* @param operatorSet The operator set to check
96
98
* @param operator Address of the operator
97
-
* @return True if the key is registered
99
+
* @return True if the key is registered, false otherwise
100
+
* @dev If the operatorSet is not configured, this function will return false
98
101
*/
99
102
function isRegistered(OperatorSet memoryoperatorSet, addressoperator) externalviewreturns (bool);
100
103
101
104
/**
102
-
* @notice Gets the configuration for an operator set
103
-
* @param operatorSet The operator set to get configuration for
104
-
* @return The operator set configuration
105
+
* @notice Gets the curve type for an operator set
106
+
* @param operatorSet The operator set to get the curve type for
107
+
* @return The curve type, either ECDSA, BN254, or NONE
105
108
*/
106
109
function getOperatorSetCurveType(
107
110
OperatorSet memoryoperatorSet
@@ -113,6 +116,7 @@ interface IKeyRegistrar is IKeyRegistrarErrors, IKeyRegistrarEvents, ISemVerMixi
113
116
* @param operator Address of the operator
114
117
* @return g1Point The BN254 G1 public key
115
118
* @return g2Point The BN254 G2 public key
119
+
* @dev Reverts if the operatorSet is not configured for BN254
116
120
*/
117
121
function getBN254Key(
118
122
OperatorSet memoryoperatorSet,
@@ -123,15 +127,17 @@ interface IKeyRegistrar is IKeyRegistrarErrors, IKeyRegistrarEvents, ISemVerMixi
123
127
* @notice Gets the ECDSA public key for an operator with a specific operator set as bytes
124
128
* @param operatorSet The operator set to get the key for
125
129
* @param operator Address of the operator
126
-
* @return pubkey The ECDSA public key
130
+
* @return pubkey The ECDSA public key in bytes format
131
+
* @dev Reverts if the operatorSet is not configured for ECDSA
127
132
*/
128
133
function getECDSAKey(OperatorSet memoryoperatorSet, addressoperator) externalviewreturns (bytesmemory);
129
134
130
135
/**
131
136
* @notice Gets the ECDSA public key for an operator with a specific operator set
132
137
* @param operatorSet The operator set to get the key for
133
138
* @param operator Address of the operator
134
-
* @return pubkey The ECDSA public key
139
+
* @return pubkey The ECDSA public key in address format
140
+
* @dev Reverts if the operatorSet is not configured for ECDSA
135
141
*/
136
142
function getECDSAAddress(OperatorSet memoryoperatorSet, addressoperator) externalviewreturns (address);
137
143
@@ -149,6 +155,7 @@ interface IKeyRegistrar is IKeyRegistrarErrors, IKeyRegistrarEvents, ISemVerMixi
149
155
* @param operatorSet The operator set to get the key hash for
150
156
* @param operator Address of the operator
151
157
* @return keyHash The key hash
158
+
* @dev Reverts if the operatorSet is not configured
152
159
*/
153
160
function getKeyHash(OperatorSet memoryoperatorSet, addressoperator) externalviewreturns (bytes32);
0 commit comments