@enclave-e3/sdk 0.1.4 → 0.1.6
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/README.md +65 -72
- package/dist/index.cjs +291 -202
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +186 -69
- package/dist/index.d.ts +186 -69
- package/dist/index.js +298 -217
- package/dist/index.js.map +1 -1
- package/package.json +23 -18
- package/LICENSE.md +0 -165
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,55 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
2
|
import { PublicClient, WalletClient, Log, Hash, Abi, TransactionReceipt, Address } from 'viem';
|
|
3
3
|
import { ProofData } from '@aztec/bb.js';
|
|
4
|
-
import { Enclave, CiphernodeRegistryOwnable, MockCiphernodeRegistry } from '@enclave-e3/contracts/types';
|
|
4
|
+
import { Enclave, CiphernodeRegistryOwnable, MockCiphernodeRegistry, EnclaveToken, MockUSDC } from '@enclave-e3/contracts/types';
|
|
5
5
|
import { CompiledCircuit } from '@noir-lang/noir_js';
|
|
6
6
|
|
|
7
|
+
type Field = string;
|
|
8
|
+
/**
|
|
9
|
+
* Describes a polynomial to be used in a Noir circuit (Greco)
|
|
10
|
+
*/
|
|
11
|
+
type Polynomial = {
|
|
12
|
+
coefficients: Field[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Describes the inputs to Greco circuit
|
|
16
|
+
*/
|
|
17
|
+
interface CircuitInputs {
|
|
18
|
+
pk0is: string[][];
|
|
19
|
+
pk1is: string[][];
|
|
20
|
+
ct0is: string[][];
|
|
21
|
+
ct1is: string[][];
|
|
22
|
+
u: string[];
|
|
23
|
+
e0: string[];
|
|
24
|
+
e1: string[];
|
|
25
|
+
e0is: string[][];
|
|
26
|
+
k1: string[];
|
|
27
|
+
r1is: string[][];
|
|
28
|
+
r2is: string[][];
|
|
29
|
+
p1is: string[][];
|
|
30
|
+
p2is: string[][];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Convert a string array to a polynomial
|
|
34
|
+
* @param stringArray - The string array
|
|
35
|
+
* @returns The polynomial
|
|
36
|
+
*/
|
|
37
|
+
declare const convertToPolynomial: (stringArray: string[]) => Polynomial;
|
|
38
|
+
/**
|
|
39
|
+
* Convert an array of string arrays to an array of polynomials
|
|
40
|
+
* @param stringArrays - The array of string arrays
|
|
41
|
+
* @returns The array of polynomials
|
|
42
|
+
*/
|
|
43
|
+
declare const convertToPolynomialArray: (stringArrays: string[][]) => Polynomial[];
|
|
44
|
+
/**
|
|
45
|
+
* Generate a proof for a given circuit and circuit inputs
|
|
46
|
+
* @dev Defaults to the UltraHonkBackend
|
|
47
|
+
* @param circuitInputs - The circuit inputs
|
|
48
|
+
* @param circuit - The circuit
|
|
49
|
+
* @returns The proof
|
|
50
|
+
*/
|
|
51
|
+
declare const generateProof: (circuitInputs: CircuitInputs, circuit: CompiledCircuit) => Promise<ProofData>;
|
|
52
|
+
|
|
7
53
|
/**
|
|
8
54
|
* SDK configuration
|
|
9
55
|
*/
|
|
@@ -28,6 +74,10 @@ interface SDKConfig {
|
|
|
28
74
|
* The CiphernodeRegistry contract address
|
|
29
75
|
*/
|
|
30
76
|
ciphernodeRegistry: `0x${string}`;
|
|
77
|
+
/**
|
|
78
|
+
* The FeeToken contract address
|
|
79
|
+
*/
|
|
80
|
+
feeToken: `0x${string}`;
|
|
31
81
|
};
|
|
32
82
|
/**
|
|
33
83
|
* The chain ID to which the contracts are deployed
|
|
@@ -51,11 +101,11 @@ interface EventListenerConfig {
|
|
|
51
101
|
interface ContractInstances {
|
|
52
102
|
enclave: Enclave;
|
|
53
103
|
ciphernodeRegistry: CiphernodeRegistryOwnable | MockCiphernodeRegistry;
|
|
104
|
+
feeToken: EnclaveToken | MockUSDC;
|
|
54
105
|
}
|
|
55
106
|
declare enum EnclaveEventType {
|
|
56
107
|
E3_REQUESTED = "E3Requested",
|
|
57
108
|
E3_ACTIVATED = "E3Activated",
|
|
58
|
-
INPUT_PUBLISHED = "InputPublished",
|
|
59
109
|
CIPHERTEXT_OUTPUT_PUBLISHED = "CiphertextOutputPublished",
|
|
60
110
|
PLAINTEXT_OUTPUT_PUBLISHED = "PlaintextOutputPublished",
|
|
61
111
|
E3_PROGRAM_ENABLED = "E3ProgramEnabled",
|
|
@@ -71,6 +121,7 @@ declare enum EnclaveEventType {
|
|
|
71
121
|
declare enum RegistryEventType {
|
|
72
122
|
COMMITTEE_REQUESTED = "CommitteeRequested",
|
|
73
123
|
COMMITTEE_PUBLISHED = "CommitteePublished",
|
|
124
|
+
COMMITTEE_FINALIZED = "CommitteeFinalized",
|
|
74
125
|
ENCLAVE_SET = "EnclaveSet",
|
|
75
126
|
OWNERSHIP_TRANSFERRED = "OwnershipTransferred",
|
|
76
127
|
INITIALIZED = "Initialized"
|
|
@@ -86,7 +137,6 @@ interface E3 {
|
|
|
86
137
|
encryptionSchemeId: string;
|
|
87
138
|
e3Program: string;
|
|
88
139
|
e3ProgramParams: string;
|
|
89
|
-
inputValidator: string;
|
|
90
140
|
decryptionVerifier: string;
|
|
91
141
|
committeePublicKey: string;
|
|
92
142
|
ciphertextOutput: string;
|
|
@@ -103,12 +153,6 @@ interface E3ActivatedData {
|
|
|
103
153
|
expiration: bigint;
|
|
104
154
|
committeePublicKey: string;
|
|
105
155
|
}
|
|
106
|
-
interface InputPublishedData {
|
|
107
|
-
e3Id: bigint;
|
|
108
|
-
data: string;
|
|
109
|
-
inputHash: bigint;
|
|
110
|
-
index: bigint;
|
|
111
|
-
}
|
|
112
156
|
interface CiphertextOutputPublishedData {
|
|
113
157
|
e3Id: bigint;
|
|
114
158
|
ciphertextOutput: string;
|
|
@@ -131,17 +175,22 @@ interface CiphernodeRemovedData {
|
|
|
131
175
|
}
|
|
132
176
|
interface CommitteeRequestedData {
|
|
133
177
|
e3Id: bigint;
|
|
134
|
-
|
|
178
|
+
seed: bigint;
|
|
135
179
|
threshold: [bigint, bigint];
|
|
180
|
+
requestBlock: bigint;
|
|
181
|
+
submissionDeadline: bigint;
|
|
136
182
|
}
|
|
137
183
|
interface CommitteePublishedData {
|
|
138
184
|
e3Id: bigint;
|
|
139
185
|
publicKey: string;
|
|
140
186
|
}
|
|
187
|
+
interface CommitteeFinalizedData {
|
|
188
|
+
e3Id: bigint;
|
|
189
|
+
nodes: string[];
|
|
190
|
+
}
|
|
141
191
|
interface EnclaveEventData {
|
|
142
192
|
[EnclaveEventType.E3_REQUESTED]: E3RequestedData;
|
|
143
193
|
[EnclaveEventType.E3_ACTIVATED]: E3ActivatedData;
|
|
144
|
-
[EnclaveEventType.INPUT_PUBLISHED]: InputPublishedData;
|
|
145
194
|
[EnclaveEventType.CIPHERTEXT_OUTPUT_PUBLISHED]: CiphertextOutputPublishedData;
|
|
146
195
|
[EnclaveEventType.PLAINTEXT_OUTPUT_PUBLISHED]: PlaintextOutputPublishedData;
|
|
147
196
|
[EnclaveEventType.E3_PROGRAM_ENABLED]: {
|
|
@@ -176,6 +225,7 @@ interface EnclaveEventData {
|
|
|
176
225
|
interface RegistryEventData {
|
|
177
226
|
[RegistryEventType.COMMITTEE_REQUESTED]: CommitteeRequestedData;
|
|
178
227
|
[RegistryEventType.COMMITTEE_PUBLISHED]: CommitteePublishedData;
|
|
228
|
+
[RegistryEventType.COMMITTEE_FINALIZED]: CommitteeFinalizedData;
|
|
179
229
|
[RegistryEventType.ENCLAVE_SET]: {
|
|
180
230
|
enclave: string;
|
|
181
231
|
};
|
|
@@ -212,9 +262,9 @@ interface SDKEventEmitter {
|
|
|
212
262
|
*/
|
|
213
263
|
interface VerifiableEncryptionResult {
|
|
214
264
|
/**
|
|
215
|
-
* The encrypted
|
|
265
|
+
* The encrypted data
|
|
216
266
|
*/
|
|
217
|
-
|
|
267
|
+
encryptedData: Uint8Array;
|
|
218
268
|
/**
|
|
219
269
|
* The proof generated by Greco
|
|
220
270
|
*/
|
|
@@ -227,7 +277,11 @@ declare enum FheProtocol {
|
|
|
227
277
|
/**
|
|
228
278
|
* The BFV protocol
|
|
229
279
|
*/
|
|
230
|
-
BFV = "BFV"
|
|
280
|
+
BFV = "BFV",
|
|
281
|
+
/**
|
|
282
|
+
* The TrBFV protocol
|
|
283
|
+
*/
|
|
284
|
+
TRBFV = "TRBFV"
|
|
231
285
|
}
|
|
232
286
|
/**
|
|
233
287
|
* Protocol parameters for an Enclave program request
|
|
@@ -248,24 +302,55 @@ interface ProtocolParams {
|
|
|
248
302
|
/**
|
|
249
303
|
* The moduli
|
|
250
304
|
*/
|
|
251
|
-
moduli: bigint;
|
|
305
|
+
moduli: bigint[];
|
|
306
|
+
/**
|
|
307
|
+
* error1
|
|
308
|
+
*/
|
|
309
|
+
error1Variance: string | undefined;
|
|
252
310
|
}
|
|
311
|
+
type ProtocolParamsName = 'INSECURE_SET_2048_1032193_1' | 'INSECURE_SET_512_10_1' | 'INSECURE_SET_512_0XFFFFEE001_1' | 'SET_8192_1000_4' | 'SET_8192_144115188075855872_2';
|
|
253
312
|
/**
|
|
254
313
|
* Parameters for the BFV protocol
|
|
255
314
|
*/
|
|
256
315
|
declare const BfvProtocolParams: {
|
|
257
316
|
/**
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
317
|
+
* Recommended parameters for BFV protocol
|
|
318
|
+
* - Degree: 2048
|
|
319
|
+
* - Plaintext modulus: 1032193
|
|
320
|
+
* - Moduli:0x3FFFFFFF000001
|
|
321
|
+
*/
|
|
263
322
|
BFV_NORMAL: {
|
|
264
323
|
readonly degree: 2048;
|
|
265
324
|
readonly plaintextModulus: 1032193n;
|
|
266
|
-
readonly moduli: 18014398492704769n;
|
|
325
|
+
readonly moduli: [18014398492704769n];
|
|
326
|
+
readonly error1Variance: "10";
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
* Recommended parameters for TrBFV protocol
|
|
330
|
+
* - Degree: 8192
|
|
331
|
+
* - Plaintext modulus: 1000
|
|
332
|
+
* - Moduli: [0x00800000022a0001, 0x00800000021a0001, 0x0080000002120001, 0x0080000001f60001]
|
|
333
|
+
*/
|
|
334
|
+
BFV_THRESHOLD: {
|
|
335
|
+
readonly degree: 8192;
|
|
336
|
+
readonly plaintextModulus: 1000n;
|
|
337
|
+
readonly moduli: [36028797055270913n, 36028797054222337n, 36028797053698049n, 36028797051863041n];
|
|
338
|
+
readonly error1Variance: "10";
|
|
267
339
|
};
|
|
268
340
|
};
|
|
341
|
+
/**
|
|
342
|
+
* The result of encrypting a value and generating a proof
|
|
343
|
+
*/
|
|
344
|
+
interface EncryptedValueAndPublicInputs {
|
|
345
|
+
/**
|
|
346
|
+
* The encrypted data
|
|
347
|
+
*/
|
|
348
|
+
encryptedData: Uint8Array;
|
|
349
|
+
/**
|
|
350
|
+
* The public inputs for the proof
|
|
351
|
+
*/
|
|
352
|
+
publicInputs: CircuitInputs;
|
|
353
|
+
}
|
|
269
354
|
|
|
270
355
|
declare class EnclaveSDK {
|
|
271
356
|
private config;
|
|
@@ -278,13 +363,11 @@ declare class EnclaveSDK {
|
|
|
278
363
|
readonly apiUrl: "https://api.etherscan.io/api";
|
|
279
364
|
};
|
|
280
365
|
};
|
|
366
|
+
blockTime: 12000;
|
|
281
367
|
contracts: {
|
|
282
|
-
readonly ensRegistry: {
|
|
283
|
-
readonly address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
|
|
284
|
-
};
|
|
285
368
|
readonly ensUniversalResolver: {
|
|
286
|
-
readonly address: "
|
|
287
|
-
readonly blockCreated:
|
|
369
|
+
readonly address: "0xeeeeeeee14d718c2b47d9923deab1335e144eeee";
|
|
370
|
+
readonly blockCreated: 23085558;
|
|
288
371
|
};
|
|
289
372
|
readonly multicall3: {
|
|
290
373
|
readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
|
|
@@ -299,6 +382,7 @@ declare class EnclaveSDK {
|
|
|
299
382
|
readonly symbol: "ETH";
|
|
300
383
|
readonly decimals: 18;
|
|
301
384
|
};
|
|
385
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
302
386
|
rpcUrls: {
|
|
303
387
|
readonly default: {
|
|
304
388
|
readonly http: readonly ["https://eth.merkle.io"];
|
|
@@ -319,17 +403,15 @@ declare class EnclaveSDK {
|
|
|
319
403
|
readonly apiUrl: "https://api-sepolia.etherscan.io/api";
|
|
320
404
|
};
|
|
321
405
|
};
|
|
406
|
+
blockTime?: number | undefined | undefined;
|
|
322
407
|
contracts: {
|
|
323
408
|
readonly multicall3: {
|
|
324
409
|
readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
|
|
325
410
|
readonly blockCreated: 751532;
|
|
326
411
|
};
|
|
327
|
-
readonly ensRegistry: {
|
|
328
|
-
readonly address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
|
|
329
|
-
};
|
|
330
412
|
readonly ensUniversalResolver: {
|
|
331
|
-
readonly address: "
|
|
332
|
-
readonly blockCreated:
|
|
413
|
+
readonly address: "0xeeeeeeee14d718c2b47d9923deab1335e144eeee";
|
|
414
|
+
readonly blockCreated: 8928790;
|
|
333
415
|
};
|
|
334
416
|
};
|
|
335
417
|
ensTlds?: readonly string[] | undefined;
|
|
@@ -340,9 +422,10 @@ declare class EnclaveSDK {
|
|
|
340
422
|
readonly symbol: "ETH";
|
|
341
423
|
readonly decimals: 18;
|
|
342
424
|
};
|
|
425
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
343
426
|
rpcUrls: {
|
|
344
427
|
readonly default: {
|
|
345
|
-
readonly http: readonly ["https://
|
|
428
|
+
readonly http: readonly ["https://11155111.rpc.thirdweb.com"];
|
|
346
429
|
};
|
|
347
430
|
};
|
|
348
431
|
sourceId?: number | undefined | undefined;
|
|
@@ -359,6 +442,7 @@ declare class EnclaveSDK {
|
|
|
359
442
|
readonly url: "https://testnet.monadexplorer.com";
|
|
360
443
|
};
|
|
361
444
|
};
|
|
445
|
+
blockTime: 400;
|
|
362
446
|
contracts: {
|
|
363
447
|
readonly multicall3: {
|
|
364
448
|
readonly address: "0xcA11bde05977b3631167028862bE2a173976CA11";
|
|
@@ -373,6 +457,7 @@ declare class EnclaveSDK {
|
|
|
373
457
|
readonly symbol: "MON";
|
|
374
458
|
readonly decimals: 18;
|
|
375
459
|
};
|
|
460
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
376
461
|
rpcUrls: {
|
|
377
462
|
readonly default: {
|
|
378
463
|
readonly http: readonly ["https://testnet-rpc.monad.xyz"];
|
|
@@ -398,6 +483,7 @@ declare class EnclaveSDK {
|
|
|
398
483
|
apiUrl?: string | undefined;
|
|
399
484
|
};
|
|
400
485
|
} | undefined | undefined;
|
|
486
|
+
blockTime?: number | undefined | undefined;
|
|
401
487
|
contracts?: {
|
|
402
488
|
[x: string]: viem.ChainContract | {
|
|
403
489
|
[sourceId: number]: viem.ChainContract | undefined;
|
|
@@ -405,7 +491,7 @@ declare class EnclaveSDK {
|
|
|
405
491
|
ensRegistry?: viem.ChainContract | undefined;
|
|
406
492
|
ensUniversalResolver?: viem.ChainContract | undefined;
|
|
407
493
|
multicall3?: viem.ChainContract | undefined;
|
|
408
|
-
|
|
494
|
+
erc6492Verifier?: viem.ChainContract | undefined;
|
|
409
495
|
} | undefined;
|
|
410
496
|
ensTlds?: readonly string[] | undefined;
|
|
411
497
|
id: 31337;
|
|
@@ -415,6 +501,7 @@ declare class EnclaveSDK {
|
|
|
415
501
|
readonly name: "Ether";
|
|
416
502
|
readonly symbol: "ETH";
|
|
417
503
|
};
|
|
504
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
418
505
|
rpcUrls: {
|
|
419
506
|
readonly default: {
|
|
420
507
|
readonly http: readonly ["http://127.0.0.1:8545"];
|
|
@@ -432,12 +519,20 @@ declare class EnclaveSDK {
|
|
|
432
519
|
private contractClient;
|
|
433
520
|
private initialized;
|
|
434
521
|
private protocol;
|
|
435
|
-
private protocolParams
|
|
522
|
+
private protocolParams?;
|
|
523
|
+
private publicClient;
|
|
436
524
|
constructor(config: SDKConfig);
|
|
437
525
|
/**
|
|
438
526
|
* Initialize the SDK
|
|
439
527
|
*/
|
|
440
528
|
initialize(): Promise<void>;
|
|
529
|
+
/**
|
|
530
|
+
* Get the public client used by the SDK
|
|
531
|
+
* @returns The public client
|
|
532
|
+
*/
|
|
533
|
+
getPublicClient: () => PublicClient;
|
|
534
|
+
getBfvParamsSet(name: ProtocolParamsName): Promise<ProtocolParams>;
|
|
535
|
+
getProtocolParams(): Promise<ProtocolParams>;
|
|
441
536
|
/**
|
|
442
537
|
* Encrypt a number using the configured protocol
|
|
443
538
|
* @param data - The number to encrypt
|
|
@@ -445,6 +540,21 @@ declare class EnclaveSDK {
|
|
|
445
540
|
* @returns The encrypted number
|
|
446
541
|
*/
|
|
447
542
|
encryptNumber(data: bigint, publicKey: Uint8Array): Promise<Uint8Array>;
|
|
543
|
+
/**
|
|
544
|
+
* Encrypt a vector using the configured protocol
|
|
545
|
+
* @param data - The vector to encrypt
|
|
546
|
+
* @param publicKey - The public key to use for encryption
|
|
547
|
+
* @returns The ciphertext
|
|
548
|
+
*/
|
|
549
|
+
encryptVector(data: BigUint64Array, publicKey: Uint8Array): Promise<Uint8Array>;
|
|
550
|
+
/**
|
|
551
|
+
* This function encrypts a number using the configured FHE protocol
|
|
552
|
+
* and generates the necessary public inputs for a zk-SNARK proof.
|
|
553
|
+
* @param data The number to encrypt
|
|
554
|
+
* @param publicKey The public key to use for encryption
|
|
555
|
+
* @returns The encrypted number and the inputs for the zk-SNARK proof
|
|
556
|
+
*/
|
|
557
|
+
encryptNumberAndGenInputs(data: bigint, publicKey: Uint8Array): Promise<EncryptedValueAndPublicInputs>;
|
|
448
558
|
/**
|
|
449
559
|
* Encrypt a number using the configured protocol and generate a zk-SNARK proof using Greco
|
|
450
560
|
* @param data - The number to encrypt
|
|
@@ -453,18 +563,38 @@ declare class EnclaveSDK {
|
|
|
453
563
|
* @returns The encrypted number and the proof
|
|
454
564
|
*/
|
|
455
565
|
encryptNumberAndGenProof(data: bigint, publicKey: Uint8Array, circuit: CompiledCircuit): Promise<VerifiableEncryptionResult>;
|
|
566
|
+
/**
|
|
567
|
+
* Encrypt a vector and generate inputs for an E3 computation
|
|
568
|
+
* @param data - The vector to encrypt
|
|
569
|
+
* @param publicKey - The public key to use for encryption
|
|
570
|
+
* @returns The encrypted vector and the inputs for the E3 computation
|
|
571
|
+
*/
|
|
572
|
+
encryptVectorAndGenInputs(data: BigUint64Array, publicKey: Uint8Array): Promise<EncryptedValueAndPublicInputs>;
|
|
573
|
+
/**
|
|
574
|
+
* Encrypt a vector using the configured protocol and generate a zk-SNARK proof using Greco
|
|
575
|
+
* @param data - The vector to encrypt
|
|
576
|
+
* @param publicKey - The public key to use for encryption
|
|
577
|
+
* @param circuit - The circuit to use for proof generation
|
|
578
|
+
* @returns The encrypted vector and the proof
|
|
579
|
+
*/
|
|
580
|
+
encryptVectorAndGenProof(data: BigUint64Array, publicKey: Uint8Array, circuit: CompiledCircuit): Promise<VerifiableEncryptionResult>;
|
|
581
|
+
/**
|
|
582
|
+
* Approve the fee token for the Enclave
|
|
583
|
+
* @param amount - The amount to approve
|
|
584
|
+
* @returns The approval transaction hash
|
|
585
|
+
*/
|
|
586
|
+
approveFeeToken(amount: bigint): Promise<Hash>;
|
|
456
587
|
/**
|
|
457
588
|
* Request a new E3 computation
|
|
458
589
|
*/
|
|
459
590
|
requestE3(params: {
|
|
460
|
-
filter: `0x${string}`;
|
|
461
591
|
threshold: [number, number];
|
|
462
592
|
startWindow: [bigint, bigint];
|
|
463
593
|
duration: bigint;
|
|
464
594
|
e3Program: `0x${string}`;
|
|
465
595
|
e3ProgramParams: `0x${string}`;
|
|
466
596
|
computeProviderParams: `0x${string}`;
|
|
467
|
-
|
|
597
|
+
customParams?: `0x${string}`;
|
|
468
598
|
gasLimit?: bigint;
|
|
469
599
|
}): Promise<Hash>;
|
|
470
600
|
/**
|
|
@@ -537,6 +667,7 @@ declare class EnclaveSDK {
|
|
|
537
667
|
contracts: {
|
|
538
668
|
enclave: `0x${string}`;
|
|
539
669
|
ciphernodeRegistry: `0x${string}`;
|
|
670
|
+
feeToken: `0x${string}`;
|
|
540
671
|
};
|
|
541
672
|
privateKey?: `0x${string}`;
|
|
542
673
|
chainId: keyof typeof EnclaveSDK.chains;
|
|
@@ -594,16 +725,22 @@ declare class ContractClient {
|
|
|
594
725
|
constructor(publicClient: PublicClient, walletClient?: WalletClient | undefined, addresses?: {
|
|
595
726
|
enclave: `0x${string}`;
|
|
596
727
|
ciphernodeRegistry: `0x${string}`;
|
|
728
|
+
feeToken: `0x${string}`;
|
|
597
729
|
});
|
|
598
730
|
/**
|
|
599
731
|
* Initialize contract instances
|
|
600
732
|
*/
|
|
601
733
|
initialize(): Promise<void>;
|
|
734
|
+
/**
|
|
735
|
+
* Approve the fee token for the Enclave
|
|
736
|
+
* approve(address spender, uint256 amount)
|
|
737
|
+
*/
|
|
738
|
+
approveFeeToken(amount: bigint): Promise<Hash>;
|
|
602
739
|
/**
|
|
603
740
|
* Request a new E3 computation
|
|
604
|
-
* request(address filter, uint32[2] threshold, uint256[2] startWindow, uint256 duration, IE3Program e3Program, bytes e3ProgramParams, bytes computeProviderParams)
|
|
741
|
+
* request(address filter, uint32[2] threshold, uint256[2] startWindow, uint256 duration, IE3Program e3Program, bytes e3ProgramParams, bytes computeProviderParams, bytes customParams)
|
|
605
742
|
*/
|
|
606
|
-
requestE3(
|
|
743
|
+
requestE3(threshold: [number, number], startWindow: [bigint, bigint], duration: bigint, e3Program: `0x${string}`, e3ProgramParams: `0x${string}`, computeProviderParams: `0x${string}`, customParams?: `0x${string}`, gasLimit?: bigint): Promise<Hash>;
|
|
607
744
|
/**
|
|
608
745
|
* Activate an E3 computation
|
|
609
746
|
* activate(uint256 e3Id, bytes memory publicKey)
|
|
@@ -664,6 +801,7 @@ declare const BFV_PARAMS_SET: {
|
|
|
664
801
|
readonly degree: 2048;
|
|
665
802
|
readonly plaintext_modulus: 1032193;
|
|
666
803
|
readonly moduli: readonly [18014398492704769n];
|
|
804
|
+
readonly error1_variance: "10";
|
|
667
805
|
};
|
|
668
806
|
interface ComputeProviderParams {
|
|
669
807
|
name: string;
|
|
@@ -673,7 +811,7 @@ interface ComputeProviderParams {
|
|
|
673
811
|
declare const DEFAULT_COMPUTE_PROVIDER_PARAMS: ComputeProviderParams;
|
|
674
812
|
declare const DEFAULT_E3_CONFIG: {
|
|
675
813
|
readonly threshold_min: 2;
|
|
676
|
-
readonly threshold_max:
|
|
814
|
+
readonly threshold_max: 5;
|
|
677
815
|
readonly window_size: 120;
|
|
678
816
|
readonly duration: 1800;
|
|
679
817
|
readonly payment_amount: "0";
|
|
@@ -682,11 +820,16 @@ declare const DEFAULT_E3_CONFIG: {
|
|
|
682
820
|
* Encode BFV parameters for the smart contract
|
|
683
821
|
* BFV (Brakerski-Fan-Vercauteren) is a type of fully homomorphic encryption
|
|
684
822
|
*/
|
|
685
|
-
declare function encodeBfvParams(degree?: number, plaintext_modulus?: number, moduli?: readonly bigint[]): `0x${string}`;
|
|
823
|
+
declare function encodeBfvParams(degree?: number, plaintext_modulus?: number, moduli?: readonly bigint[], error1_variance?: string): `0x${string}`;
|
|
824
|
+
/**
|
|
825
|
+
* Encode compute provider parameters for the smart contract'
|
|
826
|
+
* If mock is true, the compute provider parameters will return 32 bytes of 0x00
|
|
827
|
+
*/
|
|
828
|
+
declare function encodeComputeProviderParams(params: ComputeProviderParams, mock?: boolean): `0x${string}`;
|
|
686
829
|
/**
|
|
687
|
-
* Encode
|
|
830
|
+
* Encode custom parameters for the smart contract.
|
|
688
831
|
*/
|
|
689
|
-
declare function
|
|
832
|
+
declare function encodeCustomParams(params: Record<string, unknown>): `0x${string}`;
|
|
690
833
|
/**
|
|
691
834
|
* Calculate start window for E3 request
|
|
692
835
|
*/
|
|
@@ -696,30 +839,4 @@ declare function calculateStartWindow(windowSize?: number): [bigint, bigint];
|
|
|
696
839
|
*/
|
|
697
840
|
declare function decodePlaintextOutput(plaintextOutput: string): number | null;
|
|
698
841
|
|
|
699
|
-
|
|
700
|
-
* Describes the inputs to Greco circuit
|
|
701
|
-
*/
|
|
702
|
-
interface CircuitInputs {
|
|
703
|
-
pk0is: string[][];
|
|
704
|
-
pk1is: string[][];
|
|
705
|
-
ct0is: string[][];
|
|
706
|
-
ct1is: string[][];
|
|
707
|
-
u: string[];
|
|
708
|
-
e0: string[];
|
|
709
|
-
e1: string[];
|
|
710
|
-
k1: string[];
|
|
711
|
-
r1is: string[][];
|
|
712
|
-
r2is: string[][];
|
|
713
|
-
p1is: string[][];
|
|
714
|
-
p2is: string[][];
|
|
715
|
-
}
|
|
716
|
-
/**
|
|
717
|
-
* Generate a proof for a given circuit and circuit inputs
|
|
718
|
-
* @dev Defaults to the UltraHonkBackend
|
|
719
|
-
* @param circuitInputs - The circuit inputs
|
|
720
|
-
* @param circuit - The circuit
|
|
721
|
-
* @returns The proof
|
|
722
|
-
*/
|
|
723
|
-
declare const generateProof: (circuitInputs: CircuitInputs, circuit: CompiledCircuit) => Promise<ProofData>;
|
|
724
|
-
|
|
725
|
-
export { type AllEventTypes, BFV_PARAMS_SET, BfvProtocolParams, type CiphernodeAddedData, type CiphernodeRemovedData, type CiphertextOutputPublishedData, type CommitteePublishedData, type CommitteeRequestedData, type ComputeProviderParams, ContractClient, type ContractInstances, DEFAULT_COMPUTE_PROVIDER_PARAMS, DEFAULT_E3_CONFIG, type E3, type E3ActivatedData, type E3RequestedData, type EnclaveEvent, type EnclaveEventData, EnclaveEventType, EnclaveSDK, type EventCallback, type EventFilter, EventListener, type EventListenerConfig, FheProtocol, type InputPublishedData, type PlaintextOutputPublishedData, type ProtocolParams, type RegistryEventData, RegistryEventType, type SDKConfig, SDKError, type SDKEventEmitter, type VerifiableEncryptionResult, calculateStartWindow, decodePlaintextOutput, encodeBfvParams, encodeComputeProviderParams, formatBigInt, formatEventName, generateEventId, generateProof, getCurrentTimestamp, isValidAddress, isValidHash, parseBigInt, parseEventData, sleep };
|
|
842
|
+
export { type AllEventTypes, BFV_PARAMS_SET, BfvProtocolParams, type CiphernodeAddedData, type CiphernodeRemovedData, type CiphertextOutputPublishedData, type CommitteeFinalizedData, type CommitteePublishedData, type CommitteeRequestedData, type ComputeProviderParams, ContractClient, type ContractInstances, DEFAULT_COMPUTE_PROVIDER_PARAMS, DEFAULT_E3_CONFIG, type E3, type E3ActivatedData, type E3RequestedData, type EnclaveEvent, type EnclaveEventData, EnclaveEventType, EnclaveSDK, type EncryptedValueAndPublicInputs, type EventCallback, type EventFilter, EventListener, type EventListenerConfig, FheProtocol, type PlaintextOutputPublishedData, type Polynomial, type ProtocolParams, type RegistryEventData, RegistryEventType, type SDKConfig, SDKError, type SDKEventEmitter, type VerifiableEncryptionResult, calculateStartWindow, convertToPolynomial, convertToPolynomialArray, decodePlaintextOutput, encodeBfvParams, encodeComputeProviderParams, encodeCustomParams, formatBigInt, formatEventName, generateEventId, generateProof, getCurrentTimestamp, isValidAddress, isValidHash, parseBigInt, parseEventData, sleep };
|