@primuslabs/fhetransform-sdk 0.4.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/README.md +198 -0
- package/dist/abis/acl.abi.d.ts +379 -0
- package/dist/abis/acl.abi.js +495 -0
- package/dist/abis/acl.abi.js.map +1 -0
- package/dist/abis/alphatrion_reward.abi.d.ts +407 -0
- package/dist/abis/alphatrion_reward.abi.js +532 -0
- package/dist/abis/alphatrion_reward.abi.js.map +1 -0
- package/dist/abis/ciphertext_digests.abi.d.ts +336 -0
- package/dist/abis/ciphertext_digests.abi.js +444 -0
- package/dist/abis/ciphertext_digests.abi.js.map +1 -0
- package/dist/abis/ciphertext_verification.abi.d.ts +637 -0
- package/dist/abis/ciphertext_verification.abi.js +830 -0
- package/dist/abis/ciphertext_verification.abi.js.map +1 -0
- package/dist/abis/convert_token.abi.d.ts +922 -0
- package/dist/abis/convert_token.abi.js +1208 -0
- package/dist/abis/convert_token.abi.js.map +1 -0
- package/dist/abis/decryption.abi.d.ts +956 -0
- package/dist/abis/decryption.abi.js +1244 -0
- package/dist/abis/decryption.abi.js.map +1 -0
- package/dist/abis/erc20.abi.d.ts +265 -0
- package/dist/abis/erc20.abi.js +350 -0
- package/dist/abis/erc20.abi.js.map +1 -0
- package/dist/abis/fhe_executor.abi.d.ts +1535 -0
- package/dist/abis/fhe_executor.abi.js +1962 -0
- package/dist/abis/fhe_executor.abi.js.map +1 -0
- package/dist/abis/space_bridge_config.abi.d.ts +792 -0
- package/dist/abis/space_bridge_config.abi.js +1032 -0
- package/dist/abis/space_bridge_config.abi.js.map +1 -0
- package/dist/abis/token.abi.d.ts +630 -0
- package/dist/abis/token.abi.js +828 -0
- package/dist/abis/token.abi.js.map +1 -0
- package/dist/cli/eusdc.d.ts +2 -0
- package/dist/cli/eusdc.js +41 -0
- package/dist/cli/eusdc.js.map +1 -0
- package/dist/contract/callbacks.d.ts +59 -0
- package/dist/contract/callbacks.js +2 -0
- package/dist/contract/callbacks.js.map +1 -0
- package/dist/contract/convert-token.d.ts +107 -0
- package/dist/contract/convert-token.js +249 -0
- package/dist/contract/convert-token.js.map +1 -0
- package/dist/contract/token.d.ts +167 -0
- package/dist/contract/token.js +404 -0
- package/dist/contract/token.js.map +1 -0
- package/dist/contract/transaction.d.ts +29 -0
- package/dist/contract/transaction.js +2 -0
- package/dist/contract/transaction.js.map +1 -0
- package/dist/core/address.d.ts +118 -0
- package/dist/core/address.js +200 -0
- package/dist/core/address.js.map +1 -0
- package/dist/core/auth.d.ts +68 -0
- package/dist/core/auth.js +58 -0
- package/dist/core/auth.js.map +1 -0
- package/dist/core/bytes.d.ts +48 -0
- package/dist/core/bytes.js +117 -0
- package/dist/core/bytes.js.map +1 -0
- package/dist/core/cache-manager.d.ts +138 -0
- package/dist/core/cache-manager.js +440 -0
- package/dist/core/cache-manager.js.map +1 -0
- package/dist/core/chain.d.ts +41 -0
- package/dist/core/chain.js +59 -0
- package/dist/core/chain.js.map +1 -0
- package/dist/core/constants.d.ts +24 -0
- package/dist/core/constants.js +25 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/error.d.ts +2 -0
- package/dist/core/error.js +14 -0
- package/dist/core/error.js.map +1 -0
- package/dist/core/errors/error-catalog.d.ts +29 -0
- package/dist/core/errors/error-catalog.js +84 -0
- package/dist/core/errors/error-catalog.js.map +1 -0
- package/dist/core/errors/error-codes.d.ts +52 -0
- package/dist/core/errors/error-codes.js +61 -0
- package/dist/core/errors/error-codes.js.map +1 -0
- package/dist/core/errors/error-utils.d.ts +27 -0
- package/dist/core/errors/error-utils.js +110 -0
- package/dist/core/errors/error-utils.js.map +1 -0
- package/dist/core/errors/fhe-error.d.ts +98 -0
- package/dist/core/errors/fhe-error.js +190 -0
- package/dist/core/errors/fhe-error.js.map +1 -0
- package/dist/core/errors/index.d.ts +4 -0
- package/dist/core/errors/index.js +5 -0
- package/dist/core/errors/index.js.map +1 -0
- package/dist/core/estimate.d.ts +39 -0
- package/dist/core/estimate.js +111 -0
- package/dist/core/estimate.js.map +1 -0
- package/dist/core/event.d.ts +212 -0
- package/dist/core/event.js +42 -0
- package/dist/core/event.js.map +1 -0
- package/dist/core/fhe-type.d.ts +75 -0
- package/dist/core/fhe-type.js +115 -0
- package/dist/core/fhe-type.js.map +1 -0
- package/dist/core/fhe.d.ts +11 -0
- package/dist/core/fhe.js +23 -0
- package/dist/core/fhe.js.map +1 -0
- package/dist/core/handle.d.ts +42 -0
- package/dist/core/handle.js +99 -0
- package/dist/core/handle.js.map +1 -0
- package/dist/core/json-utils.d.ts +18 -0
- package/dist/core/json-utils.js +37 -0
- package/dist/core/json-utils.js.map +1 -0
- package/dist/core/kms.d.ts +42 -0
- package/dist/core/kms.js +70 -0
- package/dist/core/kms.js.map +1 -0
- package/dist/core/logger.d.ts +3 -0
- package/dist/core/logger.js +11 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/pretty-print.d.ts +18 -0
- package/dist/core/pretty-print.js +84 -0
- package/dist/core/pretty-print.js.map +1 -0
- package/dist/core/primitives.d.ts +22 -0
- package/dist/core/primitives.js +2 -0
- package/dist/core/primitives.js.map +1 -0
- package/dist/core/retryable-handler.d.ts +74 -0
- package/dist/core/retryable-handler.js +227 -0
- package/dist/core/retryable-handler.js.map +1 -0
- package/dist/core/signer-address-info.d.ts +15 -0
- package/dist/core/signer-address-info.js +33 -0
- package/dist/core/signer-address-info.js.map +1 -0
- package/dist/core/string.d.ts +28 -0
- package/dist/core/string.js +33 -0
- package/dist/core/string.js.map +1 -0
- package/dist/core/swallow.d.ts +23 -0
- package/dist/core/swallow.js +37 -0
- package/dist/core/swallow.js.map +1 -0
- package/dist/core/system-contract-info.d.ts +17 -0
- package/dist/core/system-contract-info.js +41 -0
- package/dist/core/system-contract-info.js.map +1 -0
- package/dist/core/ttl-cache.d.ts +81 -0
- package/dist/core/ttl-cache.js +113 -0
- package/dist/core/ttl-cache.js.map +1 -0
- package/dist/core/tx-error-parser.d.ts +40 -0
- package/dist/core/tx-error-parser.js +83 -0
- package/dist/core/tx-error-parser.js.map +1 -0
- package/dist/core/utils.d.ts +62 -0
- package/dist/core/utils.js +143 -0
- package/dist/core/utils.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/jazz/encrypt-key-p.d.ts +65 -0
- package/dist/jazz/encrypt-key-p.js +283 -0
- package/dist/jazz/encrypt-key-p.js.map +1 -0
- package/dist/jazz/encrypt-p.d.ts +82 -0
- package/dist/jazz/encrypt-p.js +139 -0
- package/dist/jazz/encrypt-p.js.map +1 -0
- package/dist/jazz/encrypt.d.ts +58 -0
- package/dist/jazz/encrypt.js +155 -0
- package/dist/jazz/encrypt.js.map +1 -0
- package/dist/jazz/input-proof-p.d.ts +122 -0
- package/dist/jazz/input-proof-p.js +265 -0
- package/dist/jazz/input-proof-p.js.map +1 -0
- package/dist/jazz/jazz-client-i.d.ts +16 -0
- package/dist/jazz/jazz-client-i.js +2 -0
- package/dist/jazz/jazz-client-i.js.map +1 -0
- package/dist/jazz/jazz-client.d.ts +18 -0
- package/dist/jazz/jazz-client.js +24 -0
- package/dist/jazz/jazz-client.js.map +1 -0
- package/dist/jazz/key-pair.d.ts +50 -0
- package/dist/jazz/key-pair.js +166 -0
- package/dist/jazz/key-pair.js.map +1 -0
- package/dist/jazz/mock/fake.d.ts +3 -0
- package/dist/jazz/mock/fake.js +23 -0
- package/dist/jazz/mock/fake.js.map +1 -0
- package/dist/jazz/mock/fetch-input-proof.d.ts +4 -0
- package/dist/jazz/mock/fetch-input-proof.js +63 -0
- package/dist/jazz/mock/fetch-input-proof.js.map +1 -0
- package/dist/jazz/mock/fetch-key-url.d.ts +3 -0
- package/dist/jazz/mock/fetch-key-url.js +15 -0
- package/dist/jazz/mock/fetch-key-url.js.map +1 -0
- package/dist/jazz/mock/fetch-public-decrypt.d.ts +3 -0
- package/dist/jazz/mock/fetch-public-decrypt.js +81 -0
- package/dist/jazz/mock/fetch-public-decrypt.js.map +1 -0
- package/dist/jazz/mock/fetch-user-decrypt.d.ts +4 -0
- package/dist/jazz/mock/fetch-user-decrypt.js +174 -0
- package/dist/jazz/mock/fetch-user-decrypt.js.map +1 -0
- package/dist/jazz/module/fetch-input-proof.d.ts +19 -0
- package/dist/jazz/module/fetch-input-proof.js +72 -0
- package/dist/jazz/module/fetch-input-proof.js.map +1 -0
- package/dist/jazz/module/fetch-key-url.d.ts +17 -0
- package/dist/jazz/module/fetch-key-url.js +46 -0
- package/dist/jazz/module/fetch-key-url.js.map +1 -0
- package/dist/jazz/module/fetch-public-decrypt.d.ts +19 -0
- package/dist/jazz/module/fetch-public-decrypt.js +65 -0
- package/dist/jazz/module/fetch-public-decrypt.js.map +1 -0
- package/dist/jazz/module/fetch-user-decrypt.d.ts +19 -0
- package/dist/jazz/module/fetch-user-decrypt.js +109 -0
- package/dist/jazz/module/fetch-user-decrypt.js.map +1 -0
- package/dist/jazz/module/jazz-async-request.d.ts +102 -0
- package/dist/jazz/module/jazz-async-request.js +515 -0
- package/dist/jazz/module/jazz-async-request.js.map +1 -0
- package/dist/jazz/module/jazz-p.d.ts +61 -0
- package/dist/jazz/module/jazz-p.js +33 -0
- package/dist/jazz/module/jazz-p.js.map +1 -0
- package/dist/jazz/module/s3-download.d.ts +85 -0
- package/dist/jazz/module/s3-download.js +293 -0
- package/dist/jazz/module/s3-download.js.map +1 -0
- package/dist/jazz/permit.d.ts +200 -0
- package/dist/jazz/permit.js +319 -0
- package/dist/jazz/permit.js.map +1 -0
- package/dist/jazz/public-decrypt-p.d.ts +96 -0
- package/dist/jazz/public-decrypt-p.js +258 -0
- package/dist/jazz/public-decrypt-p.js.map +1 -0
- package/dist/jazz/public-decrypt.d.ts +48 -0
- package/dist/jazz/public-decrypt.js +156 -0
- package/dist/jazz/public-decrypt.js.map +1 -0
- package/dist/jazz/read-contract.d.ts +81 -0
- package/dist/jazz/read-contract.js +125 -0
- package/dist/jazz/read-contract.js.map +1 -0
- package/dist/jazz/types/common.d.ts +17 -0
- package/dist/jazz/types/common.js +2 -0
- package/dist/jazz/types/common.js.map +1 -0
- package/dist/jazz/types/input-proof.d.ts +76 -0
- package/dist/jazz/types/input-proof.js +2 -0
- package/dist/jazz/types/input-proof.js.map +1 -0
- package/dist/jazz/types/key-url.d.ts +68 -0
- package/dist/jazz/types/key-url.js +5 -0
- package/dist/jazz/types/key-url.js.map +1 -0
- package/dist/jazz/types/public-decrypt.d.ts +61 -0
- package/dist/jazz/types/public-decrypt.js +2 -0
- package/dist/jazz/types/public-decrypt.js.map +1 -0
- package/dist/jazz/types/user-decrypt.d.ts +123 -0
- package/dist/jazz/types/user-decrypt.js +2 -0
- package/dist/jazz/types/user-decrypt.js.map +1 -0
- package/dist/jazz/user-decrypt-p.d.ts +111 -0
- package/dist/jazz/user-decrypt-p.js +280 -0
- package/dist/jazz/user-decrypt-p.js.map +1 -0
- package/dist/jazz/user-decrypt.d.ts +74 -0
- package/dist/jazz/user-decrypt.js +143 -0
- package/dist/jazz/user-decrypt.js.map +1 -0
- package/dist/native/fhe-api.js +5959 -0
- package/dist/native/fhe-api.node.cjs +6167 -0
- package/dist/native/fhe-api.node.worker.cjs +210 -0
- package/dist/native/fhe-api.wasm +0 -0
- package/dist/native/fhe-api.worker.js +164 -0
- package/dist/native/kms/node/kms_lib.d.ts +38 -0
- package/dist/native/kms/node/kms_lib.js +356 -0
- package/dist/native/kms/node/kms_lib_bg.wasm +0 -0
- package/dist/native/kms/node/kms_lib_bg.wasm.d.ts +21 -0
- package/dist/native/kms/node/package.json +11 -0
- package/dist/native/kms/web/kms_lib.d.ts +84 -0
- package/dist/native/kms/web/kms_lib.js +443 -0
- package/dist/native/kms/web/kms_lib_bg.wasm +0 -0
- package/dist/native/kms/web/kms_lib_bg.wasm.d.ts +21 -0
- package/dist/native/kms/web/package.json +15 -0
- package/dist/runtime/browser.d.ts +36 -0
- package/dist/runtime/browser.js +115 -0
- package/dist/runtime/browser.js.map +1 -0
- package/dist/runtime/node.d.ts +30 -0
- package/dist/runtime/node.js +95 -0
- package/dist/runtime/node.js.map +1 -0
- package/dist/sdk/fhetransform-sdk-b.d.ts +102 -0
- package/dist/sdk/fhetransform-sdk-b.js +294 -0
- package/dist/sdk/fhetransform-sdk-b.js.map +1 -0
- package/dist/sdk/fhetransform-sdk.d.ts +87 -0
- package/dist/sdk/fhetransform-sdk.js +135 -0
- package/dist/sdk/fhetransform-sdk.js.map +1 -0
- package/dist/sdk/jazz-service.d.ts +13 -0
- package/dist/sdk/jazz-service.js +58 -0
- package/dist/sdk/jazz-service.js.map +1 -0
- package/dist/sdk/permit-service.d.ts +45 -0
- package/dist/sdk/permit-service.js +144 -0
- package/dist/sdk/permit-service.js.map +1 -0
- package/dist/wasm/fhe-wasm-client.d.ts +19 -0
- package/dist/wasm/fhe-wasm-client.js +23 -0
- package/dist/wasm/fhe-wasm-client.js.map +1 -0
- package/dist/wasm/fhe-wasm-module.d.ts +24 -0
- package/dist/wasm/fhe-wasm-module.js +141 -0
- package/dist/wasm/fhe-wasm-module.js.map +1 -0
- package/dist/wasm/fhe-wasm-type.d.ts +59 -0
- package/dist/wasm/fhe-wasm-type.js +244 -0
- package/dist/wasm/fhe-wasm-type.js.map +1 -0
- package/dist/wasm/wasm-loader.browser.d.ts +21 -0
- package/dist/wasm/wasm-loader.browser.js +143 -0
- package/dist/wasm/wasm-loader.browser.js.map +1 -0
- package/dist/wasm/wasm-loader.node.d.ts +24 -0
- package/dist/wasm/wasm-loader.node.js +114 -0
- package/dist/wasm/wasm-loader.node.js.map +1 -0
- package/dist/wasm/worker-client.browser.d.ts +6 -0
- package/dist/wasm/worker-client.browser.js +21 -0
- package/dist/wasm/worker-client.browser.js.map +1 -0
- package/dist/wasm/worker-client.d.ts +34 -0
- package/dist/wasm/worker-client.js +160 -0
- package/dist/wasm/worker-client.js.map +1 -0
- package/dist/wasm/worker-client.node.d.ts +6 -0
- package/dist/wasm/worker-client.node.js +20 -0
- package/dist/wasm/worker-client.node.js.map +1 -0
- package/dist/wasm/worker-message.d.ts +61 -0
- package/dist/wasm/worker-message.js +2 -0
- package/dist/wasm/worker-message.js.map +1 -0
- package/dist/wasm/worker-transport.browser.d.ts +15 -0
- package/dist/wasm/worker-transport.browser.js +35 -0
- package/dist/wasm/worker-transport.browser.js.map +1 -0
- package/dist/wasm/worker-transport.d.ts +6 -0
- package/dist/wasm/worker-transport.js +2 -0
- package/dist/wasm/worker-transport.js.map +1 -0
- package/dist/wasm/worker-transport.node.d.ts +17 -0
- package/dist/wasm/worker-transport.node.js +39 -0
- package/dist/wasm/worker-transport.node.js.map +1 -0
- package/dist/wasm/worker.d.ts +1 -0
- package/dist/wasm/worker.js +69 -0
- package/dist/wasm/worker.js.map +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { FheType, UnverifiedEncryptData } from "../core/fhe-type.js";
|
|
2
|
+
import { Address, BytesHex } from "../core/primitives.js";
|
|
3
|
+
import type { IJazzClient } from "./jazz-client-i.js";
|
|
4
|
+
import { JazzProcessOptions } from "./types/common.js";
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for encryption operations.
|
|
7
|
+
*/
|
|
8
|
+
export type EncryptOptions = JazzProcessOptions & {};
|
|
9
|
+
/**
|
|
10
|
+
* A single payload item to encrypt with its FHE type.
|
|
11
|
+
*/
|
|
12
|
+
export type EncryptPayloadItem = {
|
|
13
|
+
/** Value to encrypt (number or bigint) */
|
|
14
|
+
value: number | bigint;
|
|
15
|
+
/** FHE type (uint8, uint16, uint32, etc.) */
|
|
16
|
+
fheType: FheType;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Payload can be a single item or an array of items.
|
|
20
|
+
*/
|
|
21
|
+
export type EncryptPayload = EncryptPayloadItem | EncryptPayloadItem[];
|
|
22
|
+
/**
|
|
23
|
+
* Parameters for encryption operations.
|
|
24
|
+
*/
|
|
25
|
+
export type EncryptParameters<T extends EncryptPayload> = {
|
|
26
|
+
/** Payload(s) to encrypt */
|
|
27
|
+
readonly payloads: T;
|
|
28
|
+
/** Contract address (0x-prefixed) */
|
|
29
|
+
readonly contractAddress: Address;
|
|
30
|
+
/** User address (0x-prefixed) */
|
|
31
|
+
readonly userAddress: Address;
|
|
32
|
+
/** Additional options */
|
|
33
|
+
readonly options?: EncryptOptions;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Result of an encryption operation.
|
|
37
|
+
*/
|
|
38
|
+
export type EncryptResult<T extends EncryptPayload> = {
|
|
39
|
+
/** Encrypted values (single item or array matching input) */
|
|
40
|
+
readonly encryptedValues: T extends EncryptPayloadItem[] ? UnverifiedEncryptData[] : UnverifiedEncryptData;
|
|
41
|
+
/** Input proof as hex with 0x prefix */
|
|
42
|
+
readonly inputProof: BytesHex;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Encrypts a value or batch of values with zero-knowledge proof support.
|
|
46
|
+
*
|
|
47
|
+
* This function handles the complete encryption flow:
|
|
48
|
+
* 1. Encrypts values with ZK proof using the FHE WASM module
|
|
49
|
+
* 2. Submits the ciphertext to Jazz service for handle generation and attestation
|
|
50
|
+
* 3. Verifies alphatrion signatures
|
|
51
|
+
* 4. Creates and returns the input proof
|
|
52
|
+
*
|
|
53
|
+
* @param client - The Jazz client instance
|
|
54
|
+
* @param parameters - Encryption parameters
|
|
55
|
+
* @returns EncryptResult containing encrypted values and input proof
|
|
56
|
+
* @throws Error if encryption, proof fetch, or verification fails
|
|
57
|
+
*/
|
|
58
|
+
export declare function encryptValue<T extends EncryptPayload>(client: IJazzClient, parameters: EncryptParameters<T>): Promise<EncryptResult<T>>;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { bytesToHex, fromHexString } from "../core/bytes.js";
|
|
2
|
+
import { encryptWithZk, getMetadata } from "./encrypt-p.js";
|
|
3
|
+
import { verifyHandlesAlphatrionSignatures } from "./input-proof-p.js";
|
|
4
|
+
import { encodeProofData } from "./input-proof-p.js";
|
|
5
|
+
import { fetchInputProof } from "./module/fetch-input-proof.js";
|
|
6
|
+
import { fetchInputProof as fetchInputProofMock } from "./mock/fetch-input-proof.js";
|
|
7
|
+
import { getOrFetchPublickey } from "./encrypt-key-p.js";
|
|
8
|
+
import { logger } from "../core/logger.js";
|
|
9
|
+
import { formatValue } from "../core/pretty-print.js";
|
|
10
|
+
import { FheErrorCode } from "../core/errors/error-codes.js";
|
|
11
|
+
import { FheError } from "../core/errors/fhe-error.js";
|
|
12
|
+
import { assertChecksumAddress } from "../core/address.js";
|
|
13
|
+
import { FheTransformSDKEvents } from "../core/event.js";
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// Main Encryption Function
|
|
16
|
+
// ============================================================================
|
|
17
|
+
/**
|
|
18
|
+
* Encrypts a value or batch of values with zero-knowledge proof support.
|
|
19
|
+
*
|
|
20
|
+
* This function handles the complete encryption flow:
|
|
21
|
+
* 1. Encrypts values with ZK proof using the FHE WASM module
|
|
22
|
+
* 2. Submits the ciphertext to Jazz service for handle generation and attestation
|
|
23
|
+
* 3. Verifies alphatrion signatures
|
|
24
|
+
* 4. Creates and returns the input proof
|
|
25
|
+
*
|
|
26
|
+
* @param client - The Jazz client instance
|
|
27
|
+
* @param parameters - Encryption parameters
|
|
28
|
+
* @returns EncryptResult containing encrypted values and input proof
|
|
29
|
+
* @throws Error if encryption, proof fetch, or verification fails
|
|
30
|
+
*/
|
|
31
|
+
export async function encryptValue(client, parameters) {
|
|
32
|
+
let t0;
|
|
33
|
+
// Enter method
|
|
34
|
+
logger.debug(() => ['[encryptValue] Enter', formatValue({ parameters })]);
|
|
35
|
+
assertChecksumAddress(parameters.contractAddress, "contractAddress");
|
|
36
|
+
assertChecksumAddress(parameters.userAddress, "userAddress");
|
|
37
|
+
const isArray = Array.isArray(parameters.payloads);
|
|
38
|
+
const payloads = (isArray ? parameters.payloads : [parameters.payloads]);
|
|
39
|
+
const isMock = client.sdk.isMock();
|
|
40
|
+
const chainId = await client.sdk.getChainID();
|
|
41
|
+
const sysContractInfo = await client.sdk.getSystemContractInfo();
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// Step 0: Input Validation
|
|
44
|
+
// ============================================================================
|
|
45
|
+
// TODO: Add input validation here
|
|
46
|
+
// - Validate payloads are not empty
|
|
47
|
+
// - Validate contractAddress and userAddress are valid
|
|
48
|
+
// - Validate chainId is valid
|
|
49
|
+
// ============================================================================
|
|
50
|
+
// Step 1: Get or fetch Fhe Encryption Key and CRS
|
|
51
|
+
// ============================================================================
|
|
52
|
+
t0 = Date.now();
|
|
53
|
+
logger.debug('[encryptValue] Step 1: Get or fetch Fhe Encryption Key and CRS');
|
|
54
|
+
const pks = await getOrFetchPublickey(client, { isMock });
|
|
55
|
+
logger.debug('[encryptValue] Public keys fetched', {
|
|
56
|
+
pkSize: pks.pk.data.length,
|
|
57
|
+
crsSize: pks.crs.data.length,
|
|
58
|
+
});
|
|
59
|
+
client.sdk.emitEvent({ type: FheTransformSDKEvents.GetOrFetchPublickeyEnd, durationMs: Date.now() - t0 });
|
|
60
|
+
// Generate metadata for ZK proof
|
|
61
|
+
logger.debug('[encryptValue] Generating metadata');
|
|
62
|
+
const metadata = getMetadata({
|
|
63
|
+
chainId: chainId,
|
|
64
|
+
aclAddress: sysContractInfo.aclContractAddress,
|
|
65
|
+
contractAddress: parameters.contractAddress,
|
|
66
|
+
userAddress: parameters.userAddress,
|
|
67
|
+
});
|
|
68
|
+
logger.trace('[encryptValue] Metadata generated', {
|
|
69
|
+
metadataSize: metadata.length,
|
|
70
|
+
});
|
|
71
|
+
// ============================================================================
|
|
72
|
+
// Step 2: Encrypt with ZK Proof
|
|
73
|
+
// ============================================================================
|
|
74
|
+
logger.debug('[encryptValue] Step 2: Encrypt with ZK Proof');
|
|
75
|
+
// Perform ZK encryption
|
|
76
|
+
const encryptWithZkParameters = {
|
|
77
|
+
payloads,
|
|
78
|
+
pks,
|
|
79
|
+
metadata,
|
|
80
|
+
};
|
|
81
|
+
t0 = Date.now();
|
|
82
|
+
logger.debug(() => ['[encryptValue] Performing ZK encryption', formatValue({ encryptWithZkParameters })]);
|
|
83
|
+
const ciphertextWithZKProof = await encryptWithZk(encryptWithZkParameters);
|
|
84
|
+
logger.debug(() => ['[encryptValue] ZK encryption completed', formatValue({ ciphertextWithZKProof })]);
|
|
85
|
+
client.sdk.emitEvent({ type: FheTransformSDKEvents.EncryptWithZkEnd, durationMs: Date.now() - t0 });
|
|
86
|
+
// ============================================================================
|
|
87
|
+
// Step 3: Fetch Handles and Signatures from Jazz
|
|
88
|
+
// ============================================================================
|
|
89
|
+
logger.debug('[encryptValue] Step 3: Fetching input proof from Jazz');
|
|
90
|
+
const zkProof = {
|
|
91
|
+
chainId: chainId,
|
|
92
|
+
aclContractAddress: sysContractInfo.aclContractAddress,
|
|
93
|
+
contractAddress: parameters.contractAddress,
|
|
94
|
+
userAddress: parameters.userAddress,
|
|
95
|
+
ciphertextWithZkProof: ciphertextWithZKProof,
|
|
96
|
+
};
|
|
97
|
+
const fetchInputProofParameters = {
|
|
98
|
+
payload: {
|
|
99
|
+
zkProof,
|
|
100
|
+
},
|
|
101
|
+
options: { ...parameters.options },
|
|
102
|
+
};
|
|
103
|
+
let result;
|
|
104
|
+
client.sdk.emitEvent({ type: FheTransformSDKEvents.FetchInputProofStart });
|
|
105
|
+
t0 = Date.now();
|
|
106
|
+
if (isMock) {
|
|
107
|
+
logger.trace('[encryptValue] Using mock mode for input proof fetch');
|
|
108
|
+
result = await fetchInputProofMock(client, fetchInputProofParameters, [...payloads]);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
logger.trace('[encryptValue] Using production mode for input proof fetch');
|
|
112
|
+
result = await fetchInputProof(client, fetchInputProofParameters);
|
|
113
|
+
}
|
|
114
|
+
client.sdk.emitEvent({ type: FheTransformSDKEvents.FetchInputProofEnd, durationMs: Date.now() - t0 });
|
|
115
|
+
logger.debug(() => ['[encryptValue] Input proof fetched', formatValue({ result })]);
|
|
116
|
+
if (!result.handles || result.handles.length === 0) {
|
|
117
|
+
throw new FheError({ code: FheErrorCode.JazzUnexpectedResponse, message: "Jazz returned no handles" });
|
|
118
|
+
}
|
|
119
|
+
// ============================================================================
|
|
120
|
+
// Step 4: Verify Alphatrion Signatures
|
|
121
|
+
// ============================================================================
|
|
122
|
+
t0 = Date.now();
|
|
123
|
+
logger.debug('[encryptValue] Step 4: Verifying alphatrion signatures');
|
|
124
|
+
await verifyHandlesAlphatrionSignatures(client, {
|
|
125
|
+
chainId: chainId,
|
|
126
|
+
verifyingContract: sysContractInfo.ciphertextVerificationAddress,
|
|
127
|
+
userAddress: parameters.userAddress,
|
|
128
|
+
contractAddress: parameters.contractAddress,
|
|
129
|
+
}, result);
|
|
130
|
+
logger.debug('[encryptValue] Alphatrion signatures verified successfully');
|
|
131
|
+
client.sdk.emitEvent({ type: FheTransformSDKEvents.VerifyAlphatrionSignaturesEnd, durationMs: Date.now() - t0 });
|
|
132
|
+
// ============================================================================
|
|
133
|
+
// Step 5: Create Input Proof
|
|
134
|
+
// ============================================================================
|
|
135
|
+
logger.debug('[encryptValue] Step 5: Creating input proof');
|
|
136
|
+
const inputProofBytes = encodeProofData([...result.handles], [...result.alphatrionEip712Signatures], fromHexString(result.extraData));
|
|
137
|
+
const inputProof = bytesToHex(inputProofBytes);
|
|
138
|
+
logger.trace('[encryptValue] Input proof encoded', {
|
|
139
|
+
proofSize: inputProofBytes.length,
|
|
140
|
+
proofHexLength: inputProof.length,
|
|
141
|
+
});
|
|
142
|
+
// ============================================================================
|
|
143
|
+
// Step 6: Build Result
|
|
144
|
+
// ============================================================================
|
|
145
|
+
const results = result.handles.map((handle, index) => ({
|
|
146
|
+
handle: handle,
|
|
147
|
+
data: inputProof,
|
|
148
|
+
}));
|
|
149
|
+
logger.info(() => ['[encryptValue] Encryption completed successfully', formatValue({ results })]);
|
|
150
|
+
return {
|
|
151
|
+
encryptedValues: isArray ? results : results[0],
|
|
152
|
+
inputProof,
|
|
153
|
+
};
|
|
154
|
+
}
|
|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,CAAC,GAAG,EAAE,CAAC,CAAC,kDAAkD,EAAE,WAAW,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;IAElG,OAAO;QACL,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QAC/C,UAAU;KACS,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { Address, Bytes32Hex, BytesHex } from "../core/primitives.js";
|
|
2
|
+
import { FetchInputProofResult } from "./types/input-proof.js";
|
|
3
|
+
import type { IJazzClient } from "./jazz-client-i.js";
|
|
4
|
+
/**
|
|
5
|
+
* EIP-712 domain for alphatrion ciphertext verification.
|
|
6
|
+
*/
|
|
7
|
+
export type AlphatrionEip712Domain = Readonly<{
|
|
8
|
+
/** Domain name */
|
|
9
|
+
name: 'CiphertextVerification';
|
|
10
|
+
/** Domain version */
|
|
11
|
+
version: '1';
|
|
12
|
+
/** Chain ID */
|
|
13
|
+
chainId: bigint;
|
|
14
|
+
/** Contract address that verifies the signatures */
|
|
15
|
+
verifyingContract: Address;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* EIP-712 message for alphatrion ciphertext verification.
|
|
19
|
+
*/
|
|
20
|
+
export type AlphatrionEip712Message = Readonly<{
|
|
21
|
+
/** List of ciphertext handles (32-byte hex with 0x prefix) */
|
|
22
|
+
ctHandles: readonly Bytes32Hex[];
|
|
23
|
+
/** User address (0x-prefixed) */
|
|
24
|
+
userAddress: Address;
|
|
25
|
+
/** Contract address (0x-prefixed) */
|
|
26
|
+
contractAddress: Address;
|
|
27
|
+
/** Chain ID */
|
|
28
|
+
chainId: bigint;
|
|
29
|
+
/** Additional contextual data */
|
|
30
|
+
extraData: BytesHex;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* EIP-712 message with hex string types (alias).
|
|
34
|
+
*/
|
|
35
|
+
export type AlphatrionEip712MessageHex = Readonly<{
|
|
36
|
+
ctHandles: readonly Bytes32Hex[];
|
|
37
|
+
userAddress: Address;
|
|
38
|
+
contractAddress: Address;
|
|
39
|
+
chainId: bigint;
|
|
40
|
+
extraData: BytesHex;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* EIP-712 type definitions for alphatrion verification.
|
|
44
|
+
*/
|
|
45
|
+
export type AlphatrionEip712Types = {
|
|
46
|
+
readonly CiphertextVerificationSignData: readonly [
|
|
47
|
+
{
|
|
48
|
+
readonly name: 'ctHandles';
|
|
49
|
+
readonly type: 'bytes32[]';
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
readonly name: 'userAddress';
|
|
53
|
+
readonly type: 'address';
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
readonly name: 'contractAddress';
|
|
57
|
+
readonly type: 'address';
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
readonly name: 'chainId';
|
|
61
|
+
readonly type: 'uint256';
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
readonly name: 'extraData';
|
|
65
|
+
readonly type: 'bytes';
|
|
66
|
+
}
|
|
67
|
+
];
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Complete EIP-712 structure for alphatrion verification.
|
|
71
|
+
*/
|
|
72
|
+
export type AlphatrionEip712 = {
|
|
73
|
+
readonly domain: AlphatrionEip712Domain;
|
|
74
|
+
readonly types: AlphatrionEip712Types;
|
|
75
|
+
readonly message: AlphatrionEip712Message;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Primary type name for alphatrion EIP-712 verification.
|
|
79
|
+
*/
|
|
80
|
+
export declare const alphatrionEip712PrimaryType = "CiphertextVerificationSignData";
|
|
81
|
+
/**
|
|
82
|
+
* EIP-712 type definitions for alphatrion verification.
|
|
83
|
+
*
|
|
84
|
+
* CRITICAL: Field order is authoritative — it determines the EIP-712 type hash.
|
|
85
|
+
* Changing the order will produce a different signature and break on-chain verification.
|
|
86
|
+
* Must match the Solidity struct definition exactly.
|
|
87
|
+
*/
|
|
88
|
+
export declare const alphatrionEip712Types: AlphatrionEip712Types;
|
|
89
|
+
/**
|
|
90
|
+
* Verifies alphatrion EIP-712 signatures against the Alphatrion signer set.
|
|
91
|
+
*
|
|
92
|
+
* This function:
|
|
93
|
+
* 1. Reconstructs the EIP-712 message from the result
|
|
94
|
+
* 2. Recovers the signer addresses from each signature
|
|
95
|
+
* 3. Verifies all recovered addresses are in the Alphatrion signer set
|
|
96
|
+
* 4. Verifies the threshold is met
|
|
97
|
+
*
|
|
98
|
+
* @param client - The Jazz client instance
|
|
99
|
+
* @param params - Verification parameters (chainId, verifyingContract, userAddress, contractAddress)
|
|
100
|
+
* @param result - Input proof result containing handles and signatures
|
|
101
|
+
* @throws Error if verification fails (unknown signer, threshold not met, invalid signature)
|
|
102
|
+
*/
|
|
103
|
+
export declare function verifyHandlesAlphatrionSignatures(client: IJazzClient, params: {
|
|
104
|
+
chainId: bigint;
|
|
105
|
+
verifyingContract: Address;
|
|
106
|
+
userAddress: Address;
|
|
107
|
+
contractAddress: Address;
|
|
108
|
+
}, result: FetchInputProofResult): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Encodes proof data according to the spacebridge-contracts verification format.
|
|
111
|
+
*
|
|
112
|
+
* Format:
|
|
113
|
+
* numHandles (1 byte) + numSigners (1 byte) + handles (32 bytes each) +
|
|
114
|
+
* signatures (65 bytes each) + extraData (variable length)
|
|
115
|
+
*
|
|
116
|
+
* @param ctHandles - Array of ciphertext handles (hex strings with 0x prefix)
|
|
117
|
+
* @param signatures - Array of signatures (hex strings with 0x prefix)
|
|
118
|
+
* @param extraData - Additional contextual data as Uint8Array
|
|
119
|
+
* @returns Encoded proof as Uint8Array
|
|
120
|
+
* @throws Error if numHandles or numSigners exceeds 255, or if handle/signature lengths are invalid
|
|
121
|
+
*/
|
|
122
|
+
export declare function encodeProofData(ctHandles: string[], signatures: string[], extraData: Uint8Array): Uint8Array;
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import { logger } from "../core/logger.js";
|
|
3
|
+
import { formatValue } from "../core/pretty-print.js";
|
|
4
|
+
import { readAlphatrionSignersInfo } from "./read-contract.js";
|
|
5
|
+
import { FheErrorCode } from "../core/errors/error-codes.js";
|
|
6
|
+
import { FheError } from "../core/errors/fhe-error.js";
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// EIP-712 Constants
|
|
9
|
+
// ============================================================================
|
|
10
|
+
/**
|
|
11
|
+
* Primary type name for alphatrion EIP-712 verification.
|
|
12
|
+
*/
|
|
13
|
+
export const alphatrionEip712PrimaryType = 'CiphertextVerificationSignData';
|
|
14
|
+
/**
|
|
15
|
+
* EIP-712 type definitions for alphatrion verification.
|
|
16
|
+
*
|
|
17
|
+
* CRITICAL: Field order is authoritative — it determines the EIP-712 type hash.
|
|
18
|
+
* Changing the order will produce a different signature and break on-chain verification.
|
|
19
|
+
* Must match the Solidity struct definition exactly.
|
|
20
|
+
*/
|
|
21
|
+
export const alphatrionEip712Types = {
|
|
22
|
+
// EIP712Domain: [
|
|
23
|
+
// { name: 'name', type: 'string' },
|
|
24
|
+
// { name: 'version', type: 'string' },
|
|
25
|
+
// { name: 'chainId', type: 'uint256' },
|
|
26
|
+
// { name: 'verifyingContract', type: 'address' },
|
|
27
|
+
// ] as const,
|
|
28
|
+
// CRITICAL: Field order is authoritative — it determines the EIP-712 type hash.
|
|
29
|
+
// Changing the order will produce a different signature and break on-chain verification.
|
|
30
|
+
// Must match the Solidity struct definition exactly.
|
|
31
|
+
CiphertextVerificationSignData: [
|
|
32
|
+
{ name: 'ctHandles', type: 'bytes32[]' },
|
|
33
|
+
{ name: 'userAddress', type: 'address' },
|
|
34
|
+
{ name: 'contractAddress', type: 'address' },
|
|
35
|
+
{ name: 'chainId', type: 'uint256' },
|
|
36
|
+
{ name: 'extraData', type: 'bytes' },
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// Signature Verification
|
|
41
|
+
// ============================================================================
|
|
42
|
+
/**
|
|
43
|
+
* Verifies alphatrion EIP-712 signatures against the Alphatrion signer set.
|
|
44
|
+
*
|
|
45
|
+
* This function:
|
|
46
|
+
* 1. Reconstructs the EIP-712 message from the result
|
|
47
|
+
* 2. Recovers the signer addresses from each signature
|
|
48
|
+
* 3. Verifies all recovered addresses are in the Alphatrion signer set
|
|
49
|
+
* 4. Verifies the threshold is met
|
|
50
|
+
*
|
|
51
|
+
* @param client - The Jazz client instance
|
|
52
|
+
* @param params - Verification parameters (chainId, verifyingContract, userAddress, contractAddress)
|
|
53
|
+
* @param result - Input proof result containing handles and signatures
|
|
54
|
+
* @throws Error if verification fails (unknown signer, threshold not met, invalid signature)
|
|
55
|
+
*/
|
|
56
|
+
export async function verifyHandlesAlphatrionSignatures(client, params, result) {
|
|
57
|
+
// Enter method
|
|
58
|
+
logger.debug(() => ['[verifyHandlesAlphatrionSignatures] Enter', formatValue({ params, result })]);
|
|
59
|
+
// ============================================================================
|
|
60
|
+
// Step 1: Build EIP-712 Domain and Message
|
|
61
|
+
// ============================================================================
|
|
62
|
+
const domain = {
|
|
63
|
+
name: 'CiphertextVerification',
|
|
64
|
+
version: '1',
|
|
65
|
+
chainId: params.chainId,
|
|
66
|
+
verifyingContract: params.verifyingContract,
|
|
67
|
+
};
|
|
68
|
+
const types = alphatrionEip712Types;
|
|
69
|
+
const primaryType = 'CiphertextVerificationSignData';
|
|
70
|
+
const message = {
|
|
71
|
+
ctHandles: [...result.handles],
|
|
72
|
+
userAddress: params.userAddress,
|
|
73
|
+
contractAddress: params.contractAddress,
|
|
74
|
+
chainId: params.chainId,
|
|
75
|
+
extraData: result.extraData,
|
|
76
|
+
};
|
|
77
|
+
logger.debug(() => ['[verifyHandlesAlphatrionSignatures] EIP-712 built',
|
|
78
|
+
formatValue({ domain, types, primaryType, message })]);
|
|
79
|
+
// ============================================================================
|
|
80
|
+
// Step 2: Recover Signer Addresses
|
|
81
|
+
// ============================================================================
|
|
82
|
+
const primaryTypeFields = types[primaryType];
|
|
83
|
+
if (primaryTypeFields === undefined) {
|
|
84
|
+
logger.error('[verifyHandlesAlphatrionSignatures] Primary type not found', { primaryType });
|
|
85
|
+
throw new FheError({ code: FheErrorCode.Internal, message: `Primary type "${primaryType}" not found in types` });
|
|
86
|
+
}
|
|
87
|
+
const typesToSign = {
|
|
88
|
+
[primaryType]: [...primaryTypeFields],
|
|
89
|
+
};
|
|
90
|
+
const signatures = result.alphatrionEip712Signatures;
|
|
91
|
+
const recoveredAddresses = await Promise.all(signatures.map(async (signature, index) => {
|
|
92
|
+
try {
|
|
93
|
+
const signerAddress = ethers.verifyTypedData(domain, typesToSign, message, signature);
|
|
94
|
+
logger.debug('[verifyHandlesAlphatrionSignatures] Signature recovered', {
|
|
95
|
+
index,
|
|
96
|
+
signature: signature.substring(0, 20) + '...',
|
|
97
|
+
signerAddress,
|
|
98
|
+
});
|
|
99
|
+
return signerAddress;
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
logger.error('[verifyHandlesAlphatrionSignatures] Failed to recover signature', {
|
|
103
|
+
index,
|
|
104
|
+
error: error.message,
|
|
105
|
+
});
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
}));
|
|
109
|
+
logger.debug('[verifyHandlesAlphatrionSignatures] Recovered addresses', {
|
|
110
|
+
recoveredAddresses,
|
|
111
|
+
});
|
|
112
|
+
// ============================================================================
|
|
113
|
+
// Step 3: Verify Against Alphatrion Signer Set
|
|
114
|
+
// ============================================================================
|
|
115
|
+
const { alphatrionSigners, alphatrionThreshold } = await readAlphatrionSignersInfo(client);
|
|
116
|
+
// Verify all recovered signers are in the Alphatrion signer set
|
|
117
|
+
const isInclude = recoveredAddresses.every(item => alphatrionSigners.includes(item));
|
|
118
|
+
if (!isInclude) {
|
|
119
|
+
logger.error('[verifyHandlesAlphatrionSignatures] Unknown Alphatrion signer detected', {
|
|
120
|
+
recoveredAddresses,
|
|
121
|
+
allowedSigners: alphatrionSigners,
|
|
122
|
+
});
|
|
123
|
+
throw new FheError({ code: FheErrorCode.UnknownSigner, message: 'Unknown Alphatrion Signer' });
|
|
124
|
+
}
|
|
125
|
+
// Verify threshold is met
|
|
126
|
+
if (recoveredAddresses.length < alphatrionThreshold) {
|
|
127
|
+
logger.error('[verifyHandlesAlphatrionSignatures] Threshold not met', {
|
|
128
|
+
recoveredCount: recoveredAddresses.length,
|
|
129
|
+
threshold: alphatrionThreshold,
|
|
130
|
+
});
|
|
131
|
+
throw new FheError({ code: FheErrorCode.ThresholdNotMet, message: 'recovered signer addresses should >= threshold' });
|
|
132
|
+
}
|
|
133
|
+
logger.info('[verifyHandlesAlphatrionSignatures] All signatures verified successfully', {
|
|
134
|
+
recoveredCount: recoveredAddresses.length,
|
|
135
|
+
threshold: alphatrionThreshold,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
// ============================================================================
|
|
139
|
+
// Proof Encoding
|
|
140
|
+
// ============================================================================
|
|
141
|
+
/**
|
|
142
|
+
* Encodes proof data according to the spacebridge-contracts verification format.
|
|
143
|
+
*
|
|
144
|
+
* Format:
|
|
145
|
+
* numHandles (1 byte) + numSigners (1 byte) + handles (32 bytes each) +
|
|
146
|
+
* signatures (65 bytes each) + extraData (variable length)
|
|
147
|
+
*
|
|
148
|
+
* @param ctHandles - Array of ciphertext handles (hex strings with 0x prefix)
|
|
149
|
+
* @param signatures - Array of signatures (hex strings with 0x prefix)
|
|
150
|
+
* @param extraData - Additional contextual data as Uint8Array
|
|
151
|
+
* @returns Encoded proof as Uint8Array
|
|
152
|
+
* @throws Error if numHandles or numSigners exceeds 255, or if handle/signature lengths are invalid
|
|
153
|
+
*/
|
|
154
|
+
export function encodeProofData(ctHandles, signatures, extraData) {
|
|
155
|
+
// Enter method
|
|
156
|
+
logger.debug(() => ['[encodeProofData] Enter', formatValue({ ctHandles, signatures, extraData })]);
|
|
157
|
+
const numHandles = ctHandles.length;
|
|
158
|
+
const numSigners = signatures.length;
|
|
159
|
+
// ============================================================================
|
|
160
|
+
// Step 1: Validate Inputs
|
|
161
|
+
// ============================================================================
|
|
162
|
+
// Validate counts fit in 1 byte (max 255)
|
|
163
|
+
if (numHandles > 255 || numSigners > 255) {
|
|
164
|
+
logger.error('[encodeProofData] Counts exceed 255', {
|
|
165
|
+
numHandles,
|
|
166
|
+
numSigners,
|
|
167
|
+
});
|
|
168
|
+
throw new FheError({ code: FheErrorCode.InvalidArgument, message: `numHandles:${numHandles} or numSigners:${numSigners} must fit in 1 byte` });
|
|
169
|
+
}
|
|
170
|
+
// Validate and convert handles to bytes
|
|
171
|
+
logger.trace('[encodeProofData] Validating handles');
|
|
172
|
+
const handlesBytes = ctHandles.map((h, i) => {
|
|
173
|
+
const b = ethers.getBytes(h);
|
|
174
|
+
if (b.length !== 32) {
|
|
175
|
+
logger.error('[encodeProofData] Invalid handle length', {
|
|
176
|
+
index: i,
|
|
177
|
+
handle: h.substring(0, 20) + '...',
|
|
178
|
+
expected: 32,
|
|
179
|
+
actual: b.length,
|
|
180
|
+
});
|
|
181
|
+
throw new FheError({ code: FheErrorCode.InvalidArgument, message: `the length of handle ${i} != 32 bytes` });
|
|
182
|
+
}
|
|
183
|
+
return b;
|
|
184
|
+
});
|
|
185
|
+
// Validate and convert signatures to bytes
|
|
186
|
+
logger.trace('[encodeProofData] Validating signatures');
|
|
187
|
+
const sigBytes = signatures.map((s, i) => {
|
|
188
|
+
const b = ethers.getBytes(s);
|
|
189
|
+
if (b.length !== 65) {
|
|
190
|
+
logger.error('[encodeProofData] Invalid signature length', {
|
|
191
|
+
index: i,
|
|
192
|
+
signature: s.substring(0, 20) + '...',
|
|
193
|
+
expected: 65,
|
|
194
|
+
actual: b.length,
|
|
195
|
+
});
|
|
196
|
+
throw new FheError({ code: FheErrorCode.InvalidArgument, message: `the length of signature ${i} != 65 bytes` });
|
|
197
|
+
}
|
|
198
|
+
return b;
|
|
199
|
+
});
|
|
200
|
+
// ============================================================================
|
|
201
|
+
// Step 2: Build Encoded Proof
|
|
202
|
+
// ============================================================================
|
|
203
|
+
// Calculate total length: header(2) + handles(32*n) + signatures(65*m) + extraData
|
|
204
|
+
const totalLen = 1 + 1 + 32 * numHandles + 65 * numSigners + extraData.length;
|
|
205
|
+
const proof = new Uint8Array(totalLen);
|
|
206
|
+
let offset = 0;
|
|
207
|
+
logger.trace('[encodeProofData] Encoding proof data', {
|
|
208
|
+
totalLength: totalLen,
|
|
209
|
+
headerSize: 2,
|
|
210
|
+
handlesSize: 32 * numHandles,
|
|
211
|
+
signaturesSize: 65 * numSigners,
|
|
212
|
+
extraDataSize: extraData.length,
|
|
213
|
+
});
|
|
214
|
+
// Header: numHandles + numSigners (1 byte each)
|
|
215
|
+
proof[offset++] = numHandles;
|
|
216
|
+
proof[offset++] = numSigners;
|
|
217
|
+
// Handles (32 bytes each)
|
|
218
|
+
for (let i = 0; i < handlesBytes.length; i++) {
|
|
219
|
+
const b = handlesBytes[i];
|
|
220
|
+
proof.set(b, offset);
|
|
221
|
+
offset += 32;
|
|
222
|
+
logger.trace('[encodeProofData] Encoded handle', {
|
|
223
|
+
index: i,
|
|
224
|
+
offset: offset - 32,
|
|
225
|
+
size: b.length,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
// Signatures (65 bytes each)
|
|
229
|
+
for (let i = 0; i < sigBytes.length; i++) {
|
|
230
|
+
const b = sigBytes[i];
|
|
231
|
+
proof.set(b, offset);
|
|
232
|
+
offset += 65;
|
|
233
|
+
logger.trace('[encodeProofData] Encoded signature', {
|
|
234
|
+
index: i,
|
|
235
|
+
offset: offset - 65,
|
|
236
|
+
size: b.length,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
// Extra data (variable length)
|
|
240
|
+
if (extraData.length > 0) {
|
|
241
|
+
proof.set(extraData, offset);
|
|
242
|
+
offset += extraData.length;
|
|
243
|
+
logger.trace('[encodeProofData] Encoded extra data', {
|
|
244
|
+
size: extraData.length,
|
|
245
|
+
offset: offset - extraData.length,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
// Verify encoding offset matches total length
|
|
249
|
+
if (offset !== totalLen) {
|
|
250
|
+
logger.error('[encodeProofData] Length mismatch', {
|
|
251
|
+
offset,
|
|
252
|
+
totalLen,
|
|
253
|
+
diff: offset - totalLen,
|
|
254
|
+
});
|
|
255
|
+
throw new FheError({ code: FheErrorCode.Internal, message: `proof encoding length mismatch: offset(${offset}) !== totalLen(${totalLen})` });
|
|
256
|
+
}
|
|
257
|
+
logger.info('[encodeProofData] Proof encoded successfully', {
|
|
258
|
+
totalBytes: totalLen,
|
|
259
|
+
numHandles,
|
|
260
|
+
numSigners,
|
|
261
|
+
extraDataSize: extraData.length,
|
|
262
|
+
});
|
|
263
|
+
return proof;
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=input-proof-p.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-proof-p.js","sourceRoot":"","sources":["../../src/jazz/input-proof-p.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAK3C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAqEvD,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,gCAAsE,CAAC;AAElH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA0B;IAC1D,kBAAkB;IAClB,sCAAsC;IACtC,yCAAyC;IACzC,0CAA0C;IAC1C,oDAAo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MAAM,CAAC;QAC3B,MAAM,CAAC,KAAK,CAAC,sCAAsC,EAAE;YACnD,IAAI,EAAE,SAAS,CAAC,MAAM;YACtB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM;SAClC,CAAC,CAAC;IACL,CAAC;IAED,8CAA8C;IAC9C,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QACxB,MAAM,CAAC,KAAK,CAAC,mCAAmC,EAAE;YAChD,MAAM;YACN,QAAQ;YACR,IAAI,EAAE,MAAM,GAAG,QAAQ;SACxB,CAAC,CAAC;QACH,MAAM,IAAI,QAAQ,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,0CAA0C,MAAM,kBAAkB,QAAQ,GAAG,EAAE,CAAC,CAAC;IAC9I,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,8CAA8C,EAAE;QAC1D,UAAU,EAAE,QAAQ;QACpB,UAAU;QACV,UAAU;QACV,aAAa,EAAE,SAAS,CAAC,MAAM;KAChC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EncryptParameters, EncryptPayload, EncryptResult } from "./encrypt.js";
|
|
2
|
+
import { GenerateTransportKeyPairResult } from "./key-pair.js";
|
|
3
|
+
import { SignDecryptionPermitParameters, SignedDecryptionPermitResult } from "./permit.js";
|
|
4
|
+
import { PublicDecryptParameters, PublicDecryptPayload, PublicDecryptResult } from "./public-decrypt.js";
|
|
5
|
+
import { UserDecryptParameters, UserDecryptPayload, UserDecryptResult } from "./user-decrypt.js";
|
|
6
|
+
import type { FheTransformSDK } from "../sdk/fhetransform-sdk.js";
|
|
7
|
+
export interface JazzConfig {
|
|
8
|
+
}
|
|
9
|
+
export interface IJazzClient {
|
|
10
|
+
readonly sdk: FheTransformSDK;
|
|
11
|
+
encryptValue<T extends EncryptPayload>(parameters: EncryptParameters<T>): Promise<EncryptResult<T>>;
|
|
12
|
+
decryptPublicValue<T extends PublicDecryptPayload>(parameters: PublicDecryptParameters<T>): Promise<PublicDecryptResult<T>>;
|
|
13
|
+
generateTransportKeyPair(): Promise<GenerateTransportKeyPairResult>;
|
|
14
|
+
signDecryptionPermit(parameters: SignDecryptionPermitParameters): Promise<SignedDecryptionPermitResult>;
|
|
15
|
+
decryptUserValue<T extends UserDecryptPayload>(parameters: UserDecryptParameters<T>): Promise<UserDecryptResult<T>>;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jazz-client-i.js","sourceRoot":"","sources":["../../src/jazz/jazz-client-i.ts"],"names":[],"mappings":""}
|