@inco/js 0.8.0-devnet-13 → 0.8.0-devnet-22

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.
Files changed (89) hide show
  1. package/README.md +18 -76
  2. package/dist/cjs/advancedacl/session-key.d.ts +1 -1
  3. package/dist/cjs/advancedacl/session-key.js +3 -2
  4. package/dist/cjs/attestedcompute/attested-compute.js +5 -2
  5. package/dist/cjs/attesteddecrypt/attested-decrypt.d.ts +5 -1
  6. package/dist/cjs/attesteddecrypt/attested-decrypt.js +14 -4
  7. package/dist/cjs/binary.d.ts +2 -4
  8. package/dist/cjs/binary.js +11 -6
  9. package/dist/cjs/encryption/index.d.ts +1 -1
  10. package/dist/cjs/encryption/index.js +17 -16
  11. package/dist/cjs/generated/abis/lightning.d.ts +70 -17
  12. package/dist/cjs/generated/abis/lightning.js +44 -19
  13. package/dist/cjs/generated/abis/test-elist.d.ts +10 -2
  14. package/dist/cjs/generated/abis/test-elist.js +8 -3
  15. package/dist/cjs/generated/abis/verifier.d.ts +78 -4
  16. package/dist/cjs/generated/abis/verifier.js +49 -4
  17. package/dist/cjs/generated/lightning.d.ts +60 -0
  18. package/dist/cjs/generated/lightning.js +64 -1
  19. package/dist/cjs/generated/local-node.d.ts +4 -4
  20. package/dist/cjs/generated/local-node.js +4 -4
  21. package/dist/cjs/index.d.ts +1 -1
  22. package/dist/cjs/index.js +11 -2
  23. package/dist/cjs/kms/quorumClient.d.ts +5 -13
  24. package/dist/cjs/kms/quorumClient.js +74 -259
  25. package/dist/cjs/kms/quorumConsistency.d.ts +58 -0
  26. package/dist/cjs/kms/quorumConsistency.js +200 -0
  27. package/dist/cjs/kms/signatureVerification.d.ts +35 -0
  28. package/dist/cjs/kms/signatureVerification.js +88 -0
  29. package/dist/cjs/kms/thresholdPromises.d.ts +4 -3
  30. package/dist/cjs/kms/thresholdPromises.js +25 -15
  31. package/dist/cjs/lite/hadu.d.ts +1 -1
  32. package/dist/cjs/lite/hadu.js +3 -3
  33. package/dist/cjs/lite/index.d.ts +0 -2
  34. package/dist/cjs/lite/index.js +1 -15
  35. package/dist/cjs/lite/lightning.d.ts +1 -1
  36. package/dist/cjs/lite/lightning.js +14 -33
  37. package/dist/esm/advancedacl/session-key.d.ts +1 -1
  38. package/dist/esm/advancedacl/session-key.js +3 -2
  39. package/dist/esm/attestedcompute/attested-compute.js +6 -3
  40. package/dist/esm/attesteddecrypt/attested-decrypt.d.ts +5 -1
  41. package/dist/esm/attesteddecrypt/attested-decrypt.js +15 -5
  42. package/dist/esm/binary.d.ts +2 -4
  43. package/dist/esm/binary.js +11 -6
  44. package/dist/esm/encryption/index.d.ts +1 -1
  45. package/dist/esm/encryption/index.js +2 -2
  46. package/dist/esm/generated/abis/lightning.d.ts +70 -17
  47. package/dist/esm/generated/abis/lightning.js +44 -19
  48. package/dist/esm/generated/abis/test-elist.d.ts +10 -2
  49. package/dist/esm/generated/abis/test-elist.js +8 -3
  50. package/dist/esm/generated/abis/verifier.d.ts +78 -4
  51. package/dist/esm/generated/abis/verifier.js +49 -4
  52. package/dist/esm/generated/lightning.d.ts +60 -0
  53. package/dist/esm/generated/lightning.js +64 -1
  54. package/dist/esm/generated/local-node.d.ts +4 -4
  55. package/dist/esm/generated/local-node.js +4 -4
  56. package/dist/esm/index.d.ts +1 -1
  57. package/dist/esm/index.js +2 -2
  58. package/dist/esm/kms/quorumClient.d.ts +5 -13
  59. package/dist/esm/kms/quorumClient.js +74 -259
  60. package/dist/esm/kms/quorumConsistency.d.ts +58 -0
  61. package/dist/esm/kms/quorumConsistency.js +193 -0
  62. package/dist/esm/kms/signatureVerification.d.ts +35 -0
  63. package/dist/esm/kms/signatureVerification.js +84 -0
  64. package/dist/esm/kms/thresholdPromises.d.ts +4 -3
  65. package/dist/esm/kms/thresholdPromises.js +25 -15
  66. package/dist/esm/lite/hadu.d.ts +1 -1
  67. package/dist/esm/lite/hadu.js +2 -2
  68. package/dist/esm/lite/index.d.ts +0 -2
  69. package/dist/esm/lite/index.js +1 -3
  70. package/dist/esm/lite/lightning.d.ts +1 -1
  71. package/dist/esm/lite/lightning.js +8 -27
  72. package/dist/types/advancedacl/session-key.d.ts +1 -1
  73. package/dist/types/attesteddecrypt/attested-decrypt.d.ts +5 -1
  74. package/dist/types/binary.d.ts +2 -4
  75. package/dist/types/encryption/index.d.ts +1 -1
  76. package/dist/types/generated/abis/lightning.d.ts +70 -17
  77. package/dist/types/generated/abis/test-elist.d.ts +10 -2
  78. package/dist/types/generated/abis/verifier.d.ts +78 -4
  79. package/dist/types/generated/lightning.d.ts +60 -0
  80. package/dist/types/generated/local-node.d.ts +4 -4
  81. package/dist/types/index.d.ts +1 -1
  82. package/dist/types/kms/quorumClient.d.ts +5 -13
  83. package/dist/types/kms/quorumConsistency.d.ts +58 -0
  84. package/dist/types/kms/signatureVerification.d.ts +35 -0
  85. package/dist/types/kms/thresholdPromises.d.ts +4 -3
  86. package/dist/types/lite/hadu.d.ts +1 -1
  87. package/dist/types/lite/index.d.ts +0 -2
  88. package/dist/types/lite/lightning.d.ts +1 -1
  89. package/package.json +12 -12
