@@ -19,7 +19,6 @@ contract BLSSignatureChecker is IBLSSignatureChecker {
19
19
using BN254 for BN254.G1Point;
20
20
21
21
// CONSTANTS & IMMUTABLES
22
- bytes internal constant ALIGNED_QUORUM_NUMBER = hex "00 " ;
23
22
24
23
// gas cost of multiplying 2 pairings
25
24
uint256 internal constant PAIRING_EQUALITY_CHECK_GAS = 120_000 ;
@@ -80,21 +79,28 @@ contract BLSSignatureChecker is IBLSSignatureChecker {
80
79
* @dev NOTE: Be careful to ensure `msgHash` is collision-resistant! This method does not hash
81
80
* `msgHash` in any way, so if an attacker is able to pass in an arbitrary value, they may be able
82
81
* to tamper with signature verification.
82
+ * @param quorumNumbers is the bytes array of quorum numbers that are being signed for
83
83
* @param referenceBlockNumber is the block number at which the stake information is being verified
84
84
* @param params is the struct containing information on nonsigners, stakes, quorum apks, and the aggregate signature
85
85
* @return quorumStakeTotals is the struct containing the total and signed stake for each quorum
86
86
* @return signatoryRecordHash is the hash of the signatory record, which is used for fraud proofs
87
87
*/
88
88
function checkSignatures (
89
89
bytes32 msgHash ,
90
+ bytes calldata quorumNumbers ,
90
91
uint32 referenceBlockNumber ,
91
92
NonSignerStakesAndSignature memory params
92
93
) public view returns (QuorumStakeTotals memory , bytes32 ) {
93
94
require (
94
- (ALIGNED_QUORUM_NUMBER.length == params.quorumApks.length ) &&
95
- (ALIGNED_QUORUM_NUMBER.length == params.quorumApkIndices.length ) &&
96
- (ALIGNED_QUORUM_NUMBER.length == params.totalStakeIndices.length ) &&
97
- (ALIGNED_QUORUM_NUMBER.length == params.nonSignerStakeIndices.length ),
95
+ quorumNumbers.length != 0 ,
96
+ "BLSSignatureChecker.checkSignatures: empty quorum input "
97
+ );
98
+
99
+ require (
100
+ (quorumNumbers.length == params.quorumApks.length ) &&
101
+ (quorumNumbers.length == params.quorumApkIndices.length ) &&
102
+ (quorumNumbers.length == params.totalStakeIndices.length ) &&
103
+ (quorumNumbers.length == params.nonSignerStakeIndices.length ),
98
104
"BLSSignatureChecker.checkSignatures: input quorum length mismatch "
99
105
);
100
106
@@ -121,8 +127,8 @@ contract BLSSignatureChecker is IBLSSignatureChecker {
121
127
// at the referenceBlockNumber, and derive the stake held by signers by subtracting out
122
128
// stakes held by nonsigners.
123
129
QuorumStakeTotals memory stakeTotals;
124
- stakeTotals.totalStakeForQuorum = new uint96 [](ALIGNED_QUORUM_NUMBER .length );
125
- stakeTotals.signedStakeForQuorum = new uint96 [](ALIGNED_QUORUM_NUMBER .length );
130
+ stakeTotals.totalStakeForQuorum = new uint96 [](quorumNumbers .length );
131
+ stakeTotals.signedStakeForQuorum = new uint96 [](quorumNumbers .length );
126
132
127
133
NonSignerInfo memory nonSigners;
128
134
nonSigners.quorumBitmaps = new uint256 [](
@@ -134,7 +140,7 @@ contract BLSSignatureChecker is IBLSSignatureChecker {
134
140
// Get a bitmap of the quorums signing the message, and validate that
135
141
// quorumNumbers contains only unique, valid quorum numbers
136
142
uint256 signingQuorumBitmap = BitmapUtils.orderedBytesArrayToBitmap (
137
- ALIGNED_QUORUM_NUMBER ,
143
+ quorumNumbers ,
138
144
registryCoordinator.quorumCount ()
139
145
);
140
146
@@ -191,13 +197,13 @@ contract BLSSignatureChecker is IBLSSignatureChecker {
191
197
? delegation.minWithdrawalDelayBlocks ()
192
198
: 0 ;
193
199
194
- for (uint256 i = 0 ; i < ALIGNED_QUORUM_NUMBER .length ; i++ ) {
200
+ for (uint256 i = 0 ; i < quorumNumbers .length ; i++ ) {
195
201
// If we're disallowing stale stake updates, check that each quorum's last update block
196
202
// is within withdrawalDelayBlocks
197
203
if (_staleStakesForbidden) {
198
204
require (
199
205
registryCoordinator.quorumUpdateBlockNumber (
200
- uint8 (ALIGNED_QUORUM_NUMBER [i])
206
+ uint8 (quorumNumbers [i])
201
207
) +
202
208
withdrawalDelayBlocks >
203
209
referenceBlockNumber,
@@ -210,7 +216,7 @@ contract BLSSignatureChecker is IBLSSignatureChecker {
210
216
require (
211
217
bytes24 (params.quorumApks[i].hashG1Point ()) ==
212
218
blsApkRegistry.getApkHashAtBlockNumberAndIndex ({
213
- quorumNumber: uint8 (ALIGNED_QUORUM_NUMBER [i]),
219
+ quorumNumber: uint8 (quorumNumbers [i]),
214
220
blockNumber: referenceBlockNumber,
215
221
index: params.quorumApkIndices[i]
216
222
}),
@@ -221,7 +227,7 @@ contract BLSSignatureChecker is IBLSSignatureChecker {
221
227
// Get the total and starting signed stake for the quorum at referenceBlockNumber
222
228
stakeTotals.totalStakeForQuorum[i] = stakeRegistry
223
229
.getTotalStakeAtBlockNumberFromIndex ({
224
- quorumNumber: uint8 (ALIGNED_QUORUM_NUMBER [i]),
230
+ quorumNumber: uint8 (quorumNumbers [i]),
225
231
blockNumber: referenceBlockNumber,
226
232
index: params.totalStakeIndices[i]
227
233
});
@@ -238,12 +244,12 @@ contract BLSSignatureChecker is IBLSSignatureChecker {
238
244
if (
239
245
BitmapUtils.isSet (
240
246
nonSigners.quorumBitmaps[j],
241
- uint8 (ALIGNED_QUORUM_NUMBER [i])
247
+ uint8 (quorumNumbers [i])
242
248
)
243
249
) {
244
250
stakeTotals.signedStakeForQuorum[i] -= stakeRegistry
245
251
.getStakeAtBlockNumberAndIndex ({
246
- quorumNumber: uint8 (ALIGNED_QUORUM_NUMBER [i]),
252
+ quorumNumber: uint8 (quorumNumbers [i]),
247
253
blockNumber: referenceBlockNumber,
248
254
operatorId: nonSigners.pubkeyHashes[j],
249
255
index: params.nonSignerStakeIndices[i][
0 commit comments