@cofhe/mock-contracts 0.0.0-beta-20251027110729
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +126 -0
- package/contracts/MockACL.sol +338 -0
- package/contracts/MockCoFHE.sol +441 -0
- package/contracts/MockQueryDecrypter.sol +133 -0
- package/contracts/MockTaskManager.sol +593 -0
- package/contracts/MockZkVerifier.sol +140 -0
- package/contracts/Permissioned.sol +213 -0
- package/contracts/TestBed.sol +66 -0
- package/contracts/foundry/CoFheTest.sol +432 -0
- package/contracts/foundry/MockZkVerifierSigner.sol +40 -0
- package/dist/index.d.mts +261 -0
- package/dist/index.d.ts +261 -0
- package/dist/index.js +2488 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2482 -0
- package/dist/index.mjs.map +1 -0
- package/foundry.toml +7 -0
- package/package.json +62 -0
- package/remappings.txt +5 -0
- package/src/MockACL.ts +558 -0
- package/src/MockQueryDecrypter.ts +350 -0
- package/src/MockTaskManager.ts +1026 -0
- package/src/MockZkVerifier.ts +264 -0
- package/src/TestBed.ts +286 -0
- package/src/index.ts +6 -0
- package/src/types.ts +6 -0
- package/test/TestBed.t.sol +60 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// This file is auto-generated by build-artifacts.ts
|
|
2
|
+
import { type MocksArtifact } from './index';
|
|
3
|
+
|
|
4
|
+
export const MockZkVerifierArtifact = {
|
|
5
|
+
"contractName": "MockZkVerifier",
|
|
6
|
+
"fixedAddress": "0x0000000000000000000000000000000000000100",
|
|
7
|
+
"abi": [
|
|
8
|
+
{
|
|
9
|
+
"type": "function",
|
|
10
|
+
"name": "exists",
|
|
11
|
+
"inputs": [],
|
|
12
|
+
"outputs": [
|
|
13
|
+
{
|
|
14
|
+
"name": "",
|
|
15
|
+
"type": "bool",
|
|
16
|
+
"internalType": "bool"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"stateMutability": "pure"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"type": "function",
|
|
23
|
+
"name": "insertCtHash",
|
|
24
|
+
"inputs": [
|
|
25
|
+
{
|
|
26
|
+
"name": "ctHash",
|
|
27
|
+
"type": "uint256",
|
|
28
|
+
"internalType": "uint256"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "value",
|
|
32
|
+
"type": "uint256",
|
|
33
|
+
"internalType": "uint256"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"outputs": [],
|
|
37
|
+
"stateMutability": "nonpayable"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"type": "function",
|
|
41
|
+
"name": "insertPackedCtHashes",
|
|
42
|
+
"inputs": [
|
|
43
|
+
{
|
|
44
|
+
"name": "ctHashes",
|
|
45
|
+
"type": "uint256[]",
|
|
46
|
+
"internalType": "uint256[]"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "values",
|
|
50
|
+
"type": "uint256[]",
|
|
51
|
+
"internalType": "uint256[]"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"outputs": [],
|
|
55
|
+
"stateMutability": "nonpayable"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"type": "function",
|
|
59
|
+
"name": "zkVerify",
|
|
60
|
+
"inputs": [
|
|
61
|
+
{
|
|
62
|
+
"name": "value",
|
|
63
|
+
"type": "uint256",
|
|
64
|
+
"internalType": "uint256"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"name": "utype",
|
|
68
|
+
"type": "uint8",
|
|
69
|
+
"internalType": "uint8"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"name": "user",
|
|
73
|
+
"type": "address",
|
|
74
|
+
"internalType": "address"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"name": "securityZone",
|
|
78
|
+
"type": "uint8",
|
|
79
|
+
"internalType": "uint8"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"name": "",
|
|
83
|
+
"type": "uint256",
|
|
84
|
+
"internalType": "uint256"
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"outputs": [
|
|
88
|
+
{
|
|
89
|
+
"name": "",
|
|
90
|
+
"type": "tuple",
|
|
91
|
+
"internalType": "struct EncryptedInput",
|
|
92
|
+
"components": [
|
|
93
|
+
{
|
|
94
|
+
"name": "ctHash",
|
|
95
|
+
"type": "uint256",
|
|
96
|
+
"internalType": "uint256"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"name": "securityZone",
|
|
100
|
+
"type": "uint8",
|
|
101
|
+
"internalType": "uint8"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"name": "utype",
|
|
105
|
+
"type": "uint8",
|
|
106
|
+
"internalType": "uint8"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"name": "signature",
|
|
110
|
+
"type": "bytes",
|
|
111
|
+
"internalType": "bytes"
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"stateMutability": "nonpayable"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"type": "function",
|
|
120
|
+
"name": "zkVerifyCalcCtHash",
|
|
121
|
+
"inputs": [
|
|
122
|
+
{
|
|
123
|
+
"name": "value",
|
|
124
|
+
"type": "uint256",
|
|
125
|
+
"internalType": "uint256"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"name": "utype",
|
|
129
|
+
"type": "uint8",
|
|
130
|
+
"internalType": "uint8"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"name": "user",
|
|
134
|
+
"type": "address",
|
|
135
|
+
"internalType": "address"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"name": "securityZone",
|
|
139
|
+
"type": "uint8",
|
|
140
|
+
"internalType": "uint8"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"name": "",
|
|
144
|
+
"type": "uint256",
|
|
145
|
+
"internalType": "uint256"
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
"outputs": [
|
|
149
|
+
{
|
|
150
|
+
"name": "ctHash",
|
|
151
|
+
"type": "uint256",
|
|
152
|
+
"internalType": "uint256"
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
"stateMutability": "view"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"type": "function",
|
|
159
|
+
"name": "zkVerifyCalcCtHashesPacked",
|
|
160
|
+
"inputs": [
|
|
161
|
+
{
|
|
162
|
+
"name": "values",
|
|
163
|
+
"type": "uint256[]",
|
|
164
|
+
"internalType": "uint256[]"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"name": "utypes",
|
|
168
|
+
"type": "uint8[]",
|
|
169
|
+
"internalType": "uint8[]"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"name": "user",
|
|
173
|
+
"type": "address",
|
|
174
|
+
"internalType": "address"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"name": "securityZone",
|
|
178
|
+
"type": "uint8",
|
|
179
|
+
"internalType": "uint8"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"name": "chainId",
|
|
183
|
+
"type": "uint256",
|
|
184
|
+
"internalType": "uint256"
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
"outputs": [
|
|
188
|
+
{
|
|
189
|
+
"name": "ctHashes",
|
|
190
|
+
"type": "uint256[]",
|
|
191
|
+
"internalType": "uint256[]"
|
|
192
|
+
}
|
|
193
|
+
],
|
|
194
|
+
"stateMutability": "view"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"type": "function",
|
|
198
|
+
"name": "zkVerifyPacked",
|
|
199
|
+
"inputs": [
|
|
200
|
+
{
|
|
201
|
+
"name": "values",
|
|
202
|
+
"type": "uint256[]",
|
|
203
|
+
"internalType": "uint256[]"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"name": "utypes",
|
|
207
|
+
"type": "uint8[]",
|
|
208
|
+
"internalType": "uint8[]"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"name": "user",
|
|
212
|
+
"type": "address",
|
|
213
|
+
"internalType": "address"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"name": "securityZone",
|
|
217
|
+
"type": "uint8",
|
|
218
|
+
"internalType": "uint8"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"name": "chainId",
|
|
222
|
+
"type": "uint256",
|
|
223
|
+
"internalType": "uint256"
|
|
224
|
+
}
|
|
225
|
+
],
|
|
226
|
+
"outputs": [
|
|
227
|
+
{
|
|
228
|
+
"name": "inputs",
|
|
229
|
+
"type": "tuple[]",
|
|
230
|
+
"internalType": "struct EncryptedInput[]",
|
|
231
|
+
"components": [
|
|
232
|
+
{
|
|
233
|
+
"name": "ctHash",
|
|
234
|
+
"type": "uint256",
|
|
235
|
+
"internalType": "uint256"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"name": "securityZone",
|
|
239
|
+
"type": "uint8",
|
|
240
|
+
"internalType": "uint8"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"name": "utype",
|
|
244
|
+
"type": "uint8",
|
|
245
|
+
"internalType": "uint8"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"name": "signature",
|
|
249
|
+
"type": "bytes",
|
|
250
|
+
"internalType": "bytes"
|
|
251
|
+
}
|
|
252
|
+
]
|
|
253
|
+
}
|
|
254
|
+
],
|
|
255
|
+
"stateMutability": "nonpayable"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"type": "error",
|
|
259
|
+
"name": "InvalidInputs",
|
|
260
|
+
"inputs": []
|
|
261
|
+
}
|
|
262
|
+
],
|
|
263
|
+
"deployedBytecode": "0x608060405234801561000f575f5ffd5b506004361061007b575f3560e01c8063772de59611610059578063772de596146100e9578063a2616ba914610119578063a9f046cd14610149578063d2a0693e146101655761007b565b8063267c4ae41461007f5780635946761f1461009d57806366dfcfc6146100cd575b5f5ffd5b610087610195565b6040516100949190610750565b60405180910390f35b6100b760048036038101906100b29190610a4d565b61019d565b6040516100c49190610c95565b60405180910390f35b6100e760048036038101906100e29190610cb5565b6102b5565b005b61010360048036038101906100fe9190610a4d565b61034d565b6040516101109190610d9b565b60405180910390f35b610133600480360381019061012e9190610dbb565b61045b565b6040516101409190610e92565b60405180910390f35b610163600480360381019061015e9190610eb2565b6104bd565b005b61017f600480360381019061017a9190610dbb565b61051b565b60405161018c9190610f37565b60405180910390f35b5f6001905090565b606085518551146101da576040517ff34cfab600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b845167ffffffffffffffff8111156101f5576101f461078e565b5b60405190808252806020026020018201604052801561022e57816020015b61021b61070b565b8152602001906001900390816102135790505b5090505f5f90505b85518110156102ab5761028087828151811061025557610254610f50565b5b60200260200101518783815181106102705761026f610f50565b5b602002602001015187878761045b565b82828151811061029357610292610f50565b5b60200260200101819052508080600101915050610236565b5095945050505050565b73ea30c4b8b44078bbf8a6ef5b9f1ec1626c7848d973ffffffffffffffffffffffffffffffffffffffff166315a486fe83836040518363ffffffff1660e01b8152600401610304929190610f7d565b5f604051808303815f87803b15801561031b575f5ffd5b505af115801561032d573d5f5f3e3d5ffd5b5050505060015f5f8282546103429190610fd1565b925050819055505050565b6060855185511461038a576040517ff34cfab600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b845167ffffffffffffffff8111156103a5576103a461078e565b5b6040519080825280602002602001820160405280156103d35781602001602082028036833780820191505090505b5090505f5f90505b8551811015610451576104258782815181106103fa576103f9610f50565b5b602002602001015187838151811061041557610414610f50565b5b602002602001015187878761051b565b82828151811061043857610437610f50565b5b60200260200101818152505080806001019150506103db565b5095945050505050565b61046361070b565b5f6104708587868a610533565b905061047c81886102b5565b60405180608001604052808281526020018560ff1681526020018760ff16815260200160405180602001604052805f81525081525091505095945050505050565b5f5f90505b8251811015610516576105098382815181106104e1576104e0610f50565b5b60200260200101518383815181106104fc576104fb610f50565b5b60200260200101516102b5565b80806001019150506104c2565b505050565b5f61052884868589610533565b905095945050505050565b5f5f61053e83610611565b60405160200161054e919061103e565b60405160208183030381529060405290508061057f8773ffffffffffffffffffffffffffffffffffffffff16610611565b604051602001610590929190611054565b6040516020818303038152906040529050805f546040516020016105b49190611097565b604051602081830303815290604052805190602001206040516020016105db9291906110da565b60405160208183030381529060405290505f81805190602001209050610605815f1c86885f610673565b92505050949350505050565b60605f602067ffffffffffffffff81111561062f5761062e61078e565b5b6040519080825280601f01601f1916602001820160405280156106615781602001600182028036833780820191505090505b50905082602082015280915050919050565b5f61ffff80167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6106a49190611101565b851690505f8460ff1660086106b985876106cc565b901b179050808217915050949350505050565b5f600160ff8016901c60ff168260ff1616836106e8575f610702565b600160ff8016901c60ff1660ff80166107019190611101565b5b17905092915050565b60405180608001604052805f81526020015f60ff1681526020015f60ff168152602001606081525090565b5f8115159050919050565b61074a81610736565b82525050565b5f6020820190506107635f830184610741565b92915050565b5f604051905090565b5f5ffd5b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6107c48261077e565b810181811067ffffffffffffffff821117156107e3576107e261078e565b5b80604052505050565b5f6107f5610769565b905061080182826107bb565b919050565b5f67ffffffffffffffff8211156108205761081f61078e565b5b602082029050602081019050919050565b5f5ffd5b5f819050919050565b61084781610835565b8114610851575f5ffd5b50565b5f813590506108628161083e565b92915050565b5f61087a61087584610806565b6107ec565b9050808382526020820190506020840283018581111561089d5761089c610831565b5b835b818110156108c657806108b28882610854565b84526020840193505060208101905061089f565b5050509392505050565b5f82601f8301126108e4576108e361077a565b5b81356108f4848260208601610868565b91505092915050565b5f67ffffffffffffffff8211156109175761091661078e565b5b602082029050602081019050919050565b5f60ff82169050919050565b61093d81610928565b8114610947575f5ffd5b50565b5f8135905061095881610934565b92915050565b5f61097061096b846108fd565b6107ec565b9050808382526020820190506020840283018581111561099357610992610831565b5b835b818110156109bc57806109a8888261094a565b845260208401935050602081019050610995565b5050509392505050565b5f82601f8301126109da576109d961077a565b5b81356109ea84826020860161095e565b91505092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610a1c826109f3565b9050919050565b610a2c81610a12565b8114610a36575f5ffd5b50565b5f81359050610a4781610a23565b92915050565b5f5f5f5f5f60a08688031215610a6657610a65610772565b5b5f86013567ffffffffffffffff811115610a8357610a82610776565b5b610a8f888289016108d0565b955050602086013567ffffffffffffffff811115610ab057610aaf610776565b5b610abc888289016109c6565b9450506040610acd88828901610a39565b9350506060610ade8882890161094a565b9250506080610aef88828901610854565b9150509295509295909350565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b610b2e81610835565b82525050565b610b3d81610928565b82525050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f610b7582610b43565b610b7f8185610b4d565b9350610b8f818560208601610b5d565b610b988161077e565b840191505092915050565b5f608083015f830151610bb85f860182610b25565b506020830151610bcb6020860182610b34565b506040830151610bde6040860182610b34565b5060608301518482036060860152610bf68282610b6b565b9150508091505092915050565b5f610c0e8383610ba3565b905092915050565b5f602082019050919050565b5f610c2c82610afc565b610c368185610b06565b935083602082028501610c4885610b16565b805f5b85811015610c835784840389528151610c648582610c03565b9450610c6f83610c16565b925060208a01995050600181019050610c4b565b50829750879550505050505092915050565b5f6020820190508181035f830152610cad8184610c22565b905092915050565b5f5f60408385031215610ccb57610cca610772565b5b5f610cd885828601610854565b9250506020610ce985828601610854565b9150509250929050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f610d278383610b25565b60208301905092915050565b5f602082019050919050565b5f610d4982610cf3565b610d538185610cfd565b9350610d5e83610d0d565b805f5b83811015610d8e578151610d758882610d1c565b9750610d8083610d33565b925050600181019050610d61565b5085935050505092915050565b5f6020820190508181035f830152610db38184610d3f565b905092915050565b5f5f5f5f5f60a08688031215610dd457610dd3610772565b5b5f610de188828901610854565b9550506020610df28882890161094a565b9450506040610e0388828901610a39565b9350506060610e148882890161094a565b9250506080610e2588828901610854565b9150509295509295909350565b5f608083015f830151610e475f860182610b25565b506020830151610e5a6020860182610b34565b506040830151610e6d6040860182610b34565b5060608301518482036060860152610e858282610b6b565b9150508091505092915050565b5f6020820190508181035f830152610eaa8184610e32565b905092915050565b5f5f60408385031215610ec857610ec7610772565b5b5f83013567ffffffffffffffff811115610ee557610ee4610776565b5b610ef1858286016108d0565b925050602083013567ffffffffffffffff811115610f1257610f11610776565b5b610f1e858286016108d0565b9150509250929050565b610f3181610835565b82525050565b5f602082019050610f4a5f830184610f28565b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f604082019050610f905f830185610f28565b610f9d6020830184610f28565b9392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f610fdb82610835565b9150610fe683610835565b9250828201905080821115610ffe57610ffd610fa4565b5b92915050565b5f81905092915050565b5f61101882610b43565b6110228185611004565b9350611032818560208601610b5d565b80840191505092915050565b5f611049828461100e565b915081905092915050565b5f61105f828561100e565b915061106b828461100e565b91508190509392505050565b5f819050919050565b61109161108c82610835565b611077565b82525050565b5f6110a28284611080565b60208201915081905092915050565b5f819050919050565b5f819050919050565b6110d46110cf826110b1565b6110ba565b82525050565b5f6110e5828561100e565b91506110f182846110c3565b6020820191508190509392505050565b5f61110b82610835565b915061111683610835565b925082820390508181111561112e5761112d610fa4565b5b9291505056fea26469706673582212209a9372bb7df7f6afcb2bce5c7034e71dcd36cd9afbe95c69abed265154e8332564736f6c634300081e0033"
|
|
264
|
+
} satisfies MocksArtifact;
|
package/src/TestBed.ts
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
// This file is auto-generated by build-artifacts.ts
|
|
2
|
+
import { type MocksArtifact } from './index';
|
|
3
|
+
|
|
4
|
+
export const TestBedArtifact = {
|
|
5
|
+
"contractName": "TestBed",
|
|
6
|
+
"fixedAddress": "0x0000000000000000000000000000000000000300",
|
|
7
|
+
"abi": [
|
|
8
|
+
{
|
|
9
|
+
"type": "function",
|
|
10
|
+
"name": "add",
|
|
11
|
+
"inputs": [
|
|
12
|
+
{
|
|
13
|
+
"name": "inNumber",
|
|
14
|
+
"type": "tuple",
|
|
15
|
+
"internalType": "struct InEuint32",
|
|
16
|
+
"components": [
|
|
17
|
+
{
|
|
18
|
+
"name": "ctHash",
|
|
19
|
+
"type": "uint256",
|
|
20
|
+
"internalType": "uint256"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "securityZone",
|
|
24
|
+
"type": "uint8",
|
|
25
|
+
"internalType": "uint8"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "utype",
|
|
29
|
+
"type": "uint8",
|
|
30
|
+
"internalType": "uint8"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "signature",
|
|
34
|
+
"type": "bytes",
|
|
35
|
+
"internalType": "bytes"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"outputs": [],
|
|
41
|
+
"stateMutability": "nonpayable"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"type": "function",
|
|
45
|
+
"name": "decrypt",
|
|
46
|
+
"inputs": [],
|
|
47
|
+
"outputs": [],
|
|
48
|
+
"stateMutability": "nonpayable"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"type": "function",
|
|
52
|
+
"name": "eNumber",
|
|
53
|
+
"inputs": [],
|
|
54
|
+
"outputs": [
|
|
55
|
+
{
|
|
56
|
+
"name": "",
|
|
57
|
+
"type": "uint256",
|
|
58
|
+
"internalType": "euint32"
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"stateMutability": "view"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"type": "function",
|
|
65
|
+
"name": "exists",
|
|
66
|
+
"inputs": [],
|
|
67
|
+
"outputs": [
|
|
68
|
+
{
|
|
69
|
+
"name": "",
|
|
70
|
+
"type": "bool",
|
|
71
|
+
"internalType": "bool"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"stateMutability": "pure"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"type": "function",
|
|
78
|
+
"name": "getDecryptResult",
|
|
79
|
+
"inputs": [
|
|
80
|
+
{
|
|
81
|
+
"name": "input1",
|
|
82
|
+
"type": "uint256",
|
|
83
|
+
"internalType": "euint32"
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
"outputs": [
|
|
87
|
+
{
|
|
88
|
+
"name": "",
|
|
89
|
+
"type": "uint32",
|
|
90
|
+
"internalType": "uint32"
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"stateMutability": "view"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"type": "function",
|
|
97
|
+
"name": "getDecryptResultSafe",
|
|
98
|
+
"inputs": [
|
|
99
|
+
{
|
|
100
|
+
"name": "input1",
|
|
101
|
+
"type": "uint256",
|
|
102
|
+
"internalType": "euint32"
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"outputs": [
|
|
106
|
+
{
|
|
107
|
+
"name": "value",
|
|
108
|
+
"type": "uint32",
|
|
109
|
+
"internalType": "uint32"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"name": "decrypted",
|
|
113
|
+
"type": "bool",
|
|
114
|
+
"internalType": "bool"
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
"stateMutability": "view"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"type": "function",
|
|
121
|
+
"name": "increment",
|
|
122
|
+
"inputs": [],
|
|
123
|
+
"outputs": [],
|
|
124
|
+
"stateMutability": "nonpayable"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"type": "function",
|
|
128
|
+
"name": "mul",
|
|
129
|
+
"inputs": [
|
|
130
|
+
{
|
|
131
|
+
"name": "inNumber",
|
|
132
|
+
"type": "tuple",
|
|
133
|
+
"internalType": "struct InEuint32",
|
|
134
|
+
"components": [
|
|
135
|
+
{
|
|
136
|
+
"name": "ctHash",
|
|
137
|
+
"type": "uint256",
|
|
138
|
+
"internalType": "uint256"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"name": "securityZone",
|
|
142
|
+
"type": "uint8",
|
|
143
|
+
"internalType": "uint8"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"name": "utype",
|
|
147
|
+
"type": "uint8",
|
|
148
|
+
"internalType": "uint8"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"name": "signature",
|
|
152
|
+
"type": "bytes",
|
|
153
|
+
"internalType": "bytes"
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
"outputs": [],
|
|
159
|
+
"stateMutability": "nonpayable"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"type": "function",
|
|
163
|
+
"name": "numberHash",
|
|
164
|
+
"inputs": [],
|
|
165
|
+
"outputs": [
|
|
166
|
+
{
|
|
167
|
+
"name": "",
|
|
168
|
+
"type": "uint256",
|
|
169
|
+
"internalType": "uint256"
|
|
170
|
+
}
|
|
171
|
+
],
|
|
172
|
+
"stateMutability": "view"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"type": "function",
|
|
176
|
+
"name": "setNumber",
|
|
177
|
+
"inputs": [
|
|
178
|
+
{
|
|
179
|
+
"name": "inNumber",
|
|
180
|
+
"type": "tuple",
|
|
181
|
+
"internalType": "struct InEuint32",
|
|
182
|
+
"components": [
|
|
183
|
+
{
|
|
184
|
+
"name": "ctHash",
|
|
185
|
+
"type": "uint256",
|
|
186
|
+
"internalType": "uint256"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"name": "securityZone",
|
|
190
|
+
"type": "uint8",
|
|
191
|
+
"internalType": "uint8"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"name": "utype",
|
|
195
|
+
"type": "uint8",
|
|
196
|
+
"internalType": "uint8"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"name": "signature",
|
|
200
|
+
"type": "bytes",
|
|
201
|
+
"internalType": "bytes"
|
|
202
|
+
}
|
|
203
|
+
]
|
|
204
|
+
}
|
|
205
|
+
],
|
|
206
|
+
"outputs": [],
|
|
207
|
+
"stateMutability": "nonpayable"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"type": "function",
|
|
211
|
+
"name": "setNumberTrivial",
|
|
212
|
+
"inputs": [
|
|
213
|
+
{
|
|
214
|
+
"name": "inNumber",
|
|
215
|
+
"type": "uint256",
|
|
216
|
+
"internalType": "uint256"
|
|
217
|
+
}
|
|
218
|
+
],
|
|
219
|
+
"outputs": [],
|
|
220
|
+
"stateMutability": "nonpayable"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"type": "function",
|
|
224
|
+
"name": "sub",
|
|
225
|
+
"inputs": [
|
|
226
|
+
{
|
|
227
|
+
"name": "inNumber",
|
|
228
|
+
"type": "tuple",
|
|
229
|
+
"internalType": "struct InEuint32",
|
|
230
|
+
"components": [
|
|
231
|
+
{
|
|
232
|
+
"name": "ctHash",
|
|
233
|
+
"type": "uint256",
|
|
234
|
+
"internalType": "uint256"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"name": "securityZone",
|
|
238
|
+
"type": "uint8",
|
|
239
|
+
"internalType": "uint8"
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
"name": "utype",
|
|
243
|
+
"type": "uint8",
|
|
244
|
+
"internalType": "uint8"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"name": "signature",
|
|
248
|
+
"type": "bytes",
|
|
249
|
+
"internalType": "bytes"
|
|
250
|
+
}
|
|
251
|
+
]
|
|
252
|
+
}
|
|
253
|
+
],
|
|
254
|
+
"outputs": [],
|
|
255
|
+
"stateMutability": "nonpayable"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"type": "error",
|
|
259
|
+
"name": "InvalidEncryptedInput",
|
|
260
|
+
"inputs": [
|
|
261
|
+
{
|
|
262
|
+
"name": "got",
|
|
263
|
+
"type": "uint8",
|
|
264
|
+
"internalType": "uint8"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"name": "expected",
|
|
268
|
+
"type": "uint8",
|
|
269
|
+
"internalType": "uint8"
|
|
270
|
+
}
|
|
271
|
+
]
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"type": "error",
|
|
275
|
+
"name": "SecurityZoneOutOfBounds",
|
|
276
|
+
"inputs": [
|
|
277
|
+
{
|
|
278
|
+
"name": "value",
|
|
279
|
+
"type": "int32",
|
|
280
|
+
"internalType": "int32"
|
|
281
|
+
}
|
|
282
|
+
]
|
|
283
|
+
}
|
|
284
|
+
],
|
|
285
|
+
"deployedBytecode": "0x608060405234801561000f575f5ffd5b50600436106100b2575f3560e01c806384f091db1161006f57806384f091db1461016757806384ff25c614610183578063b5872e8c1461019f578063d09de08a146101bb578063d7a0faa2146101c5578063f6bc7f3f146101e1576100b2565b806319d8a05b146100b6578063267c4ae4146100d45780633983d430146100f2578063458693c9146100fc578063647096091461012d57806367c6517414610149575b5f5ffd5b6100be610211565b6040516100cb9190610eef565b60405180910390f35b6100dc610216565b6040516100e99190610f22565b60405180910390f35b6100fa61021e565b005b61011660048036038101906101119190610f76565b61022a565b604051610124929190610fbf565b60405180910390f35b6101476004803603810190610142919061121b565b61023e565b005b610151610293565b60405161015e9190611271565b60405180910390f35b610181600480360381019061017c919061121b565b610299565b005b61019d6004803603810190610198919061121b565b6102c8565b005b6101b960048036038101906101b4919061121b565b6102f7565b005b6101c3610324565b005b6101df60048036038101906101da919061128a565b610353565b005b6101fb60048036038101906101f69190610f76565b610380565b60405161020891906112b5565b60405180910390f35b5f5481565b5f6001905090565b6102285f54610391565b565b5f5f610235836103b7565b91509150915091565b5f610248826103d5565b90505f610268610259835f54610448565b836102635f610491565b6104a3565b90506102755f5482610505565b5f819055506102845f5461054e565b61028e5f546105cd565b505050565b60015481565b6102ac5f546102a7836103d5565b61064c565b5f819055506102bb5f5461054e565b6102c55f546105cd565b50565b6102db5f546102d6836103d5565b610695565b5f819055506102ea5f5461054e565b6102f45f546105cd565b50565b610300816103d5565b5f819055505f546001819055506103175f5461054e565b6103215f546105cd565b50565b6103385f546103336001610491565b610695565b5f819055506103475f5461054e565b6103515f546105cd565b565b61035c81610491565b5f819055505f546001819055506103735f5461054e565b61037d5f546105cd565b50565b5f61038a826106de565b9050919050565b61039a816106ef565b6103aa576103a75f610491565b90505b6103b381610700565b5050565b5f5f5f5f6103c485610785565b915091508181935093505050915091565b5f5f600490508060ff16836040015160ff161461042f578260400151816040517f67cf30710000000000000000000000000000000000000000000000000000000081526004016104269291906112dd565b60405180910390fd5b61044061043b8461081b565b61085d565b915050919050565b5f610452836106ef565b6104625761045f5f610491565b92505b61046b826106ef565b61047b576104785f610491565b91505b6104896004848460136108f4565b905092915050565b5f61049c825f6109e3565b9050919050565b5f6104ad846109fd565b6104bd576104ba5f610a0e565b93505b6104c6836106ef565b6104d6576104d35f610491565b92505b6104df826106ef565b6104ef576104ec5f610491565b91505b6104fc6004858585610a20565b90509392505050565b5f61050f836106ef565b61051f5761051c5f610491565b92505b610528826106ef565b610538576105355f610491565b91505b6105466004848460076108f4565b905092915050565b73ea30c4b8b44078bbf8a6ef5b9f1ec1626c7848d973ffffffffffffffffffffffffffffffffffffffff166365d0509c82306040518363ffffffff1660e01b815260040161059d929190611343565b5f604051808303815f87803b1580156105b4575f5ffd5b505af11580156105c6573d5f5f3e3d5ffd5b5050505050565b73ea30c4b8b44078bbf8a6ef5b9f1ec1626c7848d973ffffffffffffffffffffffffffffffffffffffff166365d0509c82336040518363ffffffff1660e01b815260040161061c929190611343565b5f604051808303815f87803b158015610633575f5ffd5b505af1158015610645573d5f5f3e3d5ffd5b5050505050565b5f610656836106ef565b610666576106635f610491565b92505b61066f826106ef565b61067f5761067c5f610491565b91505b61068d60048484600f6108f4565b905092915050565b5f61069f836106ef565b6106af576106ac5f610491565b92505b6106b8826106ef565b6106c8576106c55f610491565b91505b6106d66004848460086108f4565b905092915050565b5f6106e882610b11565b9050919050565b5f6106f982610ba5565b9050919050565b5f73ea30c4b8b44078bbf8a6ef5b9f1ec1626c7848d973ffffffffffffffffffffffffffffffffffffffff16630828982783336040518363ffffffff1660e01b8152600401610750929190611343565b5f604051808303815f87803b158015610767575f5ffd5b505af1158015610779573d5f5f3e3d5ffd5b50505050819050919050565b5f5f73ea30c4b8b44078bbf8a6ef5b9f1ec1626c7848d973ffffffffffffffffffffffffffffffffffffffff1663458693c9846040518263ffffffff1660e01b81526004016107d49190611271565b6040805180830381865afa1580156107ee573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061081291906113a8565b91509150915091565b610823610e82565b6040518060800160405280835f01518152602001836020015160ff168152602001600460ff16815260200183606001518152509050919050565b5f73ea30c4b8b44078bbf8a6ef5b9f1ec1626c7848d973ffffffffffffffffffffffffffffffffffffffff166327f9c76283336040518363ffffffff1660e01b81526004016108ad9291906114c4565b6020604051808303815f875af11580156108c9573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108ed91906114f2565b9050919050565b5f73ea30c4b8b44078bbf8a6ef5b9f1ec1626c7848d973ffffffffffffffffffffffffffffffffffffffff16631888debd86846109318888610bb1565b5f67ffffffffffffffff81111561094b5761094a610ffa565b5b6040519080825280602002602001820160405280156109795781602001602082028036833780820191505090505b506040518563ffffffff1660e01b81526004016109999493929190611638565b6020604051808303815f875af11580156109b5573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109d991906114f2565b9050949350505050565b5f5f6109f184600485610c4b565b90508091505092915050565b5f610a0782610ba5565b9050919050565b5f610a19825f610d46565b9050919050565b5f73ea30c4b8b44078bbf8a6ef5b9f1ec1626c7848d973ffffffffffffffffffffffffffffffffffffffff16631888debd866004610a5f888888610d6f565b5f67ffffffffffffffff811115610a7957610a78610ffa565b5b604051908082528060200260200182016040528015610aa75781602001602082028036833780820191505090505b506040518563ffffffff1660e01b8152600401610ac79493929190611638565b6020604051808303815f875af1158015610ae3573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b0791906114f2565b9050949350505050565b5f73ea30c4b8b44078bbf8a6ef5b9f1ec1626c7848d973ffffffffffffffffffffffffffffffffffffffff1663f6bc7f3f836040518263ffffffff1660e01b8152600401610b5f9190611271565b602060405180830381865afa158015610b7a573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b9e91906114f2565b9050919050565b5f5f8214159050919050565b60605f600267ffffffffffffffff811115610bcf57610bce610ffa565b5b604051908082528060200260200182016040528015610bfd5781602001602082028036833780820191505090505b50905083815f81518110610c1457610c13611689565b5b6020026020010181815250508281600181518110610c3557610c34611689565b5b6020026020010181815250508091505092915050565b5f73ea30c4b8b44078bbf8a6ef5b9f1ec1626c7848d973ffffffffffffffffffffffffffffffffffffffff16631888debd84601a5f67ffffffffffffffff811115610c9957610c98610ffa565b5b604051908082528060200260200182016040528015610cc75781602001602082028036833780820191505090505b50610cde898960ff16610cd98a610e2b565b610d6f565b6040518563ffffffff1660e01b8152600401610cfd9493929190611638565b6020604051808303815f875af1158015610d19573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d3d91906114f2565b90509392505050565b5f5f5f90508315610d5657600190505b5f610d62825f86610c4b565b9050809250505092915050565b60605f600367ffffffffffffffff811115610d8d57610d8c610ffa565b5b604051908082528060200260200182016040528015610dbb5781602001602082028036833780820191505090505b50905084815f81518110610dd257610dd1611689565b5b6020026020010181815250508381600181518110610df357610df2611689565b5b6020026020010181815250508281600281518110610e1457610e13611689565b5b602002602001018181525050809150509392505050565b5f5f8260030b1215610e7457816040517f8f568bf8000000000000000000000000000000000000000000000000000000008152600401610e6b91906116d1565b60405180910390fd5b8163ffffffff169050919050565b60405180608001604052805f81526020015f60ff1681526020015f60ff168152602001606081525090565b5f819050919050565b5f819050919050565b5f610ed9610ed4610ecf84610ead565b610eb6565b610ead565b9050919050565b610ee981610ebf565b82525050565b5f602082019050610f025f830184610ee0565b92915050565b5f8115159050919050565b610f1c81610f08565b82525050565b5f602082019050610f355f830184610f13565b92915050565b5f604051905090565b5f5ffd5b5f5ffd5b610f5581610ead565b8114610f5f575f5ffd5b50565b5f81359050610f7081610f4c565b92915050565b5f60208284031215610f8b57610f8a610f44565b5b5f610f9884828501610f62565b91505092915050565b5f63ffffffff82169050919050565b610fb981610fa1565b82525050565b5f604082019050610fd25f830185610fb0565b610fdf6020830184610f13565b9392505050565b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b61103082610fea565b810181811067ffffffffffffffff8211171561104f5761104e610ffa565b5b80604052505050565b5f611061610f3b565b905061106d8282611027565b919050565b5f5ffd5b61107f81610ead565b8114611089575f5ffd5b50565b5f8135905061109a81611076565b92915050565b5f60ff82169050919050565b6110b5816110a0565b81146110bf575f5ffd5b50565b5f813590506110d0816110ac565b92915050565b5f5ffd5b5f5ffd5b5f67ffffffffffffffff8211156110f8576110f7610ffa565b5b61110182610fea565b9050602081019050919050565b828183375f83830152505050565b5f61112e611129846110de565b611058565b90508281526020810184848401111561114a576111496110da565b5b61115584828561110e565b509392505050565b5f82601f830112611171576111706110d6565b5b813561118184826020860161111c565b91505092915050565b5f6080828403121561119f5761119e610fe6565b5b6111a96080611058565b90505f6111b88482850161108c565b5f8301525060206111cb848285016110c2565b60208301525060406111df848285016110c2565b604083015250606082013567ffffffffffffffff81111561120357611202611072565b5b61120f8482850161115d565b60608301525092915050565b5f602082840312156112305761122f610f44565b5b5f82013567ffffffffffffffff81111561124d5761124c610f48565b5b6112598482850161118a565b91505092915050565b61126b81610ead565b82525050565b5f6020820190506112845f830184611262565b92915050565b5f6020828403121561129f5761129e610f44565b5b5f6112ac8482850161108c565b91505092915050565b5f6020820190506112c85f830184610fb0565b92915050565b6112d7816110a0565b82525050565b5f6040820190506112f05f8301856112ce565b6112fd60208301846112ce565b9392505050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61132d82611304565b9050919050565b61133d81611323565b82525050565b5f6040820190506113565f830185611262565b6113636020830184611334565b9392505050565b5f8151905061137881611076565b92915050565b61138781610f08565b8114611391575f5ffd5b50565b5f815190506113a28161137e565b92915050565b5f5f604083850312156113be576113bd610f44565b5b5f6113cb8582860161136a565b92505060206113dc85828601611394565b9150509250929050565b6113ef81610ead565b82525050565b6113fe816110a0565b82525050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f61143682611404565b611440818561140e565b935061145081856020860161141e565b61145981610fea565b840191505092915050565b5f608083015f8301516114795f8601826113e6565b50602083015161148c60208601826113f5565b50604083015161149f60408601826113f5565b50606083015184820360608601526114b7828261142c565b9150508091505092915050565b5f6040820190508181035f8301526114dc8185611464565b90506114eb6020830184611334565b9392505050565b5f6020828403121561150757611506610f44565b5b5f6115148482850161136a565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b6020811061155b5761155a61151d565b5b50565b5f81905061156b8261154a565b919050565b5f61157a8261155e565b9050919050565b61158a81611570565b82525050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f6115c483836113e6565b60208301905092915050565b5f602082019050919050565b5f6115e682611590565b6115f0818561159a565b93506115fb836115aa565b805f5b8381101561162b57815161161288826115b9565b975061161d836115d0565b9250506001810190506115fe565b5085935050505092915050565b5f60808201905061164b5f8301876112ce565b6116586020830186611581565b818103604083015261166a81856115dc565b9050818103606083015261167e81846115dc565b905095945050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f8160030b9050919050565b6116cb816116b6565b82525050565b5f6020820190506116e45f8301846116c2565b9291505056fea2646970667358221220a686ade386d6e9fea71d8a014f568d024361e50b703915f304236ac5ca6d620964736f6c634300081e0033"
|
|
286
|
+
} satisfies MocksArtifact;
|
package/src/index.ts
ADDED
package/src/types.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
+
pragma solidity ^0.8.13;
|
|
3
|
+
|
|
4
|
+
import { Test } from 'forge-std/Test.sol';
|
|
5
|
+
import { TestBed } from '../contracts/TestBed.sol';
|
|
6
|
+
import { CoFheTest } from '../contracts/foundry/CoFheTest.sol';
|
|
7
|
+
import { FHE, InEuint32, euint8, euint256 } from '@fhenixprotocol/cofhe-contracts/FHE.sol';
|
|
8
|
+
|
|
9
|
+
contract TestBedTest is Test, CoFheTest {
|
|
10
|
+
TestBed private testbed;
|
|
11
|
+
|
|
12
|
+
address private user = makeAddr('user');
|
|
13
|
+
|
|
14
|
+
function setUp() public {
|
|
15
|
+
// optional ... enable verbose logging from fhe mocks
|
|
16
|
+
// setLog(true);
|
|
17
|
+
|
|
18
|
+
testbed = new TestBed();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function testSetNumberFuzz(uint32 n) public {
|
|
22
|
+
InEuint32 memory number = createInEuint32(n, user);
|
|
23
|
+
|
|
24
|
+
//must be the user who sends transaction
|
|
25
|
+
//or else invalid permissions from fhe allow
|
|
26
|
+
vm.prank(user);
|
|
27
|
+
testbed.setNumber(number);
|
|
28
|
+
|
|
29
|
+
assertHashValue(testbed.eNumber(), n);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function testOverflow() public {
|
|
33
|
+
euint8 a = FHE.asEuint8(240);
|
|
34
|
+
euint8 b = FHE.asEuint8(240);
|
|
35
|
+
euint8 c = FHE.add(a, b);
|
|
36
|
+
|
|
37
|
+
assertHashValue(euint8.unwrap(c), (240 + 240) % 256);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function testDivideByZero() public {
|
|
41
|
+
euint8 a = FHE.asEuint8(240);
|
|
42
|
+
euint8 b = FHE.asEuint8(0);
|
|
43
|
+
euint8 c = FHE.div(a, b);
|
|
44
|
+
|
|
45
|
+
assertHashValue(euint8.unwrap(c), type(uint8).max);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function test256BitsNoOverflow() public {
|
|
49
|
+
euint256 a = FHE.asEuint256(type(uint256).max);
|
|
50
|
+
euint256 b = FHE.asEuint256(type(uint256).max);
|
|
51
|
+
euint256 c = FHE.add(a, b);
|
|
52
|
+
|
|
53
|
+
uint256 expected;
|
|
54
|
+
unchecked {
|
|
55
|
+
expected = type(uint256).max + type(uint256).max;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
assertHashValue(euint256.unwrap(c), expected);
|
|
59
|
+
}
|
|
60
|
+
}
|