@cloak.ag/sdk 1.0.2 → 1.0.4
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/chunk-S76QK36U.js +303 -0
- package/dist/crypto-3TOLQOOK.js +54 -0
- package/dist/index.cjs +140 -606
- package/dist/index.d.cts +14 -209
- package/dist/index.d.ts +14 -209
- package/dist/index.js +129 -593
- package/package.json +9 -5
package/dist/index.d.cts
CHANGED
|
@@ -34,7 +34,7 @@ interface CloakNote {
|
|
|
34
34
|
version: string;
|
|
35
35
|
/** Amount in lamports */
|
|
36
36
|
amount: number;
|
|
37
|
-
/**
|
|
37
|
+
/** Commitment hash (hex) */
|
|
38
38
|
commitment: string;
|
|
39
39
|
/** Spending secret key (hex, 64 chars) */
|
|
40
40
|
sk_spend: string;
|
|
@@ -210,50 +210,6 @@ interface WithdrawOptions extends TransferOptions {
|
|
|
210
210
|
/** Specific amount to withdraw in lamports (if not withdrawing all) */
|
|
211
211
|
amount?: number;
|
|
212
212
|
}
|
|
213
|
-
/**
|
|
214
|
-
* SP1 proof inputs for zero-knowledge proof generation
|
|
215
|
-
*/
|
|
216
|
-
interface SP1ProofInputs {
|
|
217
|
-
privateInputs: {
|
|
218
|
-
amount: number;
|
|
219
|
-
r: string;
|
|
220
|
-
sk_spend: string;
|
|
221
|
-
leaf_index: number;
|
|
222
|
-
merkle_path: {
|
|
223
|
-
path_elements: string[];
|
|
224
|
-
path_indices: number[];
|
|
225
|
-
};
|
|
226
|
-
};
|
|
227
|
-
publicInputs: {
|
|
228
|
-
root: string;
|
|
229
|
-
nf: string;
|
|
230
|
-
outputs_hash: string;
|
|
231
|
-
amount: number;
|
|
232
|
-
};
|
|
233
|
-
outputs: Array<{
|
|
234
|
-
address: string;
|
|
235
|
-
amount: number;
|
|
236
|
-
}>;
|
|
237
|
-
/**
|
|
238
|
-
* Optional swap parameters for token swaps
|
|
239
|
-
* When provided, the proof will be for a swap transaction
|
|
240
|
-
*/
|
|
241
|
-
swapParams?: {
|
|
242
|
-
output_mint: string;
|
|
243
|
-
recipient_ata: string;
|
|
244
|
-
min_output_amount: number;
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Result from proof generation
|
|
249
|
-
*/
|
|
250
|
-
interface SP1ProofResult {
|
|
251
|
-
success: boolean;
|
|
252
|
-
proof?: string;
|
|
253
|
-
publicInputs?: string;
|
|
254
|
-
generationTimeMs: number;
|
|
255
|
-
error?: string;
|
|
256
|
-
}
|
|
257
213
|
/**
|
|
258
214
|
* Merkle root response from indexer
|
|
259
215
|
*/
|
|
@@ -317,6 +273,13 @@ interface SwapOptions extends TransferOptions {
|
|
|
317
273
|
outAmount: number;
|
|
318
274
|
minOutputAmount: number;
|
|
319
275
|
}>;
|
|
276
|
+
/**
|
|
277
|
+
* Recipient's associated token account for the output token.
|
|
278
|
+
* If not provided, will be computed automatically (requires @solana/spl-token).
|
|
279
|
+
* For browser environments, it's recommended to compute this in the frontend
|
|
280
|
+
* where @solana/spl-token is properly bundled.
|
|
281
|
+
*/
|
|
282
|
+
recipientAta?: string;
|
|
320
283
|
}
|
|
321
284
|
/**
|
|
322
285
|
* Result from a swap operation
|
|
@@ -516,12 +479,11 @@ declare class CloakSDK {
|
|
|
516
479
|
private wallet?;
|
|
517
480
|
private cloakKeys?;
|
|
518
481
|
private indexer;
|
|
519
|
-
private artifactProver;
|
|
520
482
|
private relay;
|
|
521
483
|
private depositRecovery;
|
|
522
484
|
private storage;
|
|
523
485
|
/**
|
|
524
|
-
|
|
486
|
+
* Create a new Cloak SDK client
|
|
525
487
|
*
|
|
526
488
|
* @param config - Client configuration
|
|
527
489
|
*
|
|
@@ -1004,8 +966,11 @@ declare function poseidonHash(inputs: bigint[]): Promise<bigint>;
|
|
|
1004
966
|
declare function splitTo2Limbs(value: bigint): [bigint, bigint];
|
|
1005
967
|
/**
|
|
1006
968
|
* Convert a PublicKey (32 bytes) to two 128-bit limbs
|
|
969
|
+
* Uses duck typing to handle cross-module PublicKey instances
|
|
1007
970
|
*/
|
|
1008
|
-
declare function pubkeyToLimbs(pubkey: Uint8Array | PublicKey
|
|
971
|
+
declare function pubkeyToLimbs(pubkey: Uint8Array | PublicKey | {
|
|
972
|
+
toBytes: () => Uint8Array;
|
|
973
|
+
}): [bigint, bigint];
|
|
1009
974
|
/**
|
|
1010
975
|
* Compute Merkle root from leaf and path
|
|
1011
976
|
*
|
|
@@ -1514,166 +1479,6 @@ declare class IndexerService {
|
|
|
1514
1479
|
}>;
|
|
1515
1480
|
}
|
|
1516
1481
|
|
|
1517
|
-
/**
|
|
1518
|
-
* Options for artifact-based proof generation
|
|
1519
|
-
*/
|
|
1520
|
-
interface ArtifactProofGenerationOptions {
|
|
1521
|
-
/** Progress callback - called with percentage (0-100) */
|
|
1522
|
-
onProgress?: (progress: number) => void;
|
|
1523
|
-
/** Called when proof generation starts */
|
|
1524
|
-
onStart?: () => void;
|
|
1525
|
-
/** Called on successful proof generation */
|
|
1526
|
-
onSuccess?: (result: SP1ProofResult) => void;
|
|
1527
|
-
/** Called on error */
|
|
1528
|
-
onError?: (error: string) => void;
|
|
1529
|
-
/** Custom timeout in milliseconds */
|
|
1530
|
-
timeout?: number;
|
|
1531
|
-
/** Polling interval for proof status (default: 2000ms) */
|
|
1532
|
-
pollInterval?: number;
|
|
1533
|
-
}
|
|
1534
|
-
/**
|
|
1535
|
-
* Artifact-based Prover Service
|
|
1536
|
-
*
|
|
1537
|
-
* Implements the artifact-based proof generation flow where private inputs
|
|
1538
|
-
* are uploaded directly to the TEE, never passing through the backend in plaintext.
|
|
1539
|
-
*
|
|
1540
|
-
* Flow:
|
|
1541
|
-
* 1. Create artifact → get artifact_id and upload_url
|
|
1542
|
-
* 2. Upload stdin directly to TEE (bypassing backend)
|
|
1543
|
-
* 3. Request proof generation (backend only gets artifact_id)
|
|
1544
|
-
* 4. Poll for proof status until ready
|
|
1545
|
-
*
|
|
1546
|
-
* ✅ PRIVACY: Private inputs never pass through backend in plaintext
|
|
1547
|
-
*/
|
|
1548
|
-
declare class ArtifactProverService {
|
|
1549
|
-
private indexerUrl;
|
|
1550
|
-
private timeout;
|
|
1551
|
-
private pollInterval;
|
|
1552
|
-
/**
|
|
1553
|
-
* Create a new Artifact Prover Service client
|
|
1554
|
-
*
|
|
1555
|
-
* @param indexerUrl - Indexer service base URL
|
|
1556
|
-
* @param timeout - Proof generation timeout in ms (default: 5 minutes)
|
|
1557
|
-
* @param pollInterval - Polling interval for status checks (default: 2 seconds)
|
|
1558
|
-
*/
|
|
1559
|
-
constructor(indexerUrl: string, timeout?: number, pollInterval?: number);
|
|
1560
|
-
/**
|
|
1561
|
-
* Generate a zero-knowledge proof using artifact-based flow
|
|
1562
|
-
*
|
|
1563
|
-
* This process typically takes 30-180 seconds depending on the TEE.
|
|
1564
|
-
* Private inputs are uploaded directly to TEE, never passing through backend.
|
|
1565
|
-
*
|
|
1566
|
-
* @param inputs - Circuit inputs (private + public + outputs)
|
|
1567
|
-
* @param options - Optional progress tracking and callbacks
|
|
1568
|
-
* @returns Proof result with hex-encoded proof and public inputs
|
|
1569
|
-
*
|
|
1570
|
-
* @example
|
|
1571
|
-
* ```typescript
|
|
1572
|
-
* const result = await prover.generateProof(inputs);
|
|
1573
|
-
* if (result.success) {
|
|
1574
|
-
* console.log(`Proof: ${result.proof}`);
|
|
1575
|
-
* }
|
|
1576
|
-
* ```
|
|
1577
|
-
*/
|
|
1578
|
-
generateProof(inputs: SP1ProofInputs, options?: ArtifactProofGenerationOptions): Promise<SP1ProofResult>;
|
|
1579
|
-
/**
|
|
1580
|
-
* Check if the artifact prover service is available
|
|
1581
|
-
*
|
|
1582
|
-
* @returns True if service is healthy
|
|
1583
|
-
*/
|
|
1584
|
-
healthCheck(): Promise<boolean>;
|
|
1585
|
-
/**
|
|
1586
|
-
* Get the configured timeout
|
|
1587
|
-
*/
|
|
1588
|
-
getTimeout(): number;
|
|
1589
|
-
/**
|
|
1590
|
-
* Set a new timeout
|
|
1591
|
-
*/
|
|
1592
|
-
setTimeout(timeout: number): void;
|
|
1593
|
-
}
|
|
1594
|
-
|
|
1595
|
-
/**
|
|
1596
|
-
* Options for proof generation
|
|
1597
|
-
*/
|
|
1598
|
-
interface ProofGenerationOptions {
|
|
1599
|
-
/** Progress callback - called with percentage (0-100) */
|
|
1600
|
-
onProgress?: (progress: number) => void;
|
|
1601
|
-
/** Called when proof generation starts */
|
|
1602
|
-
onStart?: () => void;
|
|
1603
|
-
/** Called on successful proof generation */
|
|
1604
|
-
onSuccess?: (result: SP1ProofResult) => void;
|
|
1605
|
-
/** Called on error */
|
|
1606
|
-
onError?: (error: string) => void;
|
|
1607
|
-
/** Custom timeout in milliseconds */
|
|
1608
|
-
timeout?: number;
|
|
1609
|
-
}
|
|
1610
|
-
/**
|
|
1611
|
-
* Prover Service Client (Legacy)
|
|
1612
|
-
*
|
|
1613
|
-
* Handles zero-knowledge proof generation via the backend prover service.
|
|
1614
|
-
*
|
|
1615
|
-
* ⚠️ DEPRECATED: This implementation sends private inputs to a backend service.
|
|
1616
|
-
*
|
|
1617
|
-
* **Use ArtifactProverService instead** for privacy-preserving proof generation
|
|
1618
|
-
* where private inputs are uploaded directly to TEE, never passing through backend.
|
|
1619
|
-
*
|
|
1620
|
-
* This class is kept for backward compatibility but is not used by CloakSDK anymore.
|
|
1621
|
-
*/
|
|
1622
|
-
declare class ProverService {
|
|
1623
|
-
private indexerUrl;
|
|
1624
|
-
private timeout;
|
|
1625
|
-
/**
|
|
1626
|
-
* Create a new Prover Service client
|
|
1627
|
-
*
|
|
1628
|
-
* @param indexerUrl - Indexer/Prover service base URL
|
|
1629
|
-
* @param timeout - Proof generation timeout in ms (default: 5 minutes)
|
|
1630
|
-
*/
|
|
1631
|
-
constructor(indexerUrl: string, timeout?: number);
|
|
1632
|
-
/**
|
|
1633
|
-
* Generate a zero-knowledge proof for withdrawal
|
|
1634
|
-
*
|
|
1635
|
-
* This process typically takes 30-180 seconds depending on the backend.
|
|
1636
|
-
*
|
|
1637
|
-
* @param inputs - Circuit inputs (private + public + outputs)
|
|
1638
|
-
* @param options - Optional progress tracking and callbacks
|
|
1639
|
-
* @returns Proof result with hex-encoded proof and public inputs
|
|
1640
|
-
*
|
|
1641
|
-
* @example
|
|
1642
|
-
* ```typescript
|
|
1643
|
-
* const result = await prover.generateProof(inputs);
|
|
1644
|
-
* if (result.success) {
|
|
1645
|
-
* console.log(`Proof: ${result.proof}`);
|
|
1646
|
-
* }
|
|
1647
|
-
* ```
|
|
1648
|
-
*
|
|
1649
|
-
* @example
|
|
1650
|
-
* ```typescript
|
|
1651
|
-
* // With progress tracking
|
|
1652
|
-
* const result = await prover.generateProof(inputs, {
|
|
1653
|
-
* onProgress: (progress) => console.log(`Progress: ${progress}%`),
|
|
1654
|
-
* onStart: () => console.log("Starting proof generation..."),
|
|
1655
|
-
* onSuccess: (result) => console.log("Proof generated!"),
|
|
1656
|
-
* onError: (error) => console.error("Failed:", error)
|
|
1657
|
-
* });
|
|
1658
|
-
* ```
|
|
1659
|
-
*/
|
|
1660
|
-
generateProof(inputs: SP1ProofInputs, options?: ProofGenerationOptions): Promise<SP1ProofResult>;
|
|
1661
|
-
/**
|
|
1662
|
-
* Check if the prover service is available
|
|
1663
|
-
*
|
|
1664
|
-
* @returns True if service is healthy
|
|
1665
|
-
*/
|
|
1666
|
-
healthCheck(): Promise<boolean>;
|
|
1667
|
-
/**
|
|
1668
|
-
* Get the configured timeout
|
|
1669
|
-
*/
|
|
1670
|
-
getTimeout(): number;
|
|
1671
|
-
/**
|
|
1672
|
-
* Set a new timeout
|
|
1673
|
-
*/
|
|
1674
|
-
setTimeout(timeout: number): void;
|
|
1675
|
-
}
|
|
1676
|
-
|
|
1677
1482
|
/**
|
|
1678
1483
|
* Relay Service Client
|
|
1679
1484
|
*
|
|
@@ -2083,4 +1888,4 @@ declare function generateWithdrawSwapProof(inputs: WithdrawSwapInputs, circuitsP
|
|
|
2083
1888
|
|
|
2084
1889
|
declare const VERSION = "1.0.0";
|
|
2085
1890
|
|
|
2086
|
-
export {
|
|
1891
|
+
export { CLOAK_PROGRAM_ID, type CloakConfig, CloakError, type CloakKeyPair, type CloakNote, CloakSDK, type DepositInstructionParams, type DepositOptions, DepositRecoveryService, type DepositResult, type DepositStatus, type EncryptedNote, FIXED_FEE_LAMPORTS, type Groth16Proof, IndexerService, LAMPORTS_PER_SOL, LocalStorageAdapter, type MasterKey, type MaxLengthArray, MemoryStorageAdapter, type MerkleProof, type MerkleRootResponse, type Network, type NoteData, type NotesRangeResponse, type ProofResult, type RecoveryOptions, type RecoveryResult, RelayService, type ScanNotesOptions, type ScannedNote, type ShieldPoolPDAs, type SpendKey, type StorageAdapter, type SwapOptions, type SwapParams, type SwapResult, type Transfer, type TransferOptions, type TransferResult, type TxStatus, VARIABLE_FEE_RATE, VERSION, type ViewKey, type WalletAdapter, type WithdrawOptions, type WithdrawRegularInputs, type WithdrawSwapInputs, bigintToBytes32, buildPublicInputsBytes, bytesToHex, calculateFee, calculateRelayFee, computeCommitment, computeMerkleRoot, computeNullifier, computeNullifierAsync, computeNullifierSync, computeOutputsHash, computeOutputsHashAsync, computeOutputsHashSync, computeSwapOutputsHash, computeSwapOutputsHashAsync, computeSwapOutputsHashSync, copyNoteToClipboard, createCloakError, createDepositInstruction, deriveSpendKey, deriveViewKey, detectNetworkFromRpcUrl, downloadNote, encodeNoteSimple, encryptNoteForRecipient, exportKeys, exportNote, exportWalletKeys, filterNotesByNetwork, filterWithdrawableNotes, findNoteByCommitment, formatAmount, formatErrorForLogging, generateCloakKeys, generateCommitment, generateCommitmentAsync, generateMasterSeed, generateNote, generateNoteFromWallet, generateWithdrawRegularProof, generateWithdrawSwapProof, getAddressExplorerUrl, getDistributableAmount, getExplorerUrl, getPublicKey, getPublicViewKey, getRecipientAmount, getRpcUrlForNetwork, getShieldPoolPDAs, getViewKey, hexToBigint, hexToBytes, importKeys, importWalletKeys, isValidHex, isValidRpcUrl, isValidSolanaAddress, isWithdrawable, keypairToAdapter, parseAmount, parseNote, parseTransactionError, poseidonHash, prepareEncryptedOutput, prepareEncryptedOutputForRecipient, proofToBytes, pubkeyToLimbs, randomBytes, scanNotesForWallet, sendTransaction, serializeNote, signTransaction, splitTo2Limbs, tryDecryptNote, updateNoteWithDeposit, validateDepositParams, validateNote, validateOutputsSum, validateTransfers, validateWalletConnected, validateWithdrawableNote };
|
package/dist/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ interface CloakNote {
|
|
|
34
34
|
version: string;
|
|
35
35
|
/** Amount in lamports */
|
|
36
36
|
amount: number;
|
|
37
|
-
/**
|
|
37
|
+
/** Commitment hash (hex) */
|
|
38
38
|
commitment: string;
|
|
39
39
|
/** Spending secret key (hex, 64 chars) */
|
|
40
40
|
sk_spend: string;
|
|
@@ -210,50 +210,6 @@ interface WithdrawOptions extends TransferOptions {
|
|
|
210
210
|
/** Specific amount to withdraw in lamports (if not withdrawing all) */
|
|
211
211
|
amount?: number;
|
|
212
212
|
}
|
|
213
|
-
/**
|
|
214
|
-
* SP1 proof inputs for zero-knowledge proof generation
|
|
215
|
-
*/
|
|
216
|
-
interface SP1ProofInputs {
|
|
217
|
-
privateInputs: {
|
|
218
|
-
amount: number;
|
|
219
|
-
r: string;
|
|
220
|
-
sk_spend: string;
|
|
221
|
-
leaf_index: number;
|
|
222
|
-
merkle_path: {
|
|
223
|
-
path_elements: string[];
|
|
224
|
-
path_indices: number[];
|
|
225
|
-
};
|
|
226
|
-
};
|
|
227
|
-
publicInputs: {
|
|
228
|
-
root: string;
|
|
229
|
-
nf: string;
|
|
230
|
-
outputs_hash: string;
|
|
231
|
-
amount: number;
|
|
232
|
-
};
|
|
233
|
-
outputs: Array<{
|
|
234
|
-
address: string;
|
|
235
|
-
amount: number;
|
|
236
|
-
}>;
|
|
237
|
-
/**
|
|
238
|
-
* Optional swap parameters for token swaps
|
|
239
|
-
* When provided, the proof will be for a swap transaction
|
|
240
|
-
*/
|
|
241
|
-
swapParams?: {
|
|
242
|
-
output_mint: string;
|
|
243
|
-
recipient_ata: string;
|
|
244
|
-
min_output_amount: number;
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Result from proof generation
|
|
249
|
-
*/
|
|
250
|
-
interface SP1ProofResult {
|
|
251
|
-
success: boolean;
|
|
252
|
-
proof?: string;
|
|
253
|
-
publicInputs?: string;
|
|
254
|
-
generationTimeMs: number;
|
|
255
|
-
error?: string;
|
|
256
|
-
}
|
|
257
213
|
/**
|
|
258
214
|
* Merkle root response from indexer
|
|
259
215
|
*/
|
|
@@ -317,6 +273,13 @@ interface SwapOptions extends TransferOptions {
|
|
|
317
273
|
outAmount: number;
|
|
318
274
|
minOutputAmount: number;
|
|
319
275
|
}>;
|
|
276
|
+
/**
|
|
277
|
+
* Recipient's associated token account for the output token.
|
|
278
|
+
* If not provided, will be computed automatically (requires @solana/spl-token).
|
|
279
|
+
* For browser environments, it's recommended to compute this in the frontend
|
|
280
|
+
* where @solana/spl-token is properly bundled.
|
|
281
|
+
*/
|
|
282
|
+
recipientAta?: string;
|
|
320
283
|
}
|
|
321
284
|
/**
|
|
322
285
|
* Result from a swap operation
|
|
@@ -516,12 +479,11 @@ declare class CloakSDK {
|
|
|
516
479
|
private wallet?;
|
|
517
480
|
private cloakKeys?;
|
|
518
481
|
private indexer;
|
|
519
|
-
private artifactProver;
|
|
520
482
|
private relay;
|
|
521
483
|
private depositRecovery;
|
|
522
484
|
private storage;
|
|
523
485
|
/**
|
|
524
|
-
|
|
486
|
+
* Create a new Cloak SDK client
|
|
525
487
|
*
|
|
526
488
|
* @param config - Client configuration
|
|
527
489
|
*
|
|
@@ -1004,8 +966,11 @@ declare function poseidonHash(inputs: bigint[]): Promise<bigint>;
|
|
|
1004
966
|
declare function splitTo2Limbs(value: bigint): [bigint, bigint];
|
|
1005
967
|
/**
|
|
1006
968
|
* Convert a PublicKey (32 bytes) to two 128-bit limbs
|
|
969
|
+
* Uses duck typing to handle cross-module PublicKey instances
|
|
1007
970
|
*/
|
|
1008
|
-
declare function pubkeyToLimbs(pubkey: Uint8Array | PublicKey
|
|
971
|
+
declare function pubkeyToLimbs(pubkey: Uint8Array | PublicKey | {
|
|
972
|
+
toBytes: () => Uint8Array;
|
|
973
|
+
}): [bigint, bigint];
|
|
1009
974
|
/**
|
|
1010
975
|
* Compute Merkle root from leaf and path
|
|
1011
976
|
*
|
|
@@ -1514,166 +1479,6 @@ declare class IndexerService {
|
|
|
1514
1479
|
}>;
|
|
1515
1480
|
}
|
|
1516
1481
|
|
|
1517
|
-
/**
|
|
1518
|
-
* Options for artifact-based proof generation
|
|
1519
|
-
*/
|
|
1520
|
-
interface ArtifactProofGenerationOptions {
|
|
1521
|
-
/** Progress callback - called with percentage (0-100) */
|
|
1522
|
-
onProgress?: (progress: number) => void;
|
|
1523
|
-
/** Called when proof generation starts */
|
|
1524
|
-
onStart?: () => void;
|
|
1525
|
-
/** Called on successful proof generation */
|
|
1526
|
-
onSuccess?: (result: SP1ProofResult) => void;
|
|
1527
|
-
/** Called on error */
|
|
1528
|
-
onError?: (error: string) => void;
|
|
1529
|
-
/** Custom timeout in milliseconds */
|
|
1530
|
-
timeout?: number;
|
|
1531
|
-
/** Polling interval for proof status (default: 2000ms) */
|
|
1532
|
-
pollInterval?: number;
|
|
1533
|
-
}
|
|
1534
|
-
/**
|
|
1535
|
-
* Artifact-based Prover Service
|
|
1536
|
-
*
|
|
1537
|
-
* Implements the artifact-based proof generation flow where private inputs
|
|
1538
|
-
* are uploaded directly to the TEE, never passing through the backend in plaintext.
|
|
1539
|
-
*
|
|
1540
|
-
* Flow:
|
|
1541
|
-
* 1. Create artifact → get artifact_id and upload_url
|
|
1542
|
-
* 2. Upload stdin directly to TEE (bypassing backend)
|
|
1543
|
-
* 3. Request proof generation (backend only gets artifact_id)
|
|
1544
|
-
* 4. Poll for proof status until ready
|
|
1545
|
-
*
|
|
1546
|
-
* ✅ PRIVACY: Private inputs never pass through backend in plaintext
|
|
1547
|
-
*/
|
|
1548
|
-
declare class ArtifactProverService {
|
|
1549
|
-
private indexerUrl;
|
|
1550
|
-
private timeout;
|
|
1551
|
-
private pollInterval;
|
|
1552
|
-
/**
|
|
1553
|
-
* Create a new Artifact Prover Service client
|
|
1554
|
-
*
|
|
1555
|
-
* @param indexerUrl - Indexer service base URL
|
|
1556
|
-
* @param timeout - Proof generation timeout in ms (default: 5 minutes)
|
|
1557
|
-
* @param pollInterval - Polling interval for status checks (default: 2 seconds)
|
|
1558
|
-
*/
|
|
1559
|
-
constructor(indexerUrl: string, timeout?: number, pollInterval?: number);
|
|
1560
|
-
/**
|
|
1561
|
-
* Generate a zero-knowledge proof using artifact-based flow
|
|
1562
|
-
*
|
|
1563
|
-
* This process typically takes 30-180 seconds depending on the TEE.
|
|
1564
|
-
* Private inputs are uploaded directly to TEE, never passing through backend.
|
|
1565
|
-
*
|
|
1566
|
-
* @param inputs - Circuit inputs (private + public + outputs)
|
|
1567
|
-
* @param options - Optional progress tracking and callbacks
|
|
1568
|
-
* @returns Proof result with hex-encoded proof and public inputs
|
|
1569
|
-
*
|
|
1570
|
-
* @example
|
|
1571
|
-
* ```typescript
|
|
1572
|
-
* const result = await prover.generateProof(inputs);
|
|
1573
|
-
* if (result.success) {
|
|
1574
|
-
* console.log(`Proof: ${result.proof}`);
|
|
1575
|
-
* }
|
|
1576
|
-
* ```
|
|
1577
|
-
*/
|
|
1578
|
-
generateProof(inputs: SP1ProofInputs, options?: ArtifactProofGenerationOptions): Promise<SP1ProofResult>;
|
|
1579
|
-
/**
|
|
1580
|
-
* Check if the artifact prover service is available
|
|
1581
|
-
*
|
|
1582
|
-
* @returns True if service is healthy
|
|
1583
|
-
*/
|
|
1584
|
-
healthCheck(): Promise<boolean>;
|
|
1585
|
-
/**
|
|
1586
|
-
* Get the configured timeout
|
|
1587
|
-
*/
|
|
1588
|
-
getTimeout(): number;
|
|
1589
|
-
/**
|
|
1590
|
-
* Set a new timeout
|
|
1591
|
-
*/
|
|
1592
|
-
setTimeout(timeout: number): void;
|
|
1593
|
-
}
|
|
1594
|
-
|
|
1595
|
-
/**
|
|
1596
|
-
* Options for proof generation
|
|
1597
|
-
*/
|
|
1598
|
-
interface ProofGenerationOptions {
|
|
1599
|
-
/** Progress callback - called with percentage (0-100) */
|
|
1600
|
-
onProgress?: (progress: number) => void;
|
|
1601
|
-
/** Called when proof generation starts */
|
|
1602
|
-
onStart?: () => void;
|
|
1603
|
-
/** Called on successful proof generation */
|
|
1604
|
-
onSuccess?: (result: SP1ProofResult) => void;
|
|
1605
|
-
/** Called on error */
|
|
1606
|
-
onError?: (error: string) => void;
|
|
1607
|
-
/** Custom timeout in milliseconds */
|
|
1608
|
-
timeout?: number;
|
|
1609
|
-
}
|
|
1610
|
-
/**
|
|
1611
|
-
* Prover Service Client (Legacy)
|
|
1612
|
-
*
|
|
1613
|
-
* Handles zero-knowledge proof generation via the backend prover service.
|
|
1614
|
-
*
|
|
1615
|
-
* ⚠️ DEPRECATED: This implementation sends private inputs to a backend service.
|
|
1616
|
-
*
|
|
1617
|
-
* **Use ArtifactProverService instead** for privacy-preserving proof generation
|
|
1618
|
-
* where private inputs are uploaded directly to TEE, never passing through backend.
|
|
1619
|
-
*
|
|
1620
|
-
* This class is kept for backward compatibility but is not used by CloakSDK anymore.
|
|
1621
|
-
*/
|
|
1622
|
-
declare class ProverService {
|
|
1623
|
-
private indexerUrl;
|
|
1624
|
-
private timeout;
|
|
1625
|
-
/**
|
|
1626
|
-
* Create a new Prover Service client
|
|
1627
|
-
*
|
|
1628
|
-
* @param indexerUrl - Indexer/Prover service base URL
|
|
1629
|
-
* @param timeout - Proof generation timeout in ms (default: 5 minutes)
|
|
1630
|
-
*/
|
|
1631
|
-
constructor(indexerUrl: string, timeout?: number);
|
|
1632
|
-
/**
|
|
1633
|
-
* Generate a zero-knowledge proof for withdrawal
|
|
1634
|
-
*
|
|
1635
|
-
* This process typically takes 30-180 seconds depending on the backend.
|
|
1636
|
-
*
|
|
1637
|
-
* @param inputs - Circuit inputs (private + public + outputs)
|
|
1638
|
-
* @param options - Optional progress tracking and callbacks
|
|
1639
|
-
* @returns Proof result with hex-encoded proof and public inputs
|
|
1640
|
-
*
|
|
1641
|
-
* @example
|
|
1642
|
-
* ```typescript
|
|
1643
|
-
* const result = await prover.generateProof(inputs);
|
|
1644
|
-
* if (result.success) {
|
|
1645
|
-
* console.log(`Proof: ${result.proof}`);
|
|
1646
|
-
* }
|
|
1647
|
-
* ```
|
|
1648
|
-
*
|
|
1649
|
-
* @example
|
|
1650
|
-
* ```typescript
|
|
1651
|
-
* // With progress tracking
|
|
1652
|
-
* const result = await prover.generateProof(inputs, {
|
|
1653
|
-
* onProgress: (progress) => console.log(`Progress: ${progress}%`),
|
|
1654
|
-
* onStart: () => console.log("Starting proof generation..."),
|
|
1655
|
-
* onSuccess: (result) => console.log("Proof generated!"),
|
|
1656
|
-
* onError: (error) => console.error("Failed:", error)
|
|
1657
|
-
* });
|
|
1658
|
-
* ```
|
|
1659
|
-
*/
|
|
1660
|
-
generateProof(inputs: SP1ProofInputs, options?: ProofGenerationOptions): Promise<SP1ProofResult>;
|
|
1661
|
-
/**
|
|
1662
|
-
* Check if the prover service is available
|
|
1663
|
-
*
|
|
1664
|
-
* @returns True if service is healthy
|
|
1665
|
-
*/
|
|
1666
|
-
healthCheck(): Promise<boolean>;
|
|
1667
|
-
/**
|
|
1668
|
-
* Get the configured timeout
|
|
1669
|
-
*/
|
|
1670
|
-
getTimeout(): number;
|
|
1671
|
-
/**
|
|
1672
|
-
* Set a new timeout
|
|
1673
|
-
*/
|
|
1674
|
-
setTimeout(timeout: number): void;
|
|
1675
|
-
}
|
|
1676
|
-
|
|
1677
1482
|
/**
|
|
1678
1483
|
* Relay Service Client
|
|
1679
1484
|
*
|
|
@@ -2083,4 +1888,4 @@ declare function generateWithdrawSwapProof(inputs: WithdrawSwapInputs, circuitsP
|
|
|
2083
1888
|
|
|
2084
1889
|
declare const VERSION = "1.0.0";
|
|
2085
1890
|
|
|
2086
|
-
export {
|
|
1891
|
+
export { CLOAK_PROGRAM_ID, type CloakConfig, CloakError, type CloakKeyPair, type CloakNote, CloakSDK, type DepositInstructionParams, type DepositOptions, DepositRecoveryService, type DepositResult, type DepositStatus, type EncryptedNote, FIXED_FEE_LAMPORTS, type Groth16Proof, IndexerService, LAMPORTS_PER_SOL, LocalStorageAdapter, type MasterKey, type MaxLengthArray, MemoryStorageAdapter, type MerkleProof, type MerkleRootResponse, type Network, type NoteData, type NotesRangeResponse, type ProofResult, type RecoveryOptions, type RecoveryResult, RelayService, type ScanNotesOptions, type ScannedNote, type ShieldPoolPDAs, type SpendKey, type StorageAdapter, type SwapOptions, type SwapParams, type SwapResult, type Transfer, type TransferOptions, type TransferResult, type TxStatus, VARIABLE_FEE_RATE, VERSION, type ViewKey, type WalletAdapter, type WithdrawOptions, type WithdrawRegularInputs, type WithdrawSwapInputs, bigintToBytes32, buildPublicInputsBytes, bytesToHex, calculateFee, calculateRelayFee, computeCommitment, computeMerkleRoot, computeNullifier, computeNullifierAsync, computeNullifierSync, computeOutputsHash, computeOutputsHashAsync, computeOutputsHashSync, computeSwapOutputsHash, computeSwapOutputsHashAsync, computeSwapOutputsHashSync, copyNoteToClipboard, createCloakError, createDepositInstruction, deriveSpendKey, deriveViewKey, detectNetworkFromRpcUrl, downloadNote, encodeNoteSimple, encryptNoteForRecipient, exportKeys, exportNote, exportWalletKeys, filterNotesByNetwork, filterWithdrawableNotes, findNoteByCommitment, formatAmount, formatErrorForLogging, generateCloakKeys, generateCommitment, generateCommitmentAsync, generateMasterSeed, generateNote, generateNoteFromWallet, generateWithdrawRegularProof, generateWithdrawSwapProof, getAddressExplorerUrl, getDistributableAmount, getExplorerUrl, getPublicKey, getPublicViewKey, getRecipientAmount, getRpcUrlForNetwork, getShieldPoolPDAs, getViewKey, hexToBigint, hexToBytes, importKeys, importWalletKeys, isValidHex, isValidRpcUrl, isValidSolanaAddress, isWithdrawable, keypairToAdapter, parseAmount, parseNote, parseTransactionError, poseidonHash, prepareEncryptedOutput, prepareEncryptedOutputForRecipient, proofToBytes, pubkeyToLimbs, randomBytes, scanNotesForWallet, sendTransaction, serializeNote, signTransaction, splitTo2Limbs, tryDecryptNote, updateNoteWithDeposit, validateDepositParams, validateNote, validateOutputsSum, validateTransfers, validateWalletConnected, validateWithdrawableNote };
|