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