@cofhe/sdk 0.1.0 → 0.2.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 +62 -0
- package/adapters/ethers5.test.ts +174 -0
- package/adapters/ethers5.ts +36 -0
- package/adapters/ethers6.test.ts +169 -0
- package/adapters/ethers6.ts +36 -0
- package/adapters/hardhat-node.ts +167 -0
- package/adapters/hardhat.hh2.test.ts +159 -0
- package/adapters/hardhat.ts +36 -0
- package/adapters/index.test.ts +20 -0
- package/adapters/index.ts +5 -0
- package/adapters/smartWallet.ts +99 -0
- package/adapters/test-utils.ts +53 -0
- package/adapters/types.ts +6 -0
- package/adapters/wagmi.test.ts +156 -0
- package/adapters/wagmi.ts +17 -0
- package/chains/chains/arbSepolia.ts +14 -0
- package/chains/chains/baseSepolia.ts +14 -0
- package/chains/chains/hardhat.ts +15 -0
- package/chains/chains/localcofhe.ts +14 -0
- package/chains/chains/sepolia.ts +14 -0
- package/chains/chains.test.ts +50 -0
- package/chains/defineChain.ts +18 -0
- package/chains/index.ts +35 -0
- package/chains/types.ts +32 -0
- package/core/baseBuilder.ts +119 -0
- package/core/client.test.ts +315 -0
- package/core/client.ts +292 -0
- package/core/clientTypes.ts +108 -0
- package/core/config.test.ts +235 -0
- package/core/config.ts +220 -0
- package/core/decrypt/MockQueryDecrypterAbi.ts +129 -0
- package/core/decrypt/cofheMocksSealOutput.ts +57 -0
- package/core/decrypt/decryptHandleBuilder.ts +287 -0
- package/core/decrypt/decryptUtils.ts +28 -0
- package/core/decrypt/tnSealOutputV1.ts +59 -0
- package/core/decrypt/tnSealOutputV2.ts +298 -0
- package/core/encrypt/MockZkVerifierAbi.ts +106 -0
- package/core/encrypt/cofheMocksZkVerifySign.ts +284 -0
- package/core/encrypt/encryptInputsBuilder.test.ts +751 -0
- package/core/encrypt/encryptInputsBuilder.ts +560 -0
- package/core/encrypt/encryptUtils.ts +67 -0
- package/core/encrypt/zkPackProveVerify.ts +335 -0
- package/core/error.ts +168 -0
- package/core/fetchKeys.test.ts +195 -0
- package/core/fetchKeys.ts +144 -0
- package/core/index.ts +89 -0
- package/core/keyStore.test.ts +226 -0
- package/core/keyStore.ts +154 -0
- package/core/permits.test.ts +494 -0
- package/core/permits.ts +200 -0
- package/core/types.ts +398 -0
- package/core/utils.ts +130 -0
- package/dist/adapters.cjs +88 -0
- package/dist/adapters.d.cts +14576 -0
- package/dist/adapters.d.ts +14576 -0
- package/dist/adapters.js +83 -0
- package/dist/chains.cjs +114 -0
- package/dist/chains.d.cts +121 -0
- package/dist/chains.d.ts +121 -0
- package/dist/chains.js +1 -0
- package/dist/chunk-UGBVZNRT.js +818 -0
- package/dist/chunk-WEAZ25JO.js +105 -0
- package/dist/chunk-WGCRJCBR.js +2523 -0
- package/dist/clientTypes-5_1nwtUe.d.cts +914 -0
- package/dist/clientTypes-Es7fyi65.d.ts +914 -0
- package/dist/core.cjs +3414 -0
- package/dist/core.d.cts +111 -0
- package/dist/core.d.ts +111 -0
- package/dist/core.js +3 -0
- package/dist/node.cjs +3286 -0
- package/dist/node.d.cts +22 -0
- package/dist/node.d.ts +22 -0
- package/dist/node.js +91 -0
- package/dist/permit-fUSe6KKq.d.cts +349 -0
- package/dist/permit-fUSe6KKq.d.ts +349 -0
- package/dist/permits.cjs +871 -0
- package/dist/permits.d.cts +1045 -0
- package/dist/permits.d.ts +1045 -0
- package/dist/permits.js +1 -0
- package/dist/types-KImPrEIe.d.cts +48 -0
- package/dist/types-KImPrEIe.d.ts +48 -0
- package/dist/web.cjs +3478 -0
- package/dist/web.d.cts +38 -0
- package/dist/web.d.ts +38 -0
- package/dist/web.js +240 -0
- package/dist/zkProve.worker.cjs +93 -0
- package/dist/zkProve.worker.d.cts +2 -0
- package/dist/zkProve.worker.d.ts +2 -0
- package/dist/zkProve.worker.js +91 -0
- package/node/client.test.ts +147 -0
- package/node/config.test.ts +68 -0
- package/node/encryptInputs.test.ts +155 -0
- package/node/index.ts +97 -0
- package/node/storage.ts +51 -0
- package/package.json +27 -15
- package/permits/index.ts +68 -0
- package/permits/localstorage.test.ts +117 -0
- package/permits/permit.test.ts +477 -0
- package/permits/permit.ts +405 -0
- package/permits/sealing.test.ts +84 -0
- package/permits/sealing.ts +131 -0
- package/permits/signature.ts +79 -0
- package/permits/store.test.ts +128 -0
- package/permits/store.ts +166 -0
- package/permits/test-utils.ts +20 -0
- package/permits/types.ts +191 -0
- package/permits/utils.ts +62 -0
- package/permits/validation.test.ts +288 -0
- package/permits/validation.ts +369 -0
- package/web/client.web.test.ts +147 -0
- package/web/config.web.test.ts +69 -0
- package/web/encryptInputs.web.test.ts +172 -0
- package/web/index.ts +161 -0
- package/web/storage.ts +34 -0
- package/web/worker.builder.web.test.ts +148 -0
- package/web/worker.config.web.test.ts +329 -0
- package/web/worker.output.web.test.ts +84 -0
- package/web/workerManager.test.ts +80 -0
- package/web/workerManager.ts +214 -0
- package/web/workerManager.web.test.ts +114 -0
- package/web/zkProve.worker.ts +133 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// chains/types.ts
|
|
4
|
+
var EnvironmentSchema = z.enum(["MOCK", "TESTNET", "MAINNET"]);
|
|
5
|
+
var CofheChainSchema = z.object({
|
|
6
|
+
/** Chain ID */
|
|
7
|
+
id: z.number().int().positive(),
|
|
8
|
+
/** Human-readable chain name */
|
|
9
|
+
name: z.string().min(1),
|
|
10
|
+
/** Network identifier */
|
|
11
|
+
network: z.string().min(1),
|
|
12
|
+
/** coFhe service URL */
|
|
13
|
+
coFheUrl: z.string().url(),
|
|
14
|
+
/** Verifier service URL */
|
|
15
|
+
verifierUrl: z.string().url(),
|
|
16
|
+
/** Threshold network service URL */
|
|
17
|
+
thresholdNetworkUrl: z.string().url(),
|
|
18
|
+
/** Environment type */
|
|
19
|
+
environment: EnvironmentSchema
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// chains/defineChain.ts
|
|
23
|
+
function defineChain(chainConfig) {
|
|
24
|
+
const result = CofheChainSchema.safeParse(chainConfig);
|
|
25
|
+
if (!result.success) {
|
|
26
|
+
const errorMessages = result.error.errors.map((err) => `${err.path.join(".")}: ${err.message}`);
|
|
27
|
+
throw new Error(`Invalid chain configuration: ${errorMessages.join(", ")}`);
|
|
28
|
+
}
|
|
29
|
+
return result.data;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// chains/chains/sepolia.ts
|
|
33
|
+
var sepolia = defineChain({
|
|
34
|
+
id: 11155111,
|
|
35
|
+
name: "Sepolia",
|
|
36
|
+
network: "sepolia",
|
|
37
|
+
coFheUrl: "https://testnet-cofhe.fhenix.zone",
|
|
38
|
+
verifierUrl: "https://testnet-cofhe-vrf.fhenix.zone",
|
|
39
|
+
thresholdNetworkUrl: "https://testnet-cofhe-tn.fhenix.zone",
|
|
40
|
+
environment: "TESTNET"
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// chains/chains/arbSepolia.ts
|
|
44
|
+
var arbSepolia = defineChain({
|
|
45
|
+
id: 421614,
|
|
46
|
+
name: "Arbitrum Sepolia",
|
|
47
|
+
network: "arb-sepolia",
|
|
48
|
+
coFheUrl: "https://testnet-cofhe.fhenix.zone",
|
|
49
|
+
verifierUrl: "https://testnet-cofhe-vrf.fhenix.zone",
|
|
50
|
+
thresholdNetworkUrl: "https://testnet-cofhe-tn.fhenix.zone",
|
|
51
|
+
environment: "TESTNET"
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// chains/chains/baseSepolia.ts
|
|
55
|
+
var baseSepolia = defineChain({
|
|
56
|
+
id: 84532,
|
|
57
|
+
name: "Base Sepolia",
|
|
58
|
+
network: "base-sepolia",
|
|
59
|
+
coFheUrl: "https://testnet-cofhe.fhenix.zone",
|
|
60
|
+
verifierUrl: "https://testnet-cofhe-vrf.fhenix.zone",
|
|
61
|
+
thresholdNetworkUrl: "https://testnet-cofhe-tn.fhenix.zone",
|
|
62
|
+
environment: "TESTNET"
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// chains/chains/hardhat.ts
|
|
66
|
+
var hardhat = defineChain({
|
|
67
|
+
id: 31337,
|
|
68
|
+
name: "Hardhat",
|
|
69
|
+
network: "localhost",
|
|
70
|
+
// These are unused in the mock environment
|
|
71
|
+
coFheUrl: "http://127.0.0.1:8448",
|
|
72
|
+
verifierUrl: "http://127.0.0.1:3001",
|
|
73
|
+
thresholdNetworkUrl: "http://127.0.0.1:3000",
|
|
74
|
+
environment: "MOCK"
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// chains/chains/localcofhe.ts
|
|
78
|
+
var localcofhe = defineChain({
|
|
79
|
+
id: 420105,
|
|
80
|
+
name: "Local Cofhe",
|
|
81
|
+
network: "localhost",
|
|
82
|
+
coFheUrl: "http://127.0.0.1:9448",
|
|
83
|
+
verifierUrl: "http://127.0.0.1:3001",
|
|
84
|
+
thresholdNetworkUrl: "http://127.0.0.1:3000",
|
|
85
|
+
environment: "TESTNET"
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// chains/index.ts
|
|
89
|
+
var chains = {
|
|
90
|
+
sepolia,
|
|
91
|
+
arbSepolia,
|
|
92
|
+
baseSepolia,
|
|
93
|
+
hardhat,
|
|
94
|
+
localcofhe
|
|
95
|
+
};
|
|
96
|
+
var getChainById = (chainId) => {
|
|
97
|
+
return Object.values(chains).find((chain) => chain.id === chainId);
|
|
98
|
+
};
|
|
99
|
+
var getChainByName = (name) => {
|
|
100
|
+
return Object.values(chains).find(
|
|
101
|
+
(chain) => chain.name.toLowerCase() === name.toLowerCase() || chain.network.toLowerCase() === name.toLowerCase()
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export { arbSepolia, baseSepolia, chains, getChainById, getChainByName, hardhat, localcofhe, sepolia };
|