@zama-fhe/relayer-sdk 0.4.0-alpha.0 → 0.4.0-alpha.2

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/lib/web.d.ts CHANGED
@@ -1,61 +1,35 @@
1
- import { Eip1193Provider } from 'ethers';
1
+ import type { ApiKeyCookie } from './types/relayer';
2
+ import type { ApiKeyHeader } from './types/relayer';
3
+ import type { Auth } from './types/relayer';
4
+ import type { BearerToken } from './types/relayer';
5
+ import type { ClearValues } from './types/relayer';
6
+ import type { ClearValueType } from './types/relayer';
7
+ import { EncryptionBits } from './types/primitives';
8
+ import type { EncryptionBits as EncryptionBits_2 } from '../types/primitives';
9
+ import type { FhevmInstanceConfig } from './types/relayer';
10
+ import type { FhevmInstanceOptions } from './types/relayer';
2
11
  import { InitInput as KMSInput } from 'tkms';
3
- import { Prettify } from './utils/types';
12
+ import type { PublicDecryptResults } from './types/relayer';
13
+ import type { RelayerV2InputProofOptions } from '../relayer-provider/v2/types/types';
14
+ import type { RelayerV2InputProofOptions as RelayerV2InputProofOptions_2 } from './relayer-provider/v2/types/types';
15
+ import type { RelayerV2PublicDecryptOptions } from './relayer-provider/v2/types/types';
16
+ import type { RelayerV2UserDecryptOptions } from './relayer-provider/v2/types/types';
4
17
  import { InitInput as TFHEInput } from 'tfhe';
18
+ import type { UserDecryptResults } from './types/relayer';
19
+ import type { ZKProof } from '../types/primitives';
20
+ import type { ZKProof as ZKProof_2 } from './types/primitives';
5
21
 
6
- /**
7
- * Custom cookie authentication
8
- */
9
- export declare type ApiKeyCookie = {
10
- __type: 'ApiKeyCookie';
11
- /**
12
- * The cookie name. The default value is `x-api-key`.
13
- */
14
- cookie?: string;
15
- /**
16
- * The API key.
17
- */
18
- value: string;
19
- };
22
+ export { ApiKeyCookie }
20
23
 
21
- /**
22
- * Custom header authentication
23
- */
24
- export declare type ApiKeyHeader = {
25
- __type: 'ApiKeyHeader';
26
- /**
27
- * The header name. The default value is `x-api-key`.
28
- */
29
- header?: string;
30
- /**
31
- * The API key.
32
- */
33
- value: string;
34
- };
24
+ export { ApiKeyHeader }
35
25
 
36
- /**
37
- * Set the authentication method for the request. The default is no authentication.
38
- * It supports:
39
- * - Bearer Token
40
- * - Custom header
41
- * - Custom cookie
42
- */
43
- export declare type Auth = BearerToken | ApiKeyHeader | ApiKeyCookie;
26
+ export { Auth }
44
27
 
45
- /**
46
- * Bearer Token Authentication
47
- */
48
- export declare type BearerToken = {
49
- __type: 'BearerToken';
50
- /**
51
- * The Bearer token.
52
- */
53
- token: string;
54
- };
28
+ export { BearerToken }
55
29
 
56
- export declare type ClearValues = Record<`0x${string}`, ClearValueType>;
30
+ export { ClearValues }
57
31
 
58
- export declare type ClearValueType = bigint | boolean | `0x${string}`;
32
+ export { ClearValueType }
59
33
 
60
34
  /**
61
35
  * Creates an EIP712 structure specifically for user decrypt requests
@@ -93,49 +67,21 @@ export declare type EIP712Type = {
93
67
  type: string;
94
68
  };
95
69
 
96
- /**
97
- * **FHE Type Mapping for Input Builders**
98
- * * Maps the **number of encrypted bits** used by a FHEVM primary type
99
- * to its corresponding **FheTypeId**. This constant is primarily used by
100
- * `EncryptedInput` and `RelayerEncryptedInput` builders to determine the correct
101
- * input type and calculate the total required bit-length.
102
- *
103
- * **Structure: \{ Encrypted Bit Length: FheTypeId \}**
104
- *
105
- * | Bits | FheTypeId | FHE Type Name | Note |
106
- * | :--- | :-------- | :------------ | :--- |
107
- * | 2 | 0 | `ebool` | The boolean type. |
108
- * | (N/A)| 1 | `euint4` | **Deprecated** and omitted from this map. |
109
- * | 8 | 2 | `euint8` | |
110
- * | 16 | 3 | `euint16` | |
111
- * | 32 | 4 | `euint32` | |
112
- * | 64 | 5 | `euint64` | |
113
- * | 128 | 6 | `euint128` | |
114
- * | 160 | 7 | `eaddress` | Used for encrypted Ethereum addresses. |
115
- * | 256 | 8 | `euint256` | The maximum supported integer size. |
116
- */
117
- export declare const ENCRYPTION_TYPES: {
118
- 2: number;
119
- 8: number;
120
- 16: number;
121
- 32: number;
122
- 64: number;
123
- 128: number;
124
- 160: number;
125
- 256: number;
126
- };
127
-
128
- export declare type EncryptionBits = keyof typeof ENCRYPTION_TYPES;
70
+ export { EncryptionBits }
129
71
 
