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

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,32 @@
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 { RelayerV2PublicDecryptOptions } from './relayer-provider/v2/types/types';
15
+ import type { RelayerV2UserDecryptOptions } from './relayer-provider/v2/types/types';
4
16
  import { InitInput as TFHEInput } from 'tfhe';
17
+ import type { UserDecryptResults } from './types/relayer';
5
18
 
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
- };
19
+ export { ApiKeyCookie }
20
20
 
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
- };
21
+ export { ApiKeyHeader }
35
22
 
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;
23
+ export { Auth }
44
24
 
45
- /**
46
- * Bearer Token Authentication
47
- */
48
- export declare type BearerToken = {
49
- __type: 'BearerToken';
50
- /**
51
- * The Bearer token.
52
- */
53
- token: string;
54
- };
25
+ export { BearerToken }
55
26
 
56
- export declare type ClearValues = Record<`0x${string}`, ClearValueType>;
27
+ export { ClearValues }
57
28
 
58
- export declare type ClearValueType = bigint | boolean | `0x${string}`;
29
+ export { ClearValueType }
59
30
 
60
31
  /**
61
32
  * Creates an EIP712 structure specifically for user decrypt requests
@@ -93,39 +64,7 @@ export declare type EIP712Type = {
93
64
  type: string;
94
65
  };
95
66
 
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;
67
+ export { EncryptionBits }
129
68
 
130
69
  export declare type FhevmInstance = {
131
70
  createEncryptedInput: (contractAddress: string, userAddress: string) => RelayerEncryptedInput;
@@ -134,8 +73,8 @@ export declare type FhevmInstance = {
134
73
  privateKey: string;
135
74
  };
136
75
  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>;
76
+ publicDecrypt: (handles: (string | Uint8Array)[], options?: RelayerV2PublicDecryptOptions) => Promise<PublicDecryptResults>;
77
+ userDecrypt: (handles: HandleContractPair[], privateKey: string, publicKey: string, signature: string, contractAddresses: string[], userAddress: string, startTimestamp: string | number, durationDays: string | number, options?: RelayerV2UserDecryptOptions) => Promise<UserDecryptResults>;
139
78
  getPublicKey: () => {
140
79
  publicKeyId: string;
141
80
  publicKey: Uint8Array;
@@ -146,26 +85,9 @@ export declare type FhevmInstance = {
146
85
  } | null;
147
86
  };
148
87
 
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>;
88
+ export { FhevmInstanceConfig }
165
89
 
166
- export declare type FhevmInstanceOptions = {
167
- auth?: Auth;
168
- };
90
+ export { FhevmInstanceOptions }
169
91
 
170
92
  export declare const generateKeypair: () => {
171
93
  publicKey: string;
@@ -189,11 +111,9 @@ export declare const initSDK: ({ tfheParams, kmsParams, thread, }?: {
189
111
 
190
112
  export { KMSInput }
191
113
 
192
- export declare type PublicDecryptResults = {
193
- clearValues: ClearValues;
194
- abiEncodedClearValues: `0x${string}`;
195
- decryptionProof: `0x${string}`;
196
- };
114
+ export declare const MainnetConfig: FhevmInstanceConfig;
115
+
116
+ export { PublicDecryptResults }
197
117
 
198
118
  export declare type PublicParams<T = TFHEType['CompactPkeCrs']> = {
199
119
  2048: {
@@ -211,10 +131,9 @@ export declare type RelayerEncryptedInput = {
211
131
  add128: (value: number | bigint) => RelayerEncryptedInput;
212
132
  add256: (value: number | bigint) => RelayerEncryptedInput;
213
133
  addAddress: (value: string) => RelayerEncryptedInput;
214
- getBits: () => EncryptionBits[];
215
- encrypt: (options?: {
216
- auth?: Auth;
217
- }) => Promise<{
134
+ getBits: () => EncryptionBits_2[];
135
+ getCiphertextWithInputVerification(): Uint8Array;
136
+ encrypt: (options?: RelayerV2InputProofOptions) => Promise<{
218
137
  handles: Uint8Array[];
219
138
  inputProof: Uint8Array;
220
139
  }>;
@@ -235,6 +154,6 @@ export declare type TFHEType = {
235
154
  ZkComputeLoad: any;
236
155
  };
237
156
 
238
- export declare type UserDecryptResults = ClearValues;
157
+ export { UserDecryptResults }
239
158
 
240
159
  export { }