Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/bindings/BN254CertificateVerifier/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/bindings/BN254TableCalculator/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/bindings/CrossChainRegistry/binding.go

Large diffs are not rendered by default.

64 changes: 63 additions & 1 deletion pkg/bindings/IKeyRegistrar/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/bindings/KeyRegistrar/binding.go

Large diffs are not rendered by default.

64 changes: 63 additions & 1 deletion pkg/bindings/KeyRegistrarStorage/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/bindings/OperatorTableUpdater/binding.go

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions src/contracts/interfaces/IKeyRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,30 @@ interface IKeyRegistrar is IKeyRegistrarErrors, IKeyRegistrarEvents, ISemVerMixi
* @return keyHash The key hash
*/
function getKeyHash(OperatorSet memory operatorSet, address operator) external view returns (bytes32);

/**
* @notice Returns the message hash for ECDSA key registration
* @param operator The operator address
* @param operatorSet The operator set
* @param keyAddress The address of the key
* @return The message hash for signing
*/
function getECDSAKeyRegistrationMessageHash(
address operator,
OperatorSet memory operatorSet,
address keyAddress
) external view returns (bytes32);

/**
* @notice Returns the message hash for BN254 key registration
* @param operator The operator address
* @param operatorSet The operator set
* @param keyData The BN254 key data
* @return The message hash for signing
*/
function getBN254KeyRegistrationMessageHash(
address operator,
OperatorSet memory operatorSet,
bytes calldata keyData
) external view returns (bytes32);
}
32 changes: 7 additions & 25 deletions src/contracts/permissions/KeyRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,8 @@ contract KeyRegistrar is KeyRegistrarStorage, PermissionControllerMixin, Signatu
// Check global uniqueness
require(!globalKeyRegistry[keyHash], KeyAlreadyRegistered());

// Create EIP-712 compliant message hash
bytes32 structHash = keccak256(
abi.encode(ECDSA_KEY_REGISTRATION_TYPEHASH, operator, operatorSet.avs, operatorSet.id, keyAddress)
);
bytes32 signableDigest = _calculateSignableDigest(structHash);
// Get the signable digest for the ECDSA key registration message
bytes32 signableDigest = getECDSAKeyRegistrationMessageHash(operator, operatorSet, keyAddress);

_checkIsValidSignatureNow(keyAddress, signableDigest, signature, type(uint256).max);

Expand Down Expand Up @@ -189,10 +186,7 @@ contract KeyRegistrar is KeyRegistrarStorage, PermissionControllerMixin, Signatu
}

// Create EIP-712 compliant message hash
bytes32 structHash = keccak256(
abi.encode(BN254_KEY_REGISTRATION_TYPEHASH, operator, operatorSet.avs, operatorSet.id, keccak256(keyData))
);
bytes32 signableDigest = _calculateSignableDigest(structHash);
bytes32 signableDigest = getBN254KeyRegistrationMessageHash(operator, operatorSet, keyData);

// Decode signature from bytes to G1 point
(uint256 sigX, uint256 sigY) = abi.decode(signature, (uint256, uint256));
Expand Down Expand Up @@ -323,36 +317,24 @@ contract KeyRegistrar is KeyRegistrarStorage, PermissionControllerMixin, Signatu
return _getKeyHashForKeyData(keyInfo.keyData, curveType);
}

/**
* @notice Returns the message hash for ECDSA key registration
* @param operator The operator address
* @param operatorSet The operator set
* @param keyAddress The ECDSA key address
* @return The message hash for signing
*/
/// @inheritdoc IKeyRegistrar
function getECDSAKeyRegistrationMessageHash(
address operator,
OperatorSet memory operatorSet,
address keyAddress
) external view returns (bytes32) {
) public view returns (bytes32) {
bytes32 structHash = keccak256(
abi.encode(ECDSA_KEY_REGISTRATION_TYPEHASH, operator, operatorSet.avs, operatorSet.id, keyAddress)
);
return _calculateSignableDigest(structHash);
}

/**
* @notice Returns the message hash for BN254 key registration
* @param operator The operator address
* @param operatorSet The operator set
* @param keyData The BN254 key data
* @return The message hash for signing
*/
/// @inheritdoc IKeyRegistrar
function getBN254KeyRegistrationMessageHash(
address operator,
OperatorSet memory operatorSet,
bytes calldata keyData
) external view returns (bytes32) {
) public view returns (bytes32) {
bytes32 structHash = keccak256(
abi.encode(BN254_KEY_REGISTRATION_TYPEHASH, operator, operatorSet.avs, operatorSet.id, keccak256(keyData))
);
Expand Down