130
72
  export declare type FhevmInstance = {
131
73
  createEncryptedInput: (contractAddress: string, userAddress: string) => RelayerEncryptedInput;
74
+ requestZKProofVerification: (zkProof: ZKProof_2, options?: RelayerV2InputProofOptions_2) => Promise<{
75
+ handles: Uint8Array[];
76
+ inputProof: Uint8Array;
77
+ }>;
132
78
  generateKeypair: () => {
133
79
  publicKey: string;
134
80
  privateKey: string;
135
81
  };
136
82
  createEIP712: (publicKey: string, contractAddresses: string[], startTimestamp: string | number, durationDays: string | number) => EIP712;
137
- publicDecrypt: (handles: (string | Uint8Array)[]) => Promise<PublicDecryptResults>;
138
- userDecrypt: (handles: HandleContractPair[], privateKey: string, publicKey: string, signature: string, contractAddresses: string[], userAddress: string, startTimestamp: string | number, durationDays: string | number) => Promise<UserDecryptResults>;
83
+ publicDecrypt: (handles: (string | Uint8Array)[], options?: RelayerV2PublicDecryptOptions) => Promise<PublicDecryptResults>;
84
+ userDecrypt: (handles: HandleContractPair[], privateKey: string, publicKey: string, signature: string, contractAddresses: string[], userAddress: string, startTimestamp: string | number, durationDays: string | number, options?: RelayerV2UserDecryptOptions) => Promise<UserDecryptResults>;
139
85
  getPublicKey: () => {
140
86
  publicKeyId: string;
141
87
  publicKey: Uint8Array;
@@ -146,26 +92,9 @@ export declare type FhevmInstance = {
146
92
  } | null;
147
93
  };
148
94
 
149
- export declare type FhevmInstanceConfig = Prettify<{
150
- verifyingContractAddressDecryption: string;
151
- verifyingContractAddressInputVerification: string;
152
- kmsContractAddress: string;
153
- inputVerifierContractAddress: string;
154
- aclContractAddress: string;
155
- gatewayChainId: number;
156
- chainId?: number;
157
- relayerUrl?: string;
158
- network?: Eip1193Provider | string;
159
- publicParams?: PublicParams<Uint8Array> | null;
160
- publicKey?: {
161
- data: Uint8Array | null;
162
- id: string | null;
163
- };
164
- } & FhevmInstanceOptions>;
95
+ export { FhevmInstanceConfig }
165
96
 
166
- export declare type FhevmInstanceOptions = {
167
- auth?: Auth;
168
- };
97
+ export { FhevmInstanceOptions }
169
98
 
170
99
  export declare const generateKeypair: () => {
171
100
  publicKey: string;
@@ -189,11 +118,9 @@ export declare const initSDK: ({ tfheParams, kmsParams, thread, }?: {
189
118
 
190
119
  export { KMSInput }
191
120
 
192
- export declare type PublicDecryptResults = {
193
- clearValues: ClearValues;
194
- abiEncodedClearValues: `0x${string}`;
195
- decryptionProof: `0x${string}`;
196
- };
121
+ export declare const MainnetConfig: FhevmInstanceConfig;
122
+
123
+ export { PublicDecryptResults }
197
124
 
198
125
  export declare type PublicParams<T = TFHEType['CompactPkeCrs']> = {
199
126
  2048: {
@@ -211,10 +138,9 @@ export declare type RelayerEncryptedInput = {
211
138
  add128: (value: number | bigint) => RelayerEncryptedInput;
212
139
  add256: (value: number | bigint) => RelayerEncryptedInput;
213
140
  addAddress: (value: string) => RelayerEncryptedInput;
214
- getBits: () => EncryptionBits[];
215
- encrypt: (options?: {
216
- auth?: Auth;
217
- }) => Promise<{
141
+ getBits: () => EncryptionBits_2[];
142
+ generateZKProof(): ZKProof;
143
+ encrypt: (options?: RelayerV2InputProofOptions) => Promise<{
218
144
  handles: Uint8Array[];
219
145
  inputProof: Uint8Array;
220
146
  }>;
@@ -235,6 +161,6 @@ export declare type TFHEType = {
235
161
  ZkComputeLoad: any;
236
162
  };
237
163
 
238
- export declare type UserDecryptResults = ClearValues;
164
+ export { UserDecryptResults }
239
165
 
240
166
  export { }