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