@enclave-e3/sdk 0.0.7-test

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.
@@ -0,0 +1,712 @@
1
+ import * as viem from 'viem';
2
+ import { PublicClient, WalletClient, Log, Hash, Abi, TransactionReceipt, Address } from 'viem';
3
+ import { ProofData } from '@aztec/bb.js';
4
+ import { Enclave, CiphernodeRegistryOwnable, MockCiphernodeRegistry } from '@enclave-e3/contracts/types';
5
+ import { CompiledCircuit } from '@noir-lang/noir_js';
6
+
7
+ /**
8
+ * SDK configuration
9
+ */
10
+ interface SDKConfig {
11
+ /**
12
+ * The public client to use to interact with the blockchain
13
+ */
14
+ publicClient: PublicClient;
15
+ /**
16
+ * The wallet client to use to send/sign transactions
17
+ */
18
+ walletClient?: WalletClient;
19
+ /**
20
+ * The Enclave contracts
21
+ */
22
+ contracts: {
23
+ /**
24
+ * The Enclave contract address
25
+ */
26
+ enclave: `0x${string}`;
27
+ /**
28
+ * The CiphernodeRegistry contract address
29
+ */
30
+ ciphernodeRegistry: `0x${string}`;
31
+ };
32
+ /**
33
+ * The chain ID to which the contracts are deployed
34
+ */
35
+ chainId?: number;
36
+ /**
37
+ * The protocol to use for the Enclave requests
38
+ */
39
+ protocol: FheProtocol;
40
+ /**
41
+ * The protocol parameters to use for the Enclave requests
42
+ */
43
+ protocolParams?: ProtocolParams;
44
+ }
45
+ interface EventListenerConfig {
46
+ fromBlock?: bigint;
47
+ toBlock?: bigint;
48
+ polling?: boolean;
49
+ pollingInterval?: number;
50
+ }
51
+ interface ContractInstances {
52
+ enclave: Enclave;
53
+ ciphernodeRegistry: CiphernodeRegistryOwnable | MockCiphernodeRegistry;
54
+ }
55
+ declare enum EnclaveEventType {
56
+ E3_REQUESTED = "E3Requested",
57
+ E3_ACTIVATED = "E3Activated",
58
+ INPUT_PUBLISHED = "InputPublished",
59
+ CIPHERTEXT_OUTPUT_PUBLISHED = "CiphertextOutputPublished",
60
+ PLAINTEXT_OUTPUT_PUBLISHED = "PlaintextOutputPublished",
61
+ E3_PROGRAM_ENABLED = "E3ProgramEnabled",
62
+ E3_PROGRAM_DISABLED = "E3ProgramDisabled",
63
+ ENCRYPTION_SCHEME_ENABLED = "EncryptionSchemeEnabled",
64
+ ENCRYPTION_SCHEME_DISABLED = "EncryptionSchemeDisabled",
65
+ CIPHERNODE_REGISTRY_SET = "CiphernodeRegistrySet",
66
+ MAX_DURATION_SET = "MaxDurationSet",
67
+ ALLOWED_E3_PROGRAMS_PARAMS_SET = "AllowedE3ProgramsParamsSet",
68
+ OWNERSHIP_TRANSFERRED = "OwnershipTransferred",
69
+ INITIALIZED = "Initialized"
70
+ }
71
+ declare enum RegistryEventType {
72
+ COMMITTEE_REQUESTED = "CommitteeRequested",
73
+ COMMITTEE_PUBLISHED = "CommitteePublished",
74
+ ENCLAVE_SET = "EnclaveSet",
75
+ OWNERSHIP_TRANSFERRED = "OwnershipTransferred",
76
+ INITIALIZED = "Initialized"
77
+ }
78
+ type AllEventTypes = EnclaveEventType | RegistryEventType;
79
+ interface E3 {
80
+ seed: bigint;
81
+ threshold: readonly [number, number];
82
+ requestBlock: bigint;
83
+ startWindow: readonly [bigint, bigint];
84
+ duration: bigint;
85
+ expiration: bigint;
86
+ encryptionSchemeId: string;
87
+ e3Program: string;
88
+ e3ProgramParams: string;
89
+ inputValidator: string;
90
+ decryptionVerifier: string;
91
+ committeePublicKey: string;
92
+ ciphertextOutput: string;
93
+ plaintextOutput: string;
94
+ }
95
+ interface E3RequestedData {
96
+ e3Id: bigint;
97
+ e3: E3;
98
+ filter: string;
99
+ e3Program: string;
100
+ }
101
+ interface E3ActivatedData {
102
+ e3Id: bigint;
103
+ expiration: bigint;
104
+ committeePublicKey: string;
105
+ }
106
+ interface InputPublishedData {
107
+ e3Id: bigint;
108
+ data: string;
109
+ inputHash: bigint;
110
+ index: bigint;
111
+ }
112
+ interface CiphertextOutputPublishedData {
113
+ e3Id: bigint;
114
+ ciphertextOutput: string;
115
+ }
116
+ interface PlaintextOutputPublishedData {
117
+ e3Id: bigint;
118
+ plaintextOutput: string;
119
+ }
120
+ interface CiphernodeAddedData {
121
+ node: string;
122
+ index: bigint;
123
+ numNodes: bigint;
124
+ size: bigint;
125
+ }
126
+ interface CiphernodeRemovedData {
127
+ node: string;
128
+ index: bigint;
129
+ numNodes: bigint;
130
+ size: bigint;
131
+ }
132
+ interface CommitteeRequestedData {
133
+ e3Id: bigint;
134
+ filter: string;
135
+ threshold: [bigint, bigint];
136
+ }
137
+ interface CommitteePublishedData {
138
+ e3Id: bigint;
139
+ publicKey: string;
140
+ }
141
+ interface EnclaveEventData {
142
+ [EnclaveEventType.E3_REQUESTED]: E3RequestedData;
143
+ [EnclaveEventType.E3_ACTIVATED]: E3ActivatedData;
144
+ [EnclaveEventType.INPUT_PUBLISHED]: InputPublishedData;
145
+ [EnclaveEventType.CIPHERTEXT_OUTPUT_PUBLISHED]: CiphertextOutputPublishedData;
146
+ [EnclaveEventType.PLAINTEXT_OUTPUT_PUBLISHED]: PlaintextOutputPublishedData;
147
+ [EnclaveEventType.E3_PROGRAM_ENABLED]: {
148
+ e3Program: string;
149
+ };
150
+ [EnclaveEventType.E3_PROGRAM_DISABLED]: {
151
+ e3Program: string;
152
+ };
153
+ [EnclaveEventType.ENCRYPTION_SCHEME_ENABLED]: {
154
+ encryptionSchemeId: string;
155
+ };
156
+ [EnclaveEventType.ENCRYPTION_SCHEME_DISABLED]: {
157
+ encryptionSchemeId: string;
158
+ };
159
+ [EnclaveEventType.CIPHERNODE_REGISTRY_SET]: {
160
+ ciphernodeRegistry: string;
161
+ };
162
+ [EnclaveEventType.MAX_DURATION_SET]: {
163
+ maxDuration: bigint;
164
+ };
165
+ [EnclaveEventType.ALLOWED_E3_PROGRAMS_PARAMS_SET]: {
166
+ e3ProgramParams: string[];
167
+ };
168
+ [EnclaveEventType.OWNERSHIP_TRANSFERRED]: {
169
+ previousOwner: string;
170
+ newOwner: string;
171
+ };
172
+ [EnclaveEventType.INITIALIZED]: {
173
+ version: bigint;
174
+ };
175
+ }
176
+ interface RegistryEventData {
177
+ [RegistryEventType.COMMITTEE_REQUESTED]: CommitteeRequestedData;
178
+ [RegistryEventType.COMMITTEE_PUBLISHED]: CommitteePublishedData;
179
+ [RegistryEventType.ENCLAVE_SET]: {
180
+ enclave: string;
181
+ };
182
+ [RegistryEventType.OWNERSHIP_TRANSFERRED]: {
183
+ previousOwner: string;
184
+ newOwner: string;
185
+ };
186
+ [RegistryEventType.INITIALIZED]: {
187
+ version: bigint;
188
+ };
189
+ }
190
+ interface EnclaveEvent<T extends AllEventTypes> {
191
+ type: T;
192
+ data: T extends EnclaveEventType ? EnclaveEventData[T] : T extends RegistryEventType ? RegistryEventData[T] : unknown;
193
+ log: Log;
194
+ timestamp: Date;
195
+ blockNumber: bigint;
196
+ transactionHash: string;
197
+ }
198
+ type EventCallback<T extends AllEventTypes = AllEventTypes> = (event: EnclaveEvent<T>) => void | Promise<void>;
199
+ interface EventFilter<T = unknown> {
200
+ address?: `0x${string}`;
201
+ fromBlock?: bigint;
202
+ toBlock?: bigint;
203
+ args?: Partial<T>;
204
+ }
205
+ interface SDKEventEmitter {
206
+ on<T extends AllEventTypes>(eventType: T, callback: EventCallback<T>): void;
207
+ off<T extends AllEventTypes>(eventType: T, callback: EventCallback<T>): void;
208
+ emit<T extends AllEventTypes>(event: EnclaveEvent<T>): void;
209
+ }
210
+ /**
211
+ * Result of verifiable encryption using BFV
212
+ */
213
+ interface VerifiableEncryptionResult {
214
+ /**
215
+ * The encrypted vote
216
+ */
217
+ encryptedVote: Uint8Array;
218
+ /**
219
+ * The proof generated by Greco
220
+ */
221
+ proof: ProofData;
222
+ }
223
+ /**
224
+ * The protocol to use for the Enclave requests
225
+ */
226
+ declare enum FheProtocol {
227
+ /**
228
+ * The BFV protocol
229
+ */
230
+ BFV = "BFV"
231
+ }
232
+ /**
233
+ * Protocol parameters for an Enclave program request
234
+ * Example for BFV
235
+ * 2048, // degree
236
+ * 1032193, // plaintext_modulus
237
+ * 0x3FFFFFFF000001, // moduli
238
+ */
239
+ interface ProtocolParams {
240
+ /**
241
+ * The degree of the polynomial
242
+ */
243
+ degree: number;
244
+ /**
245
+ * The plaintext modulus
246
+ */
247
+ plaintextModulus: bigint;
248
+ /**
249
+ * The moduli
250
+ */
251
+ moduli: bigint;
252
+ }
253
+ /**
254
+ * Parameters for the BFV protocol
255
+ */
256
+ declare const BfvProtocolParams: {
257
+ /**
258
+ * Recommended parameters for BFV protocol
259
+ * - Degree: 2048
260
+ * - Plaintext modulus: 1032193
261
+ * - Moduli:0x3FFFFFFF000001
262
+ */
263
+ BFV_NORMAL: {
264
+ readonly degree: 2048;
265
+ readonly plaintextModulus: 1032193n;
266
+ readonly moduli: 18014398492704769n;
267
+ };
268
+ };
269
+
270
+ declare class EnclaveSDK {
271
+ private config;
272
+ static readonly chains: {
273
+ readonly 1: {
274
+ blockExplorers: {
275
+ readonly default: {
276
+ readonly name: "Etherscan";
277
+ readonly url: "https://etherscan.io";
278
+ readonly apiUrl: "https://api.etherscan.io/api";
279
+ };
280
+ };
281
+ contracts: {
282
+ readonly ensRegistry: {
283
+ readonly address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
284
+ };
285
+ readonly ensUniversalResolver: {
286
+ readonly address: "0xce01f8eee7E479C928F8919abD53E553a36CeF67";
287
+ readonly blockCreated: 19258213;
288
+ };
289
+ readonly multicall3: {
290
+ readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
291
+ readonly blockCreated: 14353601;
292
+ };
293
+ };
294
+ ensTlds?: readonly string[] | undefined;
295
+ id: 1;
296
+ name: "Ethereum";
297
+ nativeCurrency: {
298
+ readonly name: "Ether";
299
+ readonly symbol: "ETH";
300
+ readonly decimals: 18;
301
+ };
302
+ rpcUrls: {
303
+ readonly default: {
304
+ readonly http: readonly ["https://eth.merkle.io"];
305
+ };
306
+ };
307
+ sourceId?: number | undefined | undefined;
308
+ testnet?: boolean | undefined | undefined;
309
+ custom?: Record<string, unknown> | undefined;
310
+ fees?: viem.ChainFees<undefined> | undefined;
311
+ formatters?: undefined;
312
+ serializers?: viem.ChainSerializers<undefined, viem.TransactionSerializable> | undefined;
313
+ };
314
+ readonly 11155111: {
315
+ blockExplorers: {
316
+ readonly default: {
317
+ readonly name: "Etherscan";
318
+ readonly url: "https://sepolia.etherscan.io";
319
+ readonly apiUrl: "https://api-sepolia.etherscan.io/api";
320
+ };
321
+ };
322
+ contracts: {
323
+ readonly multicall3: {
324
+ readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
325
+ readonly blockCreated: 751532;
326
+ };
327
+ readonly ensRegistry: {
328
+ readonly address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
329
+ };
330
+ readonly ensUniversalResolver: {
331
+ readonly address: "0xc8Af999e38273D658BE1b921b88A9Ddf005769cC";
332
+ readonly blockCreated: 5317080;
333
+ };
334
+ };
335
+ ensTlds?: readonly string[] | undefined;
336
+ id: 11155111;
337
+ name: "Sepolia";
338
+ nativeCurrency: {
339
+ readonly name: "Sepolia Ether";
340
+ readonly symbol: "ETH";
341
+ readonly decimals: 18;
342
+ };
343
+ rpcUrls: {
344
+ readonly default: {
345
+ readonly http: readonly ["https://sepolia.drpc.org"];
346
+ };
347
+ };
348
+ sourceId?: number | undefined | undefined;
349
+ testnet: true;
350
+ custom?: Record<string, unknown> | undefined;
351
+ fees?: viem.ChainFees<undefined> | undefined;
352
+ formatters?: undefined;
353
+ serializers?: viem.ChainSerializers<undefined, viem.TransactionSerializable> | undefined;
354
+ };
355
+ readonly 41454: {
356
+ blockExplorers: {
357
+ readonly default: {
358
+ readonly name: "Monad Testnet explorer";
359
+ readonly url: "https://testnet.monadexplorer.com";
360
+ };
361
+ };
362
+ contracts: {
363
+ readonly multicall3: {
364
+ readonly address: "0xcA11bde05977b3631167028862bE2a173976CA11";
365
+ readonly blockCreated: 251449;
366
+ };
367
+ };
368
+ ensTlds?: readonly string[] | undefined;
369
+ id: 10143;
370
+ name: "Monad Testnet";
371
+ nativeCurrency: {
372
+ readonly name: "Testnet MON Token";
373
+ readonly symbol: "MON";
374
+ readonly decimals: 18;
375
+ };
376
+ rpcUrls: {
377
+ readonly default: {
378
+ readonly http: readonly ["https://testnet-rpc.monad.xyz"];
379
+ };
380
+ };
381
+ sourceId?: number | undefined | undefined;
382
+ testnet: true;
383
+ custom?: Record<string, unknown> | undefined;
384
+ fees?: viem.ChainFees<undefined> | undefined;
385
+ formatters?: undefined;
386
+ serializers?: viem.ChainSerializers<undefined, viem.TransactionSerializable> | undefined;
387
+ };
388
+ readonly 31337: {
389
+ blockExplorers?: {
390
+ [key: string]: {
391
+ name: string;
392
+ url: string;
393
+ apiUrl?: string | undefined;
394
+ };
395
+ default: {
396
+ name: string;
397
+ url: string;
398
+ apiUrl?: string | undefined;
399
+ };
400
+ } | undefined | undefined;
401
+ contracts?: {
402
+ [x: string]: viem.ChainContract | {
403
+ [sourceId: number]: viem.ChainContract | undefined;
404
+ } | undefined;
405
+ ensRegistry?: viem.ChainContract | undefined;
406
+ ensUniversalResolver?: viem.ChainContract | undefined;
407
+ multicall3?: viem.ChainContract | undefined;
408
+ universalSignatureVerifier?: viem.ChainContract | undefined;
409
+ } | undefined;
410
+ ensTlds?: readonly string[] | undefined;
411
+ id: 31337;
412
+ name: "Hardhat";
413
+ nativeCurrency: {
414
+ readonly decimals: 18;
415
+ readonly name: "Ether";
416
+ readonly symbol: "ETH";
417
+ };
418
+ rpcUrls: {
419
+ readonly default: {
420
+ readonly http: readonly ["http://127.0.0.1:8545"];
421
+ };
422
+ };
423
+ sourceId?: number | undefined | undefined;
424
+ testnet?: boolean | undefined | undefined;
425
+ custom?: Record<string, unknown> | undefined;
426
+ fees?: viem.ChainFees<undefined> | undefined;
427
+ formatters?: undefined;
428
+ serializers?: viem.ChainSerializers<undefined, viem.TransactionSerializable> | undefined;
429
+ };
430
+ };
431
+ private eventListener;
432
+ private contractClient;
433
+ private initialized;
434
+ private protocol;
435
+ private protocolParams;
436
+ constructor(config: SDKConfig);
437
+ /**
438
+ * Initialize the SDK
439
+ */
440
+ initialize(): Promise<void>;
441
+ /**
442
+ * Encrypt a number using the configured protocol
443
+ * @param data - The number to encrypt
444
+ * @param publicKey - The public key to use for encryption
445
+ * @returns The encrypted number
446
+ */
447
+ encryptNumber(data: bigint, publicKey: Uint8Array): Promise<Uint8Array>;
448
+ /**
449
+ * Encrypt a number using the configured protocol and generate a zk-SNARK proof using Greco
450
+ * @param data - The number to encrypt
451
+ * @param publicKey - The public key to use for encryption
452
+ * @param circuit - The circuit to use for proof generation
453
+ * @returns The encrypted number and the proof
454
+ */
455
+ encryptNumberAndGenProof(data: bigint, publicKey: Uint8Array, circuit: CompiledCircuit): Promise<VerifiableEncryptionResult>;
456
+ /**
457
+ * Request a new E3 computation
458
+ */
459
+ requestE3(params: {
460
+ filter: `0x${string}`;
461
+ threshold: [number, number];
462
+ startWindow: [bigint, bigint];
463
+ duration: bigint;
464
+ e3Program: `0x${string}`;
465
+ e3ProgramParams: `0x${string}`;
466
+ computeProviderParams: `0x${string}`;
467
+ value?: bigint;
468
+ gasLimit?: bigint;
469
+ }): Promise<Hash>;
470
+ /**
471
+ * Activate an E3 computation
472
+ */
473
+ activateE3(e3Id: bigint, publicKey: `0x${string}`, gasLimit?: bigint): Promise<Hash>;
474
+ /**
475
+ * Publish input for an E3 computation
476
+ */
477
+ publishInput(e3Id: bigint, data: `0x${string}`, gasLimit?: bigint): Promise<Hash>;
478
+ /**
479
+ * Publish ciphertext output for an E3 computation
480
+ */
481
+ publishCiphertextOutput(e3Id: bigint, ciphertextOutput: `0x${string}`, proof: `0x${string}`, gasLimit?: bigint): Promise<Hash>;
482
+ /**
483
+ * Get E3 information
484
+ */
485
+ getE3(e3Id: bigint): Promise<E3>;
486
+ /**
487
+ * Unified Event Listening - Listen to any Enclave or Registry event
488
+ */
489
+ onEnclaveEvent<T extends AllEventTypes>(eventType: T, callback: EventCallback<T>): void;
490
+ /**
491
+ * Remove event listener
492
+ */
493
+ off<T extends AllEventTypes>(eventType: T, callback: EventCallback<T>): void;
494
+ /**
495
+ * Handle an event only once
496
+ */
497
+ once<T extends AllEventTypes>(type: T, callback: EventCallback<T>): void;
498
+ /**
499
+ * Get historical events
500
+ */
501
+ getHistoricalEvents(eventType: AllEventTypes, fromBlock?: bigint, toBlock?: bigint): Promise<Log[]>;
502
+ /**
503
+ * Start polling for events
504
+ */
505
+ startEventPolling(): Promise<void>;
506
+ /**
507
+ * Stop polling for events
508
+ */
509
+ stopEventPolling(): void;
510
+ /**
511
+ * Utility methods
512
+ */
513
+ /**
514
+ * Estimate gas for a transaction
515
+ */
516
+ estimateGas(functionName: string, args: readonly unknown[], contractAddress: `0x${string}`, abi: Abi, value?: bigint): Promise<bigint>;
517
+ /**
518
+ * Wait for transaction confirmation
519
+ */
520
+ waitForTransaction(hash: Hash): Promise<unknown>;
521
+ /**
522
+ * Clean up resources
523
+ */
524
+ cleanup(): void;
525
+ /**
526
+ * Update SDK configuration
527
+ */
528
+ updateConfig(newConfig: Partial<SDKConfig>): void;
529
+ static create(options: {
530
+ rpcUrl: string;
531
+ contracts: {
532
+ enclave: `0x${string}`;
533
+ ciphernodeRegistry: `0x${string}`;
534
+ };
535
+ privateKey?: `0x${string}`;
536
+ chainId: keyof typeof EnclaveSDK.chains;
537
+ protocol: FheProtocol;
538
+ protocolParams?: ProtocolParams;
539
+ }): EnclaveSDK;
540
+ }
541
+
542
+ declare class EventListener implements SDKEventEmitter {
543
+ private publicClient;
544
+ private config;
545
+ private listeners;
546
+ private activeWatchers;
547
+ private isPolling;
548
+ private lastBlockNumber;
549
+ constructor(publicClient: PublicClient, config?: EventListenerConfig);
550
+ /**
551
+ * Listen to specific contract events
552
+ */
553
+ watchContractEvent<T extends AllEventTypes>(address: `0x${string}`, eventType: T, abi: Abi, callback: EventCallback<T>): Promise<void>;
554
+ /**
555
+ * Listen to all logs from a specific address
556
+ */
557
+ watchLogs(address: `0x${string}`, callback: (log: Log) => void): Promise<void>;
558
+ /**
559
+ * Start polling for historical events
560
+ */
561
+ startPolling(): Promise<void>;
562
+ /**
563
+ * Stop polling for events
564
+ */
565
+ stopPolling(): void;
566
+ /**
567
+ * Get historical events
568
+ */
569
+ getHistoricalEvents(address: `0x${string}`, eventType: AllEventTypes, abi: Abi, fromBlock?: bigint, toBlock?: bigint): Promise<Log[]>;
570
+ /**
571
+ * SDKEventEmitter implementation
572
+ */
573
+ on<T extends AllEventTypes>(eventType: T, callback: EventCallback<T>): void;
574
+ off<T extends AllEventTypes>(eventType: T, callback: EventCallback<T>): void;
575
+ emit<T extends AllEventTypes>(event: EnclaveEvent<T>): void;
576
+ /**
577
+ * Clean up all listeners and watchers
578
+ */
579
+ cleanup(): void;
580
+ private pollForEvents;
581
+ }
582
+
583
+ declare class ContractClient {
584
+ private publicClient;
585
+ private walletClient?;
586
+ private addresses;
587
+ private contractInfo;
588
+ constructor(publicClient: PublicClient, walletClient?: WalletClient | undefined, addresses?: {
589
+ enclave: `0x${string}`;
590
+ ciphernodeRegistry: `0x${string}`;
591
+ });
592
+ /**
593
+ * Initialize contract instances
594
+ */
595
+ initialize(): Promise<void>;
596
+ /**
597
+ * Request a new E3 computation
598
+ * request(address filter, uint32[2] threshold, uint256[2] startWindow, uint256 duration, IE3Program e3Program, bytes e3ProgramParams, bytes computeProviderParams)
599
+ */
600
+ requestE3(filter: `0x${string}`, threshold: [number, number], startWindow: [bigint, bigint], duration: bigint, e3Program: `0x${string}`, e3ProgramParams: `0x${string}`, computeProviderParams: `0x${string}`, value?: bigint, gasLimit?: bigint): Promise<Hash>;
601
+ /**
602
+ * Activate an E3 computation
603
+ * activate(uint256 e3Id, bytes memory publicKey)
604
+ */
605
+ activateE3(e3Id: bigint, publicKey: `0x${string}`, gasLimit?: bigint): Promise<Hash>;
606
+ /**
607
+ * Publish input for an E3 computation
608
+ * publishInput(uint256 e3Id, bytes memory data)
609
+ */
610
+ publishInput(e3Id: bigint, data: `0x${string}`, gasLimit?: bigint): Promise<Hash>;
611
+ /**
612
+ * Publish ciphertext output for an E3 computation
613
+ * publishCiphertextOutput(uint256 e3Id, bytes memory ciphertextOutput, bytes memory proof)
614
+ */
615
+ publishCiphertextOutput(e3Id: bigint, ciphertextOutput: `0x${string}`, proof: `0x${string}`, gasLimit?: bigint): Promise<Hash>;
616
+ /**
617
+ * Get E3 information
618
+ * Based on the contract: getE3(uint256 e3Id) returns (E3 memory e3)
619
+ */
620
+ getE3(e3Id: bigint): Promise<E3>;
621
+ /**
622
+ * Estimate gas for a transaction
623
+ */
624
+ estimateGas(functionName: string, args: readonly unknown[], contractAddress: `0x${string}`, abi: Abi, value?: bigint): Promise<bigint>;
625
+ /**
626
+ * Wait for transaction confirmation
627
+ */
628
+ waitForTransaction(hash: Hash): Promise<TransactionReceipt>;
629
+ }
630
+
631
+ declare class SDKError extends Error {
632
+ readonly code?: string | undefined;
633
+ constructor(message: string, code?: string | undefined);
634
+ }
635
+ declare function isValidAddress(address: string): address is Address;
636
+ declare function isValidHash(hash: string): hash is Hash;
637
+ declare function formatEventName(contractName: string, eventName: string): string;
638
+ declare function parseEventData<T>(log: Log): T;
639
+ /**
640
+ * Sleep for a specified number of milliseconds
641
+ */
642
+ declare const sleep: (ms: number) => Promise<void>;
643
+ declare function formatBigInt(value: bigint): string;
644
+ declare function parseBigInt(value: string): bigint;
645
+ declare function generateEventId(log: Log): string;
646
+ /**
647
+ * Get the current timestamp in seconds
648
+ */
649
+ declare function getCurrentTimestamp(): number;
650
+ declare const BFV_PARAMS_SET: {
651
+ readonly degree: 2048;
652
+ readonly plaintext_modulus: 1032193;
653
+ readonly moduli: readonly [18014398492704769n];
654
+ };
655
+ interface ComputeProviderParams {
656
+ name: string;
657
+ parallel: boolean;
658
+ batch_size: number;
659
+ }
660
+ declare const DEFAULT_COMPUTE_PROVIDER_PARAMS: ComputeProviderParams;
661
+ declare const DEFAULT_E3_CONFIG: {
662
+ readonly threshold_min: 2;
663
+ readonly threshold_max: 3;
664
+ readonly window_size: 120;
665
+ readonly duration: 1800;
666
+ readonly payment_amount: "0";
667
+ };
668
+ /**
669
+ * Encode BFV parameters for the smart contract
670
+ * BFV (Brakerski-Fan-Vercauteren) is a type of fully homomorphic encryption
671
+ */
672
+ declare function encodeBfvParams(degree?: number, plaintext_modulus?: number, moduli?: readonly bigint[]): `0x${string}`;
673
+ /**
674
+ * Encode compute provider parameters for the smart contract
675
+ */
676
+ declare function encodeComputeProviderParams(params: ComputeProviderParams): `0x${string}`;
677
+ /**
678
+ * Calculate start window for E3 request
679
+ */
680
+ declare function calculateStartWindow(windowSize?: number): [bigint, bigint];
681
+ /**
682
+ * Decode plaintextOutput bytes to get the actual result number
683
+ */
684
+ declare function decodePlaintextOutput(plaintextOutput: string): number | null;
685
+
686
+ /**
687
+ * Describes the inputs to Greco circuit
688
+ */
689
+ interface CircuitInputs {
690
+ pk0is: string[][];
691
+ pk1is: string[][];
692
+ ct0is: string[][];
693
+ ct1is: string[][];
694
+ u: string[];
695
+ e0: string[];
696
+ e1: string[];
697
+ k1: string[];
698
+ r1is: string[][];
699
+ r2is: string[][];
700
+ p1is: string[][];
701
+ p2is: string[][];
702
+ }
703
+ /**
704
+ * Generate a proof for a given circuit and circuit inputs
705
+ * @dev Defaults to the UltraHonkBackend
706
+ * @param circuitInputs - The circuit inputs
707
+ * @param circuit - The circuit
708
+ * @returns The proof
709
+ */
710
+ declare const generateProof: (circuitInputs: CircuitInputs, circuit: CompiledCircuit) => Promise<ProofData>;
711
+
712
+ 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 };