diff --git a/script/utils/OperatorLib.sol b/script/utils/OperatorLib.sol index 1c2569d1..301481b8 100644 --- a/script/utils/OperatorLib.sol +++ b/script/utils/OperatorLib.sol @@ -203,6 +203,7 @@ library OperatorLib { function registerOperatorFromAVS_OpSet( Operator memory operator, address allocationManager, + address registryCoordinator, address avs, uint32[] memory operatorSetIds ) internal { @@ -210,26 +211,23 @@ library OperatorLib { bytes memory registrationParamsData; IAllocationManager allocationManagerInstance = IAllocationManager(allocationManager); - // Create BLS pubkey registration params + + // Get the pubkey registration message hash that needs to be signed + bytes32 pubkeyRegistrationMessageHash = RegistryCoordinator(registryCoordinator).calculatePubkeyRegistrationMessageHash(operator.key.addr); + + // Sign the pubkey registration message hash + BN254.G1Point memory signature = signMessage(operator.signingKey, pubkeyRegistrationMessageHash); + IBLSApkRegistry.PubkeyRegistrationParams memory blsParams = IBLSApkRegistry.PubkeyRegistrationParams({ pubkeyG1: operator.signingKey.publicKeyG1, pubkeyG2: operator.signingKey.publicKeyG2, - pubkeyRegistrationSignature: operator.signingKey.publicKeyG1 + pubkeyRegistrationSignature: signature }); - // Get the pubkey registration message hash that needs to be signed - BN254.G1Point memory pubkeyRegistrationMessageHash = BN254.hashToG1( - keccak256(abi.encodePacked(operator.key.addr)) - ); - - // Sign the pubkey registration message hash - BN254.G1Point memory signature = signMessage(operator.signingKey, keccak256(abi.encodePacked(operator.key.addr))); - // Encode the registration data for the registry coordinator registrationParamsData = abi.encode( - blsParams, - pubkeyRegistrationMessageHash, - signature + "test-socket", // Random socket string + blsParams ); IAllocationManagerTypes.RegisterParams memory params = IAllocationManagerTypes.RegisterParams({ diff --git a/src/RegistryCoordinator.sol b/src/RegistryCoordinator.sol index 99073714..30db1198 100644 --- a/src/RegistryCoordinator.sol +++ b/src/RegistryCoordinator.sol @@ -1150,8 +1150,23 @@ contract RegistryCoordinator is view returns (BN254.G1Point memory) { - return BN254.hashToG1( - _hashTypedDataV4(keccak256(abi.encode(PUBKEY_REGISTRATION_TYPEHASH, operator))) + return BN254.hashToG1(calculatePubkeyRegistrationMessageHash(operator)); + } + + /** + * @notice Returns the message hash that an operator must sign to register their BLS public key. + * @param operator is the address of the operator registering their BLS public key + */ + function calculatePubkeyRegistrationMessageHash( + address operator + ) public view returns (bytes32) { + return _hashTypedDataV4( + keccak256( + abi.encode( + PUBKEY_REGISTRATION_TYPEHASH, + operator + ) + ) ); } diff --git a/test/unit/OperatorLib.t.sol b/test/unit/OperatorLib.t.sol index 7a73b917..38c3e0d8 100644 --- a/test/unit/OperatorLib.t.sol +++ b/test/unit/OperatorLib.t.sol @@ -174,12 +174,12 @@ contract OperatorLibTest is Test { OperatorLib.registerOperatorFromAVS_OpSet( operators[i], coreDeployment.allocationManager, + middlewareDeployment.registryCoordinator, middlewareDeployment.serviceManager, operatorSetIds ); vm.stopPrank(); } - } }