@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
package/dist/esm/viem.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { anvil, base, baseSepolia, mainnet, monadTestnet, plasmaTestnet, sepolia, worldchainSepolia, } from 'viem/chains';
|
|
2
|
+
import { getSupportedChain } from './chain.js';
|
|
3
|
+
/** Map of supported chain short names to their viem chain objects. */
|
|
4
|
+
export const chains = {
|
|
5
|
+
mainnet,
|
|
6
|
+
base,
|
|
7
|
+
sepolia,
|
|
8
|
+
baseSepolia,
|
|
9
|
+
monadTestnet,
|
|
10
|
+
plasmaTestnet,
|
|
11
|
+
anvil,
|
|
12
|
+
worldchainSepolia,
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Resolves a {@link Chainish} value to a viem {@link Chain} object.
|
|
16
|
+
*
|
|
17
|
+
* Accepts a chain ID (`number` or `bigint`), an object with an `id` field,
|
|
18
|
+
* or a chain short name (e.g. `"baseSepolia"`).
|
|
19
|
+
*
|
|
20
|
+
* @param chainish - The chain identifier to resolve.
|
|
21
|
+
* @returns The matching `viem` chain object.
|
|
22
|
+
* @throws If no supported chain matches the given identifier.
|
|
23
|
+
*/
|
|
24
|
+
export function getViemChain(chainish) {
|
|
25
|
+
const { name } = getSupportedChain(chainish);
|
|
26
|
+
const chain = chains[name];
|
|
27
|
+
if (!chain) {
|
|
28
|
+
throw new Error(`Unable to get viem chain: ${name}`);
|
|
29
|
+
}
|
|
30
|
+
return chain;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmllbS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy92aWVtLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFDTCxLQUFLLEVBQ0wsSUFBSSxFQUNKLFdBQVcsRUFDWCxPQUFPLEVBQ1AsWUFBWSxFQUNaLGFBQWEsRUFDYixPQUFPLEVBQ1AsaUJBQWlCLEdBQ2xCLE1BQU0sYUFBYSxDQUFDO0FBQ3JCLE9BQU8sRUFBWSxpQkFBaUIsRUFBRSxNQUFNLFlBQVksQ0FBQztBQU16RCxzRUFBc0U7QUFDdEUsTUFBTSxDQUFDLE1BQU0sTUFBTSxHQUFHO0lBQ3BCLE9BQU87SUFDUCxJQUFJO0lBQ0osT0FBTztJQUNQLFdBQVc7SUFDWCxZQUFZO0lBQ1osYUFBYTtJQUNiLEtBQUs7SUFDTCxpQkFBaUI7Q0FDbEIsQ0FBQztBQUVGOzs7Ozs7Ozs7R0FTRztBQUNILE1BQU0sVUFBVSxZQUFZLENBQUMsUUFBa0I7SUFDN0MsTUFBTSxFQUFFLElBQUksRUFBRSxHQUFHLGlCQUFpQixDQUFDLFFBQVEsQ0FBQyxDQUFDO0lBQzdDLE1BQU0sS0FBSyxHQUFHLE1BQU0sQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUMzQixJQUFJLENBQUMsS0FBSyxFQUFFLENBQUM7UUFDWCxNQUFNLElBQUksS0FBSyxDQUFDLDZCQUE2QixJQUFJLEVBQUUsQ0FBQyxDQUFDO0lBQ3ZELENBQUM7SUFDRCxPQUFPLEtBQUssQ0FBQztBQUNmLENBQUMifQ==
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type Account, type Address, type Chain, type Hex, PublicClient, type Transport, type WalletClient } from 'viem';
|
|
2
|
+
import type { PrivateKeyAccount } from 'viem/accounts';
|
|
3
|
+
import { DecryptionAttestation, EncryptedDecryptionAttestation } from '../attesteddecrypt/index.js';
|
|
4
|
+
import { SupportedChainId } from '../chain.js';
|
|
5
|
+
import { EncryptionScheme, SupportedTeeType } from '../encryption/encryption.js';
|
|
6
|
+
import { HexString } from '../index.js';
|
|
7
|
+
import { type XwingKeypair } from '../lite/xwing.js';
|
|
8
|
+
import { BackoffConfig } from '../retry.js';
|
|
9
|
+
import type { AllowanceVoucher, AllowanceVoucherWithSig } from './types.js';
|
|
10
|
+
import { AttestedComputeOP } from '../attestedcompute/types.js';
|
|
11
|
+
import { KmsQuorumClient } from '../kms/quorumClient.js';
|
|
12
|
+
export declare const SESSION_KEY_WARNING = "Inco Warning: signing this message may leak your private data, including from unrelated apps. Sign only if you fully trust this app.";
|
|
13
|
+
export interface Session {
|
|
14
|
+
decrypter: Address;
|
|
15
|
+
expiresAt: bigint;
|
|
16
|
+
}
|
|
17
|
+
export declare function createAllowanceVoucher(incoLiteAddress: Address, sharerWalletClient: WalletClient<Transport, Chain, Account>, verifyingContract: Address, callFunction: Hex, sharerArgData: Hex): Promise<AllowanceVoucher>;
|
|
18
|
+
export interface GrantSessionKeyArgs {
|
|
19
|
+
chainId: bigint;
|
|
20
|
+
incoLiteAddress: Address;
|
|
21
|
+
sessionVerifierContractAddress: Address;
|
|
22
|
+
granteeAddress: Address;
|
|
23
|
+
sharerWalletClient: WalletClient<Transport, Chain, Account>;
|
|
24
|
+
expiresAt: Date;
|
|
25
|
+
}
|
|
26
|
+
export interface GrantSessionKeyCustomVerifierArgs {
|
|
27
|
+
chainId: bigint;
|
|
28
|
+
incoLiteAddress: Address;
|
|
29
|
+
sessionVerifierContractAddress: Address;
|
|
30
|
+
sharerWalletClient: WalletClient<Transport, Chain, Account>;
|
|
31
|
+
sharerArgData: Hex;
|
|
32
|
+
}
|
|
33
|
+
export declare function grantSessionKey({ chainId, incoLiteAddress, sessionVerifierContractAddress, granteeAddress, sharerWalletClient, expiresAt, }: GrantSessionKeyArgs): Promise<AllowanceVoucherWithSig>;
|
|
34
|
+
export declare function grantSessionKeyCustomVerifier({ chainId, incoLiteAddress, sessionVerifierContractAddress, sharerWalletClient, sharerArgData, }: GrantSessionKeyCustomVerifierArgs): Promise<AllowanceVoucherWithSig>;
|
|
35
|
+
export declare function updateActiveVouchersSessionNonce(incoLiteAddress: Address, sharerWalletClient: WalletClient<Transport, Chain, Account>): Promise<`0x${string}`>;
|
|
36
|
+
export interface SessionKeyAttestedComputeArgs {
|
|
37
|
+
chainId: SupportedChainId;
|
|
38
|
+
ephemeralAccount: PrivateKeyAccount;
|
|
39
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
40
|
+
allowanceVoucherWithSig: AllowanceVoucherWithSig;
|
|
41
|
+
lhsHandle: HexString;
|
|
42
|
+
op: AttestedComputeOP;
|
|
43
|
+
rhsPlaintext: bigint | boolean;
|
|
44
|
+
requesterArgData?: Hex | undefined;
|
|
45
|
+
backoffConfig?: Partial<BackoffConfig> | undefined;
|
|
46
|
+
ethClient: PublicClient<Transport, Chain>;
|
|
47
|
+
executorAddress: HexString;
|
|
48
|
+
reencryptPubKey?: Uint8Array | undefined;
|
|
49
|
+
reencryptKeypair?: XwingKeypair | undefined;
|
|
50
|
+
}
|
|
51
|
+
export declare function sessionKeyAttestedCompute<T extends SupportedTeeType>({ lhsHandle, op, rhsPlaintext, backoffConfig, chainId, kmsQuorumClient, ephemeralAccount, allowanceVoucherWithSig, requesterArgData, ethClient, executorAddress, reencryptPubKey, reencryptKeypair, }: SessionKeyAttestedComputeArgs): Promise<DecryptionAttestation<EncryptionScheme, SupportedTeeType> | EncryptedDecryptionAttestation<EncryptionScheme, SupportedTeeType>>;
|
|
52
|
+
export interface SessionKeyAttestedDecryptArgs {
|
|
53
|
+
chainId: SupportedChainId;
|
|
54
|
+
ephemeralAccount: PrivateKeyAccount;
|
|
55
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
56
|
+
allowanceVoucherWithSig: AllowanceVoucherWithSig;
|
|
57
|
+
handles: HexString[];
|
|
58
|
+
requesterArgData?: Hex | undefined;
|
|
59
|
+
backoffConfig?: Partial<BackoffConfig> | undefined;
|
|
60
|
+
reencryptPubKey?: Uint8Array | undefined;
|
|
61
|
+
reencryptKeypair?: XwingKeypair | undefined;
|
|
62
|
+
ethClient: PublicClient<Transport, Chain>;
|
|
63
|
+
executorAddress: HexString;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Performs attested decrypts using a voucher-backed session key.
|
|
67
|
+
*
|
|
68
|
+
* @example Plaintext results
|
|
69
|
+
* ```ts
|
|
70
|
+
* const attestations = await sessionKeyAttestedDecrypt({
|
|
71
|
+
* chainId,
|
|
72
|
+
* kmsConnectRpcEndpointOrClient: covalidatorUrl,
|
|
73
|
+
* allowanceVoucherWithSig: voucher,
|
|
74
|
+
* ephemeralAccount,
|
|
75
|
+
* handles,
|
|
76
|
+
* });
|
|
77
|
+
* console.log(attestations[0].plaintext.value);
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @example Encrypted results
|
|
81
|
+
* ```ts
|
|
82
|
+
* const encryptedResults = await sessionKeyAttestedDecrypt({
|
|
83
|
+
* chainId,
|
|
84
|
+
* kmsConnectRpcEndpointOrClient: covalidatorUrl,
|
|
85
|
+
* allowanceVoucherWithSig: voucher,
|
|
86
|
+
* ephemeralAccount,
|
|
87
|
+
* handles,
|
|
88
|
+
* reencryptPubKey: recipientPubKey,
|
|
89
|
+
* });
|
|
90
|
+
* console.log(
|
|
91
|
+
* encryptedResults[0].encryptedPlaintext.ciphertext.value,
|
|
92
|
+
* );
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare function sessionKeyAttestedDecrypt({ chainId, kmsQuorumClient, handles, ephemeralAccount, allowanceVoucherWithSig, requesterArgData, backoffConfig, reencryptPubKey, reencryptKeypair, ethClient, executorAddress, }: SessionKeyAttestedDecryptArgs): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedTeeType> | EncryptedDecryptionAttestation<EncryptionScheme, SupportedTeeType>>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Address, Hex } from 'viem';
|
|
2
|
+
export type AllowanceVoucher = {
|
|
3
|
+
sessionNonce: Hex;
|
|
4
|
+
verifyingContract: Address;
|
|
5
|
+
callFunction: Hex;
|
|
6
|
+
sharerArgData: Hex;
|
|
7
|
+
warning: string;
|
|
8
|
+
};
|
|
9
|
+
export interface AllowanceVoucherWithSig {
|
|
10
|
+
sharer: Address;
|
|
11
|
+
voucher: AllowanceVoucher;
|
|
12
|
+
voucherSignature: Hex;
|
|
13
|
+
}
|
|
14
|
+
export interface AllowanceProof extends AllowanceVoucherWithSig {
|
|
15
|
+
requesterArgData: Uint8Array;
|
|
16
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Account, Chain, Transport, WalletClient } from 'viem';
|
|
2
|
+
import { DecryptionAttestation, EncryptedDecryptionAttestation } from '../attesteddecrypt/types.js';
|
|
3
|
+
import { HexString } from '../binary.js';
|
|
4
|
+
import { SupportedChainId } from '../chain.js';
|
|
5
|
+
import type { EncryptionScheme, SupportedTeeType } from '../encryption/encryption.js';
|
|
6
|
+
import { KmsQuorumClient } from '../kms/quorumClient.js';
|
|
7
|
+
import { type XwingKeypair } from '../lite/xwing.js';
|
|
8
|
+
import type { BackoffConfig } from '../retry.js';
|
|
9
|
+
import { AttestedComputeOP } from './types.js';
|
|
10
|
+
export declare const ATTESTED_COMPUTE_DOMAIN_NAME = "IncoAttestedCompute";
|
|
11
|
+
/**
|
|
12
|
+
* Arguments for creating an attested compute.
|
|
13
|
+
*/
|
|
14
|
+
export interface IncoLiteAttestedComputeArgs {
|
|
15
|
+
/** The wallet used to interact with the blockchain and sign the compute request */
|
|
16
|
+
walletClient: WalletClient<Transport, Chain, Account>;
|
|
17
|
+
/** The KMS quorum client instance */
|
|
18
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
19
|
+
/** The chain ID to use */
|
|
20
|
+
chainId: SupportedChainId;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates an attested compute function that can decrypt handles with an attached attestation from the covalidator.
|
|
24
|
+
* @param args - The arguments for creating the attested compute function
|
|
25
|
+
* @returns A function that can perform binary operation on a handle and return an attestation
|
|
26
|
+
* @throws {AttestedComputeError} If the creation fails
|
|
27
|
+
*
|
|
28
|
+
* @todo Support multiple operations in a single request.
|
|
29
|
+
*/
|
|
30
|
+
export declare function attestedCompute<T extends SupportedTeeType>({ executorAddress, lhsHandle, op, rhsPlaintext, backoffConfig, walletClient, kmsQuorumClient, chainId, reencryptPubKey, reencryptKeypair, }: {
|
|
31
|
+
executorAddress: HexString;
|
|
32
|
+
lhsHandle: HexString;
|
|
33
|
+
op: AttestedComputeOP;
|
|
34
|
+
rhsPlaintext: bigint | boolean;
|
|
35
|
+
backoffConfig?: Partial<BackoffConfig> | undefined;
|
|
36
|
+
walletClient: WalletClient<Transport, Chain, Account>;
|
|
37
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
38
|
+
chainId: SupportedChainId;
|
|
39
|
+
reencryptPubKey: Uint8Array;
|
|
40
|
+
reencryptKeypair: XwingKeypair;
|
|
41
|
+
}): Promise<DecryptionAttestation<EncryptionScheme, T>>;
|
|
42
|
+
export declare function attestedCompute<T extends SupportedTeeType>({ executorAddress, lhsHandle, op, rhsPlaintext, backoffConfig, walletClient, kmsQuorumClient, chainId, reencryptPubKey, }: {
|
|
43
|
+
executorAddress: HexString;
|
|
44
|
+
lhsHandle: HexString;
|
|
45
|
+
op: AttestedComputeOP;
|
|
46
|
+
rhsPlaintext: bigint | boolean;
|
|
47
|
+
backoffConfig?: Partial<BackoffConfig> | undefined;
|
|
48
|
+
walletClient: WalletClient<Transport, Chain, Account>;
|
|
49
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
50
|
+
chainId: SupportedChainId;
|
|
51
|
+
reencryptPubKey: Uint8Array;
|
|
52
|
+
reencryptKeypair?: never;
|
|
53
|
+
}): Promise<EncryptedDecryptionAttestation<EncryptionScheme, T>>;
|
|
54
|
+
export declare function attestedCompute<T extends SupportedTeeType>({ executorAddress, lhsHandle, op, rhsPlaintext, backoffConfig, walletClient, kmsQuorumClient, chainId, }: {
|
|
55
|
+
executorAddress: HexString;
|
|
56
|
+
lhsHandle: HexString;
|
|
57
|
+
op: AttestedComputeOP;
|
|
58
|
+
rhsPlaintext: bigint | boolean;
|
|
59
|
+
backoffConfig?: Partial<BackoffConfig> | undefined;
|
|
60
|
+
walletClient: WalletClient<Transport, Chain, Account>;
|
|
61
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
62
|
+
chainId: SupportedChainId;
|
|
63
|
+
reencryptPubKey?: never;
|
|
64
|
+
reencryptKeypair?: never;
|
|
65
|
+
}): Promise<DecryptionAttestation<EncryptionScheme, T>>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { DecryptionAttestation } from '../attesteddecrypt/types.js';
|
|
2
|
+
import { HexString } from '../binary.js';
|
|
3
|
+
import { EncryptionScheme, SupportedTeeType } from '../encryption/encryption.js';
|
|
4
|
+
import { SupportedScalarBinaryOp } from '../generated/es/inco/kms/lite/v1/types_pb.js';
|
|
5
|
+
import type { BackoffConfig } from '../retry.js';
|
|
6
|
+
/**
|
|
7
|
+
* Supported attested compute operations.
|
|
8
|
+
*/
|
|
9
|
+
export declare const AttestedComputeSupportedOps: {
|
|
10
|
+
readonly Eq: SupportedScalarBinaryOp.TEE_EQ;
|
|
11
|
+
readonly Ne: SupportedScalarBinaryOp.TEE_NE;
|
|
12
|
+
readonly Ge: SupportedScalarBinaryOp.TEE_GE;
|
|
13
|
+
readonly Gt: SupportedScalarBinaryOp.TEE_GT;
|
|
14
|
+
readonly Le: SupportedScalarBinaryOp.TEE_LE;
|
|
15
|
+
readonly Lt: SupportedScalarBinaryOp.TEE_LT;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* This type represents all the supported operations for attested compute.
|
|
19
|
+
*/
|
|
20
|
+
export type AttestedComputeOP = (typeof AttestedComputeSupportedOps)[keyof typeof AttestedComputeSupportedOps];
|
|
21
|
+
/**
|
|
22
|
+
* Custom error class for attested compute operations.
|
|
23
|
+
*/
|
|
24
|
+
export declare class AttestedComputeError extends Error {
|
|
25
|
+
readonly cause?: unknown | undefined;
|
|
26
|
+
constructor(message: string, cause?: unknown | undefined);
|
|
27
|
+
}
|
|
28
|
+
export type AttestedCompute<S extends EncryptionScheme> = <T extends SupportedTeeType>(args: AttestedComputeFnArgs<S, T>) => Promise<DecryptionAttestation<S, T>>;
|
|
29
|
+
export type AttestedComputeFnArgs<S extends EncryptionScheme, T extends SupportedTeeType> = {
|
|
30
|
+
/** The handle to compute on */
|
|
31
|
+
lhsHandle: HexString;
|
|
32
|
+
op: AttestedComputeOP;
|
|
33
|
+
rhsPlaintext: bigint | boolean;
|
|
34
|
+
backoffConfig?: Partial<BackoffConfig>;
|
|
35
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Account, Chain, Transport, WalletClient } from 'viem';
|
|
2
|
+
import { type HexString } from '../binary.js';
|
|
3
|
+
import { type SupportedChainId } from '../chain.js';
|
|
4
|
+
import { EncryptionScheme, type SupportedTeeType } from '../encryption/encryption.js';
|
|
5
|
+
import { type HandleWithProof } from '../generated/es/inco/kms/lite/v1/types_pb.js';
|
|
6
|
+
import { validateHandle } from '../handle.js';
|
|
7
|
+
import { KmsQuorumClient } from '../kms/quorumClient.js';
|
|
8
|
+
import type { XwingKeypair } from '../lite/xwing.js';
|
|
9
|
+
import type { BackoffConfig } from '../retry.js';
|
|
10
|
+
import { type DecryptionAttestation, type EncryptedDecryptionAttestation } from './types.js';
|
|
11
|
+
export { validateHandle };
|
|
12
|
+
export declare const ATTESTED_DECRYPT_DOMAIN_NAME = "IncoAttestedDecrypt";
|
|
13
|
+
/**
|
|
14
|
+
* Arguments for creating an attested decrypt request.
|
|
15
|
+
*/
|
|
16
|
+
export interface IncoLiteAttestedDecryptorArgs {
|
|
17
|
+
/** The wallet used to interact with the blockchain and sign the decrypt request */
|
|
18
|
+
walletClient: WalletClient<Transport, Chain, Account>;
|
|
19
|
+
/** The KMS quorum client instance */
|
|
20
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
21
|
+
/** The chain ID to use */
|
|
22
|
+
chainId: SupportedChainId;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Decrypt multiple handles in a single attested request.
|
|
26
|
+
* Returns an array of attestations aligned with the response ordering.
|
|
27
|
+
*
|
|
28
|
+
* @param args - The arguments for creating the attested decrypt function
|
|
29
|
+
* @returns A function that can decrypt handles and return an attestation
|
|
30
|
+
* @throws {AttestedDecryptError} If the creation fails
|
|
31
|
+
*/
|
|
32
|
+
export declare function attestedDecrypt({ handles, backoffConfig, walletClient, chainId, reencryptPubKey, reencryptKeypair, kmsQuorumClient, executorAddress, }: {
|
|
33
|
+
handles: HexString[];
|
|
34
|
+
backoffConfig?: Partial<BackoffConfig> | undefined;
|
|
35
|
+
walletClient: WalletClient<Transport, Chain, Account>;
|
|
36
|
+
chainId: SupportedChainId;
|
|
37
|
+
reencryptPubKey: Uint8Array;
|
|
38
|
+
reencryptKeypair: XwingKeypair;
|
|
39
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
40
|
+
executorAddress: HexString;
|
|
41
|
+
}): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedTeeType>>>;
|
|
42
|
+
/**
|
|
43
|
+
* Decrypt multiple handles in a single attested request.
|
|
44
|
+
* Returns an array of attestations aligned with the response ordering.
|
|
45
|
+
*
|
|
46
|
+
* @param args - The arguments for creating the attested decrypt function
|
|
47
|
+
* @returns A function that can decrypt handles and return an attestation
|
|
48
|
+
* @throws {AttestedDecryptError} If the creation fails
|
|
49
|
+
*/
|
|
50
|
+
export declare function attestedDecrypt({ handles, backoffConfig, walletClient, chainId, reencryptPubKey, kmsQuorumClient, executorAddress, }: {
|
|
51
|
+
handles: HexString[];
|
|
52
|
+
backoffConfig?: Partial<BackoffConfig> | undefined;
|
|
53
|
+
walletClient: WalletClient<Transport, Chain, Account>;
|
|
54
|
+
chainId: SupportedChainId;
|
|
55
|
+
reencryptPubKey: Uint8Array;
|
|
56
|
+
reencryptKeypair?: never;
|
|
57
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
58
|
+
executorAddress: HexString;
|
|
59
|
+
}): Promise<Array<EncryptedDecryptionAttestation<EncryptionScheme, SupportedTeeType>>>;
|
|
60
|
+
export declare function buildHandlesWithProofs(handles: HexString[]): Array<HandleWithProof>;
|
|
61
|
+
export declare function decryptEncryptedAttestations(attestations: Array<DecryptionAttestation<EncryptionScheme, SupportedTeeType> | EncryptedDecryptionAttestation<EncryptionScheme, SupportedTeeType>>, reencryptKeypair: XwingKeypair): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedTeeType>>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { HexString } from '../binary.js';
|
|
2
|
+
import type { EncryptionScheme, EncryptResultOf, PlaintextOf, SupportedTeeType } from '../encryption/encryption.js';
|
|
3
|
+
import type { BackoffConfig } from '../retry.js';
|
|
4
|
+
/**
|
|
5
|
+
* Custom error class for attested decrypt operations.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AttestedDecryptError extends Error {
|
|
8
|
+
readonly cause?: unknown | undefined;
|
|
9
|
+
constructor(message: string, cause?: unknown | undefined);
|
|
10
|
+
}
|
|
11
|
+
export type DecryptionAttestation<S extends EncryptionScheme, T extends SupportedTeeType> = {
|
|
12
|
+
handle: HexString;
|
|
13
|
+
plaintext: PlaintextOf<S, T>;
|
|
14
|
+
covalidatorSignatures: Uint8Array[];
|
|
15
|
+
};
|
|
16
|
+
export type EncryptedDecryptionAttestation<S extends EncryptionScheme, T extends SupportedTeeType> = {
|
|
17
|
+
handle: HexString;
|
|
18
|
+
encryptedPlaintext: EncryptResultOf<S, T>;
|
|
19
|
+
encryptedSignatures: Uint8Array[];
|
|
20
|
+
covalidatorSignatures: Uint8Array[];
|
|
21
|
+
};
|
|
22
|
+
export type AttestedDecryptor<S extends EncryptionScheme> = <T extends SupportedTeeType>(args: AttestedDecryptFnArgs<S, T>) => Promise<DecryptionAttestation<S, T>>;
|
|
23
|
+
export type AttestedDecryptFnArgs<S extends EncryptionScheme, T extends SupportedTeeType> = {
|
|
24
|
+
/** The handle to decrypt */
|
|
25
|
+
handle: HexString;
|
|
26
|
+
backoffConfig?: Partial<BackoffConfig>;
|
|
27
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Chain, PublicClient, Transport } from 'viem';
|
|
2
|
+
import type { DecryptionAttestation } from '../attesteddecrypt/types.js';
|
|
3
|
+
import type { HexString } from '../binary.js';
|
|
4
|
+
import type { EncryptionScheme, SupportedTeeType } from '../encryption/encryption.js';
|
|
5
|
+
import type { KmsQuorumClient } from '../kms/quorumClient.js';
|
|
6
|
+
import type { BackoffConfig } from '../retry.js';
|
|
7
|
+
/**
|
|
8
|
+
* Reveal multiple handles in a single attested request without wallet authentication.
|
|
9
|
+
* Returns an array of plaintext attestations aligned with the response ordering.
|
|
10
|
+
*
|
|
11
|
+
* @param args - The arguments for the attested reveal request
|
|
12
|
+
* @returns An array of decryption attestations
|
|
13
|
+
* @throws {AttestedRevealError} If the reveal fails
|
|
14
|
+
*/
|
|
15
|
+
export declare function attestedReveal({ handles, kmsQuorumClient, executorAddress, publicClient, backoffConfig, }: {
|
|
16
|
+
handles: HexString[];
|
|
17
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
18
|
+
executorAddress: HexString;
|
|
19
|
+
publicClient: PublicClient<Transport, Chain>;
|
|
20
|
+
backoffConfig?: Partial<BackoffConfig> | undefined;
|
|
21
|
+
}): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedTeeType>>>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
import { Hex } from 'viem';
|
|
3
|
+
/** Schema for a `0x`-prefixed hex string. */
|
|
4
|
+
export declare const HexString: Schema.TemplateLiteral<`0x${string}`>;
|
|
5
|
+
/** A `0x`-prefixed hex-encoded string (e.g. `"0xdeadbeef"`). */
|
|
6
|
+
export type HexString = typeof HexString.Type;
|
|
7
|
+
/** A value that can represent raw bytes — either a hex string or a `Uint8Array`. */
|
|
8
|
+
export type BytesIsh = string | Uint8Array;
|
|
9
|
+
/**
|
|
10
|
+
* Converts a `Uint8Array` to a `bigint`. Returns `0n` for empty arrays.
|
|
11
|
+
* @param byteArray - The byte array to convert.
|
|
12
|
+
* @returns The unsigned big-endian integer representation of the bytes.
|
|
13
|
+
*/
|
|
14
|
+
export declare function bytesToBigInt(byteArray: Uint8Array): bigint;
|
|
15
|
+
/**
|
|
16
|
+
* Converts a `Buffer` to a `bigint`.
|
|
17
|
+
* @param buffer - The buffer to convert.
|
|
18
|
+
* @returns The unsigned big-endian integer representation of the buffer.
|
|
19
|
+
*/
|
|
20
|
+
export declare function bufferToBigInt(buffer: Buffer): bigint;
|
|
21
|
+
/**
|
|
22
|
+
* Converts a `bigint` to a 32-byte `Buffer`, zero-padded on the left.
|
|
23
|
+
* @param value - The bigint to convert.
|
|
24
|
+
* @returns A 32-byte big-endian buffer.
|
|
25
|
+
* @throws If the bigint is negative or too large to fit in 32 bytes.
|
|
26
|
+
*/
|
|
27
|
+
export declare function bigintToBytes(value: bigint): Buffer;
|
|
28
|
+
/**
|
|
29
|
+
* Converts a `bigint` to a {@link Bytes32} hex string, left-padded to 32 bytes.
|
|
30
|
+
* @param value - The bigint to convert.
|
|
31
|
+
* @returns A `Bytes32` hex string.
|
|
32
|
+
* @throws If the bigint is negative or too large to fit in 32 bytes.
|
|
33
|
+
*/
|
|
34
|
+
export declare function bigintToBytes32(value: bigint): Bytes32;
|
|
35
|
+
/**
|
|
36
|
+
* Left-pads a byte array with zeros to the specified length.
|
|
37
|
+
* @param bs - The byte array to pad.
|
|
38
|
+
* @param n - The desired total length in bytes.
|
|
39
|
+
* @returns A new `Buffer` of length `n` with `bs` right-aligned.
|
|
40
|
+
* @throws If `bs` is longer than `n` (would require truncation).
|
|
41
|
+
*/
|
|
42
|
+
export declare function padLeft(bs: Uint8Array, n: number): Buffer;
|
|
43
|
+
/**
|
|
44
|
+
* Parses a {@link BytesIsh} value as a 32-byte value and converts it to a `bigint`.
|
|
45
|
+
* @param bs - A hex string or `Uint8Array` representing exactly 32 bytes.
|
|
46
|
+
* @returns The `bigint` representation of the 32-byte value.
|
|
47
|
+
* @throws If the input is not exactly 32 bytes.
|
|
48
|
+
*/
|
|
49
|
+
export declare function bytes32ToBigint(bs: BytesIsh): bigint;
|
|
50
|
+
/**
|
|
51
|
+
* Decodes a hex string into a `Buffer`. Handles both `0x`-prefixed and bare hex strings.
|
|
52
|
+
* @param hexString - The hex string to decode.
|
|
53
|
+
* @returns A `Buffer` containing the decoded bytes.
|
|
54
|
+
*/
|
|
55
|
+
export declare function bytesFromHexString(hexString: string): Buffer;
|
|
56
|
+
/**
|
|
57
|
+
* Asserts that a string is a valid `0x`-prefixed hex string and narrows its type to `Hex`.
|
|
58
|
+
* @param value - The string to validate.
|
|
59
|
+
* @returns The input typed as `Hex`.
|
|
60
|
+
* @throws If `value` is not a valid hex string.
|
|
61
|
+
*/
|
|
62
|
+
export declare function mustBeHex(value: string): Hex;
|
|
63
|
+
/**
|
|
64
|
+
* Normalises a string to a `0x`-prefixed `Hex` value, adding the prefix if missing.
|
|
65
|
+
* @param value - A hex string, with or without a `0x` prefix.
|
|
66
|
+
* @returns The `0x`-prefixed `Hex` string.
|
|
67
|
+
* @throws If the resulting string is not valid hex.
|
|
68
|
+
*/
|
|
69
|
+
export declare function normaliseToHex(value: string): Hex;
|
|
70
|
+
/**
|
|
71
|
+
* Encodes a `Uint8Array` as a `0x`-prefixed hex string.
|
|
72
|
+
* @param bs - The byte array to encode.
|
|
73
|
+
* @returns A `Hex` string representation of the bytes.
|
|
74
|
+
*/
|
|
75
|
+
export declare function bytesToHex(bs: Uint8Array): Hex;
|
|
76
|
+
/** Schema for a 32-byte (66-character with `0x` prefix) hex string, branded as `Bytes32`. Accepts both hex strings and `Uint8Array` inputs. */
|
|
77
|
+
export declare const Bytes32: Schema.brand<Schema.filter<Schema.transformOrFail<Schema.Union<[typeof Schema.String, Schema.refine<object & Uint8Array<ArrayBufferLike>, Schema.Schema<object, object, never>>]>, Schema.TemplateLiteral<`0x${string}`>, never>>, "Bytes32">;
|
|
78
|
+
/**
|
|
79
|
+
* Parses and validates a {@link BytesIsh} value as a {@link Bytes32}.
|
|
80
|
+
* @param x - A hex string or `Uint8Array` to parse.
|
|
81
|
+
* @returns A validated `Bytes32` value.
|
|
82
|
+
* @throws If the input is not exactly 32 bytes.
|
|
83
|
+
*/
|
|
84
|
+
export declare function asBytes32(x: BytesIsh): Bytes32;
|
|
85
|
+
/** A branded 32-byte hex string type (`0x` + 64 hex characters). */
|
|
86
|
+
export type Bytes32 = typeof Bytes32.Type;
|
|
87
|
+
/** A branded 20-byte Ethereum address type (`0x` + 40 hex characters). */
|
|
88
|
+
export type Address = typeof Address.Type;
|
|
89
|
+
/** Schema for a 20-byte `0x`-prefixed Ethereum address, branded as `Address`. */
|
|
90
|
+
export declare const Address: Schema.brand<Schema.filter<Schema.TemplateLiteral<`0x${string}`>>, "Address">;
|
|
91
|
+
/**
|
|
92
|
+
* Parses and validates a string as an Ethereum {@link Address} (20-byte, `0x`-prefixed).
|
|
93
|
+
* @param address - The string to parse.
|
|
94
|
+
* @returns A validated `Address` value.
|
|
95
|
+
* @throws If the input is not a valid 20-byte hex address.
|
|
96
|
+
*/
|
|
97
|
+
export declare function parseAddress(address: string): Address;
|
|
98
|
+
/**
|
|
99
|
+
* Parses and validates a string as a {@link HexString} (`0x`-prefixed).
|
|
100
|
+
* @param hex - The string to parse.
|
|
101
|
+
* @returns A validated `HexString` value.
|
|
102
|
+
* @throws If the input is not a valid `0x`-prefixed hex string.
|
|
103
|
+
*/
|
|
104
|
+
export declare function parseHex(hex: string): HexString;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map of supported chain short names to their chain IDs.
|
|
3
|
+
*
|
|
4
|
+
* @remarks This mirrors viem chain definitions without depending on viem directly,
|
|
5
|
+
* to work around Pulumi closure serialisation issues.
|
|
6
|
+
*/
|
|
7
|
+
export declare const supportedChains: {
|
|
8
|
+
readonly mainnet: 1;
|
|
9
|
+
readonly base: 8453;
|
|
10
|
+
readonly baseSepolia: 84532;
|
|
11
|
+
readonly sepolia: 11155111;
|
|
12
|
+
readonly monadTestnet: 10143;
|
|
13
|
+
readonly plasmaTestnet: 9746;
|
|
14
|
+
readonly worldchainSepolia: 4801;
|
|
15
|
+
readonly anvil: 31337;
|
|
16
|
+
};
|
|
17
|
+
type SupportedChains = typeof supportedChains;
|
|
18
|
+
/** Numeric chain ID of a supported chain (e.g. `84532`, `11155111`). */
|
|
19
|
+
export type SupportedChainId = SupportedChains[keyof SupportedChains];
|
|
20
|
+
/** Short name of a supported chain (e.g. `"baseSepolia"`, `"sepolia"`). */
|
|
21
|
+
export type SupportedChainName = keyof SupportedChains;
|
|
22
|
+
/** A supported chain identified by both its short name and numeric ID. */
|
|
23
|
+
export type SupportedChain = {
|
|
24
|
+
name: SupportedChainName;
|
|
25
|
+
id: SupportedChainId;
|
|
26
|
+
};
|
|
27
|
+
/** A value that can represent a number — either a `number` or a `bigint`. */
|
|
28
|
+
export type Numberish = number | bigint;
|
|
29
|
+
/** A flexible chain identifier: a chain ID (`number` | `bigint`), an object with an `id` field, or a chain short name. */
|
|
30
|
+
export type Chainish = {
|
|
31
|
+
id: Numberish;
|
|
32
|
+
} | Numberish | string;
|
|
33
|
+
/**
|
|
34
|
+
* Map of supported chain IDs to their short names.
|
|
35
|
+
* Public networks use the `shortName` from https://github.com/ethereum-lists/chains.
|
|
36
|
+
* Local Anvil uses `31337` (same ID as GoChain Testnet in the registry) but the SDK labels it `anvil`.
|
|
37
|
+
*/
|
|
38
|
+
export declare const chainShortNames: Record<SupportedChainId, string>;
|
|
39
|
+
/**
|
|
40
|
+
* Resolves a {@link Chainish} value to a {@link SupportedChain}.
|
|
41
|
+
*
|
|
42
|
+
* Accepts a chain ID (`number` or `bigint`), an object with an `id` field,
|
|
43
|
+
* or a chain short name (e.g. `"baseSepolia"`).
|
|
44
|
+
*
|
|
45
|
+
* @param chainish - The chain identifier to resolve.
|
|
46
|
+
* @returns The matching `SupportedChain` with both `name` and `id`.
|
|
47
|
+
* @throws If no supported chain matches the given identifier.
|
|
48
|
+
*/
|
|
49
|
+
export declare function getSupportedChain(chainish: Chainish): SupportedChain;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Account, Chain, Transport, WalletClient } from 'viem';
|
|
2
|
+
import type { HexString } from '../binary.js';
|
|
3
|
+
import type { SupportedChainId } from '../chain.js';
|
|
4
|
+
import { ViemClient } from '../viem.js';
|
|
5
|
+
export declare function fetchEip712DomainVersion(executorAddress: HexString, ethClient: ViemClient): Promise<string>;
|
|
6
|
+
export declare function buildEip712Payload(params: {
|
|
7
|
+
executorAddress: HexString;
|
|
8
|
+
ethClient: ViemClient;
|
|
9
|
+
chainId: SupportedChainId;
|
|
10
|
+
handles: HexString[];
|
|
11
|
+
reencryptPubKey: Uint8Array;
|
|
12
|
+
}): Promise<import("../reencryption/eip712.js").EIP712<{
|
|
13
|
+
handles: `0x${string}`[];
|
|
14
|
+
publicKey: `0x${string}`;
|
|
15
|
+
}>>;
|
|
16
|
+
type WalletSignTypedDataParams = Parameters<WalletClient<Transport, Chain, Account>['signTypedData']>[0];
|
|
17
|
+
export declare function signEip712(walletClient: WalletClient<Transport, Chain, Account>, eip712Payload: WalletSignTypedDataParams): Promise<`0x${string}`>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { buildEip712Payload, fetchEip712DomainVersion, signEip712, } from './eip712.js';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Account, Chain, PublicClient, Transport, WalletClient } from 'viem';
|
|
2
|
+
import { validateHandle } from '../attesteddecrypt/attested-decrypt.js';
|
|
3
|
+
import { type HexString } from '../binary.js';
|
|
4
|
+
import { type SupportedChainId } from '../chain.js';
|
|
5
|
+
import { type EncryptionScheme, type SupportedTeeType } from '../encryption/encryption.js';
|
|
6
|
+
import { KmsQuorumClient } from '../kms/quorumClient.js';
|
|
7
|
+
import type { XwingKeypair } from '../lite/xwing.js';
|
|
8
|
+
import type { BackoffConfig } from '../retry.js';
|
|
9
|
+
import { type EListDecryptionAttestation, type EncryptedEListDecryptionAttestation } from './types.js';
|
|
10
|
+
export { validateHandle };
|
|
11
|
+
export declare function eListAttestedDecrypt({ handle, backoffConfig, walletClient, chainId, reencryptPubKey, reencryptKeypair, kmsQuorumClient, executorAddress, }: {
|
|
12
|
+
handle: HexString;
|
|
13
|
+
backoffConfig?: Partial<BackoffConfig> | undefined;
|
|
14
|
+
walletClient: WalletClient<Transport, Chain, Account>;
|
|
15
|
+
chainId: SupportedChainId;
|
|
16
|
+
reencryptPubKey: Uint8Array;
|
|
17
|
+
reencryptKeypair: XwingKeypair;
|
|
18
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
19
|
+
executorAddress: HexString;
|
|
20
|
+
}): Promise<EListDecryptionAttestation<EncryptionScheme, SupportedTeeType>>;
|
|
21
|
+
export declare function eListAttestedDecrypt({ handle, backoffConfig, walletClient, chainId, reencryptPubKey, kmsQuorumClient, executorAddress, }: {
|
|
22
|
+
handle: HexString;
|
|
23
|
+
backoffConfig?: Partial<BackoffConfig> | undefined;
|
|
24
|
+
walletClient: WalletClient<Transport, Chain, Account>;
|
|
25
|
+
chainId: SupportedChainId;
|
|
26
|
+
reencryptPubKey: Uint8Array;
|
|
27
|
+
reencryptKeypair?: never;
|
|
28
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
29
|
+
executorAddress: HexString;
|
|
30
|
+
}): Promise<EncryptedEListDecryptionAttestation<EncryptionScheme, SupportedTeeType>>;
|
|
31
|
+
export declare function eListAttestedDecrypt({ handle, backoffConfig, walletClient, chainId, kmsQuorumClient, executorAddress, }: {
|
|
32
|
+
handle: HexString;
|
|
33
|
+
backoffConfig?: Partial<BackoffConfig> | undefined;
|
|
34
|
+
walletClient: WalletClient<Transport, Chain, Account>;
|
|
35
|
+
chainId: SupportedChainId;
|
|
36
|
+
reencryptPubKey?: never;
|
|
37
|
+
reencryptKeypair?: never;
|
|
38
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
39
|
+
executorAddress: HexString;
|
|
40
|
+
}): Promise<EListDecryptionAttestation<EncryptionScheme, SupportedTeeType>>;
|
|
41
|
+
/**
|
|
42
|
+
* Reveal a single elist handle without wallet authentication.
|
|
43
|
+
* Returns plaintext values along with an attestation of the checksum.
|
|
44
|
+
*/
|
|
45
|
+
export declare function eListAttestedReveal({ handle, backoffConfig, kmsQuorumClient, executorAddress, publicClient, }: {
|
|
46
|
+
handle: HexString;
|
|
47
|
+
backoffConfig?: Partial<BackoffConfig> | undefined;
|
|
48
|
+
kmsQuorumClient: KmsQuorumClient;
|
|
49
|
+
executorAddress: HexString;
|
|
50
|
+
publicClient: PublicClient<Transport, Chain>;
|
|
51
|
+
}): Promise<EListDecryptionAttestation<EncryptionScheme, SupportedTeeType>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { HexString } from '../binary.js';
|
|
2
|
+
import type { EncryptionScheme, EncryptResultOf, PlaintextOf, SupportedTeeType } from '../encryption/encryption.js';
|
|
3
|
+
import { handleTypes } from '../index.js';
|
|
4
|
+
import type { BackoffConfig } from '../retry.js';
|
|
5
|
+
/**
|
|
6
|
+
* Custom error class for elist attested decrypt operations.
|
|
7
|
+
*/
|
|
8
|
+
export declare class EListAttestedDecryptError extends Error {
|
|
9
|
+
readonly cause?: unknown | undefined;
|
|
10
|
+
constructor(message: string, cause?: unknown | undefined);
|
|
11
|
+
}
|
|
12
|
+
export type EListDecryptionAttestation<S extends EncryptionScheme, T extends SupportedTeeType> = {
|
|
13
|
+
handle: HexString;
|
|
14
|
+
commitmentProof: PlaintextOf<S, typeof handleTypes.euint256>;
|
|
15
|
+
values: PlaintextOf<S, T>[];
|
|
16
|
+
covalidatorSignatures: Uint8Array[];
|
|
17
|
+
commitments: Uint8Array[];
|
|
18
|
+
};
|
|
19
|
+
export type EncryptedEListDecryptionAttestation<S extends EncryptionScheme, T extends SupportedTeeType> = {
|
|
20
|
+
handle: HexString;
|
|
21
|
+
commitmentProof: PlaintextOf<S, typeof handleTypes.euint256>;
|
|
22
|
+
values: EncryptResultOf<S, T>[];
|
|
23
|
+
covalidatorSignatures: Uint8Array[];
|
|
24
|
+
commitments: Uint8Array[];
|
|
25
|
+
};
|
|
26
|
+
export type EListAttestedDecryptor<S extends EncryptionScheme> = <T extends SupportedTeeType>(args: EListAttestedDecryptFnArgs<S, T>) => Promise<EListDecryptionAttestation<S, T>>;
|
|
27
|
+
export type EListAttestedDecryptFnArgs<S extends EncryptionScheme, T extends SupportedTeeType> = {
|
|
28
|
+
/** The handle to decrypt */
|
|
29
|
+
handle: HexString;
|
|
30
|
+
backoffConfig?: Partial<BackoffConfig>;
|
|
31
|
+
};
|