Skip to content

Commit 3fb5b61

Browse files
fix: bls sig operator state retriever sorting (#480)
**Motivation:** Non-signer pubkeys were not properly ordered in the last iteration of this feature **Modifications:** Added OZ libraries as packed utilities for sorting, added sorting of the non-signers before returning them **Result:** Now all parameters returned are sorted in ascending order, which allows for strong assurances regarding non-duplicates in the array --------- Co-authored-by: rubydusa <[email protected]>
1 parent fd26169 commit 3fb5b61

File tree

4 files changed

+959
-29
lines changed

4 files changed

+959
-29
lines changed

src/unaudited/BLSSigCheckOperatorStateRetriever.sol

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@ import {BitmapUtils} from "../libraries/BitmapUtils.sol";
1010
import {BN254} from "../libraries/BN254.sol";
1111
import {BN256G2} from "./BN256G2.sol";
1212
import {OperatorStateRetriever} from "../OperatorStateRetriever.sol";
13-
import {ECUtils} from "./ECUtils.sol";
13+
import {BLSSigCheckUtils, Arrays} from "./BLSSigCheckUtils.sol";
1414

1515
/**
1616
* @title BLSSigCheckOperatorStateRetriever with view functions that allow to retrieve the state of an AVSs registry system.
1717
* @dev This contract inherits from OperatorStateRetriever and adds the getNonSignerStakesAndSignature function.
1818
* @author Bread coop
1919
*/
2020
contract BLSSigCheckOperatorStateRetriever is OperatorStateRetriever {
21-
using ECUtils for BN254.G1Point;
21+
using BLSSigCheckUtils for BN254.G1Point;
2222
using BN254 for BN254.G1Point;
2323
using BitmapUtils for uint256;
24+
using Arrays for bytes32[];
2425

2526
/// @dev Thrown when the signature is not on the curve.
2627
error InvalidSigma();
@@ -150,9 +151,13 @@ contract BLSSigCheckOperatorStateRetriever is OperatorStateRetriever {
150151

151152
// Trim the nonSignerOperatorIds array to the actual count
152153
bytes32[] memory trimmedNonSignerOperatorIds = new bytes32[](nonSignerOperatorsCount);
153-
BN254.G1Point[] memory nonSignerPubkeys = new BN254.G1Point[](nonSignerOperatorsCount);
154154
for (uint256 i = 0; i < nonSignerOperatorsCount; i++) {
155155
trimmedNonSignerOperatorIds[i] = nonSignerOperatorIds[i];
156+
}
157+
trimmedNonSignerOperatorIds = Arrays.sort(trimmedNonSignerOperatorIds);
158+
159+
BN254.G1Point[] memory nonSignerPubkeys = new BN254.G1Point[](nonSignerOperatorsCount);
160+
for (uint256 i = 0; i < nonSignerOperatorsCount; i++) {
156161
address nonSignerOperator =
157162
registryCoordinator.getOperatorFromId(trimmedNonSignerOperatorIds[i]);
158163
(nonSignerPubkeys[i],) = m.blsApkRegistry.getRegisteredPubkey(nonSignerOperator);

0 commit comments

Comments
 (0)