@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/bin/commands/config.js +13 -0
- package/bin/commands/handle.js +22 -0
- package/bin/commands/input-proof.js +75 -0
- package/bin/commands/pubkey-clear.js +18 -0
- package/bin/commands/pubkey-fetch.js +9 -0
- package/bin/commands/pubkey-info.js +44 -0
- package/bin/commands/public-decrypt.js +64 -0
- package/bin/commands/test-fhecounter-getcount.js +49 -0
- package/bin/commands/zkproof-generate.js +68 -0
- package/bin/instance.js +15 -0
- package/bin/pubkeyCache.js +126 -0
- package/bin/relayer.js +132 -59
- package/bin/utils.js +345 -8
- package/bundle/relayer-sdk-js.js +6322 -5578
- package/bundle/relayer-sdk-js.umd.cjs +5 -5
- package/bundle.d.ts +1 -1
- package/lib/internal.js +6138 -0
- package/lib/node.cjs +1263 -380
- package/lib/node.d.ts +40 -114
- package/lib/node.js +1264 -381
- package/lib/web.d.ts +40 -114
- package/lib/web.js +1263 -380
- package/package.json +5 -2
package/lib/node.d.ts
CHANGED
|
@@ -1,62 +1,36 @@
|
|
|
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 {
|
|
3
|
-
import {
|
|
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 { 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 { TfheClientKey } from 'node-tfhe';
|
|
5
18
|
import { TfheCompactPublicKey } from 'node-tfhe';
|
|
19
|
+
import type { UserDecryptResults } from './types/relayer';
|
|
20
|
+
import type { ZKProof } from '../types/primitives';
|
|
21
|
+
import type { ZKProof as ZKProof_2 } from './types/primitives';
|
|
6
22
|
|
|
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
|
-
};
|
|
23
|
+
export { ApiKeyCookie }
|
|
21
24
|
|
|
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
|
-
};
|
|
25
|
+
export { ApiKeyHeader }
|
|
36
26
|
|
|
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;
|
|
27
|
+
export { Auth }
|
|
45
28
|
|
|
46
|
-
|
|
47
|
-
* Bearer Token Authentication
|
|
48
|
-
*/
|
|
49
|
-
export declare type BearerToken = {
|
|
50
|
-
__type: 'BearerToken';
|
|
51
|
-
/**
|
|
52
|
-
* The Bearer token.
|
|
53
|
-
*/
|
|
54
|
-
token: string;
|
|
55
|
-
};
|
|
29
|
+
export { BearerToken }
|
|
56
30
|
|
|
57
|
-
export
|
|
31
|
+
export { ClearValues }
|
|
58
32
|
|
|
59
|
-
export
|
|
33
|
+
export { ClearValueType }
|
|
60
34
|
|
|
61
35
|
/**
|
|
62
36
|
* Creates an EIP712 structure specifically for user decrypt requests
|
|
@@ -102,49 +76,21 @@ export declare type EIP712Type = {
|
|
|
102
76
|
type: string;
|
|
103
77
|
};
|
|
104
78
|
|
|
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;
|
|
79
|
+
export { EncryptionBits }
|
|
138
80
|
|
|
139
81
|
export declare type FhevmInstance = {
|
|
140
82
|
createEncryptedInput: (contractAddress: string, userAddress: string) => RelayerEncryptedInput;
|
|
83
|
+
requestZKProofVerification: (zkProof: ZKProof_2, options?: RelayerV2InputProofOptions_2) => Promise<{
|
|
84
|
+
handles: Uint8Array[];
|
|
85
|
+
inputProof: Uint8Array;
|
|
86
|
+
}>;
|
|
141
87
|
generateKeypair: () => {
|
|
142
88
|
publicKey: string;
|
|
143
89
|
privateKey: string;
|
|
144
90
|
};
|
|
145
91
|
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>;
|
|
92
|
+
publicDecrypt: (handles: (string | Uint8Array)[], options?: RelayerV2PublicDecryptOptions) => Promise<PublicDecryptResults>;
|
|
93
|
+
userDecrypt: (handles: HandleContractPair[], privateKey: string, publicKey: string, signature: string, contractAddresses: string[], userAddress: string, startTimestamp: string | number, durationDays: string | number, options?: RelayerV2UserDecryptOptions) => Promise<UserDecryptResults>;
|
|
148
94
|
getPublicKey: () => {
|
|
149
95
|
publicKeyId: string;
|
|
150
96
|
publicKey: Uint8Array;
|
|
@@ -155,26 +101,9 @@ export declare type FhevmInstance = {
|
|
|
155
101
|
} | null;
|
|
156
102
|
};
|
|
157
103
|
|
|
158
|
-
export
|
|
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>;
|
|
104
|
+
export { FhevmInstanceConfig }
|
|
174
105
|
|
|
175
|
-
export
|
|
176
|
-
auth?: Auth;
|
|
177
|
-
};
|
|
106
|
+
export { FhevmInstanceOptions }
|
|
178
107
|
|
|
179
108
|
export declare const generateKeypair: () => {
|
|
180
109
|
publicKey: string;
|
|
@@ -190,11 +119,9 @@ export declare type HandleContractPair = {
|
|
|
190
119
|
contractAddress: string;
|
|
191
120
|
};
|
|
192
121
|
|
|
193
|
-
export declare
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
decryptionProof: `0x${string}`;
|
|
197
|
-
};
|
|
122
|
+
export declare const MainnetConfig: FhevmInstanceConfig;
|
|
123
|
+
|
|
124
|
+
export { PublicDecryptResults }
|
|
198
125
|
|
|
199
126
|
export declare type PublicParams<T = TFHEType['CompactPkeCrs']> = {
|
|
200
127
|
2048: {
|
|
@@ -212,10 +139,9 @@ export declare type RelayerEncryptedInput = {
|
|
|
212
139
|
add128: (value: number | bigint) => RelayerEncryptedInput;
|
|
213
140
|
add256: (value: number | bigint) => RelayerEncryptedInput;
|
|
214
141
|
addAddress: (value: string) => RelayerEncryptedInput;
|
|
215
|
-
getBits: () =>
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}) => Promise<{
|
|
142
|
+
getBits: () => EncryptionBits_2[];
|
|
143
|
+
generateZKProof(): ZKProof;
|
|
144
|
+
encrypt: (options?: RelayerV2InputProofOptions) => Promise<{
|
|
219
145
|
handles: Uint8Array[];
|
|
220
146
|
inputProof: Uint8Array;
|
|
221
147
|
}>;
|
|
@@ -234,6 +160,6 @@ export declare type TFHEType = {
|
|
|
234
160
|
ZkComputeLoad: any;
|
|
235
161
|
};
|
|
236
162
|
|
|
237
|
-
export
|
|
163
|
+
export { UserDecryptResults }
|
|
238
164
|
|
|
239
165
|
export { }
|