-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rename ed25519 to eddsa, key storage to extensions, add bas…
…e key manager
- Loading branch information
Showing
11 changed files
with
140 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.25; | ||
|
||
import {BaseManager} from "./BaseManager.sol"; | ||
|
||
/** | ||
* @title KeyManager | ||
* @notice Abstract contract for managing keys | ||
*/ | ||
abstract contract KeyManager is BaseManager { | ||
/** | ||
* @notice Updates the key associated with an operator | ||
* @param operator The address of the operator | ||
* @param key The key to update | ||
*/ | ||
|
||
function _updateKey(address operator, bytes memory key) internal virtual; | ||
|
||
/** | ||
* @notice Returns the operator address associated with a given key | ||
* @param key The key for which to find the associated operator | ||
* @return The address of the operator linked to the specified key | ||
*/ | ||
function operatorByKey( | ||
bytes memory key | ||
) public view virtual returns (address); | ||
|
||
/** | ||
* @notice Returns the current or previous key for a given operator | ||
* @dev Returns the previous key if the key was updated in the current epoch | ||
* @param operator The address of the operator | ||
* @return The key associated with the specified operator | ||
*/ | ||
function operatorKey( | ||
address operator | ||
) public view virtual returns (bytes memory); | ||
|
||
/** | ||
* @notice Checks if a key was active at a specific timestamp | ||
* @param timestamp The timestamp to check | ||
* @param key The key to check | ||
* @return True if the key was active at the timestamp, false otherwise | ||
*/ | ||
function keyWasActiveAt(uint48 timestamp, bytes memory key) public view virtual returns (bool); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,16 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.25; | ||
|
||
import {IVault} from "@symbiotic/interfaces/vault/IVault.sol"; | ||
import {IBaseDelegator} from "@symbiotic/interfaces/delegator/IBaseDelegator.sol"; | ||
import {Subnetwork} from "@symbiotic/contracts/libraries/Subnetwork.sol"; | ||
|
||
import {Time} from "@openzeppelin/contracts/utils/types/Time.sol"; | ||
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; | ||
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; | ||
|
||
import {VaultManager} from "../managers/VaultManager.sol"; | ||
import {OperatorManager} from "../managers/OperatorManager.sol"; | ||
import {AccessManager} from "../managers/AccessManager.sol"; | ||
import {KeyManager} from "../managers/KeyManager.sol"; | ||
|
||
abstract contract BaseMiddleware is VaultManager, OperatorManager, AccessManager { | ||
using Subnetwork for address; | ||
/** | ||
* @notice Updates the key associated with an operator | ||
* @param operator The address of the operator | ||
* @param key The key to update | ||
*/ | ||
|
||
function _updateKey(address operator, bytes memory key) internal virtual; | ||
|
||
/** | ||
* @notice Returns the operator address associated with a given key | ||
* @param key The key for which to find the associated operator | ||
* @return The address of the operator linked to the specified key | ||
*/ | ||
function operatorByKey( | ||
bytes memory key | ||
) public view virtual returns (address); | ||
|
||
/** | ||
* @notice Returns the current or previous key for a given operator | ||
* @dev Returns the previous key if the key was updated in the current epoch | ||
* @param operator The address of the operator | ||
* @return The key associated with the specified operator | ||
*/ | ||
function operatorKey( | ||
address operator | ||
) public view virtual returns (bytes memory); | ||
} | ||
/** | ||
* @title BaseMiddleware | ||
* @notice Abstract base contract that combines core manager functionality | ||
* @dev Inherits from VaultManager, OperatorManager, AccessManager and KeyManager to provide | ||
* comprehensive middleware capabilities for vault and operator management, access control, | ||
* and key management | ||
*/ | ||
abstract contract BaseMiddleware is VaultManager, OperatorManager, AccessManager, KeyManager {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.25; | ||
|
||
import {BaseMiddleware} from "../../BaseMiddleware.sol"; | ||
|
||
/** | ||
* @title NoKeyStorage | ||
* @notice A middleware extension that provides no key storage functionality | ||
* @dev Implements BaseMiddleware and always reverts on key operations | ||
*/ | ||
abstract contract NoKeyStorage is BaseMiddleware { | ||
bool public constant NoKeyStorageEnabled = true; | ||
|
||
error KeyStorageDisabled(); | ||
|
||
/** | ||
* @notice Gets the operator address associated with a key | ||
* @param key The key to lookup (unused) | ||
* @return The operator address (always reverts) | ||
*/ | ||
function operatorByKey(bytes memory key) public pure override returns (address) { | ||
revert KeyStorageDisabled(); | ||
} | ||
|
||
/** | ||
* @notice Gets an operator's active key | ||
* @param operator The operator address to lookup (unused) | ||
* @return The operator's key (always reverts) | ||
*/ | ||
function operatorKey(address operator) public pure override returns (bytes memory) { | ||
revert KeyStorageDisabled(); | ||
} | ||
|
||
/** | ||
* @notice Checks if a key was active at a specific timestamp | ||
* @param timestamp The timestamp to check (unused) | ||
* @param key The key to check (unused) | ||
* @return Whether key was active (always reverts) | ||
*/ | ||
function keyWasActiveAt(uint48 timestamp, bytes memory key) public pure override returns (bool) { | ||
revert KeyStorageDisabled(); | ||
} | ||
|
||
/** | ||
* @notice Updates an operator's key | ||
* @param operator The operator address (unused) | ||
* @param key The new key (unused) | ||
*/ | ||
function _updateKey(address operator, bytes memory key) internal virtual override { | ||
revert KeyStorageDisabled(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters