diff --git a/test/utils/BN256G2.sol b/test/utils/BN256G2.sol index 45cd34b2..9d407b41 100644 --- a/test/utils/BN256G2.sol +++ b/test/utils/BN256G2.sol @@ -174,7 +174,7 @@ library BN256G2 { function _modInv(uint256 a, uint256 n) internal view returns (uint256 result) { bool success; - assembly ("memory-safe") { + assembly ("memory-safe") { let freemem := mload(0x40) mstore(freemem, 0x20) mstore(add(freemem, 0x20), 0x20) @@ -334,4 +334,4 @@ library BN256G2 { d = d / 2; } } -} \ No newline at end of file +} diff --git a/test/utils/MockAVSDeployer.sol b/test/utils/MockAVSDeployer.sol index dd1de21d..82cd0423 100644 --- a/test/utils/MockAVSDeployer.sol +++ b/test/utils/MockAVSDeployer.sol @@ -53,7 +53,7 @@ import {BLSApkRegistryHarness} from "../harnesses/BLSApkRegistryHarness.sol"; import {EmptyContract} from "eigenlayer-contracts/src/test/mocks/EmptyContract.sol"; import {StakeRegistryHarness} from "../harnesses/StakeRegistryHarness.sol"; -import {OperatorLib} from "../utils/OperatorLib.sol"; +import {OperatorWalletLib} from "../utils/OperatorWalletLib.sol"; import "forge-std/Test.sol"; @@ -549,10 +549,16 @@ contract MockAVSDeployer is Test { }); } - function _createOperators(uint256 numOperators, uint256 startIndex) internal returns (OperatorLib.Operator[] memory) { - OperatorLib.Operator[] memory operators = new OperatorLib.Operator[](numOperators); + function _createOperators( + uint256 numOperators, + uint256 startIndex + ) internal returns (OperatorWalletLib.Operator[] memory) { + OperatorWalletLib.Operator[] memory operators = + new OperatorWalletLib.Operator[](numOperators); for (uint256 i = 0; i < numOperators; i++) { - operators[i] = OperatorLib.createOperator(string(abi.encodePacked("operator-", i + startIndex))); + operators[i] = OperatorWalletLib.createOperator( + string(abi.encodePacked("operator-", i + startIndex)) + ); } return operators; } diff --git a/test/utils/OperatorLib.sol b/test/utils/OperatorWalletLib.sol similarity index 72% rename from test/utils/OperatorLib.sol rename to test/utils/OperatorWalletLib.sol index 082c6f03..561eb1e3 100644 --- a/test/utils/OperatorLib.sol +++ b/test/utils/OperatorWalletLib.sol @@ -6,7 +6,7 @@ import {BN254} from "src/libraries/BN254.sol"; import {BN256G2} from "./BN256G2.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; -library OperatorLib { +library OperatorWalletLib { using BN254 for *; using Strings for uint256; @@ -21,47 +21,46 @@ library OperatorLib { BN254.G1Point publicKeyG1; } - Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code"))))); - struct Operator { Wallet key; BLSWallet signingKey; } - function createBLSWallet(uint256 salt) internal returns (BLSWallet memory) { + Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code"))))); + + function createBLSWallet( + uint256 salt + ) internal returns (BLSWallet memory) { uint256 privateKey = uint256(keccak256(abi.encodePacked(salt))); BN254.G1Point memory publicKeyG1 = BN254.generatorG1().scalar_mul(privateKey); BN254.G2Point memory publicKeyG2 = mul(privateKey); - return BLSWallet({ - privateKey: privateKey, - publicKeyG2: publicKeyG2, - publicKeyG1: publicKeyG1 - }); + return + BLSWallet({privateKey: privateKey, publicKeyG2: publicKeyG2, publicKeyG1: publicKeyG1}); } - function createWallet(uint256 salt) internal pure returns (Wallet memory) { + function createWallet( + uint256 salt + ) internal pure returns (Wallet memory) { uint256 privateKey = uint256(keccak256(abi.encodePacked(salt))); address addr = vm.addr(privateKey); - return Wallet({ - privateKey: privateKey, - addr: addr - }); + return Wallet({privateKey: privateKey, addr: addr}); } - function createOperator(string memory name) internal returns (Operator memory) { + function createOperator( + string memory name + ) internal returns (Operator memory) { uint256 salt = uint256(keccak256(abi.encodePacked(name))); Wallet memory vmWallet = createWallet(salt); BLSWallet memory blsWallet = createBLSWallet(salt); - return Operator({ - key: vmWallet, - signingKey: blsWallet - }); + return Operator({key: vmWallet, signingKey: blsWallet}); } - function mul(uint256 x) internal returns (BN254.G2Point memory g2Point) { + function mul( + uint256 x + ) internal returns (BN254.G2Point memory g2Point) { string[] memory inputs = new string[](5); inputs[0] = "go"; inputs[1] = "run"; @@ -84,5 +83,4 @@ library OperatorLib { res = vm.ffi(inputs); g2Point.Y[0] = abi.decode(res, (uint256)); } - -} \ No newline at end of file +}