@@ -79,7 +79,7 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
7979 * @param quorumNumber The number of the new quorum
8080 */
8181 function initializeQuorum (uint8 quorumNumber ) public virtual onlyRegistryCoordinator {
82- require (apkHistory[quorumNumber].length == 0 , " BLSApkRegistry.initializeQuorum: quorum already exists " );
82+ require (apkHistory[quorumNumber].length == 0 , QuorumAlreadyExists () );
8383
8484 apkHistory[quorumNumber].push (ApkUpdate ({
8585 apkHash: bytes24 (0 ),
@@ -100,17 +100,9 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
100100 BN254.G1Point calldata pubkeyRegistrationMessageHash
101101 ) external onlyRegistryCoordinator returns (bytes32 operatorId ) {
102102 bytes32 pubkeyHash = BN254.hashG1Point (params.pubkeyG1);
103- require (
104- pubkeyHash != ZERO_PK_HASH, "BLSApkRegistry.registerBLSPublicKey: cannot register zero pubkey "
105- );
106- require (
107- operatorToPubkeyHash[operator] == bytes32 (0 ),
108- "BLSApkRegistry.registerBLSPublicKey: operator already registered pubkey "
109- );
110- require (
111- pubkeyHashToOperator[pubkeyHash] == address (0 ),
112- "BLSApkRegistry.registerBLSPublicKey: public key already registered "
113- );
103+ require (pubkeyHash != ZERO_PK_HASH, ZeroPubKey ());
104+ require (operatorToPubkeyHash[operator] == bytes32 (0 ), OperatorAlreadyRegistered ());
105+ require (pubkeyHashToOperator[pubkeyHash] == address (0 ), BLSPubkeyAlreadyRegistered ());
114106
115107 // gamma = h(sigma, P, P', H(m))
116108 uint256 gamma = uint256 (keccak256 (abi.encodePacked (
@@ -130,7 +122,7 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
130122 BN254.negGeneratorG2 (),
131123 pubkeyRegistrationMessageHash.plus (BN254.generatorG1 ().scalar_mul (gamma)),
132124 params.pubkeyG2
133- ), " BLSApkRegistry.registerBLSPublicKey: either the G1 signature is wrong, or G1 and G2 private key do not match " );
125+ ), InvalidBLSSignatureOrPrivateKey () );
134126
135127 operatorToPubkey[operator] = params.pubkeyG1;
136128 operatorToPubkeyHash[operator] = pubkeyHash;
@@ -151,7 +143,7 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
151143 // Validate quorum exists and get history length
152144 uint8 quorumNumber = uint8 (quorumNumbers[i]);
153145 uint256 historyLength = apkHistory[quorumNumber].length ;
154- require (historyLength != 0 , " BLSApkRegistry._processQuorumApkUpdate: quorum does not exist " );
146+ require (historyLength != 0 , QuorumDoesNotExist () );
155147
156148 // Update aggregate public key for this quorum
157149 newApk = currentApk[quorumNumber].plus (point);
@@ -185,10 +177,7 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
185177 BN254.G1Point memory pubkey = operatorToPubkey[operator];
186178 bytes32 pubkeyHash = operatorToPubkeyHash[operator];
187179
188- require (
189- pubkeyHash != bytes32 (0 ),
190- "BLSApkRegistry.getRegisteredPubkey: operator is not registered "
191- );
180+ require (pubkeyHash != bytes32 (0 ), OperatorNotRegistered ());
192181
193182 return (pubkey, pubkeyHash);
194183 }
@@ -253,11 +242,11 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
253242 */
254243 require (
255244 blockNumber >= quorumApkUpdate.updateBlockNumber,
256- " BLSApkRegistry.getApkHashAtBlockNumberAndIndex: index too recent "
245+ BlockNumberTooRecent ()
257246 );
258247 require (
259248 quorumApkUpdate.nextUpdateBlockNumber == 0 || blockNumber < quorumApkUpdate.nextUpdateBlockNumber,
260- " BLSApkRegistry.getApkHashAtBlockNumberAndIndex: not latest apk update "
249+ BlockNumberNotLatest ()
261250 );
262251
263252 return quorumApkUpdate.apkHash;
@@ -280,9 +269,6 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
280269 }
281270
282271 function _checkRegistryCoordinator () internal view {
283- require (
284- msg .sender == address (registryCoordinator),
285- "BLSApkRegistry._checkRegistryCoordinator: caller is not the registry coordinator "
286- );
272+ require (msg .sender == address (registryCoordinator), OnlyRegistryCoordinatorOwner ());
287273 }
288274}
0 commit comments