@cofhe/foundry-plugin 0.0.0-alpha-20260813125113 → 0.0.0-alpha-20260818094925
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/README.md +8 -8
- package/contracts/CofheClient.sol +16 -16
- package/contracts/CofheTest.sol +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @cofhe/foundry-plugin
|
|
2
2
|
|
|
3
|
-
Foundry test utilities for [CoFHE](https://github.com/FhenixProtocol/cofhesdk). Provides `CofheTest` (base test contract with mock deployment) and `CofheClient` (SDK-like client for encrypting inputs, decrypting outputs, and managing
|
|
3
|
+
Foundry test utilities for [CoFHE](https://github.com/FhenixProtocol/cofhesdk). Provides `CofheTest` (base test contract with mock deployment) and `CofheClient` (SDK-like client for encrypting inputs, decrypting outputs, and managing acps).
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -88,10 +88,10 @@ contract MyTest is CofheTest {
|
|
|
88
88
|
| `account()` | Returns the connected account address |
|
|
89
89
|
| `createExternalEbool/8/16/32/64/128/address(value, consumingContract)` | Creates a batch-signed encrypted input bound to `consumingContract`; returns `(external*Hash, bytes signature)` |
|
|
90
90
|
| `createEuint32sBatch(values, consumingContract)` | Creates a batch of encrypted uint32s sharing one signature |
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
93
|
-
| `decryptForView(ctHash, sealingKey,
|
|
94
|
-
| `
|
|
95
|
-
| `
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
91
|
+
| `decryptForTx_withoutACP(ctHash)` | Decrypts a globally-allowed ciphertext; returns `(ctHash, plaintext, signature)` |
|
|
92
|
+
| `decryptForTx_withACP(ctHash, acp)` | Decrypts with a permission; returns `(ctHash, plaintext, signature)` |
|
|
93
|
+
| `decryptForView(ctHash, sealingKey, acp)` | Seals and unseals for off-chain reading |
|
|
94
|
+
| `acp_createSelf()` | Creates a self-acp for the connected account |
|
|
95
|
+
| `acp_createShared(recipient)` | Creates the issuer half of a shared acp |
|
|
96
|
+
| `acp_exportShared(acp)` | Strips recipient fields for safe transmission |
|
|
97
|
+
| `acp_importShared(export)` | Completes a shared acp as the recipient |
|
|
@@ -16,8 +16,8 @@ import {
|
|
|
16
16
|
DECRYPT_RESULT_SIGNER_ADDRESS
|
|
17
17
|
} from '@cofhe/mock-contracts/contracts/MockCoFHE.sol';
|
|
18
18
|
|
|
19
|
-
/// @notice Portable representation of the issuer's half of a shared
|
|
20
|
-
struct
|
|
19
|
+
/// @notice Portable representation of the issuer's half of a shared acp, safe to transmit as cleartext.
|
|
20
|
+
struct SharedACPExport {
|
|
21
21
|
address issuer;
|
|
22
22
|
uint64 expiration;
|
|
23
23
|
address recipient;
|
|
@@ -265,26 +265,26 @@ contract CofheClient is Test {
|
|
|
265
265
|
// =====================
|
|
266
266
|
|
|
267
267
|
/// @notice Decrypts a globally-allowed ciphertext and returns the plaintext with a publishable signature.
|
|
268
|
-
function
|
|
268
|
+
function decryptForTx_withoutACP(
|
|
269
269
|
bytes32 ctHash
|
|
270
270
|
) public view onlyConnected returns (bytes32, uint256, bytes memory) {
|
|
271
271
|
uint256 ct = uint256(ctHash);
|
|
272
272
|
|
|
273
|
-
(bool allowed, string memory error, uint256 decryptedValue) = mockThresholdNetwork.
|
|
273
|
+
(bool allowed, string memory error, uint256 decryptedValue) = mockThresholdNetwork.decryptForTxWithoutACP(ct);
|
|
274
274
|
require(allowed, string.concat('CofheClient: decryptForTx failed: ', error));
|
|
275
275
|
|
|
276
276
|
bytes memory signature = mockThresholdNetworkSigner.signDecryptResult(ct, decryptedValue);
|
|
277
277
|
return (ctHash, decryptedValue, signature);
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
-
/// @notice Decrypts a ciphertext using
|
|
281
|
-
function
|
|
280
|
+
/// @notice Decrypts a ciphertext using an ACP and returns the plaintext with a publishable signature.
|
|
281
|
+
function decryptForTx_withACP(
|
|
282
282
|
bytes32 ctHash,
|
|
283
283
|
ACP memory acp
|
|
284
284
|
) public view onlyConnected returns (bytes32, uint256, bytes memory) {
|
|
285
285
|
uint256 ct = uint256(ctHash);
|
|
286
286
|
|
|
287
|
-
(bool allowed, string memory error, uint256 decryptedValue) = mockThresholdNetwork.
|
|
287
|
+
(bool allowed, string memory error, uint256 decryptedValue) = mockThresholdNetwork.decryptForTxWithACP(
|
|
288
288
|
ct,
|
|
289
289
|
acp
|
|
290
290
|
);
|
|
@@ -298,7 +298,7 @@ contract CofheClient is Test {
|
|
|
298
298
|
// DECRYPT FOR VIEW
|
|
299
299
|
// =====================
|
|
300
300
|
|
|
301
|
-
/// @notice Decrypts a ciphertext for off-chain reading by sealing/unsealing with the
|
|
301
|
+
/// @notice Decrypts a ciphertext for off-chain reading by sealing/unsealing with the acp's sealing key.
|
|
302
302
|
function decryptForView(bytes32 ctHash, ACP memory acp) public view onlyConnected returns (uint256) {
|
|
303
303
|
uint256 ct = uint256(ctHash);
|
|
304
304
|
|
|
@@ -313,7 +313,7 @@ contract CofheClient is Test {
|
|
|
313
313
|
}
|
|
314
314
|
|
|
315
315
|
// =====================
|
|
316
|
-
//
|
|
316
|
+
// ACPS
|
|
317
317
|
// =====================
|
|
318
318
|
|
|
319
319
|
bytes32 private constant PERMISSION_TYPE_HASH =
|
|
@@ -387,7 +387,7 @@ contract CofheClient is Test {
|
|
|
387
387
|
return keccak256(abi.encodePacked(seed));
|
|
388
388
|
}
|
|
389
389
|
|
|
390
|
-
/// @notice Creates a self-
|
|
390
|
+
/// @notice Creates a self-acp for the connected account, signed with the stored private key.
|
|
391
391
|
function ACP_createSelf() public view onlyConnected returns (ACP memory acp) {
|
|
392
392
|
acp = createBaseACP();
|
|
393
393
|
acp.issuer = _account;
|
|
@@ -395,7 +395,7 @@ contract CofheClient is Test {
|
|
|
395
395
|
acp = _signIssuerSelf(acp, _pkey);
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
-
/// @notice Creates the issuer side of a shared
|
|
398
|
+
/// @notice Creates the issuer side of a shared acp. The result has no sealingKey (added by recipient on import).
|
|
399
399
|
function ACP_createShared(address recipient) public view onlyConnected returns (ACP memory acp) {
|
|
400
400
|
acp = createBaseACP();
|
|
401
401
|
acp.issuer = _account;
|
|
@@ -403,9 +403,9 @@ contract CofheClient is Test {
|
|
|
403
403
|
acp = _signIssuerShared(acp, _pkey);
|
|
404
404
|
}
|
|
405
405
|
|
|
406
|
-
/// @notice Exports a shared
|
|
407
|
-
function ACP_exportShared(ACP memory acp) public pure returns (
|
|
408
|
-
exported =
|
|
406
|
+
/// @notice Exports a shared acp, stripping sensitive/recipient-specific fields.
|
|
407
|
+
function ACP_exportShared(ACP memory acp) public pure returns (SharedACPExport memory exported) {
|
|
408
|
+
exported = SharedACPExport({
|
|
409
409
|
issuer: acp.issuer,
|
|
410
410
|
expiration: acp.expiration,
|
|
411
411
|
recipient: acp.recipient,
|
|
@@ -418,9 +418,9 @@ contract CofheClient is Test {
|
|
|
418
418
|
});
|
|
419
419
|
}
|
|
420
420
|
|
|
421
|
-
/// @notice Imports a shared
|
|
421
|
+
/// @notice Imports a shared acp export, adds the recipient's sealing key and signature.
|
|
422
422
|
function ACP_importShared(
|
|
423
|
-
|
|
423
|
+
SharedACPExport memory data
|
|
424
424
|
) public view onlyConnected returns (ACP memory acp) {
|
|
425
425
|
require(data.recipient == _account, 'CofheClient: recipient mismatch');
|
|
426
426
|
|
package/contracts/CofheTest.sol
CHANGED
|
@@ -53,7 +53,7 @@ abstract contract CofheTest is Test {
|
|
|
53
53
|
mockAcl = new MockACL();
|
|
54
54
|
vm.label(address(mockAcl), 'MockACL');
|
|
55
55
|
|
|
56
|
-
// ACP (
|
|
56
|
+
// ACP (ACP V3): default revoker (verification inherited by the ACL)
|
|
57
57
|
acpRevoker = new ACPTimestampRevoker();
|
|
58
58
|
vm.label(address(acpRevoker), 'ACPTimestampRevoker');
|
|
59
59
|
mockAcl.setDefaultRevokerContract(address(acpRevoker));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cofhe/foundry-plugin",
|
|
3
|
-
"version": "0.0.0-alpha-
|
|
3
|
+
"version": "0.0.0-alpha-20260818094925",
|
|
4
4
|
"description": "Foundry plugin for CoFHE — Write and test FHE enabled contracts",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"fhenix"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@fhenixprotocol/cofhe-contracts": "0.2.0-beta.
|
|
27
|
+
"@fhenixprotocol/cofhe-contracts": "0.2.0-beta.3",
|
|
28
28
|
"@openzeppelin/contracts": "5.4.0",
|
|
29
|
-
"@cofhe/mock-contracts": "0.0.0-alpha-
|
|
29
|
+
"@cofhe/mock-contracts": "0.0.0-alpha-20260818094925"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"forge-std": "github:foundry-rs/forge-std#c0f966cb111f621bfb283b2a388bc7be18953bba",
|