@cofhe/foundry-plugin 0.5.2 → 0.6.1
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/contracts/CofheClient.sol +54 -5
- package/package.json +5 -4
|
@@ -11,7 +11,10 @@ import { MockZkVerifierSigner } from './MockZkVerifierSigner.sol';
|
|
|
11
11
|
import { MockThresholdNetwork } from '@cofhe/mock-contracts/contracts/MockThresholdNetwork.sol';
|
|
12
12
|
import { MockThresholdNetworkSigner } from './MockThresholdNetworkSigner.sol';
|
|
13
13
|
import { Permission, PermissionUtils } from '@cofhe/mock-contracts/contracts/Permissioned.sol';
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
ZK_VERIFIER_SIGNER_ADDRESS,
|
|
16
|
+
DECRYPT_RESULT_SIGNER_ADDRESS
|
|
17
|
+
} from '@cofhe/mock-contracts/contracts/MockCoFHE.sol';
|
|
15
18
|
|
|
16
19
|
/// @notice Portable representation of the issuer's half of a shared permit, safe to transmit as cleartext.
|
|
17
20
|
struct SharedPermitExport {
|
|
@@ -116,6 +119,55 @@ contract CofheClient is Test {
|
|
|
116
119
|
return abi.decode(abi.encode(createEncryptedInput(Utils.EADDRESS_TFHE, uint256(uint160(value)))), (InEaddress));
|
|
117
120
|
}
|
|
118
121
|
|
|
122
|
+
/// @notice Creates an encrypted boolean input as hash plus proof.
|
|
123
|
+
function createInEbool_asHashPlusProof(bool value) public returns (externalEbool hash, bytes memory proof) {
|
|
124
|
+
InEbool memory input = createInEbool(value);
|
|
125
|
+
hash = externalEbool.wrap(bytes32(input.ctHash));
|
|
126
|
+
proof = input.signature;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/// @notice Creates an encrypted uint8 input as hash plus proof.
|
|
130
|
+
function createInEuint8_asHashPlusProof(uint8 value) public returns (externalEuint8 hash, bytes memory proof) {
|
|
131
|
+
InEuint8 memory input = createInEuint8(value);
|
|
132
|
+
hash = externalEuint8.wrap(bytes32(input.ctHash));
|
|
133
|
+
proof = input.signature;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/// @notice Creates an encrypted uint16 input as hash plus proof.
|
|
137
|
+
function createInEuint16_asHashPlusProof(uint16 value) public returns (externalEuint16 hash, bytes memory proof) {
|
|
138
|
+
InEuint16 memory input = createInEuint16(value);
|
|
139
|
+
hash = externalEuint16.wrap(bytes32(input.ctHash));
|
|
140
|
+
proof = input.signature;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/// @notice Creates an encrypted uint32 input as hash plus proof.
|
|
144
|
+
function createInEuint32_asHashPlusProof(uint32 value) public returns (externalEuint32 hash, bytes memory proof) {
|
|
145
|
+
InEuint32 memory input = createInEuint32(value);
|
|
146
|
+
hash = externalEuint32.wrap(bytes32(input.ctHash));
|
|
147
|
+
proof = input.signature;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/// @notice Creates an encrypted uint64 input as hash plus proof.
|
|
151
|
+
function createInEuint64_asHashPlusProof(uint64 value) public returns (externalEuint64 hash, bytes memory proof) {
|
|
152
|
+
InEuint64 memory input = createInEuint64(value);
|
|
153
|
+
hash = externalEuint64.wrap(bytes32(input.ctHash));
|
|
154
|
+
proof = input.signature;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/// @notice Creates an encrypted uint128 input as hash plus proof.
|
|
158
|
+
function createInEuint128_asHashPlusProof(uint128 value) public returns (externalEuint128 hash, bytes memory proof) {
|
|
159
|
+
InEuint128 memory input = createInEuint128(value);
|
|
160
|
+
hash = externalEuint128.wrap(bytes32(input.ctHash));
|
|
161
|
+
proof = input.signature;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/// @notice Creates an encrypted address input as hash plus proof.
|
|
165
|
+
function createInEaddress_asHashPlusProof(address value) public returns (externalEaddress hash, bytes memory proof) {
|
|
166
|
+
InEaddress memory input = createInEaddress(value);
|
|
167
|
+
hash = externalEaddress.wrap(bytes32(input.ctHash));
|
|
168
|
+
proof = input.signature;
|
|
169
|
+
}
|
|
170
|
+
|
|
119
171
|
// =====================
|
|
120
172
|
// DECRYPT FOR TX
|
|
121
173
|
// =====================
|
|
@@ -155,10 +207,7 @@ contract CofheClient is Test {
|
|
|
155
207
|
// =====================
|
|
156
208
|
|
|
157
209
|
/// @notice Decrypts a ciphertext for off-chain reading by sealing/unsealing with the permit's sealing key.
|
|
158
|
-
function decryptForView(
|
|
159
|
-
bytes32 ctHash,
|
|
160
|
-
Permission memory permission
|
|
161
|
-
) public view onlyConnected returns (uint256) {
|
|
210
|
+
function decryptForView(bytes32 ctHash, Permission memory permission) public view onlyConnected returns (uint256) {
|
|
162
211
|
uint256 ct = uint256(ctHash);
|
|
163
212
|
|
|
164
213
|
(bool allowed, string memory error, bytes32 sealedOutput) = mockThresholdNetwork.querySealOutput(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cofhe/foundry-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Foundry plugin for CoFHE — Write and test FHE enabled contracts",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -24,12 +24,13 @@
|
|
|
24
24
|
"fhenix"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@fhenixprotocol/cofhe-contracts": "0.1.
|
|
27
|
+
"@fhenixprotocol/cofhe-contracts": "0.1.4",
|
|
28
28
|
"@openzeppelin/contracts": "5.4.0",
|
|
29
|
-
"@cofhe/mock-contracts": "0.
|
|
29
|
+
"@cofhe/mock-contracts": "0.6.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"forge-std": "github:foundry-rs/forge-std#c0f966cb111f621bfb283b2a388bc7be18953bba"
|
|
32
|
+
"forge-std": "github:foundry-rs/forge-std#c0f966cb111f621bfb283b2a388bc7be18953bba",
|
|
33
|
+
"@cofhe/test-setup": "0.0.0"
|
|
33
34
|
},
|
|
34
35
|
"publishConfig": {
|
|
35
36
|
"access": "public",
|