@cloak.ag/sdk 1.0.1 → 1.0.3
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 +246 -422
- package/dist/index.d.cts +104 -84
- package/dist/index.d.ts +104 -84
- package/dist/index.js +234 -411
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -505,13 +505,17 @@ declare const CLOAK_PROGRAM_ID: PublicKey;
|
|
|
505
505
|
*
|
|
506
506
|
* Provides high-level API for interacting with the Cloak protocol,
|
|
507
507
|
* including deposits, withdrawals, and private transfers.
|
|
508
|
+
*
|
|
509
|
+
* Supports two modes:
|
|
510
|
+
* 1. Node.js mode with keypairBytes - for scripts and backend services
|
|
511
|
+
* 2. Wallet adapter mode - for browser applications with wallet integration
|
|
508
512
|
*/
|
|
509
513
|
declare class CloakSDK {
|
|
510
514
|
private config;
|
|
511
|
-
private keypair
|
|
515
|
+
private keypair?;
|
|
516
|
+
private wallet?;
|
|
512
517
|
private cloakKeys?;
|
|
513
518
|
private indexer;
|
|
514
|
-
private artifactProver;
|
|
515
519
|
private relay;
|
|
516
520
|
private depositRecovery;
|
|
517
521
|
private storage;
|
|
@@ -520,15 +524,27 @@ declare class CloakSDK {
|
|
|
520
524
|
*
|
|
521
525
|
* @param config - Client configuration
|
|
522
526
|
*
|
|
523
|
-
* @example
|
|
527
|
+
* @example Node.js mode (with keypair)
|
|
524
528
|
* ```typescript
|
|
525
529
|
* const sdk = new CloakSDK({
|
|
526
530
|
* keypairBytes: keypair.secretKey,
|
|
527
531
|
* network: "devnet"
|
|
528
532
|
* });
|
|
533
|
+
* ```
|
|
534
|
+
*
|
|
535
|
+
* @example Browser mode (with wallet adapter)
|
|
536
|
+
* ```typescript
|
|
537
|
+
* const sdk = new CloakSDK({
|
|
538
|
+
* wallet: walletAdapter,
|
|
539
|
+
* network: "devnet"
|
|
540
|
+
* });
|
|
541
|
+
* ```
|
|
529
542
|
*/
|
|
530
543
|
constructor(config: {
|
|
531
|
-
|
|
544
|
+
/** Keypair bytes for signing (Node.js mode) */
|
|
545
|
+
keypairBytes?: Uint8Array;
|
|
546
|
+
/** Wallet adapter for signing (Browser mode) */
|
|
547
|
+
wallet?: WalletAdapter;
|
|
532
548
|
network?: Network;
|
|
533
549
|
cloakKeys?: CloakKeyPair;
|
|
534
550
|
storage?: StorageAdapter;
|
|
@@ -536,6 +552,14 @@ declare class CloakSDK {
|
|
|
536
552
|
indexerUrl?: string;
|
|
537
553
|
relayUrl?: string;
|
|
538
554
|
});
|
|
555
|
+
/**
|
|
556
|
+
* Get the public key for deposits (from keypair or wallet)
|
|
557
|
+
*/
|
|
558
|
+
getPublicKey(): PublicKey;
|
|
559
|
+
/**
|
|
560
|
+
* Check if the SDK is using a wallet adapter
|
|
561
|
+
*/
|
|
562
|
+
isWalletMode(): boolean;
|
|
539
563
|
/**
|
|
540
564
|
* Deposit SOL into the Cloak protocol
|
|
541
565
|
*
|
|
@@ -979,8 +1003,11 @@ declare function poseidonHash(inputs: bigint[]): Promise<bigint>;
|
|
|
979
1003
|
declare function splitTo2Limbs(value: bigint): [bigint, bigint];
|
|
980
1004
|
/**
|
|
981
1005
|
* Convert a PublicKey (32 bytes) to two 128-bit limbs
|
|
1006
|
+
* Uses duck typing to handle cross-module PublicKey instances
|
|
982
1007
|
*/
|
|
983
|
-
declare function pubkeyToLimbs(pubkey: Uint8Array | PublicKey
|
|
1008
|
+
declare function pubkeyToLimbs(pubkey: Uint8Array | PublicKey | {
|
|
1009
|
+
toBytes: () => Uint8Array;
|
|
1010
|
+
}): [bigint, bigint];
|
|
984
1011
|
/**
|
|
985
1012
|
* Compute Merkle root from leaf and path
|
|
986
1013
|
*
|
|
@@ -1489,84 +1516,6 @@ declare class IndexerService {
|
|
|
1489
1516
|
}>;
|
|
1490
1517
|
}
|
|
1491
1518
|
|
|
1492
|
-
/**
|
|
1493
|
-
* Options for artifact-based proof generation
|
|
1494
|
-
*/
|
|
1495
|
-
interface ArtifactProofGenerationOptions {
|
|
1496
|
-
/** Progress callback - called with percentage (0-100) */
|
|
1497
|
-
onProgress?: (progress: number) => void;
|
|
1498
|
-
/** Called when proof generation starts */
|
|
1499
|
-
onStart?: () => void;
|
|
1500
|
-
/** Called on successful proof generation */
|
|
1501
|
-
onSuccess?: (result: SP1ProofResult) => void;
|
|
1502
|
-
/** Called on error */
|
|
1503
|
-
onError?: (error: string) => void;
|
|
1504
|
-
/** Custom timeout in milliseconds */
|
|
1505
|
-
timeout?: number;
|
|
1506
|
-
/** Polling interval for proof status (default: 2000ms) */
|
|
1507
|
-
pollInterval?: number;
|
|
1508
|
-
}
|
|
1509
|
-
/**
|
|
1510
|
-
* Artifact-based Prover Service
|
|
1511
|
-
*
|
|
1512
|
-
* Implements the artifact-based proof generation flow where private inputs
|
|
1513
|
-
* are uploaded directly to the TEE, never passing through the backend in plaintext.
|
|
1514
|
-
*
|
|
1515
|
-
* Flow:
|
|
1516
|
-
* 1. Create artifact → get artifact_id and upload_url
|
|
1517
|
-
* 2. Upload stdin directly to TEE (bypassing backend)
|
|
1518
|
-
* 3. Request proof generation (backend only gets artifact_id)
|
|
1519
|
-
* 4. Poll for proof status until ready
|
|
1520
|
-
*
|
|
1521
|
-
* ✅ PRIVACY: Private inputs never pass through backend in plaintext
|
|
1522
|
-
*/
|
|
1523
|
-
declare class ArtifactProverService {
|
|
1524
|
-
private indexerUrl;
|
|
1525
|
-
private timeout;
|
|
1526
|
-
private pollInterval;
|
|
1527
|
-
/**
|
|
1528
|
-
* Create a new Artifact Prover Service client
|
|
1529
|
-
*
|
|
1530
|
-
* @param indexerUrl - Indexer service base URL
|
|
1531
|
-
* @param timeout - Proof generation timeout in ms (default: 5 minutes)
|
|
1532
|
-
* @param pollInterval - Polling interval for status checks (default: 2 seconds)
|
|
1533
|
-
*/
|
|
1534
|
-
constructor(indexerUrl: string, timeout?: number, pollInterval?: number);
|
|
1535
|
-
/**
|
|
1536
|
-
* Generate a zero-knowledge proof using artifact-based flow
|
|
1537
|
-
*
|
|
1538
|
-
* This process typically takes 30-180 seconds depending on the TEE.
|
|
1539
|
-
* Private inputs are uploaded directly to TEE, never passing through backend.
|
|
1540
|
-
*
|
|
1541
|
-
* @param inputs - Circuit inputs (private + public + outputs)
|
|
1542
|
-
* @param options - Optional progress tracking and callbacks
|
|
1543
|
-
* @returns Proof result with hex-encoded proof and public inputs
|
|
1544
|
-
*
|
|
1545
|
-
* @example
|
|
1546
|
-
* ```typescript
|
|
1547
|
-
* const result = await prover.generateProof(inputs);
|
|
1548
|
-
* if (result.success) {
|
|
1549
|
-
* console.log(`Proof: ${result.proof}`);
|
|
1550
|
-
* }
|
|
1551
|
-
* ```
|
|
1552
|
-
*/
|
|
1553
|
-
generateProof(inputs: SP1ProofInputs, options?: ArtifactProofGenerationOptions): Promise<SP1ProofResult>;
|
|
1554
|
-
/**
|
|
1555
|
-
* Check if the artifact prover service is available
|
|
1556
|
-
*
|
|
1557
|
-
* @returns True if service is healthy
|
|
1558
|
-
*/
|
|
1559
|
-
healthCheck(): Promise<boolean>;
|
|
1560
|
-
/**
|
|
1561
|
-
* Get the configured timeout
|
|
1562
|
-
*/
|
|
1563
|
-
getTimeout(): number;
|
|
1564
|
-
/**
|
|
1565
|
-
* Set a new timeout
|
|
1566
|
-
*/
|
|
1567
|
-
setTimeout(timeout: number): void;
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
1519
|
/**
|
|
1571
1520
|
* Options for proof generation
|
|
1572
1521
|
*/
|
|
@@ -1979,6 +1928,77 @@ interface ShieldPoolPDAs {
|
|
|
1979
1928
|
*/
|
|
1980
1929
|
declare function getShieldPoolPDAs(programId?: PublicKey, mint?: PublicKey): ShieldPoolPDAs;
|
|
1981
1930
|
|
|
1931
|
+
/**
|
|
1932
|
+
* Direct Circom WASM Proof Generation
|
|
1933
|
+
*
|
|
1934
|
+
* This module provides direct proof generation using snarkjs and Circom WASM,
|
|
1935
|
+
* matching the approach used in services-new/tests/src/proof.ts
|
|
1936
|
+
*
|
|
1937
|
+
* This is the preferred method when circuits are available locally,
|
|
1938
|
+
* as it doesn't require a backend prover service.
|
|
1939
|
+
*/
|
|
1940
|
+
|
|
1941
|
+
interface WithdrawRegularInputs {
|
|
1942
|
+
root: bigint;
|
|
1943
|
+
nullifier: bigint;
|
|
1944
|
+
outputs_hash: bigint;
|
|
1945
|
+
public_amount: bigint;
|
|
1946
|
+
amount: bigint;
|
|
1947
|
+
leaf_index: bigint;
|
|
1948
|
+
sk: [bigint, bigint];
|
|
1949
|
+
r: [bigint, bigint];
|
|
1950
|
+
pathElements: bigint[];
|
|
1951
|
+
pathIndices: number[];
|
|
1952
|
+
num_outputs: number;
|
|
1953
|
+
out_addr: bigint[][];
|
|
1954
|
+
out_amount: bigint[];
|
|
1955
|
+
out_flags: number[];
|
|
1956
|
+
var_fee: bigint;
|
|
1957
|
+
rem: bigint;
|
|
1958
|
+
}
|
|
1959
|
+
interface WithdrawSwapInputs {
|
|
1960
|
+
sk_spend: bigint;
|
|
1961
|
+
r: bigint;
|
|
1962
|
+
amount: bigint;
|
|
1963
|
+
leaf_index: bigint;
|
|
1964
|
+
path_elements: bigint[];
|
|
1965
|
+
path_indices: number[];
|
|
1966
|
+
root: bigint;
|
|
1967
|
+
nullifier: bigint;
|
|
1968
|
+
outputs_hash: bigint;
|
|
1969
|
+
public_amount: bigint;
|
|
1970
|
+
input_mint: bigint[];
|
|
1971
|
+
output_mint: bigint[];
|
|
1972
|
+
recipient_ata: bigint[];
|
|
1973
|
+
min_output_amount: bigint;
|
|
1974
|
+
var_fee: bigint;
|
|
1975
|
+
rem: bigint;
|
|
1976
|
+
}
|
|
1977
|
+
interface ProofResult {
|
|
1978
|
+
proof: Groth16Proof;
|
|
1979
|
+
publicSignals: string[];
|
|
1980
|
+
proofBytes: Uint8Array;
|
|
1981
|
+
publicInputsBytes: Uint8Array;
|
|
1982
|
+
}
|
|
1983
|
+
/**
|
|
1984
|
+
* Generate Groth16 proof for regular withdrawal using Circom WASM
|
|
1985
|
+
*
|
|
1986
|
+
* This matches the approach in services-new/tests/src/proof.ts
|
|
1987
|
+
*
|
|
1988
|
+
* @param inputs - Circuit inputs
|
|
1989
|
+
* @param circuitsPath - Path or URL to circuits directory. In browser, use URL like '/circuits' or full URL.
|
|
1990
|
+
*/
|
|
1991
|
+
declare function generateWithdrawRegularProof(inputs: WithdrawRegularInputs, circuitsPath: string): Promise<ProofResult>;
|
|
1992
|
+
/**
|
|
1993
|
+
* Generate Groth16 proof for swap withdrawal using Circom WASM
|
|
1994
|
+
*
|
|
1995
|
+
* This matches the approach in services-new/tests/src/proof.ts
|
|
1996
|
+
*
|
|
1997
|
+
* @param inputs - Circuit inputs
|
|
1998
|
+
* @param circuitsPath - Path or URL to circuits directory. In browser, use URL like '/circuits' or full URL.
|
|
1999
|
+
*/
|
|
2000
|
+
declare function generateWithdrawSwapProof(inputs: WithdrawSwapInputs, circuitsPath: string): Promise<ProofResult>;
|
|
2001
|
+
|
|
1982
2002
|
/**
|
|
1983
2003
|
* Cloak SDK - TypeScript SDK for Private Transactions on Solana
|
|
1984
2004
|
*
|
|
@@ -1987,4 +2007,4 @@ declare function getShieldPoolPDAs(programId?: PublicKey, mint?: PublicKey): Shi
|
|
|
1987
2007
|
|
|
1988
2008
|
declare const VERSION = "1.0.0";
|
|
1989
2009
|
|
|
1990
|
-
export {
|
|
2010
|
+
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 ProofGenerationOptions, type ProofResult, ProverService, type RecoveryOptions, type RecoveryResult, RelayService, type SP1ProofInputs, type SP1ProofResult, 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
|
@@ -505,13 +505,17 @@ declare const CLOAK_PROGRAM_ID: PublicKey;
|
|
|
505
505
|
*
|
|
506
506
|
* Provides high-level API for interacting with the Cloak protocol,
|
|
507
507
|
* including deposits, withdrawals, and private transfers.
|
|
508
|
+
*
|
|
509
|
+
* Supports two modes:
|
|
510
|
+
* 1. Node.js mode with keypairBytes - for scripts and backend services
|
|
511
|
+
* 2. Wallet adapter mode - for browser applications with wallet integration
|
|
508
512
|
*/
|
|
509
513
|
declare class CloakSDK {
|
|
510
514
|
private config;
|
|
511
|
-
private keypair
|
|
515
|
+
private keypair?;
|
|
516
|
+
private wallet?;
|
|
512
517
|
private cloakKeys?;
|
|
513
518
|
private indexer;
|
|
514
|
-
private artifactProver;
|
|
515
519
|
private relay;
|
|
516
520
|
private depositRecovery;
|
|
517
521
|
private storage;
|
|
@@ -520,15 +524,27 @@ declare class CloakSDK {
|
|
|
520
524
|
*
|
|
521
525
|
* @param config - Client configuration
|
|
522
526
|
*
|
|
523
|
-
* @example
|
|
527
|
+
* @example Node.js mode (with keypair)
|
|
524
528
|
* ```typescript
|
|
525
529
|
* const sdk = new CloakSDK({
|
|
526
530
|
* keypairBytes: keypair.secretKey,
|
|
527
531
|
* network: "devnet"
|
|
528
532
|
* });
|
|
533
|
+
* ```
|
|
534
|
+
*
|
|
535
|
+
* @example Browser mode (with wallet adapter)
|
|
536
|
+
* ```typescript
|
|
537
|
+
* const sdk = new CloakSDK({
|
|
538
|
+
* wallet: walletAdapter,
|
|
539
|
+
* network: "devnet"
|
|
540
|
+
* });
|
|
541
|
+
* ```
|
|
529
542
|
*/
|
|
530
543
|
constructor(config: {
|
|
531
|
-
|
|
544
|
+
/** Keypair bytes for signing (Node.js mode) */
|
|
545
|
+
keypairBytes?: Uint8Array;
|
|
546
|
+
/** Wallet adapter for signing (Browser mode) */
|
|
547
|
+
wallet?: WalletAdapter;
|
|
532
548
|
network?: Network;
|
|
533
549
|
cloakKeys?: CloakKeyPair;
|
|
534
550
|
storage?: StorageAdapter;
|
|
@@ -536,6 +552,14 @@ declare class CloakSDK {
|
|
|
536
552
|
indexerUrl?: string;
|
|
537
553
|
relayUrl?: string;
|
|
538
554
|
});
|
|
555
|
+
/**
|
|
556
|
+
* Get the public key for deposits (from keypair or wallet)
|
|
557
|
+
*/
|
|
558
|
+
getPublicKey(): PublicKey;
|
|
559
|
+
/**
|
|
560
|
+
* Check if the SDK is using a wallet adapter
|
|
561
|
+
*/
|
|
562
|
+
isWalletMode(): boolean;
|
|
539
563
|
/**
|
|
540
564
|
* Deposit SOL into the Cloak protocol
|
|
541
565
|
*
|
|
@@ -979,8 +1003,11 @@ declare function poseidonHash(inputs: bigint[]): Promise<bigint>;
|
|
|
979
1003
|
declare function splitTo2Limbs(value: bigint): [bigint, bigint];
|
|
980
1004
|
/**
|
|
981
1005
|
* Convert a PublicKey (32 bytes) to two 128-bit limbs
|
|
1006
|
+
* Uses duck typing to handle cross-module PublicKey instances
|
|
982
1007
|
*/
|
|
983
|
-
declare function pubkeyToLimbs(pubkey: Uint8Array | PublicKey
|
|
1008
|
+
declare function pubkeyToLimbs(pubkey: Uint8Array | PublicKey | {
|
|
1009
|
+
toBytes: () => Uint8Array;
|
|
1010
|
+
}): [bigint, bigint];
|
|
984
1011
|
/**
|
|
985
1012
|
* Compute Merkle root from leaf and path
|
|
986
1013
|
*
|
|
@@ -1489,84 +1516,6 @@ declare class IndexerService {
|
|
|
1489
1516
|
}>;
|
|
1490
1517
|
}
|
|
1491
1518
|
|
|
1492
|
-
/**
|
|
1493
|
-
* Options for artifact-based proof generation
|
|
1494
|
-
*/
|
|
1495
|
-
interface ArtifactProofGenerationOptions {
|
|
1496
|
-
/** Progress callback - called with percentage (0-100) */
|
|
1497
|
-
onProgress?: (progress: number) => void;
|
|
1498
|
-
/** Called when proof generation starts */
|
|
1499
|
-
onStart?: () => void;
|
|
1500
|
-
/** Called on successful proof generation */
|
|
1501
|
-
onSuccess?: (result: SP1ProofResult) => void;
|
|
1502
|
-
/** Called on error */
|
|
1503
|
-
onError?: (error: string) => void;
|
|
1504
|
-
/** Custom timeout in milliseconds */
|
|
1505
|
-
timeout?: number;
|
|
1506
|
-
/** Polling interval for proof status (default: 2000ms) */
|
|
1507
|
-
pollInterval?: number;
|
|
1508
|
-
}
|
|
1509
|
-
/**
|
|
1510
|
-
* Artifact-based Prover Service
|
|
1511
|
-
*
|
|
1512
|
-
* Implements the artifact-based proof generation flow where private inputs
|
|
1513
|
-
* are uploaded directly to the TEE, never passing through the backend in plaintext.
|
|
1514
|
-
*
|
|
1515
|
-
* Flow:
|
|
1516
|
-
* 1. Create artifact → get artifact_id and upload_url
|
|
1517
|
-
* 2. Upload stdin directly to TEE (bypassing backend)
|
|
1518
|
-
* 3. Request proof generation (backend only gets artifact_id)
|
|
1519
|
-
* 4. Poll for proof status until ready
|
|
1520
|
-
*
|
|
1521
|
-
* ✅ PRIVACY: Private inputs never pass through backend in plaintext
|
|
1522
|
-
*/
|
|
1523
|
-
declare class ArtifactProverService {
|
|
1524
|
-
private indexerUrl;
|
|
1525
|
-
private timeout;
|
|
1526
|
-
private pollInterval;
|
|
1527
|
-
/**
|
|
1528
|
-
* Create a new Artifact Prover Service client
|
|
1529
|
-
*
|
|
1530
|
-
* @param indexerUrl - Indexer service base URL
|
|
1531
|
-
* @param timeout - Proof generation timeout in ms (default: 5 minutes)
|
|
1532
|
-
* @param pollInterval - Polling interval for status checks (default: 2 seconds)
|
|
1533
|
-
*/
|
|
1534
|
-
constructor(indexerUrl: string, timeout?: number, pollInterval?: number);
|
|
1535
|
-
/**
|
|
1536
|
-
* Generate a zero-knowledge proof using artifact-based flow
|
|
1537
|
-
*
|
|
1538
|
-
* This process typically takes 30-180 seconds depending on the TEE.
|
|
1539
|
-
* Private inputs are uploaded directly to TEE, never passing through backend.
|
|
1540
|
-
*
|
|
1541
|
-
* @param inputs - Circuit inputs (private + public + outputs)
|
|
1542
|
-
* @param options - Optional progress tracking and callbacks
|
|
1543
|
-
* @returns Proof result with hex-encoded proof and public inputs
|
|
1544
|
-
*
|
|
1545
|
-
* @example
|
|
1546
|
-
* ```typescript
|
|
1547
|
-
* const result = await prover.generateProof(inputs);
|
|
1548
|
-
* if (result.success) {
|
|
1549
|
-
* console.log(`Proof: ${result.proof}`);
|
|
1550
|
-
* }
|
|
1551
|
-
* ```
|
|
1552
|
-
*/
|
|
1553
|
-
generateProof(inputs: SP1ProofInputs, options?: ArtifactProofGenerationOptions): Promise<SP1ProofResult>;
|
|
1554
|
-
/**
|
|
1555
|
-
* Check if the artifact prover service is available
|
|
1556
|
-
*
|
|
1557
|
-
* @returns True if service is healthy
|
|
1558
|
-
*/
|
|
1559
|
-
healthCheck(): Promise<boolean>;
|
|
1560
|
-
/**
|
|
1561
|
-
* Get the configured timeout
|
|
1562
|
-
*/
|
|
1563
|
-
getTimeout(): number;
|
|
1564
|
-
/**
|
|
1565
|
-
* Set a new timeout
|
|
1566
|
-
*/
|
|
1567
|
-
setTimeout(timeout: number): void;
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
1519
|
/**
|
|
1571
1520
|
* Options for proof generation
|
|
1572
1521
|
*/
|
|
@@ -1979,6 +1928,77 @@ interface ShieldPoolPDAs {
|
|
|
1979
1928
|
*/
|
|
1980
1929
|
declare function getShieldPoolPDAs(programId?: PublicKey, mint?: PublicKey): ShieldPoolPDAs;
|
|
1981
1930
|
|
|
1931
|
+
/**
|
|
1932
|
+
* Direct Circom WASM Proof Generation
|
|
1933
|
+
*
|
|
1934
|
+
* This module provides direct proof generation using snarkjs and Circom WASM,
|
|
1935
|
+
* matching the approach used in services-new/tests/src/proof.ts
|
|
1936
|
+
*
|
|
1937
|
+
* This is the preferred method when circuits are available locally,
|
|
1938
|
+
* as it doesn't require a backend prover service.
|
|
1939
|
+
*/
|
|
1940
|
+
|
|
1941
|
+
interface WithdrawRegularInputs {
|
|
1942
|
+
root: bigint;
|
|
1943
|
+
nullifier: bigint;
|
|
1944
|
+
outputs_hash: bigint;
|
|
1945
|
+
public_amount: bigint;
|
|
1946
|
+
amount: bigint;
|
|
1947
|
+
leaf_index: bigint;
|
|
1948
|
+
sk: [bigint, bigint];
|
|
1949
|
+
r: [bigint, bigint];
|
|
1950
|
+
pathElements: bigint[];
|
|
1951
|
+
pathIndices: number[];
|
|
1952
|
+
num_outputs: number;
|
|
1953
|
+
out_addr: bigint[][];
|
|
1954
|
+
out_amount: bigint[];
|
|
1955
|
+
out_flags: number[];
|
|
1956
|
+
var_fee: bigint;
|
|
1957
|
+
rem: bigint;
|
|
1958
|
+
}
|
|
1959
|
+
interface WithdrawSwapInputs {
|
|
1960
|
+
sk_spend: bigint;
|
|
1961
|
+
r: bigint;
|
|
1962
|
+
amount: bigint;
|
|
1963
|
+
leaf_index: bigint;
|
|
1964
|
+
path_elements: bigint[];
|
|
1965
|
+
path_indices: number[];
|
|
1966
|
+
root: bigint;
|
|
1967
|
+
nullifier: bigint;
|
|
1968
|
+
outputs_hash: bigint;
|
|
1969
|
+
public_amount: bigint;
|
|
1970
|
+
input_mint: bigint[];
|
|
1971
|
+
output_mint: bigint[];
|
|
1972
|
+
recipient_ata: bigint[];
|
|
1973
|
+
min_output_amount: bigint;
|
|
1974
|
+
var_fee: bigint;
|
|
1975
|
+
rem: bigint;
|
|
1976
|
+
}
|
|
1977
|
+
interface ProofResult {
|
|
1978
|
+
proof: Groth16Proof;
|
|
1979
|
+
publicSignals: string[];
|
|
1980
|
+
proofBytes: Uint8Array;
|
|
1981
|
+
publicInputsBytes: Uint8Array;
|
|
1982
|
+
}
|
|
1983
|
+
/**
|
|
1984
|
+
* Generate Groth16 proof for regular withdrawal using Circom WASM
|
|
1985
|
+
*
|
|
1986
|
+
* This matches the approach in services-new/tests/src/proof.ts
|
|
1987
|
+
*
|
|
1988
|
+
* @param inputs - Circuit inputs
|
|
1989
|
+
* @param circuitsPath - Path or URL to circuits directory. In browser, use URL like '/circuits' or full URL.
|
|
1990
|
+
*/
|
|
1991
|
+
declare function generateWithdrawRegularProof(inputs: WithdrawRegularInputs, circuitsPath: string): Promise<ProofResult>;
|
|
1992
|
+
/**
|
|
1993
|
+
* Generate Groth16 proof for swap withdrawal using Circom WASM
|
|
1994
|
+
*
|
|
1995
|
+
* This matches the approach in services-new/tests/src/proof.ts
|
|
1996
|
+
*
|
|
1997
|
+
* @param inputs - Circuit inputs
|
|
1998
|
+
* @param circuitsPath - Path or URL to circuits directory. In browser, use URL like '/circuits' or full URL.
|
|
1999
|
+
*/
|
|
2000
|
+
declare function generateWithdrawSwapProof(inputs: WithdrawSwapInputs, circuitsPath: string): Promise<ProofResult>;
|
|
2001
|
+
|
|
1982
2002
|
/**
|
|
1983
2003
|
* Cloak SDK - TypeScript SDK for Private Transactions on Solana
|
|
1984
2004
|
*
|
|
@@ -1987,4 +2007,4 @@ declare function getShieldPoolPDAs(programId?: PublicKey, mint?: PublicKey): Shi
|
|
|
1987
2007
|
|
|
1988
2008
|
declare const VERSION = "1.0.0";
|
|
1989
2009
|
|
|
1990
|
-
export {
|
|
2010
|
+
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 ProofGenerationOptions, type ProofResult, ProverService, type RecoveryOptions, type RecoveryResult, RelayService, type SP1ProofInputs, type SP1ProofResult, 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 };
|