From 7486bb67a85552847c3b4bc8129ce3d5bf8afab6 Mon Sep 17 00:00:00 2001 From: steven Date: Wed, 4 Dec 2024 09:35:13 -0500 Subject: [PATCH 1/2] fix: revert making library function vis external --- src/libraries/BN254.sol | 22 +++++++++++----------- src/libraries/QuorumBitmapHistoryLib.sol | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/libraries/BN254.sol b/src/libraries/BN254.sol index 4d0edf70..37e3d273 100644 --- a/src/libraries/BN254.sol +++ b/src/libraries/BN254.sol @@ -46,7 +46,7 @@ library BN254 { uint256[2] Y; } - function generatorG1() external pure returns (G1Point memory) { + function generatorG1() internal pure returns (G1Point memory) { return G1Point(1, 2); } @@ -62,7 +62,7 @@ library BN254 { /// this is because of the (unknown to us) convention used in the bn254 pairing precompile contract /// "Elements a * i + b of F_p^2 are encoded as two elements of F_p, (a, b)." /// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-197.md#encoding - function generatorG2() external pure returns (G2Point memory) { + function generatorG2() internal pure returns (G2Point memory) { return G2Point([G2x1, G2x0], [G2y1, G2y0]); } @@ -73,7 +73,7 @@ library BN254 { uint256 internal constant nG2y1 = 17805874995975841540914202342111839520379459829704422454583296818431106115052; uint256 internal constant nG2y0 = 13392588948715843804641432497768002650278120570034223513918757245338268106653; - function negGeneratorG2() external pure returns (G2Point memory) { + function negGeneratorG2() internal pure returns (G2Point memory) { return G2Point([nG2x1, nG2x0], [nG2y1, nG2y0]); } @@ -84,7 +84,7 @@ library BN254 { * @param p Some point in G1. * @return The negation of `p`, i.e. p.plus(p.negate()) should be zero. */ - function negate(G1Point memory p) external pure returns (G1Point memory) { + function negate(G1Point memory p) internal pure returns (G1Point memory) { // The prime q in the base field F_q for G1 if (p.X == 0 && p.Y == 0) { return G1Point(0, 0); @@ -122,7 +122,7 @@ library BN254 { * @param p the point to multiply * @param s the scalar to multiply by * @dev this function is only safe to use if the scalar is 9 bits or less - */ + */ function scalar_mul_tiny(BN254.G1Point memory p, uint16 s) internal view returns (BN254.G1Point memory) { require(s < 2**9, "scalar-too-large"); @@ -155,7 +155,7 @@ library BN254 { ++i; } } - + // return the accumulated product return acc; } @@ -194,7 +194,7 @@ library BN254 { G2Point memory a2, G1Point memory b1, G2Point memory b2 - ) external view returns (bool) { + ) internal view returns (bool) { G1Point[2] memory p1 = [a1, b1]; G2Point[2] memory p2 = [a2, b2]; @@ -238,7 +238,7 @@ library BN254 { G1Point memory b1, G2Point memory b2, uint256 pairingGas - ) external view returns (bool, bool) { + ) internal view returns (bool, bool) { G1Point[2] memory p1 = [a1, b1]; G2Point[2] memory p2 = [a2, b2]; @@ -270,7 +270,7 @@ library BN254 { /// @return hashedG1 the keccak256 hash of the G1 Point /// @dev used for BLS signatures - function hashG1Point(BN254.G1Point memory pk) external pure returns (bytes32 hashedG1) { + function hashG1Point(BN254.G1Point memory pk) internal pure returns (bytes32 hashedG1) { assembly { mstore(0, mload(pk)) mstore(0x20, mload(add(0x20, pk))) @@ -282,14 +282,14 @@ library BN254 { /// @dev used for BLS signatures function hashG2Point( BN254.G2Point memory pk - ) external pure returns (bytes32) { + ) internal pure returns (bytes32) { return keccak256(abi.encodePacked(pk.X[0], pk.X[1], pk.Y[0], pk.Y[1])); } /** * @notice adapted from https://github.com/HarryR/solcrypto/blob/master/contracts/altbn128.sol */ - function hashToG1(bytes32 _x) external view returns (G1Point memory) { + function hashToG1(bytes32 _x) internal view returns (G1Point memory) { uint256 beta = 0; uint256 y = 0; diff --git a/src/libraries/QuorumBitmapHistoryLib.sol b/src/libraries/QuorumBitmapHistoryLib.sol index 4a3e72fd..c971d64d 100644 --- a/src/libraries/QuorumBitmapHistoryLib.sol +++ b/src/libraries/QuorumBitmapHistoryLib.sol @@ -41,7 +41,7 @@ library QuorumBitmapHistoryLib { function currentOperatorBitmap( mapping(bytes32 => IRegistryCoordinator.QuorumBitmapUpdate[]) storage self, bytes32 operatorId - ) external view returns (uint192) { + ) internal view returns (uint192) { uint256 historyLength = self[operatorId].length; if (historyLength == 0) { return 0; @@ -59,7 +59,7 @@ library QuorumBitmapHistoryLib { mapping(bytes32 => IRegistryCoordinator.QuorumBitmapUpdate[]) storage self, uint32 blockNumber, bytes32[] memory operatorIds - ) external view returns (uint32[] memory) { + ) internal view returns (uint32[] memory) { uint32[] memory indices = new uint32[](operatorIds.length); for (uint256 i = 0; i < operatorIds.length; i++) { indices[i] = getQuorumBitmapIndexAtBlockNumber(self, blockNumber, operatorIds[i]); @@ -78,7 +78,7 @@ library QuorumBitmapHistoryLib { bytes32 operatorId, uint32 blockNumber, uint256 index - ) external view returns (uint192) { + ) internal view returns (uint192) { IRegistryCoordinator.QuorumBitmapUpdate memory quorumBitmapUpdate = self[operatorId][index]; /** @@ -107,7 +107,7 @@ library QuorumBitmapHistoryLib { mapping(bytes32 => IRegistryCoordinator.QuorumBitmapUpdate[]) storage self, bytes32 operatorId, uint192 newBitmap - ) external { + ) internal { uint256 historyLength = self[operatorId].length; if (historyLength == 0) { From 0512a906c52f5e2811b6b7cbee97df0101efe406 Mon Sep 17 00:00:00 2001 From: steven Date: Wed, 4 Dec 2024 09:57:02 -0500 Subject: [PATCH 2/2] fix: signature checker internal --- src/libraries/SignatureCheckerLib.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/SignatureCheckerLib.sol b/src/libraries/SignatureCheckerLib.sol index c01fd3a7..410462cc 100644 --- a/src/libraries/SignatureCheckerLib.sol +++ b/src/libraries/SignatureCheckerLib.sol @@ -11,7 +11,7 @@ import "@openzeppelin-upgrades/contracts/utils/cryptography/SignatureCheckerUpgr */ library SignatureCheckerLib { error InvalidSignature(); - + /** * @notice Validates a signature using EIP-1271 standard. * @param signer The address of the signer. @@ -22,7 +22,7 @@ library SignatureCheckerLib { address signer, bytes32 digestHash, bytes memory signature - ) external view { + ) internal view { if (!SignatureCheckerUpgradeable.isValidSignatureNow(signer, digestHash, signature)) { revert InvalidSignature(); }