diff --git a/SmartContracts/src/avs/PreconfRegistry.sol b/SmartContracts/src/avs/PreconfRegistry.sol index 9b6de67..d45209d 100644 --- a/SmartContracts/src/avs/PreconfRegistry.sol +++ b/SmartContracts/src/avs/PreconfRegistry.sol @@ -124,11 +124,7 @@ contract PreconfRegistry is IPreconfRegistry, BLSSignatureChecker, Initializable // revert ValidatorSignatureExpired(); // } - // Point compress the public key just how it is done on the consensus layer - uint256[2] memory compressedPubKey = addValidatorParams[i].pubkey.compress(); - // Use the hash for ease of mapping - bytes32 pubKeyHash = keccak256(abi.encodePacked(compressedPubKey)); - + bytes32 pubKeyHash = _hashBLSPubKey(addValidatorParams[i].pubkey); Validator memory validator = validators[pubKeyHash]; // Update the validator if it has no preconfer assigned, or if it has stopped proposing @@ -162,11 +158,7 @@ contract PreconfRegistry is IPreconfRegistry, BLSSignatureChecker, Initializable */ function removeValidators(RemoveValidatorParam[] calldata removeValidatorParams) external { for (uint256 i; i < removeValidatorParams.length; ++i) { - // Point compress the public key just how it is done on the consensus layer - uint256[2] memory compressedPubKey = removeValidatorParams[i].pubkey.compress(); - // Use the hash for ease of mapping - bytes32 pubKeyHash = keccak256(abi.encodePacked(compressedPubKey)); - + bytes32 pubKeyHash = _hashBLSPubKey(removeValidatorParams[i].pubkey); Validator memory validator = validators[pubKeyHash]; // Revert if the validator is not active (or already removed, but waiting to stop proposing) @@ -238,4 +230,9 @@ contract PreconfRegistry is IPreconfRegistry, BLSSignatureChecker, Initializable { return abi.encodePacked(block.chainid, validatorOp, expiry, preconfer); } + + function _hashBLSPubKey(BLS12381.G1Point calldata pubkey) internal pure returns (bytes32) { + uint256[2] memory compressedPubKey = pubkey.compress(); + return keccak256(abi.encodePacked(compressedPubKey)); + } }