@inco/lightning-js 0.0.0-bootstrap.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/LICENSE +201 -0
- package/README.md +587 -0
- package/dist/cjs/advancedacl/index.d.ts +2 -0
- package/dist/cjs/advancedacl/index.js +19 -0
- package/dist/cjs/advancedacl/session-key.d.ts +95 -0
- package/dist/cjs/advancedacl/session-key.js +376 -0
- package/dist/cjs/advancedacl/types.d.ts +16 -0
- package/dist/cjs/advancedacl/types.js +3 -0
- package/dist/cjs/attestedcompute/attested-compute.d.ts +65 -0
- package/dist/cjs/attestedcompute/attested-compute.js +80 -0
- package/dist/cjs/attestedcompute/types.d.ts +35 -0
- package/dist/cjs/attestedcompute/types.js +46 -0
- package/dist/cjs/attesteddecrypt/attested-decrypt.d.ts +61 -0
- package/dist/cjs/attesteddecrypt/attested-decrypt.js +118 -0
- package/dist/cjs/attesteddecrypt/index.d.ts +1 -0
- package/dist/cjs/attesteddecrypt/index.js +18 -0
- package/dist/cjs/attesteddecrypt/types.d.ts +27 -0
- package/dist/cjs/attesteddecrypt/types.js +16 -0
- package/dist/cjs/attestedreveal/attested-reveal.d.ts +21 -0
- package/dist/cjs/attestedreveal/attested-reveal.js +31 -0
- package/dist/cjs/attestedreveal/index.d.ts +2 -0
- package/dist/cjs/attestedreveal/index.js +21 -0
- package/dist/cjs/attestedreveal/types.d.ts +4 -0
- package/dist/cjs/attestedreveal/types.js +13 -0
- package/dist/cjs/binary.d.ts +104 -0
- package/dist/cjs/binary.js +171 -0
- package/dist/cjs/chain.d.ts +50 -0
- package/dist/cjs/chain.js +62 -0
- package/dist/cjs/eip712/eip712.d.ts +18 -0
- package/dist/cjs/eip712/eip712.js +51 -0
- package/dist/cjs/eip712/index.d.ts +1 -0
- package/dist/cjs/eip712/index.js +8 -0
- package/dist/cjs/elistattesteddecrypt/elist-attested-decrypt.d.ts +51 -0
- package/dist/cjs/elistattesteddecrypt/elist-attested-decrypt.js +94 -0
- package/dist/cjs/elistattesteddecrypt/index.d.ts +2 -0
- package/dist/cjs/elistattesteddecrypt/index.js +22 -0
- package/dist/cjs/elistattesteddecrypt/types.d.ts +31 -0
- package/dist/cjs/elistattesteddecrypt/types.js +16 -0
- package/dist/cjs/encryption/encryption.d.ts +235 -0
- package/dist/cjs/encryption/encryption.js +226 -0
- package/dist/cjs/encryption/index.d.ts +1 -0
- package/dist/cjs/encryption/index.js +19 -0
- package/dist/cjs/generated/abis/add-two.d.ts +117 -0
- package/dist/cjs/generated/abis/add-two.js +80 -0
- package/dist/cjs/generated/abis/lightning.d.ts +3362 -0
- package/dist/cjs/generated/abis/lightning.js +2445 -0
- package/dist/cjs/generated/abis/test-elist.d.ts +276 -0
- package/dist/cjs/generated/abis/test-elist.js +168 -0
- package/dist/cjs/generated/abis/verifier.d.ts +1353 -0
- package/dist/cjs/generated/abis/verifier.js +954 -0
- package/dist/cjs/generated/es/inco/covalidator/compute/v1/server_pb.d.ts +1494 -0
- package/dist/cjs/generated/es/inco/covalidator/compute/v1/server_pb.js +395 -0
- package/dist/cjs/generated/es/inco/covalidator/compute/v1/types_pb.d.ts +247 -0
- package/dist/cjs/generated/es/inco/covalidator/compute/v1/types_pb.js +80 -0
- package/dist/cjs/generated/es/inco/helioswrapper/v1/helioswrapper_pb.d.ts +77 -0
- package/dist/cjs/generated/es/inco/helioswrapper/v1/helioswrapper_pb.js +28 -0
- package/dist/cjs/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +685 -0
- package/dist/cjs/generated/es/inco/kms/lite/v1/kms_service_pb.js +100 -0
- package/dist/cjs/generated/es/inco/kms/lite/v1/types_pb.d.ts +289 -0
- package/dist/cjs/generated/es/inco/kms/lite/v1/types_pb.js +136 -0
- package/dist/cjs/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.d.ts +371 -0
- package/dist/cjs/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.js +88 -0
- package/dist/cjs/generated/lightning.d.ts +830 -0
- package/dist/cjs/generated/lightning.js +872 -0
- package/dist/cjs/generated/local-node.d.ts +50 -0
- package/dist/cjs/generated/local-node.js +107 -0
- package/dist/cjs/handle.d.ts +123 -0
- package/dist/cjs/handle.js +221 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.js +31 -0
- package/dist/cjs/kms/client.d.ts +12 -0
- package/dist/cjs/kms/client.js +47 -0
- package/dist/cjs/kms/quorumClient.d.ts +65 -0
- package/dist/cjs/kms/quorumClient.js +463 -0
- package/dist/cjs/kms/quorumConsistency.d.ts +82 -0
- package/dist/cjs/kms/quorumConsistency.js +269 -0
- package/dist/cjs/kms/signatureVerification.d.ts +35 -0
- package/dist/cjs/kms/signatureVerification.js +88 -0
- package/dist/cjs/kms/thresholdPromises.d.ts +8 -0
- package/dist/cjs/kms/thresholdPromises.js +62 -0
- package/dist/cjs/lite/attested-compute.d.ts +6 -0
- package/dist/cjs/lite/attested-compute.js +8 -0
- package/dist/cjs/lite/attested-decrypt.d.ts +4 -0
- package/dist/cjs/lite/attested-decrypt.js +6 -0
- package/dist/cjs/lite/deployments.d.ts +24 -0
- package/dist/cjs/lite/deployments.js +21 -0
- package/dist/cjs/lite/hadu.d.ts +4 -0
- package/dist/cjs/lite/hadu.js +28 -0
- package/dist/cjs/lite/index.d.ts +13 -0
- package/dist/cjs/lite/index.js +31 -0
- package/dist/cjs/lite/lightning.d.ts +459 -0
- package/dist/cjs/lite/lightning.js +696 -0
- package/dist/cjs/lite/types.d.ts +47 -0
- package/dist/cjs/lite/types.js +3 -0
- package/dist/cjs/lite/xwing.d.ts +154 -0
- package/dist/cjs/lite/xwing.js +326 -0
- package/dist/cjs/local/index.d.ts +1 -0
- package/dist/cjs/local/index.js +18 -0
- package/dist/cjs/local/local-node.d.ts +37 -0
- package/dist/cjs/local/local-node.js +80 -0
- package/dist/cjs/reencryption/eip712.d.ts +56 -0
- package/dist/cjs/reencryption/eip712.js +90 -0
- package/dist/cjs/reencryption/index.d.ts +2 -0
- package/dist/cjs/reencryption/index.js +19 -0
- package/dist/cjs/reencryption/types.d.ts +48 -0
- package/dist/cjs/reencryption/types.js +3 -0
- package/dist/cjs/retry.d.ts +30 -0
- package/dist/cjs/retry.js +87 -0
- package/dist/cjs/schema.d.ts +4 -0
- package/dist/cjs/schema.js +19 -0
- package/dist/cjs/test/mocks.d.ts +20 -0
- package/dist/cjs/test/mocks.js +72 -0
- package/dist/cjs/viem.d.ts +1141 -0
- package/dist/cjs/viem.js +36 -0
- package/dist/esm/advancedacl/index.d.ts +2 -0
- package/dist/esm/advancedacl/index.js +3 -0
- package/dist/esm/advancedacl/session-key.d.ts +95 -0
- package/dist/esm/advancedacl/session-key.js +367 -0
- package/dist/esm/advancedacl/types.d.ts +16 -0
- package/dist/esm/advancedacl/types.js +2 -0
- package/dist/esm/attestedcompute/attested-compute.d.ts +65 -0
- package/dist/esm/attestedcompute/attested-compute.js +76 -0
- package/dist/esm/attestedcompute/types.d.ts +35 -0
- package/dist/esm/attestedcompute/types.js +42 -0
- package/dist/esm/attesteddecrypt/attested-decrypt.d.ts +61 -0
- package/dist/esm/attesteddecrypt/attested-decrypt.js +112 -0
- package/dist/esm/attesteddecrypt/index.d.ts +1 -0
- package/dist/esm/attesteddecrypt/index.js +2 -0
- package/dist/esm/attesteddecrypt/types.d.ts +27 -0
- package/dist/esm/attesteddecrypt/types.js +12 -0
- package/dist/esm/attestedreveal/attested-reveal.d.ts +21 -0
- package/dist/esm/attestedreveal/attested-reveal.js +28 -0
- package/dist/esm/attestedreveal/index.d.ts +2 -0
- package/dist/esm/attestedreveal/index.js +3 -0
- package/dist/esm/attestedreveal/types.d.ts +4 -0
- package/dist/esm/attestedreveal/types.js +9 -0
- package/dist/esm/binary.d.ts +104 -0
- package/dist/esm/binary.js +155 -0
- package/dist/esm/chain.d.ts +50 -0
- package/dist/esm/chain.js +58 -0
- package/dist/esm/eip712/eip712.d.ts +18 -0
- package/dist/esm/eip712/eip712.js +46 -0
- package/dist/esm/eip712/index.d.ts +1 -0
- package/dist/esm/eip712/index.js +2 -0
- package/dist/esm/elistattesteddecrypt/elist-attested-decrypt.d.ts +51 -0
- package/dist/esm/elistattesteddecrypt/elist-attested-decrypt.js +89 -0
- package/dist/esm/elistattesteddecrypt/index.d.ts +2 -0
- package/dist/esm/elistattesteddecrypt/index.js +3 -0
- package/dist/esm/elistattesteddecrypt/types.d.ts +31 -0
- package/dist/esm/elistattesteddecrypt/types.js +12 -0
- package/dist/esm/encryption/encryption.d.ts +235 -0
- package/dist/esm/encryption/encryption.js +214 -0
- package/dist/esm/encryption/index.d.ts +1 -0
- package/dist/esm/encryption/index.js +2 -0
- package/dist/esm/generated/abis/add-two.d.ts +117 -0
- package/dist/esm/generated/abis/add-two.js +77 -0
- package/dist/esm/generated/abis/lightning.d.ts +3362 -0
- package/dist/esm/generated/abis/lightning.js +2442 -0
- package/dist/esm/generated/abis/test-elist.d.ts +276 -0
- package/dist/esm/generated/abis/test-elist.js +165 -0
- package/dist/esm/generated/abis/verifier.d.ts +1353 -0
- package/dist/esm/generated/abis/verifier.js +951 -0
- package/dist/esm/generated/es/inco/covalidator/compute/v1/server_pb.d.ts +1494 -0
- package/dist/esm/generated/es/inco/covalidator/compute/v1/server_pb.js +392 -0
- package/dist/esm/generated/es/inco/covalidator/compute/v1/types_pb.d.ts +247 -0
- package/dist/esm/generated/es/inco/covalidator/compute/v1/types_pb.js +77 -0
- package/dist/esm/generated/es/inco/helioswrapper/v1/helioswrapper_pb.d.ts +77 -0
- package/dist/esm/generated/es/inco/helioswrapper/v1/helioswrapper_pb.js +25 -0
- package/dist/esm/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +685 -0
- package/dist/esm/generated/es/inco/kms/lite/v1/kms_service_pb.js +97 -0
- package/dist/esm/generated/es/inco/kms/lite/v1/types_pb.d.ts +289 -0
- package/dist/esm/generated/es/inco/kms/lite/v1/types_pb.js +133 -0
- package/dist/esm/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.d.ts +371 -0
- package/dist/esm/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.js +85 -0
- package/dist/esm/generated/lightning.d.ts +830 -0
- package/dist/esm/generated/lightning.js +869 -0
- package/dist/esm/generated/local-node.d.ts +50 -0
- package/dist/esm/generated/local-node.js +104 -0
- package/dist/esm/handle.d.ts +123 -0
- package/dist/esm/handle.js +212 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/kms/client.d.ts +12 -0
- package/dist/esm/kms/client.js +40 -0
- package/dist/esm/kms/quorumClient.d.ts +65 -0
- package/dist/esm/kms/quorumClient.js +459 -0
- package/dist/esm/kms/quorumConsistency.d.ts +82 -0
- package/dist/esm/kms/quorumConsistency.js +260 -0
- package/dist/esm/kms/signatureVerification.d.ts +35 -0
- package/dist/esm/kms/signatureVerification.js +84 -0
- package/dist/esm/kms/thresholdPromises.d.ts +8 -0
- package/dist/esm/kms/thresholdPromises.js +59 -0
- package/dist/esm/lite/attested-compute.d.ts +6 -0
- package/dist/esm/lite/attested-compute.js +4 -0
- package/dist/esm/lite/attested-decrypt.d.ts +4 -0
- package/dist/esm/lite/attested-decrypt.js +3 -0
- package/dist/esm/lite/deployments.d.ts +24 -0
- package/dist/esm/lite/deployments.js +17 -0
- package/dist/esm/lite/hadu.d.ts +4 -0
- package/dist/esm/lite/hadu.js +24 -0
- package/dist/esm/lite/index.d.ts +13 -0
- package/dist/esm/lite/index.js +10 -0
- package/dist/esm/lite/lightning.d.ts +459 -0
- package/dist/esm/lite/lightning.js +692 -0
- package/dist/esm/lite/types.d.ts +47 -0
- package/dist/esm/lite/types.js +2 -0
- package/dist/esm/lite/xwing.d.ts +154 -0
- package/dist/esm/lite/xwing.js +311 -0
- package/dist/esm/local/index.d.ts +1 -0
- package/dist/esm/local/index.js +2 -0
- package/dist/esm/local/local-node.d.ts +37 -0
- package/dist/esm/local/local-node.js +76 -0
- package/dist/esm/reencryption/eip712.d.ts +56 -0
- package/dist/esm/reencryption/eip712.js +87 -0
- package/dist/esm/reencryption/index.d.ts +2 -0
- package/dist/esm/reencryption/index.js +3 -0
- package/dist/esm/reencryption/types.d.ts +48 -0
- package/dist/esm/reencryption/types.js +2 -0
- package/dist/esm/retry.d.ts +30 -0
- package/dist/esm/retry.js +82 -0
- package/dist/esm/schema.d.ts +4 -0
- package/dist/esm/schema.js +15 -0
- package/dist/esm/test/mocks.d.ts +20 -0
- package/dist/esm/test/mocks.js +64 -0
- package/dist/esm/viem.d.ts +1141 -0
- package/dist/esm/viem.js +32 -0
- package/dist/types/advancedacl/index.d.ts +2 -0
- package/dist/types/advancedacl/session-key.d.ts +95 -0
- package/dist/types/advancedacl/types.d.ts +16 -0
- package/dist/types/attestedcompute/attested-compute.d.ts +65 -0
- package/dist/types/attestedcompute/types.d.ts +35 -0
- package/dist/types/attesteddecrypt/attested-decrypt.d.ts +61 -0
- package/dist/types/attesteddecrypt/index.d.ts +1 -0
- package/dist/types/attesteddecrypt/types.d.ts +27 -0
- package/dist/types/attestedreveal/attested-reveal.d.ts +21 -0
- package/dist/types/attestedreveal/index.d.ts +2 -0
- package/dist/types/attestedreveal/types.d.ts +4 -0
- package/dist/types/binary.d.ts +104 -0
- package/dist/types/chain.d.ts +50 -0
- package/dist/types/eip712/eip712.d.ts +18 -0
- package/dist/types/eip712/index.d.ts +1 -0
- package/dist/types/elistattesteddecrypt/elist-attested-decrypt.d.ts +51 -0
- package/dist/types/elistattesteddecrypt/index.d.ts +2 -0
- package/dist/types/elistattesteddecrypt/types.d.ts +31 -0
- package/dist/types/encryption/encryption.d.ts +235 -0
- package/dist/types/encryption/index.d.ts +1 -0
- package/dist/types/generated/abis/add-two.d.ts +117 -0
- package/dist/types/generated/abis/lightning.d.ts +3362 -0
- package/dist/types/generated/abis/test-elist.d.ts +276 -0
- package/dist/types/generated/abis/verifier.d.ts +1353 -0
- package/dist/types/generated/es/inco/covalidator/compute/v1/server_pb.d.ts +1494 -0
- package/dist/types/generated/es/inco/covalidator/compute/v1/types_pb.d.ts +247 -0
- package/dist/types/generated/es/inco/helioswrapper/v1/helioswrapper_pb.d.ts +77 -0
- package/dist/types/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +685 -0
- package/dist/types/generated/es/inco/kms/lite/v1/types_pb.d.ts +289 -0
- package/dist/types/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.d.ts +371 -0
- package/dist/types/generated/lightning.d.ts +830 -0
- package/dist/types/generated/local-node.d.ts +50 -0
- package/dist/types/handle.d.ts +123 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/kms/client.d.ts +12 -0
- package/dist/types/kms/quorumClient.d.ts +65 -0
- package/dist/types/kms/quorumConsistency.d.ts +82 -0
- package/dist/types/kms/signatureVerification.d.ts +35 -0
- package/dist/types/kms/thresholdPromises.d.ts +8 -0
- package/dist/types/lite/attested-compute.d.ts +6 -0
- package/dist/types/lite/attested-decrypt.d.ts +4 -0
- package/dist/types/lite/deployments.d.ts +24 -0
- package/dist/types/lite/hadu.d.ts +4 -0
- package/dist/types/lite/index.d.ts +13 -0
- package/dist/types/lite/lightning.d.ts +459 -0
- package/dist/types/lite/types.d.ts +47 -0
- package/dist/types/lite/xwing.d.ts +154 -0
- package/dist/types/local/index.d.ts +1 -0
- package/dist/types/local/local-node.d.ts +37 -0
- package/dist/types/reencryption/eip712.d.ts +56 -0
- package/dist/types/reencryption/index.d.ts +2 -0
- package/dist/types/reencryption/types.d.ts +48 -0
- package/dist/types/retry.d.ts +30 -0
- package/dist/types/schema.d.ts +4 -0
- package/dist/types/test/mocks.d.ts +20 -0
- package/dist/types/viem.d.ts +1141 -0
- package/package.json +129 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export declare const localNodeLightningConfig: {
|
|
2
|
+
readonly mainnet: {
|
|
3
|
+
readonly executorAddress: "0x4b9911b0191B0b6a6eA8F2Ed562e20Cff5AC8624";
|
|
4
|
+
readonly chainId: 31337;
|
|
5
|
+
readonly covalidatorUrls: readonly ["http://localhost:50055"];
|
|
6
|
+
readonly signers: readonly ["0xDD166476574D64D54A8d65810478007eDccc1d1d"];
|
|
7
|
+
readonly hostChainRpcUrls: readonly ["http://localhost:8545"];
|
|
8
|
+
readonly senderPrivateKey: "0x7f2a092a3ecab2e11400fc235b8d3d6b76fb7ec14c71b64baf5a6885a36c1b3a";
|
|
9
|
+
};
|
|
10
|
+
readonly demonet: {
|
|
11
|
+
readonly executorAddress: "0xad9Af2e804FbF14d69391167F1FCDf918A3980fb";
|
|
12
|
+
readonly chainId: 31337;
|
|
13
|
+
readonly covalidatorUrls: readonly ["http://localhost:50055"];
|
|
14
|
+
readonly signers: readonly ["0x9cDbDc8E83F84B9D6d3c19356B8C590f0CE1F549"];
|
|
15
|
+
readonly hostChainRpcUrls: readonly ["http://localhost:8545"];
|
|
16
|
+
readonly senderPrivateKey: "0x8e6681c7870f0adc53511b6f38515a5b0f4e3a3fa62a62505f58c61e64c92497";
|
|
17
|
+
};
|
|
18
|
+
readonly testnet: {
|
|
19
|
+
readonly executorAddress: "0xe9CB49A5b16C6D4a093E5900AA8b450FD40541B6";
|
|
20
|
+
readonly chainId: 31337;
|
|
21
|
+
readonly covalidatorUrls: readonly ["http://localhost:50055"];
|
|
22
|
+
readonly signers: readonly ["0x8A853ACC000D50bfb59e1D04635959957e28Db38"];
|
|
23
|
+
readonly hostChainRpcUrls: readonly ["http://localhost:8545"];
|
|
24
|
+
readonly senderPrivateKey: "0x835c46722a63e5132eaf24d0a1dad8689d43b85bdcc0e592c23e55fa603895d7";
|
|
25
|
+
};
|
|
26
|
+
readonly devnet: {
|
|
27
|
+
readonly executorAddress: "0xB3C06f0Ed967a7E366ba31C67927DDf93d7c1154";
|
|
28
|
+
readonly chainId: 31337;
|
|
29
|
+
readonly covalidatorUrls: readonly ["http://localhost:50055"];
|
|
30
|
+
readonly signers: readonly ["0x29C5a8C17d8c0A2B2036365EA6908291A35dDadF"];
|
|
31
|
+
readonly hostChainRpcUrls: readonly ["http://localhost:8545"];
|
|
32
|
+
readonly senderPrivateKey: "0xbea2b6c911de6a581e7e5fab9da94edbb00c5ddba7ab1645c100b012997c842e";
|
|
33
|
+
};
|
|
34
|
+
readonly alphanet: {
|
|
35
|
+
readonly executorAddress: "0xc0d693DeEF0A91CE39208676b6da09B822abd199";
|
|
36
|
+
readonly chainId: 31337;
|
|
37
|
+
readonly covalidatorUrls: readonly ["http://localhost:50055"];
|
|
38
|
+
readonly signers: readonly ["0x8E873085348a3406A07907E5d1465B9824bA07cd"];
|
|
39
|
+
readonly hostChainRpcUrls: readonly ["http://localhost:8545"];
|
|
40
|
+
readonly senderPrivateKey: "0x279c172cf3638a79642daa5f7666c600befde318550d7579cf96280920e318b6";
|
|
41
|
+
};
|
|
42
|
+
readonly scratch: {
|
|
43
|
+
readonly executorAddress: "0xb390b23b8fa1761a85035E7C135bf93713d1d4d1";
|
|
44
|
+
readonly chainId: 31337;
|
|
45
|
+
readonly covalidatorUrls: readonly ["http://localhost:50055"];
|
|
46
|
+
readonly signers: readonly ["0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"];
|
|
47
|
+
readonly hostChainRpcUrls: readonly ["http://127.0.0.1:8567"];
|
|
48
|
+
readonly senderPrivateKey: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// WARNING: LOCAL DEVELOPMENT ONLY - DO NOT USE IN PRODUCTION
|
|
3
|
+
// ============================================================================
|
|
4
|
+
//
|
|
5
|
+
// This file contains TEST KEYS that are publicly known and have no value.
|
|
6
|
+
//
|
|
7
|
+
// SECURITY NOTICE: All URLs in this configuration use HTTP (unencrypted).
|
|
8
|
+
// This is acceptable ONLY for localhost connections where traffic never
|
|
9
|
+
// leaves the local machine.
|
|
10
|
+
//
|
|
11
|
+
// DO NOT modify these URLs to point to non-localhost addresses without
|
|
12
|
+
// switching to HTTPS. Using HTTP with remote hosts exposes sensitive data
|
|
13
|
+
// (including private keys and transaction data) to network interception.
|
|
14
|
+
//
|
|
15
|
+
// For production or any non-local environment, use the appropriate
|
|
16
|
+
// network configuration files which enforce HTTPS for all remote connections.
|
|
17
|
+
// ============================================================================
|
|
18
|
+
export const localNodeLightningConfig = {
|
|
19
|
+
"mainnet": {
|
|
20
|
+
"executorAddress": "0x4b9911b0191B0b6a6eA8F2Ed562e20Cff5AC8624",
|
|
21
|
+
"chainId": 31337,
|
|
22
|
+
"covalidatorUrls": [
|
|
23
|
+
"http://localhost:50055"
|
|
24
|
+
],
|
|
25
|
+
"signers": [
|
|
26
|
+
"0xDD166476574D64D54A8d65810478007eDccc1d1d"
|
|
27
|
+
],
|
|
28
|
+
"hostChainRpcUrls": [
|
|
29
|
+
"http://localhost:8545"
|
|
30
|
+
],
|
|
31
|
+
"senderPrivateKey": "0x7f2a092a3ecab2e11400fc235b8d3d6b76fb7ec14c71b64baf5a6885a36c1b3a"
|
|
32
|
+
},
|
|
33
|
+
"demonet": {
|
|
34
|
+
"executorAddress": "0xad9Af2e804FbF14d69391167F1FCDf918A3980fb",
|
|
35
|
+
"chainId": 31337,
|
|
36
|
+
"covalidatorUrls": [
|
|
37
|
+
"http://localhost:50055"
|
|
38
|
+
],
|
|
39
|
+
"signers": [
|
|
40
|
+
"0x9cDbDc8E83F84B9D6d3c19356B8C590f0CE1F549"
|
|
41
|
+
],
|
|
42
|
+
"hostChainRpcUrls": [
|
|
43
|
+
"http://localhost:8545"
|
|
44
|
+
],
|
|
45
|
+
"senderPrivateKey": "0x8e6681c7870f0adc53511b6f38515a5b0f4e3a3fa62a62505f58c61e64c92497"
|
|
46
|
+
},
|
|
47
|
+
"testnet": {
|
|
48
|
+
"executorAddress": "0xe9CB49A5b16C6D4a093E5900AA8b450FD40541B6",
|
|
49
|
+
"chainId": 31337,
|
|
50
|
+
"covalidatorUrls": [
|
|
51
|
+
"http://localhost:50055"
|
|
52
|
+
],
|
|
53
|
+
"signers": [
|
|
54
|
+
"0x8A853ACC000D50bfb59e1D04635959957e28Db38"
|
|
55
|
+
],
|
|
56
|
+
"hostChainRpcUrls": [
|
|
57
|
+
"http://localhost:8545"
|
|
58
|
+
],
|
|
59
|
+
"senderPrivateKey": "0x835c46722a63e5132eaf24d0a1dad8689d43b85bdcc0e592c23e55fa603895d7"
|
|
60
|
+
},
|
|
61
|
+
"devnet": {
|
|
62
|
+
"executorAddress": "0xB3C06f0Ed967a7E366ba31C67927DDf93d7c1154",
|
|
63
|
+
"chainId": 31337,
|
|
64
|
+
"covalidatorUrls": [
|
|
65
|
+
"http://localhost:50055"
|
|
66
|
+
],
|
|
67
|
+
"signers": [
|
|
68
|
+
"0x29C5a8C17d8c0A2B2036365EA6908291A35dDadF"
|
|
69
|
+
],
|
|
70
|
+
"hostChainRpcUrls": [
|
|
71
|
+
"http://localhost:8545"
|
|
72
|
+
],
|
|
73
|
+
"senderPrivateKey": "0xbea2b6c911de6a581e7e5fab9da94edbb00c5ddba7ab1645c100b012997c842e"
|
|
74
|
+
},
|
|
75
|
+
"alphanet": {
|
|
76
|
+
"executorAddress": "0xc0d693DeEF0A91CE39208676b6da09B822abd199",
|
|
77
|
+
"chainId": 31337,
|
|
78
|
+
"covalidatorUrls": [
|
|
79
|
+
"http://localhost:50055"
|
|
80
|
+
],
|
|
81
|
+
"signers": [
|
|
82
|
+
"0x8E873085348a3406A07907E5d1465B9824bA07cd"
|
|
83
|
+
],
|
|
84
|
+
"hostChainRpcUrls": [
|
|
85
|
+
"http://localhost:8545"
|
|
86
|
+
],
|
|
87
|
+
"senderPrivateKey": "0x279c172cf3638a79642daa5f7666c600befde318550d7579cf96280920e318b6"
|
|
88
|
+
},
|
|
89
|
+
"scratch": {
|
|
90
|
+
"executorAddress": "0xb390b23b8fa1761a85035E7C135bf93713d1d4d1",
|
|
91
|
+
"chainId": 31337,
|
|
92
|
+
"covalidatorUrls": [
|
|
93
|
+
"http://localhost:50055"
|
|
94
|
+
],
|
|
95
|
+
"signers": [
|
|
96
|
+
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
|
|
97
|
+
],
|
|
98
|
+
"hostChainRpcUrls": [
|
|
99
|
+
"http://127.0.0.1:8567"
|
|
100
|
+
],
|
|
101
|
+
"senderPrivateKey": "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9jYWwtbm9kZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9nZW5lcmF0ZWQvbG9jYWwtbm9kZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwrRUFBK0U7QUFDL0UsNkRBQTZEO0FBQzdELCtFQUErRTtBQUMvRSxFQUFFO0FBQ0YsMEVBQTBFO0FBQzFFLEVBQUU7QUFDRiwwRUFBMEU7QUFDMUUsd0VBQXdFO0FBQ3hFLDRCQUE0QjtBQUM1QixFQUFFO0FBQ0YsdUVBQXVFO0FBQ3ZFLDBFQUEwRTtBQUMxRSx5RUFBeUU7QUFDekUsRUFBRTtBQUNGLG1FQUFtRTtBQUNuRSw4RUFBOEU7QUFDOUUsK0VBQStFO0FBRS9FLE1BQU0sQ0FBQyxNQUFNLHdCQUF3QixHQUFHO0lBQ3RDLFNBQVMsRUFBRTtRQUNULGlCQUFpQixFQUFFLDRDQUE0QztRQUMvRCxTQUFTLEVBQUUsS0FBSztRQUNoQixpQkFBaUIsRUFBRTtZQUNqQix3QkFBd0I7U0FDekI7UUFDRCxTQUFTLEVBQUU7WUFDVCw0Q0FBNEM7U0FDN0M7UUFDRCxrQkFBa0IsRUFBRTtZQUNsQix1QkFBdUI7U0FDeEI7UUFDRCxrQkFBa0IsRUFBRSxvRUFBb0U7S0FDekY7SUFDRCxTQUFTLEVBQUU7UUFD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lBQ0QsU0FBUyxFQUFFO1FBQ1QsaUJBQWlCLEVBQUUsNENBQTRDO1FBQy9ELFNBQVMsRUFBRSxLQUFLO1FBQ2hCLGlCQUFpQixFQUFFO1lBQ2pCLHdCQUF3QjtTQUN6QjtRQUNELFNBQVMsRUFBRTtZQUNULDRDQUE0QztTQUM3QztRQUNELGtCQUFrQixFQUFFO1lBQ2xCLHVCQUF1QjtTQUN4QjtRQUNELGtCQUFrQixFQUFFLG9FQUFvRTtLQUN6RjtDQUNPLENBQUMifQ==
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
import { HexString } from './binary.js';
|
|
3
|
+
/** Current handle version byte, appended as the last byte of every handle. */
|
|
4
|
+
export declare const HANDLE_VERSION = 0;
|
|
5
|
+
/**
|
|
6
|
+
* Domain separators for handle derivation. Must be kept in sync with Solidity
|
|
7
|
+
* (contracts/lightning/src/Types.sol) and Go (pkg/hostchain/handle.go). Prefixing every
|
|
8
|
+
* keccak256 preimage with a unique constant string makes cross-derivation-path
|
|
9
|
+
* collision resistance structural rather than incidental.
|
|
10
|
+
*/
|
|
11
|
+
export declare const SEP_INPUT_HANDLE = "inco/handle/input-handle";
|
|
12
|
+
export declare const SEP_INPUT_CONTEXT = "inco/handle/input-context";
|
|
13
|
+
export declare const SEP_OP_RESULT = "inco/handle/op-result";
|
|
14
|
+
export declare const SEP_ELIST_OP_RESULT = "inco/handle/elist-result";
|
|
15
|
+
export declare const BYTE_ELIST_ELEMENT_TYPE_INDEX = 29;
|
|
16
|
+
/**
|
|
17
|
+
* Map of ENCRYPTION type names to their integer identifiers.
|
|
18
|
+
*
|
|
19
|
+
* Keys provide a semantic interpretation over the underlying integral type.
|
|
20
|
+
* For example, `ebool` interprets a `uint16` as a boolean, `ebytes64` interprets
|
|
21
|
+
* a `uint512` as a 64-byte array, etc.
|
|
22
|
+
*/
|
|
23
|
+
export declare const handleTypes: Readonly<{
|
|
24
|
+
ebool: 0;
|
|
25
|
+
euint4: 1;
|
|
26
|
+
euint8: 2;
|
|
27
|
+
euint16: 3;
|
|
28
|
+
euint32: 4;
|
|
29
|
+
euint64: 5;
|
|
30
|
+
euint128: 6;
|
|
31
|
+
euint160: 7;
|
|
32
|
+
euint256: 8;
|
|
33
|
+
ebytes64: 9;
|
|
34
|
+
ebytes128: 10;
|
|
35
|
+
ebytes256: 11;
|
|
36
|
+
}>;
|
|
37
|
+
/** Schema that validates a string is one of the known ENCRYPTION type names (e.g. `"ebool"`, `"euint256"`). */
|
|
38
|
+
export declare const HandleTypeName: Schema.SchemaClass<"ebool" | "euint4" | "euint8" | "euint16" | "euint32" | "euint64" | "euint128" | "euint160" | "euint256" | "ebytes64" | "ebytes128" | "ebytes256", "ebool" | "euint4" | "euint8" | "euint16" | "euint32" | "euint64" | "euint128" | "euint160" | "euint256" | "ebytes64" | "ebytes128" | "ebytes256", never>;
|
|
39
|
+
/** A valid ENCRYPTION type name string (e.g. `"ebool"`, `"euint32"`, `"ebytes64"`). */
|
|
40
|
+
export type HandleTypeName = typeof HandleTypeName.Type;
|
|
41
|
+
/** The typeof {@link handleTypes} — mapping from ENCRYPTION type names to integer IDs. */
|
|
42
|
+
export type HandleTypes = typeof handleTypes;
|
|
43
|
+
/** Integer identifier of an ENCRYPTION type (0–11), corresponding to a {@link HandleTypeName}. */
|
|
44
|
+
export type TeeType = HandleTypes[keyof HandleTypes];
|
|
45
|
+
/**
|
|
46
|
+
* Type guard that checks whether a number is a valid {@link TeeType} identifier.
|
|
47
|
+
* @param value - The number to check.
|
|
48
|
+
* @returns `true` if `value` is a known ENCRYPTION type integer (0–11).
|
|
49
|
+
*/
|
|
50
|
+
export declare function isTeeType(value: number): value is TeeType;
|
|
51
|
+
/** Schema for the context required to compute a deterministic ENCRYPTION handle. */
|
|
52
|
+
export declare const InputContext: Schema.Struct<{
|
|
53
|
+
hostChainId: typeof Schema.BigInt;
|
|
54
|
+
aclAddress: Schema.TemplateLiteral<`0x${string}`>;
|
|
55
|
+
userAddress: Schema.TemplateLiteral<`0x${string}`>;
|
|
56
|
+
contractAddress: Schema.TemplateLiteral<`0x${string}`>;
|
|
57
|
+
version: typeof Schema.Number;
|
|
58
|
+
inputType: typeof Schema.Number;
|
|
59
|
+
}>;
|
|
60
|
+
/** Context fields (chain ID, ACL address, user/contract addresses, version, on-chain inputType) used to derive a deterministic handle. */
|
|
61
|
+
export type InputContext = typeof InputContext.Type;
|
|
62
|
+
/**
|
|
63
|
+
* A 32-byte hex string representing an ENCRYPTION ciphertext handle.
|
|
64
|
+
*
|
|
65
|
+
* Format: `keccak_hash[0:29] || index_handle || handle_type || handle_version`
|
|
66
|
+
*
|
|
67
|
+
* @see pkg/hostchain/handle.md for the handle format spec.
|
|
68
|
+
*/
|
|
69
|
+
export type Handle = HexString;
|
|
70
|
+
/**
|
|
71
|
+
* Expected length of a handle in bytes.
|
|
72
|
+
* Handle format: 29 bytes hash + 1 byte index + 1 byte type + 1 byte version = 32 bytes
|
|
73
|
+
*/
|
|
74
|
+
export declare const HANDLE_LENGTH_BYTES = 32;
|
|
75
|
+
/**
|
|
76
|
+
* Validates handle integrity by checking format, length, and version.
|
|
77
|
+
* Matches the validation in Go's HandleFromBytes (pkg/hostchain/handle.go).
|
|
78
|
+
* @param handle - The handle to validate
|
|
79
|
+
* @throws Error if handle is malformed (wrong format, length, or unsupported version)
|
|
80
|
+
*/
|
|
81
|
+
export declare function validateHandle(handle: HexString): void;
|
|
82
|
+
/**
|
|
83
|
+
* Extracts the {@link TeeType} from byte 30 of a validated handle.
|
|
84
|
+
* @param handle - A 32-byte hex handle string.
|
|
85
|
+
* @returns The ENCRYPTION type identifier stored in the handle.
|
|
86
|
+
* @throws If the handle is malformed or contains an invalid ENCRYPTION type.
|
|
87
|
+
* @see pkg/hostchain/handle.md for the handle format spec.
|
|
88
|
+
*/
|
|
89
|
+
export declare function getHandleType(handle: HexString): TeeType;
|
|
90
|
+
/**
|
|
91
|
+
* Extracts the elist element {@link TeeType} from byte 29 of a validated handle.
|
|
92
|
+
* @param handle - A 32-byte hex handle string for an elist.
|
|
93
|
+
* @returns The ENCRYPTION type identifier of the elist elements.
|
|
94
|
+
* @throws If the handle is malformed or contains an invalid ENCRYPTION type at byte 29.
|
|
95
|
+
*/
|
|
96
|
+
export declare function getEListElementType(handle: HexString): TeeType;
|
|
97
|
+
/**
|
|
98
|
+
* Computes the final handle for an input based on the ciphertext and the input context, matches the handle generation
|
|
99
|
+
* in Go and Solidity.
|
|
100
|
+
*
|
|
101
|
+
* @param ciphertext Note this is different from the input which has the external handle prepended
|
|
102
|
+
* @param indexHandle
|
|
103
|
+
* @param handleType
|
|
104
|
+
* @param handleVersion
|
|
105
|
+
* @param context
|
|
106
|
+
*/
|
|
107
|
+
export declare function computeHandle({ ciphertext, indexHandle, handleType, handleVersion, context, }: {
|
|
108
|
+
ciphertext: Uint8Array;
|
|
109
|
+
indexHandle: number;
|
|
110
|
+
handleType: TeeType;
|
|
111
|
+
handleVersion: number;
|
|
112
|
+
context: InputContext;
|
|
113
|
+
}): Buffer;
|
|
114
|
+
/**
|
|
115
|
+
* Computes the Keccak-256 hash of an ABI-packed {@link InputContext}.
|
|
116
|
+
*
|
|
117
|
+
* The context is packed as: `"evm/" || SEP_INPUT_CONTEXT || HANDLE_VERSION || inputType ||
|
|
118
|
+
* chainId || aclAddress || userAddress || contractAddress || version`.
|
|
119
|
+
*
|
|
120
|
+
* @param context - The input context to hash.
|
|
121
|
+
* @returns A 32-byte `Buffer` containing the Keccak-256 digest.
|
|
122
|
+
*/
|
|
123
|
+
export declare function hashInputContext(context: InputContext): Buffer;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
import { Keccak } from 'sha3';
|
|
3
|
+
import { encodePacked, hexToBytes, toHex } from 'viem';
|
|
4
|
+
import { HexString } from './binary.js';
|
|
5
|
+
/** Current handle version byte, appended as the last byte of every handle. */
|
|
6
|
+
export const HANDLE_VERSION = 0;
|
|
7
|
+
/**
|
|
8
|
+
* Domain separators for handle derivation. Must be kept in sync with Solidity
|
|
9
|
+
* (contracts/lightning/src/Types.sol) and Go (pkg/hostchain/handle.go). Prefixing every
|
|
10
|
+
* keccak256 preimage with a unique constant string makes cross-derivation-path
|
|
11
|
+
* collision resistance structural rather than incidental.
|
|
12
|
+
*/
|
|
13
|
+
export const SEP_INPUT_HANDLE = 'inco/handle/input-handle';
|
|
14
|
+
export const SEP_INPUT_CONTEXT = 'inco/handle/input-context';
|
|
15
|
+
export const SEP_OP_RESULT = 'inco/handle/op-result';
|
|
16
|
+
export const SEP_ELIST_OP_RESULT = 'inco/handle/elist-result';
|
|
17
|
+
// The index of the byte in the handle where elist element type is stored
|
|
18
|
+
export const BYTE_ELIST_ELEMENT_TYPE_INDEX = 29;
|
|
19
|
+
/**
|
|
20
|
+
* Map of ENCRYPTION type names to their integer identifiers.
|
|
21
|
+
*
|
|
22
|
+
* Keys provide a semantic interpretation over the underlying integral type.
|
|
23
|
+
* For example, `ebool` interprets a `uint16` as a boolean, `ebytes64` interprets
|
|
24
|
+
* a `uint512` as a 64-byte array, etc.
|
|
25
|
+
*/
|
|
26
|
+
export const handleTypes = Object.freeze({
|
|
27
|
+
ebool: 0,
|
|
28
|
+
euint4: 1,
|
|
29
|
+
euint8: 2,
|
|
30
|
+
euint16: 3,
|
|
31
|
+
euint32: 4,
|
|
32
|
+
euint64: 5,
|
|
33
|
+
euint128: 6,
|
|
34
|
+
euint160: 7,
|
|
35
|
+
euint256: 8,
|
|
36
|
+
ebytes64: 9,
|
|
37
|
+
ebytes128: 10,
|
|
38
|
+
ebytes256: 11,
|
|
39
|
+
});
|
|
40
|
+
const handleNames = Object.keys(handleTypes);
|
|
41
|
+
/** Schema that validates a string is one of the known ENCRYPTION type names (e.g. `"ebool"`, `"euint256"`). */
|
|
42
|
+
export const HandleTypeName = Schema.Literal(...handleNames);
|
|
43
|
+
/**
|
|
44
|
+
* Type guard that checks whether a number is a valid {@link TeeType} identifier.
|
|
45
|
+
* @param value - The number to check.
|
|
46
|
+
* @returns `true` if `value` is a known ENCRYPTION type integer (0–11).
|
|
47
|
+
*/
|
|
48
|
+
export function isTeeType(value) {
|
|
49
|
+
return Object.values(handleTypes).includes(value);
|
|
50
|
+
}
|
|
51
|
+
/** Schema for the context required to compute a deterministic ENCRYPTION handle. */
|
|
52
|
+
export const InputContext = Schema.Struct({
|
|
53
|
+
hostChainId: Schema.BigInt,
|
|
54
|
+
aclAddress: HexString,
|
|
55
|
+
userAddress: HexString,
|
|
56
|
+
contractAddress: HexString,
|
|
57
|
+
version: Schema.Number,
|
|
58
|
+
inputType: Schema.Number,
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* Expected length of a handle in bytes.
|
|
62
|
+
* Handle format: 29 bytes hash + 1 byte index + 1 byte type + 1 byte version = 32 bytes
|
|
63
|
+
*/
|
|
64
|
+
export const HANDLE_LENGTH_BYTES = 32;
|
|
65
|
+
/**
|
|
66
|
+
* Validates handle integrity by checking format, length, and version.
|
|
67
|
+
* Matches the validation in Go's HandleFromBytes (pkg/hostchain/handle.go).
|
|
68
|
+
* @param handle - The handle to validate
|
|
69
|
+
* @throws Error if handle is malformed (wrong format, length, or unsupported version)
|
|
70
|
+
*/
|
|
71
|
+
export function validateHandle(handle) {
|
|
72
|
+
// Check format: must start with 0x prefix and have correct length
|
|
73
|
+
if (!handle.startsWith('0x') ||
|
|
74
|
+
handle.length !== 2 + 2 * HANDLE_LENGTH_BYTES) {
|
|
75
|
+
throw new Error(`Invalid handle format: must be a ${HANDLE_LENGTH_BYTES}-byte hex string with 0x prefix`);
|
|
76
|
+
}
|
|
77
|
+
const handleBytes = hexToBytes(handle);
|
|
78
|
+
// Validate handle version (byte 31 must match HANDLE_VERSION)
|
|
79
|
+
const handleVersion = handleBytes[31];
|
|
80
|
+
if (handleVersion !== HANDLE_VERSION) {
|
|
81
|
+
throw new Error(`Unsupported handle version: expected ${HANDLE_VERSION}, got ${handleVersion} for handle ${handle}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Extracts the {@link TeeType} from byte 30 of a validated handle.
|
|
86
|
+
* @param handle - A 32-byte hex handle string.
|
|
87
|
+
* @returns The ENCRYPTION type identifier stored in the handle.
|
|
88
|
+
* @throws If the handle is malformed or contains an invalid ENCRYPTION type.
|
|
89
|
+
* @see pkg/hostchain/handle.md for the handle format spec.
|
|
90
|
+
*/
|
|
91
|
+
export function getHandleType(handle) {
|
|
92
|
+
// Validate handle integrity before extracting type
|
|
93
|
+
validateHandle(handle);
|
|
94
|
+
const handleBytes = hexToBytes(handle);
|
|
95
|
+
const handleType = handleBytes[30];
|
|
96
|
+
if (!isTeeType(handleType)) {
|
|
97
|
+
throw new Error(`Invalid handle type ${handleType} for handle ${handle}`);
|
|
98
|
+
}
|
|
99
|
+
return handleType;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Extracts the elist element {@link TeeType} from byte 29 of a validated handle.
|
|
103
|
+
* @param handle - A 32-byte hex handle string for an elist.
|
|
104
|
+
* @returns The ENCRYPTION type identifier of the elist elements.
|
|
105
|
+
* @throws If the handle is malformed or contains an invalid ENCRYPTION type at byte 29.
|
|
106
|
+
*/
|
|
107
|
+
export function getEListElementType(handle) {
|
|
108
|
+
validateHandle(handle);
|
|
109
|
+
const handleBytes = hexToBytes(handle);
|
|
110
|
+
const elementType = handleBytes[BYTE_ELIST_ELEMENT_TYPE_INDEX];
|
|
111
|
+
if (!isTeeType(elementType)) {
|
|
112
|
+
throw new Error(`Invalid elist element type ${elementType} for handle ${handle}`);
|
|
113
|
+
}
|
|
114
|
+
return elementType;
|
|
115
|
+
}
|
|
116
|
+
// Handle format reference (kept in sync with Solidity in contracts/lightning/src and Go in pkg/hostchain/handle.go):
|
|
117
|
+
/// @dev handle format for user inputs: keccak256(keccak256(CiphertextList) || index_handle)[0:29] || index_handle || handle_type || handle_version
|
|
118
|
+
/// @dev handle format for op results: keccak256(keccak256(rawCiphertextList) || index_handle)[0:30] || handle_type || handle_version
|
|
119
|
+
/// @dev CiphertextList layout: 1 byte (= N) for handles_list size, N bytes for handles_types (1 per handle), followed by the original raw ciphertext list
|
|
120
|
+
/**
|
|
121
|
+
* Computes the final handle for an input based on the ciphertext and the input context, matches the handle generation
|
|
122
|
+
* in Go and Solidity.
|
|
123
|
+
*
|
|
124
|
+
* @param ciphertext Note this is different from the input which has the external handle prepended
|
|
125
|
+
* @param indexHandle
|
|
126
|
+
* @param handleType
|
|
127
|
+
* @param handleVersion
|
|
128
|
+
* @param context
|
|
129
|
+
*/
|
|
130
|
+
export function computeHandle({ ciphertext, indexHandle, handleType, handleVersion, context, }) {
|
|
131
|
+
assertUint8(indexHandle);
|
|
132
|
+
assertUint8(handleType);
|
|
133
|
+
assertUint8(handleVersion);
|
|
134
|
+
if (handleVersion !== HANDLE_VERSION) {
|
|
135
|
+
throw new Error(`Unsupported handle version: expected ${HANDLE_VERSION}, got ${handleVersion}`);
|
|
136
|
+
}
|
|
137
|
+
const packed = encodePacked([
|
|
138
|
+
'string',
|
|
139
|
+
'uint8',
|
|
140
|
+
'uint8',
|
|
141
|
+
'uint32',
|
|
142
|
+
'bytes',
|
|
143
|
+
'uint8',
|
|
144
|
+
'string',
|
|
145
|
+
'uint256',
|
|
146
|
+
'address',
|
|
147
|
+
'address',
|
|
148
|
+
'address',
|
|
149
|
+
'uint16',
|
|
150
|
+
], [
|
|
151
|
+
SEP_INPUT_HANDLE,
|
|
152
|
+
handleVersion,
|
|
153
|
+
handleType,
|
|
154
|
+
ciphertext.length,
|
|
155
|
+
toHex(ciphertext),
|
|
156
|
+
indexHandle,
|
|
157
|
+
// Note: The x/hostchain spec requires the chain ID to be prefixed with 'evm/' for EVM chains
|
|
158
|
+
'evm/',
|
|
159
|
+
context.hostChainId,
|
|
160
|
+
context.aclAddress,
|
|
161
|
+
context.userAddress,
|
|
162
|
+
context.contractAddress,
|
|
163
|
+
context.version,
|
|
164
|
+
]);
|
|
165
|
+
const hash = new Keccak(256).update(Buffer.from(hexToBytes(packed))).digest();
|
|
166
|
+
const handle = Buffer.alloc(32);
|
|
167
|
+
hash.copy(handle, 0, 0, 29);
|
|
168
|
+
handle.writeUInt8(indexHandle, 29);
|
|
169
|
+
handle.writeUInt8(handleType, 30);
|
|
170
|
+
handle.writeUInt8(handleVersion, 31);
|
|
171
|
+
return handle;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Computes the Keccak-256 hash of an ABI-packed {@link InputContext}.
|
|
175
|
+
*
|
|
176
|
+
* The context is packed as: `"evm/" || SEP_INPUT_CONTEXT || HANDLE_VERSION || inputType ||
|
|
177
|
+
* chainId || aclAddress || userAddress || contractAddress || version`.
|
|
178
|
+
*
|
|
179
|
+
* @param context - The input context to hash.
|
|
180
|
+
* @returns A 32-byte `Buffer` containing the Keccak-256 digest.
|
|
181
|
+
*/
|
|
182
|
+
export function hashInputContext(context) {
|
|
183
|
+
const packed = encodePacked([
|
|
184
|
+
'string',
|
|
185
|
+
'string',
|
|
186
|
+
'uint8',
|
|
187
|
+
'uint8',
|
|
188
|
+
'uint256',
|
|
189
|
+
'address',
|
|
190
|
+
'address',
|
|
191
|
+
'address',
|
|
192
|
+
'uint16',
|
|
193
|
+
], [
|
|
194
|
+
// Note: The x/hostchain spec requires the chain ID to be prefixed with 'evm/' for EVM chains
|
|
195
|
+
'evm/',
|
|
196
|
+
SEP_INPUT_CONTEXT,
|
|
197
|
+
HANDLE_VERSION,
|
|
198
|
+
context.inputType,
|
|
199
|
+
context.hostChainId,
|
|
200
|
+
context.aclAddress,
|
|
201
|
+
context.userAddress,
|
|
202
|
+
context.contractAddress,
|
|
203
|
+
context.version,
|
|
204
|
+
]);
|
|
205
|
+
return new Keccak(256).update(Buffer.from(hexToBytes(packed))).digest();
|
|
206
|
+
}
|
|
207
|
+
function assertUint8(value) {
|
|
208
|
+
if (!Number.isInteger(value) || value < 0 || value > 255) {
|
|
209
|
+
throw new Error(`Invalid uint8 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TUFBTSxNQUFNLEdBQUcsWUFBWSxDQUN6QjtRQUNFLFFBQVE7UUFDUixRQUFRO1FBQ1IsT0FBTztRQUNQLE9BQU87UUFDUCxTQUFTO1FBQ1QsU0FBUztRQUNULFNBQVM7UUFDVCxTQUFTO1FBQ1QsUUFBUTtLQUNULEVBQ0Q7UUFDRSw2RkFBNkY7UUFDN0YsTUFBTTtRQUNOLGlCQUFpQjtRQUNqQixjQUFjO1FBQ2QsT0FBTyxDQUFDLFNBQVM7UUFDakIsT0FBTyxDQUFDLFdBQVc7UUFDbkIsT0FBTyxDQUFDLFVBQVU7UUFDbEIsT0FBTyxDQUFDLFdBQVc7UUFDbkIsT0FBTyxDQUFDLGVBQWU7UUFDdkIsT0FBTyxDQUFDLE9BQU87S0FDaEIsQ0FDRixDQUFDO0lBQ0YsT0FBTyxJQUFJLE1BQU0sQ0FBQyxHQUFHLENBQUMsQ0FBQyxNQUFNLENBQUMsTUFBTSxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLE1BQU0sRUFBRSxDQUFDO0FBQzFFLENBQUM7QUFFRCxTQUFTLFdBQVcsQ0FBQyxLQUFhO0lBQ2hDLElBQUksQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyxJQUFJLEtBQUssR0FBRyxDQUFDLElBQUksS0FBSyxHQUFHLEdBQUcsRUFBRSxDQUFDO1FBQ3pELE1BQU0sSUFBSSxLQUFLLENBQUMsd0JBQXdCLEtBQUssRUFBRSxDQUFDLENBQUM7SUFDbkQsQ0FBQztBQUNILENBQUMifQ==
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from './binary.js';
|
|
2
|
+
export * from './chain.js';
|
|
3
|
+
export { HANDLE_LENGTH_BYTES, HANDLE_VERSION, HandleTypeName, InputContext, getHandleType, handleTypes, isTeeType, validateHandle, type Handle, type HandleTypes, type TeeType, } from './handle.js';
|
|
4
|
+
export * from './schema.js';
|
|
5
|
+
export * from './viem.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './binary.js';
|
|
2
|
+
export * from './chain.js';
|
|
3
|
+
export { HANDLE_LENGTH_BYTES, HANDLE_VERSION, HandleTypeName, InputContext, getHandleType, handleTypes, isTeeType, validateHandle, } from './handle.js';
|
|
4
|
+
export * from './schema.js';
|
|
5
|
+
export * from './viem.js';
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxhQUFhLENBQUM7QUFDNUIsY0FBYyxZQUFZLENBQUM7QUFDM0IsT0FBTyxFQUNMLG1CQUFtQixFQUNuQixjQUFjLEVBQ2QsY0FBYyxFQUNkLFlBQVksRUFDWixhQUFhLEVBQ2IsV0FBVyxFQUNYLFNBQVMsRUFDVCxjQUFjLEdBSWYsTUFBTSxhQUFhLENBQUM7QUFDckIsY0FBYyxhQUFhLENBQUM7QUFDNUIsY0FBYyxXQUFXLENBQUMifQ==
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Client } from '@connectrpc/connect';
|
|
2
|
+
import type { Address } from 'viem';
|
|
3
|
+
import type { SupportedChain } from '../chain.js';
|
|
4
|
+
import { KmsService } from '../generated/es/inco/kms/lite/v1/kms_service_pb.js';
|
|
5
|
+
export declare const TEST_DEFAULT_COVALIDATOR_SIGNER: Address;
|
|
6
|
+
export type KmsClient = Client<typeof KmsService> & {
|
|
7
|
+
signerAddress: Address;
|
|
8
|
+
};
|
|
9
|
+
export declare function getKmsClient(kmsConnectRpcEndpointOrClient: string | KmsClient, signerAddress: Address): KmsClient;
|
|
10
|
+
export declare function defaultCovalidatorGrpc(chain: SupportedChain): string;
|
|
11
|
+
export declare function lightningDevnetCovalidatorGrpc(chain: SupportedChain): string;
|
|
12
|
+
export declare function lightningTestnetCovalidatorGrpc(chain: SupportedChain): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createClient } from '@connectrpc/connect';
|
|
2
|
+
import { createConnectTransport } from '@connectrpc/connect-web';
|
|
3
|
+
import { KmsService } from '../generated/es/inco/kms/lite/v1/kms_service_pb.js';
|
|
4
|
+
// anvil zeroth address, while there is only one signer,
|
|
5
|
+
// this does not matter, as we use these addresses for signer ordering
|
|
6
|
+
// [WARNING] This is the default signer for the Inco Lightning public testnet.
|
|
7
|
+
export const TEST_DEFAULT_COVALIDATOR_SIGNER = '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266';
|
|
8
|
+
// Helper function to get a KMS client from a string or a Client instance.
|
|
9
|
+
export function getKmsClient(kmsConnectRpcEndpointOrClient, signerAddress) {
|
|
10
|
+
if (typeof kmsConnectRpcEndpointOrClient === 'string') {
|
|
11
|
+
const transport = createConnectTransport({
|
|
12
|
+
baseUrl: kmsConnectRpcEndpointOrClient,
|
|
13
|
+
});
|
|
14
|
+
const client = createClient(KmsService, transport);
|
|
15
|
+
return Object.assign(client, { signerAddress });
|
|
16
|
+
}
|
|
17
|
+
return Object.assign(kmsConnectRpcEndpointOrClient, { signerAddress });
|
|
18
|
+
}
|
|
19
|
+
// Helper function to return the default gRPC endpoint for the covalidator.
|
|
20
|
+
// Currently, this returns the covalidator for the Inco Lightning public testnet.
|
|
21
|
+
export function defaultCovalidatorGrpc(chain) {
|
|
22
|
+
return lightningTestnetCovalidatorGrpc(chain);
|
|
23
|
+
}
|
|
24
|
+
// Helper function to get the devnet gRPC endpoint for the Inco Lightning covalidator.
|
|
25
|
+
export function lightningDevnetCovalidatorGrpc(chain) {
|
|
26
|
+
return getCovalidatorGrpcHelper(chain, 'devnet', 'lightning');
|
|
27
|
+
}
|
|
28
|
+
// Helper function to get the testnet gRPC endpoint for the Inco Lightning covalidator.
|
|
29
|
+
export function lightningTestnetCovalidatorGrpc(chain) {
|
|
30
|
+
return getCovalidatorGrpcHelper(chain, 'testnet', 'lightning');
|
|
31
|
+
}
|
|
32
|
+
// Convert camelCase to dash-case.
|
|
33
|
+
function camelToDashCase(str) {
|
|
34
|
+
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
35
|
+
}
|
|
36
|
+
// Small helper, as our GCP covalidator URLs are in a specific format.
|
|
37
|
+
function getCovalidatorGrpcHelper(chain, network, cluster) {
|
|
38
|
+
return `https://grpc.${camelToDashCase(chain.name)}.${cluster}.${network}.inco.org`;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xpZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2ttcy9jbGllbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFlLFlBQVksRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ2hFLE9BQU8sRUFBRSxzQkFBc0IsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBR2pFLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxvREFBb0QsQ0FBQztBQUVoRix3REFBd0Q7QUFDeEQsc0VBQXNFO0FBQ3RFLDhFQUE4RTtBQUM5RSxNQUFNLENBQUMsTUFBTSwrQkFBK0IsR0FDMUMsNENBQTRDLENBQUM7QUFJL0MsMEVBQTBFO0FBQzFFLE1BQU0sVUFBVSxZQUFZLENBQzFCLDZCQUFpRCxFQUNqRCxhQUFzQjtJQUV0QixJQUFJLE9BQU8sNkJBQTZCLEtBQUssUUFBUSxFQUFFLENBQUM7UUFDdEQsTUFBTSxTQUFTLEdBQUcsc0JBQXNCLENBQUM7WUFDdkMsT0FBTyxFQUFFLDZCQUE2QjtTQUN2QyxDQUFDLENBQUM7UUFDSCxNQUFNLE1BQU0sR0FBRyxZQUFZLENBQUMsVUF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9BQU8sV0FBVyxDQUFDO0FBQ3RGLENBQUMifQ==
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type Address } from 'viem';
|
|
2
|
+
import type { DecryptionAttestation, EncryptedDecryptionAttestation } from '../attesteddecrypt/types.js';
|
|
3
|
+
import { type EListDecryptionAttestation, type EncryptedEListDecryptionAttestation } from '../elistattesteddecrypt/types.js';
|
|
4
|
+
import type { EncryptionScheme, SupportedTeeType } from '../encryption/encryption.js';
|
|
5
|
+
import type { AttestedComputeRequest, AttestedDecryptRequest, AttestedRevealRequest, EListAttestedDecryptRequest, EListAttestedRevealRequest } from '../generated/es/inco/kms/lite/v1/kms_service_pb.js';
|
|
6
|
+
import { type XwingKeypair } from '../lite/xwing.js';
|
|
7
|
+
import type { BackoffConfig } from '../retry.js';
|
|
8
|
+
import { type KmsClient } from './client.js';
|
|
9
|
+
import type { ViemClient } from '../viem.js';
|
|
10
|
+
export declare class KmsQuorumClient {
|
|
11
|
+
private readonly kmss;
|
|
12
|
+
private readonly threshold;
|
|
13
|
+
private constructor();
|
|
14
|
+
private constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Creates a KmsQuorumClient from an array of URLs.
|
|
17
|
+
* Requires signer addresses and threshold to be explicitly provided.
|
|
18
|
+
*
|
|
19
|
+
* @param urls - Array of KMS endpoint URLs
|
|
20
|
+
* @param signers - Array of signer addresses, must match the length of URLs
|
|
21
|
+
* @param threshold - Number of successful responses required (must be between 1 and urls.length)
|
|
22
|
+
* @throws {Error} If URLs array is empty, signers length doesn't match URLs length, or threshold is invalid
|
|
23
|
+
*/
|
|
24
|
+
static fromUrls(urls: string[], signers: Address[], threshold: number): KmsQuorumClient;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a KmsQuorumClient from an array of KmsClient instances.
|
|
27
|
+
* Each KmsClient must have a signerAddress property.
|
|
28
|
+
*
|
|
29
|
+
* @param kmsClients - Array of KMS client instances
|
|
30
|
+
* @param threshold - Number of successful responses required (must be between 1 and kmsClients.length)
|
|
31
|
+
* @throws {Error} If KMS clients array is empty or threshold is invalid
|
|
32
|
+
*/
|
|
33
|
+
static fromKmsClients(kmsClients: KmsClient[], threshold: number): KmsQuorumClient;
|
|
34
|
+
attestedDecrypt(request: AttestedDecryptRequest, executorAddress: Address, client: ViemClient, backoffConfig?: Partial<BackoffConfig>, reencryptKeypair?: XwingKeypair): Promise<(DecryptionAttestation<EncryptionScheme, SupportedTeeType> | EncryptedDecryptionAttestation<EncryptionScheme, SupportedTeeType>)[]>;
|
|
35
|
+
attestedCompute(request: AttestedComputeRequest, executorAddress: Address, client: ViemClient, backoffConfig?: Partial<BackoffConfig>, reencryptKeypair?: XwingKeypair): Promise<DecryptionAttestation<EncryptionScheme, SupportedTeeType> | EncryptedDecryptionAttestation<EncryptionScheme, SupportedTeeType>>;
|
|
36
|
+
attestedReveal(request: AttestedRevealRequest, executorAddress: Address, client: ViemClient, backoffConfig?: Partial<BackoffConfig>): Promise<(DecryptionAttestation<EncryptionScheme, SupportedTeeType> | EncryptedDecryptionAttestation<EncryptionScheme, SupportedTeeType>)[]>;
|
|
37
|
+
eListAttestedDecrypt(request: EListAttestedDecryptRequest, executorAddress: Address, client: ViemClient, backoffConfig?: Partial<BackoffConfig>, reencryptKeypair?: XwingKeypair): Promise<EListDecryptionAttestation<EncryptionScheme, SupportedTeeType> | EncryptedEListDecryptionAttestation<EncryptionScheme, SupportedTeeType>>;
|
|
38
|
+
eListAttestedReveal(request: EListAttestedRevealRequest, executorAddress: Address, client: ViemClient, backoffConfig?: Partial<BackoffConfig>): Promise<EListDecryptionAttestation<EncryptionScheme, SupportedTeeType>>;
|
|
39
|
+
/**
|
|
40
|
+
* Generic method to execute a KMS operation across all clients with retry and threshold logic.
|
|
41
|
+
* Returns results with both the response and signer address.
|
|
42
|
+
*/
|
|
43
|
+
private executeKmsOperationWithThreshold;
|
|
44
|
+
/**
|
|
45
|
+
* Collects signatures from responses and sorts them by signer address (ascending).
|
|
46
|
+
* This is required by SignatureVerifier.
|
|
47
|
+
*/
|
|
48
|
+
private collectAndSortSignatures;
|
|
49
|
+
/**
|
|
50
|
+
* Builds a plaintext attestation from a DecryptionAttestation proto message.
|
|
51
|
+
*/
|
|
52
|
+
private buildPlaintextAttestation;
|
|
53
|
+
private buildAggregatedAttestations;
|
|
54
|
+
private buildAggregatedComputeAttestation;
|
|
55
|
+
private buildAggregatedEListAttestation;
|
|
56
|
+
/**
|
|
57
|
+
* Verifies proof hashes at two levels:
|
|
58
|
+
* 1. Aggregate: keccak256(concat(proofHashes)) must equal the attested commitmentProof
|
|
59
|
+
* 2. Per-element:
|
|
60
|
+
* - For plaintext (reveal): proofHash[i] = keccak256(value[i])
|
|
61
|
+
* - For reencryption (decrypt): proofHash[i] = keccak256(commitment[i] || plaintext[i])
|
|
62
|
+
* — requires reencryptKeypair to decrypt the ciphertext first.
|
|
63
|
+
*/
|
|
64
|
+
private verifyElementProofHashes;
|
|
65
|
+
}
|