@@ -6,7 +6,7 @@ import {BN254} from "src/libraries/BN254.sol";
6
6
import {BN256G2} from "./BN256G2.sol " ;
7
7
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol " ;
8
8
9
- library OperatorLib {
9
+ library OperatorWalletLib {
10
10
using BN254 for * ;
11
11
using Strings for uint256 ;
12
12
@@ -21,47 +21,46 @@ library OperatorLib {
21
21
BN254.G1Point publicKeyG1;
22
22
}
23
23
24
- Vm private constant vm = Vm (address (uint160 (uint256 (keccak256 ("hevm cheat code " )))));
25
-
26
24
struct Operator {
27
25
Wallet key;
28
26
BLSWallet signingKey;
29
27
}
30
28
31
- function createBLSWallet (uint256 salt ) internal returns (BLSWallet memory ) {
29
+ Vm private constant vm = Vm (address (uint160 (uint256 (keccak256 ("hevm cheat code " )))));
30
+
31
+ function createBLSWallet (
32
+ uint256 salt
33
+ ) internal returns (BLSWallet memory ) {
32
34
uint256 privateKey = uint256 (keccak256 (abi.encodePacked (salt)));
33
35
BN254.G1Point memory publicKeyG1 = BN254.generatorG1 ().scalar_mul (privateKey);
34
36
BN254.G2Point memory publicKeyG2 = mul (privateKey);
35
37
36
- return BLSWallet ({
37
- privateKey: privateKey,
38
- publicKeyG2: publicKeyG2,
39
- publicKeyG1: publicKeyG1
40
- });
38
+ return
39
+ BLSWallet ({privateKey: privateKey, publicKeyG2: publicKeyG2, publicKeyG1: publicKeyG1});
41
40
}
42
41
43
- function createWallet (uint256 salt ) internal pure returns (Wallet memory ) {
42
+ function createWallet (
43
+ uint256 salt
44
+ ) internal pure returns (Wallet memory ) {
44
45
uint256 privateKey = uint256 (keccak256 (abi.encodePacked (salt)));
45
46
address addr = vm.addr (privateKey);
46
47
47
- return Wallet ({
48
- privateKey: privateKey,
49
- addr: addr
50
- });
48
+ return Wallet ({privateKey: privateKey, addr: addr});
51
49
}
52
50
53
- function createOperator (string memory name ) internal returns (Operator memory ) {
51
+ function createOperator (
52
+ string memory name
53
+ ) internal returns (Operator memory ) {
54
54
uint256 salt = uint256 (keccak256 (abi.encodePacked (name)));
55
55
Wallet memory vmWallet = createWallet (salt);
56
56
BLSWallet memory blsWallet = createBLSWallet (salt);
57
57
58
- return Operator ({
59
- key: vmWallet,
60
- signingKey: blsWallet
61
- });
58
+ return Operator ({key: vmWallet, signingKey: blsWallet});
62
59
}
63
60
64
- function mul (uint256 x ) internal returns (BN254.G2Point memory g2Point ) {
61
+ function mul (
62
+ uint256 x
63
+ ) internal returns (BN254.G2Point memory g2Point ) {
65
64
string [] memory inputs = new string [](5 );
66
65
inputs[0 ] = "go " ;
67
66
inputs[1 ] = "run " ;
@@ -84,5 +83,4 @@ library OperatorLib {
84
83
res = vm.ffi (inputs);
85
84
g2Point.Y[0 ] = abi.decode (res, (uint256 ));
86
85
}
87
-
88
- }
86
+ }
0 commit comments