@enclave-e3/sdk 0.1.11 → 0.1.13
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/dist/index.cjs +13 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -32
- package/dist/index.d.ts +15 -32
- package/dist/index.js +12 -93
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -91,7 +91,6 @@ interface ContractInstances {
|
|
|
91
91
|
}
|
|
92
92
|
declare enum EnclaveEventType {
|
|
93
93
|
E3_REQUESTED = "E3Requested",
|
|
94
|
-
E3_ACTIVATED = "E3Activated",
|
|
95
94
|
CIPHERTEXT_OUTPUT_PUBLISHED = "CiphertextOutputPublished",
|
|
96
95
|
PLAINTEXT_OUTPUT_PUBLISHED = "PlaintextOutputPublished",
|
|
97
96
|
E3_PROGRAM_ENABLED = "E3ProgramEnabled",
|
|
@@ -117,9 +116,7 @@ interface E3 {
|
|
|
117
116
|
seed: bigint;
|
|
118
117
|
threshold: readonly [number, number];
|
|
119
118
|
requestBlock: bigint;
|
|
120
|
-
|
|
121
|
-
duration: bigint;
|
|
122
|
-
expiration: bigint;
|
|
119
|
+
inputWindow: readonly [bigint, bigint];
|
|
123
120
|
encryptionSchemeId: string;
|
|
124
121
|
e3Program: string;
|
|
125
122
|
e3ProgramParams: string;
|
|
@@ -164,10 +161,11 @@ interface CommitteeRequestedData {
|
|
|
164
161
|
seed: bigint;
|
|
165
162
|
threshold: [bigint, bigint];
|
|
166
163
|
requestBlock: bigint;
|
|
167
|
-
|
|
164
|
+
committeeDeadline: bigint;
|
|
168
165
|
}
|
|
169
166
|
interface CommitteePublishedData {
|
|
170
167
|
e3Id: bigint;
|
|
168
|
+
nodes: string[];
|
|
171
169
|
publicKey: string;
|
|
172
170
|
}
|
|
173
171
|
interface CommitteeFinalizedData {
|
|
@@ -176,7 +174,6 @@ interface CommitteeFinalizedData {
|
|
|
176
174
|
}
|
|
177
175
|
interface EnclaveEventData {
|
|
178
176
|
[EnclaveEventType.E3_REQUESTED]: E3RequestedData;
|
|
179
|
-
[EnclaveEventType.E3_ACTIVATED]: E3ActivatedData;
|
|
180
177
|
[EnclaveEventType.CIPHERTEXT_OUTPUT_PUBLISHED]: CiphertextOutputPublishedData;
|
|
181
178
|
[EnclaveEventType.PLAINTEXT_OUTPUT_PUBLISHED]: PlaintextOutputPublishedData;
|
|
182
179
|
[EnclaveEventType.E3_PROGRAM_ENABLED]: {
|
|
@@ -535,8 +532,7 @@ declare class EnclaveSDK {
|
|
|
535
532
|
*/
|
|
536
533
|
requestE3(params: {
|
|
537
534
|
threshold: [number, number];
|
|
538
|
-
|
|
539
|
-
duration: bigint;
|
|
535
|
+
inputWindow: [bigint, bigint];
|
|
540
536
|
e3Program: `0x${string}`;
|
|
541
537
|
e3ProgramParams: `0x${string}`;
|
|
542
538
|
computeProviderParams: `0x${string}`;
|
|
@@ -549,14 +545,6 @@ declare class EnclaveSDK {
|
|
|
549
545
|
* @returns The public key
|
|
550
546
|
*/
|
|
551
547
|
getE3PublicKey(e3Id: bigint): Promise<`0x${string}`>;
|
|
552
|
-
/**
|
|
553
|
-
* Activate an E3 computation
|
|
554
|
-
*/
|
|
555
|
-
activateE3(e3Id: bigint, gasLimit?: bigint): Promise<Hash>;
|
|
556
|
-
/**
|
|
557
|
-
* Publish input for an E3 computation
|
|
558
|
-
*/
|
|
559
|
-
publishInput(e3Id: bigint, data: `0x${string}`, gasLimit?: bigint): Promise<Hash>;
|
|
560
548
|
/**
|
|
561
549
|
* Publish ciphertext output for an E3 computation
|
|
562
550
|
*/
|
|
@@ -683,19 +671,9 @@ declare class ContractClient {
|
|
|
683
671
|
approveFeeToken(amount: bigint): Promise<Hash>;
|
|
684
672
|
/**
|
|
685
673
|
* Request a new E3 computation
|
|
686
|
-
* request(
|
|
687
|
-
*/
|
|
688
|
-
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>;
|
|
689
|
-
/**
|
|
690
|
-
* Activate an E3 computation
|
|
691
|
-
* activate(uint256 e3Id)
|
|
692
|
-
*/
|
|
693
|
-
activateE3(e3Id: bigint, gasLimit?: bigint): Promise<Hash>;
|
|
694
|
-
/**
|
|
695
|
-
* Publish input for an E3 computation
|
|
696
|
-
* publishInput(uint256 e3Id, bytes memory data)
|
|
674
|
+
* request(uint32[2] threshold, uint256[2] inputWindow, IE3Program e3Program, bytes e3ProgramParams, bytes computeProviderParams, bytes customParams)
|
|
697
675
|
*/
|
|
698
|
-
|
|
676
|
+
requestE3(threshold: [number, number], inputWindow: [bigint, bigint], e3Program: `0x${string}`, e3ProgramParams: `0x${string}`, computeProviderParams: `0x${string}`, customParams?: `0x${string}`, gasLimit?: bigint): Promise<Hash>;
|
|
699
677
|
/**
|
|
700
678
|
* Publish ciphertext output for an E3 computation
|
|
701
679
|
* publishCiphertextOutput(uint256 e3Id, bytes memory ciphertextOutput, bytes memory proof)
|
|
@@ -740,8 +718,10 @@ declare function parseBigInt(value: string): bigint;
|
|
|
740
718
|
declare function generateEventId(log: Log): string;
|
|
741
719
|
/**
|
|
742
720
|
* Get the current timestamp in seconds
|
|
721
|
+
* from onchain
|
|
722
|
+
* @param publicClient - The public client to use
|
|
743
723
|
*/
|
|
744
|
-
declare function getCurrentTimestamp():
|
|
724
|
+
declare function getCurrentTimestamp(publicClient: PublicClient): Promise<bigint>;
|
|
745
725
|
interface ComputeProviderParams {
|
|
746
726
|
name: string;
|
|
747
727
|
parallel: boolean;
|
|
@@ -751,7 +731,6 @@ declare const DEFAULT_COMPUTE_PROVIDER_PARAMS: ComputeProviderParams;
|
|
|
751
731
|
declare const DEFAULT_E3_CONFIG: {
|
|
752
732
|
readonly threshold_min: 2;
|
|
753
733
|
readonly threshold_max: 5;
|
|
754
|
-
readonly window_size: 120;
|
|
755
734
|
readonly duration: 1800;
|
|
756
735
|
readonly payment_amount: "0";
|
|
757
736
|
};
|
|
@@ -771,11 +750,15 @@ declare function encodeComputeProviderParams(params: ComputeProviderParams, mock
|
|
|
771
750
|
declare function encodeCustomParams(params: Record<string, unknown>): `0x${string}`;
|
|
772
751
|
/**
|
|
773
752
|
* Calculate start window for E3 request
|
|
753
|
+
* @dev This function can be used for testing purposes, or for E3s which need to start as soon as possible.
|
|
754
|
+
* @param publicClient - The public client to use
|
|
755
|
+
* @param duration - The duration of the input window in seconds
|
|
756
|
+
* @param startBuffer - Buffer in seconds added to current timestamp for input window start
|
|
774
757
|
*/
|
|
775
|
-
declare function
|
|
758
|
+
declare function calculateInputWindow(publicClient: PublicClient, duration?: number, startBuffer?: bigint): Promise<[bigint, bigint]>;
|
|
776
759
|
/**
|
|
777
760
|
* Decode plaintextOutput bytes to get the actual result number
|
|
778
761
|
*/
|
|
779
762
|
declare function decodePlaintextOutput(plaintextOutput: string): number | null;
|
|
780
763
|
|
|
781
|
-
export { type AllEventTypes, type BfvParams, 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, type PlaintextOutputPublishedData, type Polynomial, type RegistryEventData, RegistryEventType, type SDKConfig, SDKError, type SDKEventEmitter, type ThresholdBfvParamsPresetName, ThresholdBfvParamsPresetNames, type VerifiableEncryptionResult,
|
|
764
|
+
export { type AllEventTypes, type BfvParams, 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, type PlaintextOutputPublishedData, type Polynomial, type RegistryEventData, RegistryEventType, type SDKConfig, SDKError, type SDKEventEmitter, type ThresholdBfvParamsPresetName, ThresholdBfvParamsPresetNames, type VerifiableEncryptionResult, calculateInputWindow, decodePlaintextOutput, encodeBfvParams, encodeComputeProviderParams, encodeCustomParams, formatBigInt, formatEventName, generateEventId, generateProof, getCurrentTimestamp, isValidAddress, isValidHash, parseBigInt, parseEventData, sleep };
|
package/dist/index.d.ts
CHANGED
|
@@ -91,7 +91,6 @@ interface ContractInstances {
|
|
|
91
91
|
}
|
|
92
92
|
declare enum EnclaveEventType {
|
|
93
93
|
E3_REQUESTED = "E3Requested",
|
|
94
|
-
E3_ACTIVATED = "E3Activated",
|
|
95
94
|
CIPHERTEXT_OUTPUT_PUBLISHED = "CiphertextOutputPublished",
|
|
96
95
|
PLAINTEXT_OUTPUT_PUBLISHED = "PlaintextOutputPublished",
|
|
97
96
|
E3_PROGRAM_ENABLED = "E3ProgramEnabled",
|
|
@@ -117,9 +116,7 @@ interface E3 {
|
|
|
117
116
|
seed: bigint;
|
|
118
117
|
threshold: readonly [number, number];
|
|
119
118
|
requestBlock: bigint;
|
|
120
|
-
|
|
121
|
-
duration: bigint;
|
|
122
|
-
expiration: bigint;
|
|
119
|
+
inputWindow: readonly [bigint, bigint];
|
|
123
120
|
encryptionSchemeId: string;
|
|
124
121
|
e3Program: string;
|
|
125
122
|
e3ProgramParams: string;
|
|
@@ -164,10 +161,11 @@ interface CommitteeRequestedData {
|
|
|
164
161
|
seed: bigint;
|
|
165
162
|
threshold: [bigint, bigint];
|
|
166
163
|
requestBlock: bigint;
|
|
167
|
-
|
|
164
|
+
committeeDeadline: bigint;
|
|
168
165
|
}
|
|
169
166
|
interface CommitteePublishedData {
|
|
170
167
|
e3Id: bigint;
|
|
168
|
+
nodes: string[];
|
|
171
169
|
publicKey: string;
|
|
172
170
|
}
|
|
173
171
|
interface CommitteeFinalizedData {
|
|
@@ -176,7 +174,6 @@ interface CommitteeFinalizedData {
|
|
|
176
174
|
}
|
|
177
175
|
interface EnclaveEventData {
|
|
178
176
|
[EnclaveEventType.E3_REQUESTED]: E3RequestedData;
|
|
179
|
-
[EnclaveEventType.E3_ACTIVATED]: E3ActivatedData;
|
|
180
177
|
[EnclaveEventType.CIPHERTEXT_OUTPUT_PUBLISHED]: CiphertextOutputPublishedData;
|
|
181
178
|
[EnclaveEventType.PLAINTEXT_OUTPUT_PUBLISHED]: PlaintextOutputPublishedData;
|
|
182
179
|
[EnclaveEventType.E3_PROGRAM_ENABLED]: {
|
|
@@ -535,8 +532,7 @@ declare class EnclaveSDK {
|
|
|
535
532
|
*/
|
|
536
533
|
requestE3(params: {
|
|
537
534
|
threshold: [number, number];
|
|
538
|
-
|
|
539
|
-
duration: bigint;
|
|
535
|
+
inputWindow: [bigint, bigint];
|
|
540
536
|
e3Program: `0x${string}`;
|
|
541
537
|
e3ProgramParams: `0x${string}`;
|
|
542
538
|
computeProviderParams: `0x${string}`;
|
|
@@ -549,14 +545,6 @@ declare class EnclaveSDK {
|
|
|
549
545
|
* @returns The public key
|
|
550
546
|
*/
|
|
551
547
|
getE3PublicKey(e3Id: bigint): Promise<`0x${string}`>;
|
|
552
|
-
/**
|
|
553
|
-
* Activate an E3 computation
|
|
554
|
-
*/
|
|
555
|
-
activateE3(e3Id: bigint, gasLimit?: bigint): Promise<Hash>;
|
|
556
|
-
/**
|
|
557
|
-
* Publish input for an E3 computation
|
|
558
|
-
*/
|
|
559
|
-
publishInput(e3Id: bigint, data: `0x${string}`, gasLimit?: bigint): Promise<Hash>;
|
|
560
548
|
/**
|
|
561
549
|
* Publish ciphertext output for an E3 computation
|
|
562
550
|
*/
|
|
@@ -683,19 +671,9 @@ declare class ContractClient {
|
|
|
683
671
|
approveFeeToken(amount: bigint): Promise<Hash>;
|
|
684
672
|
/**
|
|
685
673
|
* Request a new E3 computation
|
|
686
|
-
* request(
|
|
687
|
-
*/
|
|
688
|
-
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>;
|
|
689
|
-
/**
|
|
690
|
-
* Activate an E3 computation
|
|
691
|
-
* activate(uint256 e3Id)
|
|
692
|
-
*/
|
|
693
|
-
activateE3(e3Id: bigint, gasLimit?: bigint): Promise<Hash>;
|
|
694
|
-
/**
|
|
695
|
-
* Publish input for an E3 computation
|
|
696
|
-
* publishInput(uint256 e3Id, bytes memory data)
|
|
674
|
+
* request(uint32[2] threshold, uint256[2] inputWindow, IE3Program e3Program, bytes e3ProgramParams, bytes computeProviderParams, bytes customParams)
|
|
697
675
|
*/
|
|
698
|
-
|
|
676
|
+
requestE3(threshold: [number, number], inputWindow: [bigint, bigint], e3Program: `0x${string}`, e3ProgramParams: `0x${string}`, computeProviderParams: `0x${string}`, customParams?: `0x${string}`, gasLimit?: bigint): Promise<Hash>;
|
|
699
677
|
/**
|
|
700
678
|
* Publish ciphertext output for an E3 computation
|
|
701
679
|
* publishCiphertextOutput(uint256 e3Id, bytes memory ciphertextOutput, bytes memory proof)
|
|
@@ -740,8 +718,10 @@ declare function parseBigInt(value: string): bigint;
|
|
|
740
718
|
declare function generateEventId(log: Log): string;
|
|
741
719
|
/**
|
|
742
720
|
* Get the current timestamp in seconds
|
|
721
|
+
* from onchain
|
|
722
|
+
* @param publicClient - The public client to use
|
|
743
723
|
*/
|
|
744
|
-
declare function getCurrentTimestamp():
|
|
724
|
+
declare function getCurrentTimestamp(publicClient: PublicClient): Promise<bigint>;
|
|
745
725
|
interface ComputeProviderParams {
|
|
746
726
|
name: string;
|
|
747
727
|
parallel: boolean;
|
|
@@ -751,7 +731,6 @@ declare const DEFAULT_COMPUTE_PROVIDER_PARAMS: ComputeProviderParams;
|
|
|
751
731
|
declare const DEFAULT_E3_CONFIG: {
|
|
752
732
|
readonly threshold_min: 2;
|
|
753
733
|
readonly threshold_max: 5;
|
|
754
|
-
readonly window_size: 120;
|
|
755
734
|
readonly duration: 1800;
|
|
756
735
|
readonly payment_amount: "0";
|
|
757
736
|
};
|
|
@@ -771,11 +750,15 @@ declare function encodeComputeProviderParams(params: ComputeProviderParams, mock
|
|
|
771
750
|
declare function encodeCustomParams(params: Record<string, unknown>): `0x${string}`;
|
|
772
751
|
/**
|
|
773
752
|
* Calculate start window for E3 request
|
|
753
|
+
* @dev This function can be used for testing purposes, or for E3s which need to start as soon as possible.
|
|
754
|
+
* @param publicClient - The public client to use
|
|
755
|
+
* @param duration - The duration of the input window in seconds
|
|
756
|
+
* @param startBuffer - Buffer in seconds added to current timestamp for input window start
|
|
774
757
|
*/
|
|
775
|
-
declare function
|
|
758
|
+
declare function calculateInputWindow(publicClient: PublicClient, duration?: number, startBuffer?: bigint): Promise<[bigint, bigint]>;
|
|
776
759
|
/**
|
|
777
760
|
* Decode plaintextOutput bytes to get the actual result number
|
|
778
761
|
*/
|
|
779
762
|
declare function decodePlaintextOutput(plaintextOutput: string): number | null;
|
|
780
763
|
|
|
781
|
-
export { type AllEventTypes, type BfvParams, 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, type PlaintextOutputPublishedData, type Polynomial, type RegistryEventData, RegistryEventType, type SDKConfig, SDKError, type SDKEventEmitter, type ThresholdBfvParamsPresetName, ThresholdBfvParamsPresetNames, type VerifiableEncryptionResult,
|
|
764
|
+
export { type AllEventTypes, type BfvParams, 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, type PlaintextOutputPublishedData, type Polynomial, type RegistryEventData, RegistryEventType, type SDKConfig, SDKError, type SDKEventEmitter, type ThresholdBfvParamsPresetName, ThresholdBfvParamsPresetNames, type VerifiableEncryptionResult, calculateInputWindow, decodePlaintextOutput, encodeBfvParams, encodeComputeProviderParams, encodeCustomParams, formatBigInt, formatEventName, generateEventId, generateProof, getCurrentTimestamp, isValidAddress, isValidHash, parseBigInt, parseEventData, sleep };
|
package/dist/index.js
CHANGED
|
@@ -41,8 +41,9 @@ function parseBigInt(value) {
|
|
|
41
41
|
function generateEventId(log) {
|
|
42
42
|
return `${log.blockHash}-${log.logIndex}`;
|
|
43
43
|
}
|
|
44
|
-
function getCurrentTimestamp() {
|
|
45
|
-
|
|
44
|
+
async function getCurrentTimestamp(publicClient) {
|
|
45
|
+
const block = await publicClient.getBlock();
|
|
46
|
+
return block.timestamp;
|
|
46
47
|
}
|
|
47
48
|
var DEFAULT_COMPUTE_PROVIDER_PARAMS = {
|
|
48
49
|
name: "risc0",
|
|
@@ -52,8 +53,6 @@ var DEFAULT_COMPUTE_PROVIDER_PARAMS = {
|
|
|
52
53
|
var DEFAULT_E3_CONFIG = {
|
|
53
54
|
threshold_min: 2,
|
|
54
55
|
threshold_max: 5,
|
|
55
|
-
window_size: 120,
|
|
56
|
-
// 2 minutes in seconds
|
|
57
56
|
duration: 1800,
|
|
58
57
|
// 30 minutes in seconds
|
|
59
58
|
payment_amount: "0"
|
|
@@ -105,9 +104,10 @@ function encodeCustomParams(params) {
|
|
|
105
104
|
const bytes = encoder.encode(jsonString);
|
|
106
105
|
return `0x${Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
107
106
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
var inputWindowStartBuffer = 15n;
|
|
108
|
+
async function calculateInputWindow(publicClient, duration = DEFAULT_E3_CONFIG.duration, startBuffer = inputWindowStartBuffer) {
|
|
109
|
+
const now = await getCurrentTimestamp(publicClient);
|
|
110
|
+
return [BigInt(now) + startBuffer, BigInt(now) + startBuffer + BigInt(duration)];
|
|
111
111
|
}
|
|
112
112
|
function decodePlaintextOutput(plaintextOutput) {
|
|
113
113
|
try {
|
|
@@ -201,9 +201,9 @@ var ContractClient = class {
|
|
|
201
201
|
}
|
|
202
202
|
/**
|
|
203
203
|
* Request a new E3 computation
|
|
204
|
-
* request(
|
|
204
|
+
* request(uint32[2] threshold, uint256[2] inputWindow, IE3Program e3Program, bytes e3ProgramParams, bytes computeProviderParams, bytes customParams)
|
|
205
205
|
*/
|
|
206
|
-
async requestE3(threshold,
|
|
206
|
+
async requestE3(threshold, inputWindow, e3Program, e3ProgramParams, computeProviderParams, customParams, gasLimit) {
|
|
207
207
|
if (!this.walletClient) {
|
|
208
208
|
throw new SDKError("Wallet client required for write operations", "NO_WALLET");
|
|
209
209
|
}
|
|
@@ -222,8 +222,7 @@ var ContractClient = class {
|
|
|
222
222
|
args: [
|
|
223
223
|
{
|
|
224
224
|
threshold,
|
|
225
|
-
|
|
226
|
-
duration,
|
|
225
|
+
inputWindow,
|
|
227
226
|
e3Program,
|
|
228
227
|
e3ProgramParams,
|
|
229
228
|
computeProviderParams,
|
|
@@ -239,66 +238,6 @@ var ContractClient = class {
|
|
|
239
238
|
throw new SDKError(`Failed to request E3: ${error}`, "REQUEST_E3_FAILED");
|
|
240
239
|
}
|
|
241
240
|
}
|
|
242
|
-
/**
|
|
243
|
-
* Activate an E3 computation
|
|
244
|
-
* activate(uint256 e3Id)
|
|
245
|
-
*/
|
|
246
|
-
async activateE3(e3Id, gasLimit) {
|
|
247
|
-
if (!this.walletClient) {
|
|
248
|
-
throw new SDKError("Wallet client required for write operations", "NO_WALLET");
|
|
249
|
-
}
|
|
250
|
-
if (!this.contractInfo) {
|
|
251
|
-
await this.initialize();
|
|
252
|
-
}
|
|
253
|
-
try {
|
|
254
|
-
const account = this.walletClient.account;
|
|
255
|
-
if (!account) {
|
|
256
|
-
throw new SDKError("No account connected", "NO_ACCOUNT");
|
|
257
|
-
}
|
|
258
|
-
const { request } = await this.publicClient.simulateContract({
|
|
259
|
-
address: this.addresses.enclave,
|
|
260
|
-
abi: Enclave__factory.abi,
|
|
261
|
-
functionName: "activate",
|
|
262
|
-
args: [e3Id],
|
|
263
|
-
account,
|
|
264
|
-
gas: gasLimit
|
|
265
|
-
});
|
|
266
|
-
const hash = await this.walletClient.writeContract(request);
|
|
267
|
-
return hash;
|
|
268
|
-
} catch (error) {
|
|
269
|
-
throw new SDKError(`Failed to activate E3: ${error}`, "ACTIVATE_E3_FAILED");
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Publish input for an E3 computation
|
|
274
|
-
* publishInput(uint256 e3Id, bytes memory data)
|
|
275
|
-
*/
|
|
276
|
-
async publishInput(e3Id, data, gasLimit) {
|
|
277
|
-
if (!this.walletClient) {
|
|
278
|
-
throw new SDKError("Wallet client required for write operations", "NO_WALLET");
|
|
279
|
-
}
|
|
280
|
-
if (!this.contractInfo) {
|
|
281
|
-
await this.initialize();
|
|
282
|
-
}
|
|
283
|
-
try {
|
|
284
|
-
const account = this.walletClient.account;
|
|
285
|
-
if (!account) {
|
|
286
|
-
throw new SDKError("No account connected", "NO_ACCOUNT");
|
|
287
|
-
}
|
|
288
|
-
const { request } = await this.publicClient.simulateContract({
|
|
289
|
-
address: this.addresses.enclave,
|
|
290
|
-
abi: Enclave__factory.abi,
|
|
291
|
-
functionName: "publishInput",
|
|
292
|
-
args: [e3Id, data],
|
|
293
|
-
account,
|
|
294
|
-
gas: gasLimit
|
|
295
|
-
});
|
|
296
|
-
const hash = await this.walletClient.writeContract(request);
|
|
297
|
-
return hash;
|
|
298
|
-
} catch (error) {
|
|
299
|
-
throw new SDKError(`Failed to publish input: ${error}`, "PUBLISH_INPUT_FAILED");
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
241
|
/**
|
|
303
242
|
* Publish ciphertext output for an E3 computation
|
|
304
243
|
* publishCiphertextOutput(uint256 e3Id, bytes memory ciphertextOutput, bytes memory proof)
|
|
@@ -607,7 +546,6 @@ var EventListener = class {
|
|
|
607
546
|
// src/types.ts
|
|
608
547
|
var EnclaveEventType = /* @__PURE__ */ ((EnclaveEventType2) => {
|
|
609
548
|
EnclaveEventType2["E3_REQUESTED"] = "E3Requested";
|
|
610
|
-
EnclaveEventType2["E3_ACTIVATED"] = "E3Activated";
|
|
611
549
|
EnclaveEventType2["CIPHERTEXT_OUTPUT_PUBLISHED"] = "CiphertextOutputPublished";
|
|
612
550
|
EnclaveEventType2["PLAINTEXT_OUTPUT_PUBLISHED"] = "PlaintextOutputPublished";
|
|
613
551
|
EnclaveEventType2["E3_PROGRAM_ENABLED"] = "E3ProgramEnabled";
|
|
@@ -873,8 +811,7 @@ var EnclaveSDK = class _EnclaveSDK {
|
|
|
873
811
|
}
|
|
874
812
|
return this.contractClient.requestE3(
|
|
875
813
|
params.threshold,
|
|
876
|
-
params.
|
|
877
|
-
params.duration,
|
|
814
|
+
params.inputWindow,
|
|
878
815
|
params.e3Program,
|
|
879
816
|
params.e3ProgramParams,
|
|
880
817
|
params.computeProviderParams,
|
|
@@ -893,24 +830,6 @@ var EnclaveSDK = class _EnclaveSDK {
|
|
|
893
830
|
}
|
|
894
831
|
return this.contractClient.getE3PublicKey(e3Id);
|
|
895
832
|
}
|
|
896
|
-
/**
|
|
897
|
-
* Activate an E3 computation
|
|
898
|
-
*/
|
|
899
|
-
async activateE3(e3Id, gasLimit) {
|
|
900
|
-
if (!this.initialized) {
|
|
901
|
-
await this.initialize();
|
|
902
|
-
}
|
|
903
|
-
return this.contractClient.activateE3(e3Id, gasLimit);
|
|
904
|
-
}
|
|
905
|
-
/**
|
|
906
|
-
* Publish input for an E3 computation
|
|
907
|
-
*/
|
|
908
|
-
async publishInput(e3Id, data, gasLimit) {
|
|
909
|
-
if (!this.initialized) {
|
|
910
|
-
await this.initialize();
|
|
911
|
-
}
|
|
912
|
-
return this.contractClient.publishInput(e3Id, data, gasLimit);
|
|
913
|
-
}
|
|
914
833
|
/**
|
|
915
834
|
* Publish ciphertext output for an E3 computation
|
|
916
835
|
*/
|
|
@@ -1062,7 +981,7 @@ export {
|
|
|
1062
981
|
RegistryEventType,
|
|
1063
982
|
SDKError,
|
|
1064
983
|
ThresholdBfvParamsPresetNames,
|
|
1065
|
-
|
|
984
|
+
calculateInputWindow,
|
|
1066
985
|
decodePlaintextOutput,
|
|
1067
986
|
encodeBfvParams,
|
|
1068
987
|
encodeComputeProviderParams,
|