@@ -16,12 +16,12 @@ export declare const localNodeLightningConfig: {
16
16
  readonly senderPrivateKey: "0x3ff395b755c4dc09837d0672dd421915e9b9835a4733edf63d8fd12b3fe4475c";
17
17
  };
18
18
  readonly devnet: {
19
- readonly executorAddress: "0xDF3830489208461f72Df6E45D0e6cbF9DBB74fe1";
19
+ readonly executorAddress: "0x6c9132D324231D2F68a1491686b0d4c10ee7d257";
20
20
  readonly chainId: 31337;
21
21
  readonly covalidatorUrls: readonly ["http://localhost:50055"];
22
- readonly signers: readonly ["0xadAA7b651e894D2B1F4929AC49d065b0143d1506"];
22
+ readonly signers: readonly ["0xD413DF212d2aeDf4F66241441c018Ce71a2119F1"];
23
23
  readonly hostChainRpcUrl: "http://localhost:8545";
24
- readonly senderPrivateKey: "0xf829aecfc84240e8bfedfc3274d745a209a1e7d15693f424e0596ef55739215b";
24
+ readonly senderPrivateKey: "0x5683b966233cfbb5e8355f45cdb5fca9d6c713701909d01086cb85276fb9f474";
25
25
  };
26
26
  readonly alphanet: {
27
27
  readonly executorAddress: "0xc0d693DeEF0A91CE39208676b6da09B822abd199";
@@ -32,7 +32,7 @@ export declare const localNodeLightningConfig: {
32
32
  readonly senderPrivateKey: "0x279c172cf3638a79642daa5f7666c600befde318550d7579cf96280920e318b6";
33
33
  };
34
34
  readonly scratch: {
35
- readonly executorAddress: "0xF253724506f9aF666C301c0aD94f92f92Ff390E4";
35
+ readonly executorAddress: "0x4d71c2268a5a0d525519d2055eaee6b3f5597999";
36
36
  readonly chainId: 31337;
37
37
  readonly covalidatorUrls: readonly ["http://localhost:50055"];
38
38
  readonly signers: readonly ["0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"];
@@ -1,5 +1,5 @@
1
1
  export * from './binary.js';
2
2
  export * from './chain.js';
3
- export * from './handle.js';
3
+ export { HANDLE_LENGTH_BYTES, HANDLE_VERSION, HandleTypeName, InputContext, getHandleType, handleTypes, isFheType, validateHandle, type FheType, type Handle, type HandleTypes, } from './handle.js';
4
4
  export * from './schema.js';
5
5
  export * from './viem.js';
@@ -2,9 +2,10 @@ import type { Address } from 'viem';
2
2
  import type { DecryptionAttestation, EncryptedDecryptionAttestation } from '../attesteddecrypt/types.js';
3
3
  import type { EncryptionScheme, SupportedFheType } from '../encryption/encryption.js';
4
4
  import type { AttestedComputeRequest, AttestedDecryptRequest, AttestedRevealRequest } from '../generated/es/inco/kms/lite/v1/kms_service_pb.js';
5
- import type { XwingKeypair } from '../lite/index.js';
5
+ import type { XwingKeypair } from '../lite/xwing.js';
6
6
  import type { BackoffConfig } from '../retry.js';
7
7
  import { type KmsClient } from './client.js';
8
+ import type { ViemClient } from './signatureVerification.js';
8
9
  export declare class KmsQuorumClient {
9
10
  private readonly kmss;
10
11
  private readonly threshold;
@@ -29,9 +30,9 @@ export declare class KmsQuorumClient {
29
30
  * @throws {Error} If KMS clients array is empty or threshold is invalid
30
31
  */
31
32
  static fromKmsClients(kmsClients: KmsClient[], threshold: number): KmsQuorumClient;
32
- attestedDecrypt(request: AttestedDecryptRequest, backoffConfig?: Partial<BackoffConfig>, reencryptKeypair?: XwingKeypair): Promise<(DecryptionAttestation<EncryptionScheme, SupportedFheType> | EncryptedDecryptionAttestation<EncryptionScheme, SupportedFheType>)[]>;
33
- attestedCompute(request: AttestedComputeRequest, backoffConfig?: Partial<BackoffConfig>, reencryptKeypair?: XwingKeypair): Promise<DecryptionAttestation<EncryptionScheme, SupportedFheType> | EncryptedDecryptionAttestation<EncryptionScheme, SupportedFheType>>;
34
- attestedReveal(request: AttestedRevealRequest, backoffConfig?: Partial<BackoffConfig>): Promise<(DecryptionAttestation<EncryptionScheme, SupportedFheType> | EncryptedDecryptionAttestation<EncryptionScheme, SupportedFheType>)[]>;
33
+ attestedDecrypt(request: AttestedDecryptRequest, backoffConfig?: Partial<BackoffConfig>, reencryptKeypair?: XwingKeypair, executorAddress?: Address, client?: ViemClient): Promise<(DecryptionAttestation<EncryptionScheme, SupportedFheType> | EncryptedDecryptionAttestation<EncryptionScheme, SupportedFheType>)[]>;
34
+ attestedCompute(request: AttestedComputeRequest, backoffConfig?: Partial<BackoffConfig>, reencryptKeypair?: XwingKeypair, executorAddress?: Address, client?: ViemClient): Promise<DecryptionAttestation<EncryptionScheme, SupportedFheType> | EncryptedDecryptionAttestation<EncryptionScheme, SupportedFheType>>;
35
+ attestedReveal(request: AttestedRevealRequest, backoffConfig?: Partial<BackoffConfig>, executorAddress?: Address, client?: ViemClient): Promise<(DecryptionAttestation<EncryptionScheme, SupportedFheType> | EncryptedDecryptionAttestation<EncryptionScheme, SupportedFheType>)[]>;
35
36
  /**
36
37
  * Generic method to execute a KMS operation across all clients with retry and threshold logic.
37
38
  * Returns results with both the response and signer address.
@@ -48,13 +49,4 @@ export declare class KmsQuorumClient {
48
49
  private buildPlaintextAttestation;
49
50
  private buildAggregatedAttestations;
50
51
  private buildAggregatedComputeAttestation;
51
- private verifyResponseConsistency;
52
- private verifyComputeResponseConsistency;
53
- /**
54
- * Verifies that two plaintext byte arrays are identical.
55
- * Uses constant-time comparison to prevent timing side-channel attacks.
56
- */
57
- private verifyPlaintextBytesConsistency;
58
- private verifyPlaintextConsistency;
59
- private verifyCiphertextConsistency;
60
52
  }
@@ -0,0 +1,58 @@
1
+ import type { Address } from 'viem';
2
+ import type { AttestedComputeRequest, AttestedComputeResponse, AttestedDecryptResponse, AttestedRevealResponse, DecryptionAttestation as ProtoDecryptionAttestation } from '../generated/es/inco/kms/lite/v1/kms_service_pb.js';
3
+ import type { XwingKeypair } from '../lite/xwing.js';
4
+ /**
5
+ * Computes a canonical key for a single attestation.
6
+ * For plaintext/reencryption+keypair, the key is handle:hex(value).
7
+ * For reencryption without a keypair (XWing ciphertexts are non-deterministic),
8
+ * falls back to handle:op-type as a structural stand-in.
9
+ */
10
+ export declare function computeAttestationKey(att: ProtoDecryptionAttestation, reencryptKeypair?: XwingKeypair): Promise<string>;
11
+ /**
12
+ * Validates that all responses in a winning bucket have the same attestation
13
+ * count and types as the quorum-elected reference (bucket[0]).
14
+ */
15
+ export declare function validateDecryptResponseStructure<T extends AttestedDecryptResponse | AttestedRevealResponse>(bucket: Array<{
16
+ response: T;
17
+ signer: Address;
18
+ }>): void;
19
+ /**
20
+ * Validates that all responses in a winning bucket have a decryption
21
+ * attestation with the same case as the quorum-elected reference (bucket[0]),
22
+ * and that the case is consistent with the request's reencryptPubKey.
23
+ */
24
+ export declare function validateComputeResponseStructure(bucket: Array<{
25
+ response: AttestedComputeResponse;
26
+ signer: Address;
27
+ }>, request?: AttestedComputeRequest): void;
28
+ /**
29
+ * Verifies decrypt/reveal response consistency using hash-bucket voting.
30
+ * Collects all N responses, buckets them by content key, and returns the
31
+ * winning bucket (the first one with >= threshold votes).
32
+ *
33
+ * This is robust against a faulty first-responding node: even if responses[0]
34
+ * disagrees, a quorum of agreeing responses will form a winning bucket.
35
+ */
36
+ export declare function verifyDecryptResponseConsistency<T extends AttestedDecryptResponse | AttestedRevealResponse>(allResults: Array<{
37
+ response: T;
38
+ signer: Address;
39
+ }>, threshold: number, reencryptKeypair?: XwingKeypair): Promise<{
40
+ reference: T;
41
+ winningResults: Array<{
42
+ response: T;
43
+ signer: Address;
44
+ }>;
45
+ }>;
46
+ /**
47
+ * Verifies compute response consistency using hash-bucket voting.
48
+ */
49
+ export declare function verifyComputeResponseConsistency(allResults: Array<{
50
+ response: AttestedComputeResponse;
51
+ signer: Address;
52
+ }>, threshold: number, request?: AttestedComputeRequest, reencryptKeypair?: XwingKeypair): Promise<{
53
+ reference: AttestedComputeResponse;
54
+ winningResults: Array<{
55
+ response: AttestedComputeResponse;
56
+ signer: Address;
57
+ }>;
58
+ }>;
@@ -0,0 +1,35 @@
1
+ import type { Account, Address, Chain, PublicClient, Transport, WalletClient } from 'viem';
2
+ export type ViemClient = WalletClient<Transport, Chain, Account> | PublicClient<Transport, Chain>;
3
+ /**
4
+ * Verifies covalidator signatures for a plaintext DecryptionAttestation
5
+ * by calling `isValidDecryptionAttestation` on the IncoVerifier contract.
6
+ *
7
+ * This delegates all verification logic (EIP-712 digest computation,
8
+ * ECDSA recovery, signer authorization, threshold check) to the contract,
9
+ * ensuring exact parity with on-chain verification.
10
+ *
11
+ * @param handle - The handle hex string (bytes32)
12
+ * @param rawValueBytes - The raw plaintext value bytes (will be left-padded to 32 bytes)
13
+ * @param signatures - The covalidator ECDSA signatures to verify
14
+ * @param executorAddress - The Lightning contract address (executor)
15
+ * @param client - A viem client capable of reading contract state
16
+ * @throws If the contract returns false (insufficient valid signatures)
17
+ */
18
+ export declare function verifyPlaintextAttestationSignatures(handle: string, rawValueBytes: Uint8Array, signatures: Uint8Array[], executorAddress: Address, client: ViemClient): Promise<void>;
19
+ /**
20
+ * Verifies covalidator envelope signatures for reencryption attestations
21
+ * by calling `isValidReencryptionAttestation` on the IncoVerifier contract.
22
+ *
23
+ * Each covalidator signs over its own unique (userCiphertext, handle, encryptedSignature)
24
+ * tuple, so all three per-covalidator arrays must be aligned by index and sorted
25
+ * by signer address in ascending order.
26
+ *
27
+ * @param handle - The handle hex string (bytes32)
28
+ * @param userCiphertexts - Per-covalidator ciphertexts (sorted by signer address)
29
+ * @param encryptedSignatures - Per-covalidator encrypted inner signatures (sorted by signer address)
30
+ * @param envelopeSignatures - Per-covalidator envelope signatures (sorted by signer address)
31
+ * @param executorAddress - The Lightning contract address (executor)
32
+ * @param client - A viem client capable of reading contract state
33
+ * @throws If the contract returns false (insufficient valid signatures)
34
+ */
35
+ export declare function verifyReencryptionAttestationSignatures(handle: string, userCiphertexts: Uint8Array[], encryptedSignatures: Uint8Array[], envelopeSignatures: Uint8Array[], executorAddress: Address, client: ViemClient): Promise<void>;
@@ -1,7 +1,8 @@
1
1
  /**
2
- * Executes promises and returns results as soon as threshold is reached
2
+ * Executes all promises and returns all successful results.
3
+ * Rejects early if it becomes mathematically impossible to reach the threshold.
3
4
  * @param promises Array of promises to execute
4
- * @param threshold Number of successful responses needed
5
- * @returns Promise that resolves with threshold number of results
5
+ * @param threshold Minimum number of successful responses required
6
+ * @returns Promise that resolves with all successful results (length >= threshold)
6
7
  */
7
8
  export declare function executeWithThreshold<T>(promises: Promise<T>[], threshold: number): Promise<T[]>;
@@ -1,4 +1,4 @@
1
- import { PlaintextWithContext } from '../encryption/index.js';
1
+ import { PlaintextWithContext } from '../encryption/encryption.js';
2
2
  import { InputPayload } from '../generated/es/inco/covalidator/compute/v1/types_pb.js';
3
3
  export declare function encodeInput({ plaintext, context, }: PlaintextWithContext): Uint8Array;
4
4
  export declare function decodeInput(input: Uint8Array): InputPayload;
@@ -4,6 +4,4 @@ export type { HandleWithProof } from '../generated/es/inco/kms/lite/v1/types_pb.
4
4
  export * from './attested-compute.js';
5
5
  export * from './attested-decrypt.js';
6
6
  export * from './deployments.js';
7
- export * from './hadu.js';
8
7
  export * from './lightning.js';
9
- export { TEST_NETWORK_SEED_KEY, XWING_PUBLIC_KEY_SIZE, decodeXwingPrivateKey, decodeXwingPublicKey, decrypt, deriveXwingKeypairFromSeed, encodeXwingPublicKey, encrypt, generateXwingKeypair, getXwingDecryptor, getXwingEncryptor, type XwingDecryptorArgs, type XwingEncryptorArgs, type XwingKeypair, } from './xwing.js';
@@ -4,7 +4,7 @@ import { AllowanceVoucherWithSig } from '../advancedacl/types.js';
4
4
  import { AttestedComputeOP } from '../attestedcompute/types.js';
5
5
  import { DecryptionAttestation, EncryptedDecryptionAttestation } from '../attesteddecrypt/index.js';
6
6
  import { Address, HexString } from '../binary.js';
7
- import { EncryptionScheme, SupportedFheType } from '../encryption/index.js';
7
+ import { EncryptionScheme, SupportedFheType } from '../encryption/encryption.js';
8
8
  import { incoVerifierAbi } from '../generated/abis/verifier.js';
9
9
  import { lightningDeployments } from '../generated/lightning.js';
10
10
  import { localNodeLightningConfig } from '../generated/local-node.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inco/js",
3
- "version": "0.8.0-devnet-13",
3
+ "version": "0.8.0-devnet-22",
4
4
  "repository": "https://github.com/Inco-fhevm/inco-monorepo",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -80,17 +80,17 @@
80
80
  "test:update-snapshots": "bun vitest run --project unit --update"
81
81
  },
82
82
  "dependencies": {
83
- "@bufbuild/protobuf": "^2.2.3",
84
- "@connectrpc/connect": "^2.0.0",
85
- "@connectrpc/connect-node": "^2.0.0",
86
- "@connectrpc/connect-web": "^2.0.1",
87
- "@grpc/grpc-js": "^1.13.4",
88
- "@hpke/hybridkem-x-wing": "^0.6.1",
89
- "@hpke/core": "^1.7.5",
90
- "@hpke/chacha20poly1305": "^1.7.1",
91
- "effect": "^3.17.13",
92
- "sha3": "^2.1.4",
93
- "viem": "^2.39.3"
83
+ "@bufbuild/protobuf": "2.10.0",
84
+ "@connectrpc/connect": "2.1.0",
85
+ "@connectrpc/connect-node": "2.1.0",
86
+ "@connectrpc/connect-web": "2.1.0",
87
+ "@grpc/grpc-js": "1.14.0",
88
+ "@hpke/hybridkem-x-wing": "0.6.1",
89
+ "@hpke/core": "1.7.5",
90
+ "@hpke/chacha20poly1305": "1.7.1",
91
+ "effect": "3.18.4",
92
+ "sha3": "2.1.4",
93
+ "viem": "2.39.3"
94
94
  },
95
95
  "devDependencies": {
96
96
  "@inco/pega": "workspace:*",