@cofhe/hardhat-3-plugin 0.6.1 → 0.7.0
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 +34 -0
- package/README.md +10 -6
- package/dist/{chunk-AAZRPK26.js → chunk-E7DR6EGV.js} +25 -1
- package/dist/{hre-PG4EAJES.js → hre-CYH6NXPG.js} +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -2
- package/package.json +3 -3
- package/src/deploy.ts +31 -1
- package/src/hooks/hre.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @cofhe/hardhat-3-plugin
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- fb87d91: **Breaking: Permit (V2) → ACP (Access Control Permission).** Permits become scoped, revocable ACPs; old names are removed rather than deprecated. Highlights (full list in the [0.7.0 migration guide](https://cofhesdk.fhenix.io/migrating-to-0-7-0)):
|
|
8
|
+
|
|
9
|
+
- `Permit`/`Permission`/`PermitUtils`/`client.permits` → `ACP`/`ACPPublic`/`ACPUtils`/`client.acp`; `getPermission()` → `getPublic()`
|
|
10
|
+
- `ACPPrivate` & `ACPPublic` are top-level types, `ACP` is the union; the sealing keypair is flattened to `sealingPrivateKey`/`sealingKey` (the `SealingKey` class is removed)
|
|
11
|
+
- New scope fields (`scope`, `contracts`, `handles: bytes32[]`) and revocation fields renamed `validatorId`/`validatorContract` → `revokerData`/`revokerContract`; default revoker `ACPTimestampRevoker` with `revokeACP`/`revokeAllACPs`/`isACPRevoked` on the client
|
|
12
|
+
- EIP-712 domain bumped to `("ACL", "2")` with new `ACPIssuerSelf`/`ACPIssuerShared`/`ACPRecipient` types — previously signed permits no longer verify; the permit store migrates by wiping retired-format permits
|
|
13
|
+
- `ACPUtils.export()` produces a fixed `SharedACP` shape and only accepts signed sharing ACPs
|
|
14
|
+
|
|
15
|
+
- fb87d91: **On-chain ACP sharing.** New `ACPShareRegistry` contract (deployed with the mocks) lets an issuer post a sharing ACP on-chain for its recipient to discover and import — replacing the JSON copy-paste hand-off.
|
|
16
|
+
|
|
17
|
+
- `client.acp.shareOnChain(acp)` posts a signed sharing ACP (issuer-only, same guards as `export()`); `cancelShare(shareId)` retracts it
|
|
18
|
+
- `client.acp.getIncomingShares()` lists importable shares addressed to the connected account (unexpired, not revoked — the registry checks the share's own revoker)
|
|
19
|
+
- `client.acp.importFromChain(share)` imports like the JSON flow (recipient sealing key + signature); `dismissShare(shareId)` cleans up the entry
|
|
20
|
+
- config: `acp.sharingRegistry: Record<chainId, address>`
|
|
21
|
+
- registry exposes `isShareValid(shareId)` as an on-chain verification hook for contracts
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [fb87d91]
|
|
26
|
+
- Updated dependencies [fb87d91]
|
|
27
|
+
- Updated dependencies [fb87d91]
|
|
28
|
+
- Updated dependencies [fb87d91]
|
|
29
|
+
- Updated dependencies [fb87d91]
|
|
30
|
+
- Updated dependencies [d4d662f]
|
|
31
|
+
- Updated dependencies [fb87d91]
|
|
32
|
+
- Updated dependencies [fb87d91]
|
|
33
|
+
- Updated dependencies [f01cac7]
|
|
34
|
+
- @cofhe/sdk@0.7.0
|
|
35
|
+
- @cofhe/mock-contracts@0.7.0
|
|
36
|
+
|
|
3
37
|
## 0.6.1
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -114,7 +114,7 @@ await client.connect(publicClient, walletClient);
|
|
|
114
114
|
|
|
115
115
|
### `cofhe.createClientWithBatteries(walletClient?)`
|
|
116
116
|
|
|
117
|
-
Creates a fully initialized `CofheClient` in one call — configures it for Hardhat, connects it, and creates a self-
|
|
117
|
+
Creates a fully initialized `CofheClient` in one call — configures it for Hardhat, connects it, and creates a self-acp so it can decrypt encrypted FHE variables out of the box.
|
|
118
118
|
|
|
119
119
|
```typescript
|
|
120
120
|
// Uses the first account in the connection automatically:
|
|
@@ -241,14 +241,18 @@ describe('Encrypted counter', async () => {
|
|
|
241
241
|
it('encrypts, stores, and decrypts a uint32', async () => {
|
|
242
242
|
const client = await cofhe.createClientWithBatteries(walletClient);
|
|
243
243
|
|
|
244
|
-
// Encrypt
|
|
245
|
-
|
|
244
|
+
// Encrypt - returns [hash, signature]: one hash per input, plus the shared batch signature.
|
|
245
|
+
// setConsumingContract binds the signature to the contract that will consume it.
|
|
246
|
+
const [hash, signature] = await client
|
|
247
|
+
.encryptInputs([Encryptable.uint32(42n)])
|
|
248
|
+
.setConsumingContract(simpleTest.address)
|
|
249
|
+
.execute();
|
|
246
250
|
|
|
247
|
-
// Store on-chain via SimpleTest
|
|
251
|
+
// Store on-chain via SimpleTest (batch entry point takes an array plus the signature)
|
|
248
252
|
await walletClient.writeContract({
|
|
249
253
|
...simpleTest,
|
|
250
|
-
functionName: '
|
|
251
|
-
args: [
|
|
254
|
+
functionName: 'setValueBatch',
|
|
255
|
+
args: [[hash], signature],
|
|
252
256
|
});
|
|
253
257
|
|
|
254
258
|
const ctHash = (await publicClient.readContract({
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createTestClient, custom } from "viem";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import { privateKeyToAccount } from "viem/accounts";
|
|
5
|
-
import { MockTaskManagerArtifact, MockThresholdNetworkArtifact } from "@cofhe/mock-contracts";
|
|
5
|
+
import { MockACLArtifact, MockTaskManagerArtifact, MockThresholdNetworkArtifact } from "@cofhe/mock-contracts";
|
|
6
6
|
import {
|
|
7
7
|
TASK_MANAGER_ADDRESS,
|
|
8
8
|
MOCKS_ZK_VERIFIER_ADDRESS,
|
|
@@ -58,6 +58,28 @@ async function deployMocks(ctx, options = {}) {
|
|
|
58
58
|
chain: null
|
|
59
59
|
});
|
|
60
60
|
log("vv", "ACL address set in TaskManager", 2);
|
|
61
|
+
const acpRevokerAddress = await deployVariable(ctx, "ACPTimestampRevoker", []);
|
|
62
|
+
logDeployment("ACPTimestampRevoker", acpRevokerAddress);
|
|
63
|
+
await ctx.walletClient.writeContract({
|
|
64
|
+
address: aclAddress,
|
|
65
|
+
abi: MockACLArtifact.abi,
|
|
66
|
+
functionName: "setDefaultRevokerContract",
|
|
67
|
+
args: [acpRevokerAddress],
|
|
68
|
+
account,
|
|
69
|
+
chain: null
|
|
70
|
+
});
|
|
71
|
+
log("vv", "Default revoker contract set in ACL", 2);
|
|
72
|
+
const acpShareRegistryAddress = await deployVariable(ctx, "ACPShareRegistry", []);
|
|
73
|
+
logDeployment("ACPShareRegistry", acpShareRegistryAddress);
|
|
74
|
+
await ctx.walletClient.writeContract({
|
|
75
|
+
address: aclAddress,
|
|
76
|
+
abi: MockACLArtifact.abi,
|
|
77
|
+
functionName: "setShareRegistry",
|
|
78
|
+
args: [acpShareRegistryAddress],
|
|
79
|
+
account,
|
|
80
|
+
chain: null
|
|
81
|
+
});
|
|
82
|
+
log("vv", "Share registry set in ACL", 2);
|
|
61
83
|
const verifierSigner = privateKeyToAccount(MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY);
|
|
62
84
|
await ctx.walletClient.writeContract({
|
|
63
85
|
address: TASK_MANAGER_ADDRESS,
|
|
@@ -114,6 +136,8 @@ async function deployMocks(ctx, options = {}) {
|
|
|
114
136
|
return {
|
|
115
137
|
MockTaskManager: TASK_MANAGER_ADDRESS,
|
|
116
138
|
MockACL: aclAddress,
|
|
139
|
+
ACPTimestampRevoker: acpRevokerAddress,
|
|
140
|
+
ACPShareRegistry: acpShareRegistryAddress,
|
|
117
141
|
MockZkVerifier: MOCKS_ZK_VERIFIER_ADDRESS,
|
|
118
142
|
MockThresholdNetwork: MOCKS_THRESHOLD_NETWORK_ADDRESS
|
|
119
143
|
};
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
getMockContractsNpmPaths,
|
|
4
4
|
mock_expectPlaintext,
|
|
5
5
|
mock_getPlaintext
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-E7DR6EGV.js";
|
|
7
7
|
import {
|
|
8
8
|
mock_setLoggingEnabled,
|
|
9
9
|
mock_withLogs
|
|
@@ -61,7 +61,7 @@ function createCofheConnection(publicClient, walletClient, transport, artifacts,
|
|
|
61
61
|
const config = await this.createConfig();
|
|
62
62
|
const client = this.createClient(config);
|
|
63
63
|
await client.connect(publicClient, signerClient);
|
|
64
|
-
await client.
|
|
64
|
+
await client.acp.createSelf({ issuer: address });
|
|
65
65
|
return client;
|
|
66
66
|
},
|
|
67
67
|
mocks: {
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ type LogMocksDeploy = '' | 'v' | 'vv';
|
|
|
15
15
|
type DeployedMockContracts = {
|
|
16
16
|
MockTaskManager: `0x${string}`;
|
|
17
17
|
MockACL: `0x${string}`;
|
|
18
|
+
ACPTimestampRevoker: `0x${string}`;
|
|
19
|
+
ACPShareRegistry: `0x${string}`;
|
|
18
20
|
MockZkVerifier: `0x${string}`;
|
|
19
21
|
MockThresholdNetwork: `0x${string}`;
|
|
20
22
|
};
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
getMockContractsNpmPaths,
|
|
4
4
|
mock_expectPlaintext,
|
|
5
5
|
mock_getPlaintext
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-E7DR6EGV.js";
|
|
7
7
|
import {
|
|
8
8
|
localcofheFundAccount,
|
|
9
9
|
localcofheFundWalletIfNeeded
|
|
@@ -26,7 +26,7 @@ var plugin = {
|
|
|
26
26
|
id: "@cofhe/hardhat-3-plugin",
|
|
27
27
|
hookHandlers: {
|
|
28
28
|
config: async () => import("./config-YK3LB5IH.js"),
|
|
29
|
-
hre: async () => import("./hre-
|
|
29
|
+
hre: async () => import("./hre-CYH6NXPG.js")
|
|
30
30
|
},
|
|
31
31
|
tasks: [
|
|
32
32
|
task(TASK_COFHE_USE_FAUCET, "Fund an account via the localcofhe faucet").addOption({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cofhe/hardhat-3-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Hardhat 3 plugin for CoFHE — deploys mock contracts and wires up the hre.cofhe interface",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"chalk": "4.1.2",
|
|
30
30
|
"viem": "2.38.6",
|
|
31
|
-
"@cofhe/mock-contracts": "0.
|
|
32
|
-
"@cofhe/sdk": "0.
|
|
31
|
+
"@cofhe/mock-contracts": "0.7.0",
|
|
32
|
+
"@cofhe/sdk": "0.7.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "20.19.15",
|
package/src/deploy.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { createTestClient, custom } from 'viem';
|
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
6
6
|
|
|
7
|
-
import { MockTaskManagerArtifact, MockThresholdNetworkArtifact } from '@cofhe/mock-contracts';
|
|
7
|
+
import { MockACLArtifact, MockTaskManagerArtifact, MockThresholdNetworkArtifact } from '@cofhe/mock-contracts';
|
|
8
8
|
import {
|
|
9
9
|
TASK_MANAGER_ADDRESS,
|
|
10
10
|
MOCKS_ZK_VERIFIER_ADDRESS,
|
|
@@ -26,6 +26,8 @@ export type LogMocksDeploy = '' | 'v' | 'vv';
|
|
|
26
26
|
export type DeployedMockContracts = {
|
|
27
27
|
MockTaskManager: `0x${string}`;
|
|
28
28
|
MockACL: `0x${string}`;
|
|
29
|
+
ACPTimestampRevoker: `0x${string}`;
|
|
30
|
+
ACPShareRegistry: `0x${string}`;
|
|
29
31
|
MockZkVerifier: `0x${string}`;
|
|
30
32
|
MockThresholdNetwork: `0x${string}`;
|
|
31
33
|
};
|
|
@@ -109,6 +111,32 @@ export async function deployMocks(ctx: DeployContext, options: DeployMocksArgs =
|
|
|
109
111
|
});
|
|
110
112
|
log('vv', 'ACL address set in TaskManager', 2);
|
|
111
113
|
|
|
114
|
+
// 5b. ACP (ACP V3): default revoker (verification is inherited by the ACL)
|
|
115
|
+
const acpRevokerAddress = await deployVariable(ctx, 'ACPTimestampRevoker', []);
|
|
116
|
+
logDeployment('ACPTimestampRevoker', acpRevokerAddress);
|
|
117
|
+
await ctx.walletClient.writeContract({
|
|
118
|
+
address: aclAddress,
|
|
119
|
+
abi: MockACLArtifact.abi,
|
|
120
|
+
functionName: 'setDefaultRevokerContract',
|
|
121
|
+
args: [acpRevokerAddress],
|
|
122
|
+
account,
|
|
123
|
+
chain: null,
|
|
124
|
+
});
|
|
125
|
+
log('vv', 'Default revoker contract set in ACL', 2);
|
|
126
|
+
|
|
127
|
+
// 5c. ACP: on-chain hand-off for sharing ACPs
|
|
128
|
+
const acpShareRegistryAddress = await deployVariable(ctx, 'ACPShareRegistry', []);
|
|
129
|
+
logDeployment('ACPShareRegistry', acpShareRegistryAddress);
|
|
130
|
+
await ctx.walletClient.writeContract({
|
|
131
|
+
address: aclAddress,
|
|
132
|
+
abi: MockACLArtifact.abi,
|
|
133
|
+
functionName: 'setShareRegistry',
|
|
134
|
+
args: [acpShareRegistryAddress],
|
|
135
|
+
account,
|
|
136
|
+
chain: null,
|
|
137
|
+
});
|
|
138
|
+
log('vv', 'Share registry set in ACL', 2);
|
|
139
|
+
|
|
112
140
|
// 6. Set ZkVerifier signer (the key is well-known and shared with the SDK)
|
|
113
141
|
const verifierSigner = privateKeyToAccount(MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY);
|
|
114
142
|
await ctx.walletClient.writeContract({
|
|
@@ -181,6 +209,8 @@ export async function deployMocks(ctx: DeployContext, options: DeployMocksArgs =
|
|
|
181
209
|
return {
|
|
182
210
|
MockTaskManager: TASK_MANAGER_ADDRESS,
|
|
183
211
|
MockACL: aclAddress,
|
|
212
|
+
ACPTimestampRevoker: acpRevokerAddress,
|
|
213
|
+
ACPShareRegistry: acpShareRegistryAddress,
|
|
184
214
|
MockZkVerifier: MOCKS_ZK_VERIFIER_ADDRESS,
|
|
185
215
|
MockThresholdNetwork: MOCKS_THRESHOLD_NETWORK_ADDRESS,
|
|
186
216
|
};
|
package/src/hooks/hre.ts
CHANGED
|
@@ -74,7 +74,7 @@ function createCofheConnection(
|
|
|
74
74
|
const config = await this.createConfig();
|
|
75
75
|
const client = this.createClient(config);
|
|
76
76
|
await client.connect(publicClient, signerClient);
|
|
77
|
-
await client.
|
|
77
|
+
await client.acp.createSelf({ issuer: address });
|
|
78
78
|
return client;
|
|
79
79
|
},
|
|
80
80
|
|