@cofhe/hardhat-3-plugin 0.6.1 → 0.7.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/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # @cofhe/hardhat-3-plugin
2
2
 
3
+ ## 0.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [e907d8c]
8
+ - @cofhe/mock-contracts@0.7.1
9
+ - @cofhe/sdk@0.7.1
10
+
11
+ ## 0.7.0
12
+
13
+ ### Minor Changes
14
+
15
+ - 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)):
16
+
17
+ - `Permit`/`Permission`/`PermitUtils`/`client.permits` → `ACP`/`ACPPublic`/`ACPUtils`/`client.acp`; `getPermission()` → `getPublic()`
18
+ - `ACPPrivate` & `ACPPublic` are top-level types, `ACP` is the union; the sealing keypair is flattened to `sealingPrivateKey`/`sealingKey` (the `SealingKey` class is removed)
19
+ - 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
20
+ - 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
21
+ - `ACPUtils.export()` produces a fixed `SharedACP` shape and only accepts signed sharing ACPs
22
+
23
+ - 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.
24
+
25
+ - `client.acp.shareOnChain(acp)` posts a signed sharing ACP (issuer-only, same guards as `export()`); `cancelShare(shareId)` retracts it
26
+ - `client.acp.getIncomingShares()` lists importable shares addressed to the connected account (unexpired, not revoked — the registry checks the share's own revoker)
27
+ - `client.acp.importFromChain(share)` imports like the JSON flow (recipient sealing key + signature); `dismissShare(shareId)` cleans up the entry
28
+ - config: `acp.sharingRegistry: Record<chainId, address>`
29
+ - registry exposes `isShareValid(shareId)` as an on-chain verification hook for contracts
30
+
31
+ ### Patch Changes
32
+
33
+ - Updated dependencies [fb87d91]
34
+ - Updated dependencies [fb87d91]
35
+ - Updated dependencies [fb87d91]
36
+ - Updated dependencies [fb87d91]
37
+ - Updated dependencies [fb87d91]
38
+ - Updated dependencies [d4d662f]
39
+ - Updated dependencies [fb87d91]
40
+ - Updated dependencies [fb87d91]
41
+ - Updated dependencies [f01cac7]
42
+ - @cofhe/sdk@0.7.0
43
+ - @cofhe/mock-contracts@0.7.0
44
+
3
45
  ## 0.6.1
4
46
 
5
47
  ### 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-permit so it can decrypt encrypted FHE variables out of the box.
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
- const [enc] = await client.encryptInputs([Encryptable.uint32(42n)]).execute();
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: 'setValue',
251
- args: [enc],
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-AAZRPK26.js";
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.permits.createSelf({ issuer: address });
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-AAZRPK26.js";
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-PG4EAJES.js")
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.6.1",
3
+ "version": "0.7.1",
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.6.1",
32
- "@cofhe/sdk": "0.6.1"
31
+ "@cofhe/mock-contracts": "0.7.1",
32
+ "@cofhe/sdk": "0.7.1"
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.permits.createSelf({ issuer: address });
77
+ await client.acp.createSelf({ issuer: address });
78
78
  return client;
79
79
  },
80
80