@veil-cash/sdk 0.6.3 → 0.6.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/README.md +1 -0
- package/SDK.md +45 -0
- package/dist/cli/index.cjs +145 -115
- package/dist/index.cjs +113 -90
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +102 -64
- package/dist/index.d.ts +102 -64
- package/dist/index.js +90 -48
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/ffjavascript.d.ts +28 -0
- package/src/index.ts +1 -1
- package/src/keypair.ts +2 -4
- package/src/prover.ts +108 -36
- package/src/subaccount.ts +2 -0
- package/src/transaction.ts +8 -2
- package/src/transfer.ts +5 -1
- package/src/types.ts +21 -0
- package/src/utils.ts +12 -5
- package/src/utxo.ts +1 -0
- package/src/withdraw.ts +2 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
1
2
|
import MerkleTree from 'fixed-merkle-tree-legacy';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -73,6 +74,80 @@ declare class Utxo {
|
|
|
73
74
|
static decrypt(data: string, keypair: Keypair): Utxo;
|
|
74
75
|
}
|
|
75
76
|
|
|
77
|
+
/**
|
|
78
|
+
* ZK Proof generation for Veil SDK
|
|
79
|
+
* Uses snarkjs groth16 to generate proofs for transactions
|
|
80
|
+
*/
|
|
81
|
+
/**
|
|
82
|
+
* Input data for ZK proof generation
|
|
83
|
+
*/
|
|
84
|
+
interface ProofInput {
|
|
85
|
+
root: bigint;
|
|
86
|
+
inputNullifier: bigint[];
|
|
87
|
+
outputCommitment: bigint[];
|
|
88
|
+
publicAmount: string;
|
|
89
|
+
extDataHash: bigint;
|
|
90
|
+
inAmount: bigint[];
|
|
91
|
+
inPrivateKey: (string | null)[];
|
|
92
|
+
inBlinding: bigint[];
|
|
93
|
+
inPathIndices: number[];
|
|
94
|
+
inPathElements: (bigint | number)[][];
|
|
95
|
+
outAmount: bigint[];
|
|
96
|
+
outBlinding: bigint[];
|
|
97
|
+
outPubkey: bigint[];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Directory/base URL where proving keys are hosted, or a resolver that returns
|
|
101
|
+
* the circuit base path without the `.wasm` / `.zkey` extension.
|
|
102
|
+
*/
|
|
103
|
+
type ProvingKeyPath = string | ((circuitName: string) => string);
|
|
104
|
+
interface ProveOptions {
|
|
105
|
+
/**
|
|
106
|
+
* Proving key location.
|
|
107
|
+
*
|
|
108
|
+
* In Node this defaults to the package/source `keys` directory. In browsers
|
|
109
|
+
* this defaults to `/keys`, so apps can serve `/keys/transaction2.wasm` and
|
|
110
|
+
* `/keys/transaction2.zkey` from their own origin.
|
|
111
|
+
*/
|
|
112
|
+
provingKeyPath?: ProvingKeyPath;
|
|
113
|
+
/** Force snarkjs single-threaded proving. Defaults to true. */
|
|
114
|
+
singleThread?: boolean;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Generate a ZK proof for a transaction
|
|
118
|
+
*
|
|
119
|
+
* @param input - Proof input data
|
|
120
|
+
* @param circuitName - Circuit name (e.g., 'transaction2' or 'transaction16')
|
|
121
|
+
* @returns Serialized proof as hex string
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* const proof = await prove(proofInput, 'transaction2');
|
|
126
|
+
* // Returns: 0x1234...abcd (256 bytes hex)
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
declare function prove(input: ProofInput, circuitName: string, options?: ProveOptions): Promise<string>;
|
|
130
|
+
/**
|
|
131
|
+
* Get the supported circuit names and their max input counts
|
|
132
|
+
*/
|
|
133
|
+
declare const CIRCUIT_CONFIG: {
|
|
134
|
+
readonly transaction2: {
|
|
135
|
+
readonly maxInputs: 2;
|
|
136
|
+
readonly maxOutputs: 2;
|
|
137
|
+
};
|
|
138
|
+
readonly transaction16: {
|
|
139
|
+
readonly maxInputs: 16;
|
|
140
|
+
readonly maxOutputs: 2;
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Select the appropriate circuit based on input count
|
|
145
|
+
*
|
|
146
|
+
* @param inputCount - Number of input UTXOs
|
|
147
|
+
* @returns Circuit name to use
|
|
148
|
+
*/
|
|
149
|
+
declare function selectCircuit(inputCount: number): string;
|
|
150
|
+
|
|
76
151
|
/**
|
|
77
152
|
* Type definitions for Veil SDK
|
|
78
153
|
*/
|
|
@@ -274,6 +349,13 @@ interface BuildWithdrawProofOptions {
|
|
|
274
349
|
pool?: RelayPool;
|
|
275
350
|
/** Optional RPC URL */
|
|
276
351
|
rpcUrl?: string;
|
|
352
|
+
/**
|
|
353
|
+
* Optional proving key directory/base URL or resolver.
|
|
354
|
+
*
|
|
355
|
+
* Browsers default to `/keys`, expecting files like
|
|
356
|
+
* `/keys/transaction2.wasm` and `/keys/transaction2.zkey`.
|
|
357
|
+
*/
|
|
358
|
+
provingKeyPath?: ProvingKeyPath;
|
|
277
359
|
/** Progress callback */
|
|
278
360
|
onProgress?: (stage: string, detail?: string) => void;
|
|
279
361
|
}
|
|
@@ -291,6 +373,13 @@ interface BuildTransferProofOptions {
|
|
|
291
373
|
pool?: RelayPool;
|
|
292
374
|
/** Optional RPC URL */
|
|
293
375
|
rpcUrl?: string;
|
|
376
|
+
/**
|
|
377
|
+
* Optional proving key directory/base URL or resolver.
|
|
378
|
+
*
|
|
379
|
+
* Browsers default to `/keys`, expecting files like
|
|
380
|
+
* `/keys/transaction2.wasm` and `/keys/transaction2.zkey`.
|
|
381
|
+
*/
|
|
382
|
+
provingKeyPath?: ProvingKeyPath;
|
|
294
383
|
/** Progress callback */
|
|
295
384
|
onProgress?: (stage: string, detail?: string) => void;
|
|
296
385
|
}
|
|
@@ -485,6 +574,13 @@ interface SubaccountMergeOptions {
|
|
|
485
574
|
rpcUrl?: string;
|
|
486
575
|
/** Optional relay URL */
|
|
487
576
|
relayUrl?: string;
|
|
577
|
+
/**
|
|
578
|
+
* Optional proving key directory/base URL or resolver.
|
|
579
|
+
*
|
|
580
|
+
* Browsers default to `/keys`, expecting files like
|
|
581
|
+
* `/keys/transaction2.wasm` and `/keys/transaction2.zkey`.
|
|
582
|
+
*/
|
|
583
|
+
provingKeyPath?: ProvingKeyPath;
|
|
488
584
|
/** Progress callback */
|
|
489
585
|
onProgress?: (stage: string, detail?: string) => void;
|
|
490
586
|
}
|
|
@@ -931,11 +1027,6 @@ declare function buildWithdrawProof(options: BuildWithdrawProofOptions): Promise
|
|
|
931
1027
|
*/
|
|
932
1028
|
declare function withdraw(options: BuildWithdrawProofOptions): Promise<WithdrawResult>;
|
|
933
1029
|
|
|
934
|
-
/**
|
|
935
|
-
* Transfer functions for Veil SDK
|
|
936
|
-
* Build ZK proofs to transfer funds privately within the pool
|
|
937
|
-
*/
|
|
938
|
-
|
|
939
1030
|
/**
|
|
940
1031
|
* Check if a recipient is registered and get their deposit key
|
|
941
1032
|
*
|
|
@@ -1022,6 +1113,7 @@ declare function mergeUtxos(options: {
|
|
|
1022
1113
|
keypair: Keypair;
|
|
1023
1114
|
pool?: RelayPool;
|
|
1024
1115
|
rpcUrl?: string;
|
|
1116
|
+
provingKeyPath?: ProvingKeyPath;
|
|
1025
1117
|
onProgress?: (stage: string, detail?: string) => void;
|
|
1026
1118
|
}): Promise<TransferResult>;
|
|
1027
1119
|
|
|
@@ -1077,6 +1169,8 @@ interface PrepareTransactionParams {
|
|
|
1077
1169
|
relayer?: string | bigint | number;
|
|
1078
1170
|
/** Optional progress callback */
|
|
1079
1171
|
onProgress?: (stage: string, detail?: string) => void;
|
|
1172
|
+
/** Optional proving key directory/base URL or circuit path resolver */
|
|
1173
|
+
provingKeyPath?: ProvingKeyPath;
|
|
1080
1174
|
}
|
|
1081
1175
|
/**
|
|
1082
1176
|
* Prepare a transaction (withdrawal or transfer)
|
|
@@ -1108,7 +1202,7 @@ interface PrepareTransactionParams {
|
|
|
1108
1202
|
* });
|
|
1109
1203
|
* ```
|
|
1110
1204
|
*/
|
|
1111
|
-
declare function prepareTransaction({ commitments, inputs, outputs, fee, recipient, relayer, onProgress, }: PrepareTransactionParams): Promise<TransactionResult>;
|
|
1205
|
+
declare function prepareTransaction({ commitments, inputs, outputs, fee, recipient, relayer, onProgress, provingKeyPath, }: PrepareTransactionParams): Promise<TransactionResult>;
|
|
1112
1206
|
|
|
1113
1207
|
/**
|
|
1114
1208
|
* Merkle tree utilities for Veil SDK
|
|
@@ -1146,63 +1240,6 @@ declare function getMerklePath(tree: MerkleTree, commitment: bigint | string): {
|
|
|
1146
1240
|
pathIndices: number;
|
|
1147
1241
|
};
|
|
1148
1242
|
|
|
1149
|
-
/**
|
|
1150
|
-
* ZK Proof generation for Veil SDK
|
|
1151
|
-
* Uses snarkjs groth16 to generate proofs for transactions
|
|
1152
|
-
*/
|
|
1153
|
-
/**
|
|
1154
|
-
* Input data for ZK proof generation
|
|
1155
|
-
*/
|
|
1156
|
-
interface ProofInput {
|
|
1157
|
-
root: bigint;
|
|
1158
|
-
inputNullifier: bigint[];
|
|
1159
|
-
outputCommitment: bigint[];
|
|
1160
|
-
publicAmount: string;
|
|
1161
|
-
extDataHash: bigint;
|
|
1162
|
-
inAmount: bigint[];
|
|
1163
|
-
inPrivateKey: (string | null)[];
|
|
1164
|
-
inBlinding: bigint[];
|
|
1165
|
-
inPathIndices: number[];
|
|
1166
|
-
inPathElements: (bigint | number)[][];
|
|
1167
|
-
outAmount: bigint[];
|
|
1168
|
-
outBlinding: bigint[];
|
|
1169
|
-
outPubkey: bigint[];
|
|
1170
|
-
}
|
|
1171
|
-
/**
|
|
1172
|
-
* Generate a ZK proof for a transaction
|
|
1173
|
-
*
|
|
1174
|
-
* @param input - Proof input data
|
|
1175
|
-
* @param circuitName - Circuit name (e.g., 'transaction2' or 'transaction16')
|
|
1176
|
-
* @returns Serialized proof as hex string
|
|
1177
|
-
*
|
|
1178
|
-
* @example
|
|
1179
|
-
* ```typescript
|
|
1180
|
-
* const proof = await prove(proofInput, 'transaction2');
|
|
1181
|
-
* // Returns: 0x1234...abcd (256 bytes hex)
|
|
1182
|
-
* ```
|
|
1183
|
-
*/
|
|
1184
|
-
declare function prove(input: ProofInput, circuitName: string): Promise<string>;
|
|
1185
|
-
/**
|
|
1186
|
-
* Get the supported circuit names and their max input counts
|
|
1187
|
-
*/
|
|
1188
|
-
declare const CIRCUIT_CONFIG: {
|
|
1189
|
-
readonly transaction2: {
|
|
1190
|
-
readonly maxInputs: 2;
|
|
1191
|
-
readonly maxOutputs: 2;
|
|
1192
|
-
};
|
|
1193
|
-
readonly transaction16: {
|
|
1194
|
-
readonly maxInputs: 16;
|
|
1195
|
-
readonly maxOutputs: 2;
|
|
1196
|
-
};
|
|
1197
|
-
};
|
|
1198
|
-
/**
|
|
1199
|
-
* Select the appropriate circuit based on input count
|
|
1200
|
-
*
|
|
1201
|
-
* @param inputCount - Number of input UTXOs
|
|
1202
|
-
* @returns Circuit name to use
|
|
1203
|
-
*/
|
|
1204
|
-
declare function selectCircuit(inputCount: number): string;
|
|
1205
|
-
|
|
1206
1243
|
/**
|
|
1207
1244
|
* Contract addresses for Veil on Base
|
|
1208
1245
|
*/
|
|
@@ -2751,6 +2788,7 @@ declare function mergeSubaccount(options: SubaccountMergeOptions): Promise<Subac
|
|
|
2751
2788
|
* Crypto utilities for Veil SDK
|
|
2752
2789
|
* Poseidon hash, hex conversion, and random number generation
|
|
2753
2790
|
*/
|
|
2791
|
+
|
|
2754
2792
|
/**
|
|
2755
2793
|
* SNARK scalar field size
|
|
2756
2794
|
*/
|
|
@@ -2816,4 +2854,4 @@ declare function getExtDataHash(extData: ExtDataInput): bigint;
|
|
|
2816
2854
|
*/
|
|
2817
2855
|
declare function shuffle<T>(array: T[]): T[];
|
|
2818
2856
|
|
|
2819
|
-
export { ADDRESSES, type BuildTransferProofOptions, type BuildWithdrawProofOptions, CIRCUIT_CONFIG, type DepositTxOptions, ENTRY_ABI, ERC20_ABI, type EncryptedMessage, type ExtData, type ExtDataInput, FIELD_SIZE, FORWARDER_ABI, FORWARDER_CONTRACT_VERSION, FORWARDER_FACTORY_ABI, Keypair, MAX_SUBACCOUNT_SLOTS, MERKLE_TREE_HEIGHT, type MessageSigner, type NetworkAddresses, POOL_ABI, POOL_CONFIG, type PendingDeposit, type PoolConfig, type PrepareTransactionParams, type PrivateBalanceResult, type ProgressCallback, type ProofArgs, type ProofBuildResult, type ProofInput, QUEUE_ABI, type QueueBalanceResult, type RegisterTxOptions, RelayError, type RelayErrorResponse, type RelayExtData, type RelayMetadata, type RelayPool, type RelayProofArgs, type RelayRequest, type RelayResponse, type RelayType, type SubaccountAsset, type SubaccountAssetBalance, type SubaccountBalances, type SubaccountDeployRequest, type SubaccountMergeOptions, type SubaccountMergeResult, type SubaccountPrivateBalanceStatus, type SubaccountPrivateBalances, type SubaccountQueueStatus, type SubaccountRecoveryResult, type SubaccountRelayResult, type SubaccountSlot, type SubaccountStatusResult, type SubaccountSweepRequest, type SubaccountWithdrawTypedData, type SubmitRelayOptions, type Token, type TransactionData, type TransactionResult, type TransferResult, Utxo, type UtxoInfo, type UtxoParams, type UtxoSelectionResult, VEIL_SIGNED_MESSAGE, type WithdrawResult, buildApproveUSDCTx, buildChangeDepositKeyTx, buildDepositETHTx, buildDepositTx, buildDepositUSDCTx, buildMerkleTree, buildRegisterTx, buildSubaccountRecoveryTx, buildSubaccountWithdrawTypedData, buildTransferProof, buildWithdrawProof, checkRecipientRegistration, checkRelayHealth, deploySubaccountForwarder, deriveSubaccountChildDepositKey, deriveSubaccountChildOwner, deriveSubaccountChildPrivateKey, deriveSubaccountSalt, deriveSubaccountSlot, findNextSubaccountWithdrawNonce, getAddresses, getDailyFreeRemaining, getExtDataHash, getForwarderFactoryAddress, getMerklePath, getPoolAddress, getPrivateBalance, getQueueAddress, getQueueBalance, getRelayInfo, getRelayUrl, getSubaccountPrivateBalance, getSubaccountStatus, isSubaccountForwarderDeployed, isSubaccountWithdrawNonceUsed, mergeSubaccount, mergeUtxos, packEncryptedMessage, poseidonHash, poseidonHash2, predictSubaccountForwarder, prepareTransaction, prove, randomBN, selectCircuit, selectUtxosForWithdraw, shuffle, signSubaccountWithdraw, submitRelay, sweepSubaccountForwarder, toBuffer, toFixedHex, transfer, unpackEncryptedMessage, withdraw };
|
|
2857
|
+
export { ADDRESSES, type BuildTransferProofOptions, type BuildWithdrawProofOptions, CIRCUIT_CONFIG, type DepositTxOptions, ENTRY_ABI, ERC20_ABI, type EncryptedMessage, type ExtData, type ExtDataInput, FIELD_SIZE, FORWARDER_ABI, FORWARDER_CONTRACT_VERSION, FORWARDER_FACTORY_ABI, Keypair, MAX_SUBACCOUNT_SLOTS, MERKLE_TREE_HEIGHT, type MessageSigner, type NetworkAddresses, POOL_ABI, POOL_CONFIG, type PendingDeposit, type PoolConfig, type PrepareTransactionParams, type PrivateBalanceResult, type ProgressCallback, type ProofArgs, type ProofBuildResult, type ProofInput, type ProveOptions, type ProvingKeyPath, QUEUE_ABI, type QueueBalanceResult, type RegisterTxOptions, RelayError, type RelayErrorResponse, type RelayExtData, type RelayMetadata, type RelayPool, type RelayProofArgs, type RelayRequest, type RelayResponse, type RelayType, type SubaccountAsset, type SubaccountAssetBalance, type SubaccountBalances, type SubaccountDeployRequest, type SubaccountMergeOptions, type SubaccountMergeResult, type SubaccountPrivateBalanceStatus, type SubaccountPrivateBalances, type SubaccountQueueStatus, type SubaccountRecoveryResult, type SubaccountRelayResult, type SubaccountSlot, type SubaccountStatusResult, type SubaccountSweepRequest, type SubaccountWithdrawTypedData, type SubmitRelayOptions, type Token, type TransactionData, type TransactionResult, type TransferResult, Utxo, type UtxoInfo, type UtxoParams, type UtxoSelectionResult, VEIL_SIGNED_MESSAGE, type WithdrawResult, buildApproveUSDCTx, buildChangeDepositKeyTx, buildDepositETHTx, buildDepositTx, buildDepositUSDCTx, buildMerkleTree, buildRegisterTx, buildSubaccountRecoveryTx, buildSubaccountWithdrawTypedData, buildTransferProof, buildWithdrawProof, checkRecipientRegistration, checkRelayHealth, deploySubaccountForwarder, deriveSubaccountChildDepositKey, deriveSubaccountChildOwner, deriveSubaccountChildPrivateKey, deriveSubaccountSalt, deriveSubaccountSlot, findNextSubaccountWithdrawNonce, getAddresses, getDailyFreeRemaining, getExtDataHash, getForwarderFactoryAddress, getMerklePath, getPoolAddress, getPrivateBalance, getQueueAddress, getQueueBalance, getRelayInfo, getRelayUrl, getSubaccountPrivateBalance, getSubaccountStatus, isSubaccountForwarderDeployed, isSubaccountWithdrawNonceUsed, mergeSubaccount, mergeUtxos, packEncryptedMessage, poseidonHash, poseidonHash2, predictSubaccountForwarder, prepareTransaction, prove, randomBN, selectCircuit, selectUtxosForWithdraw, shuffle, signSubaccountWithdraw, submitRelay, sweepSubaccountForwarder, toBuffer, toFixedHex, transfer, unpackEncryptedMessage, withdraw };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
1
2
|
import MerkleTree from 'fixed-merkle-tree-legacy';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -73,6 +74,80 @@ declare class Utxo {
|
|
|
73
74
|
static decrypt(data: string, keypair: Keypair): Utxo;
|
|
74
75
|
}
|
|
75
76
|
|
|
77
|
+
/**
|
|
78
|
+
* ZK Proof generation for Veil SDK
|
|
79
|
+
* Uses snarkjs groth16 to generate proofs for transactions
|
|
80
|
+
*/
|
|
81
|
+
/**
|
|
82
|
+
* Input data for ZK proof generation
|
|
83
|
+
*/
|
|
84
|
+
interface ProofInput {
|
|
85
|
+
root: bigint;
|
|
86
|
+
inputNullifier: bigint[];
|
|
87
|
+
outputCommitment: bigint[];
|
|
88
|
+
publicAmount: string;
|
|
89
|
+
extDataHash: bigint;
|
|
90
|
+
inAmount: bigint[];
|
|
91
|
+
inPrivateKey: (string | null)[];
|
|
92
|
+
inBlinding: bigint[];
|
|
93
|
+
inPathIndices: number[];
|
|
94
|
+
inPathElements: (bigint | number)[][];
|
|
95
|
+
outAmount: bigint[];
|
|
96
|
+
outBlinding: bigint[];
|
|
97
|
+
outPubkey: bigint[];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Directory/base URL where proving keys are hosted, or a resolver that returns
|
|
101
|
+
* the circuit base path without the `.wasm` / `.zkey` extension.
|
|
102
|
+
*/
|
|
103
|
+
type ProvingKeyPath = string | ((circuitName: string) => string);
|
|
104
|
+
interface ProveOptions {
|
|
105
|
+
/**
|
|
106
|
+
* Proving key location.
|
|
107
|
+
*
|
|
108
|
+
* In Node this defaults to the package/source `keys` directory. In browsers
|
|
109
|
+
* this defaults to `/keys`, so apps can serve `/keys/transaction2.wasm` and
|
|
110
|
+
* `/keys/transaction2.zkey` from their own origin.
|
|
111
|
+
*/
|
|
112
|
+
provingKeyPath?: ProvingKeyPath;
|
|
113
|
+
/** Force snarkjs single-threaded proving. Defaults to true. */
|
|
114
|
+
singleThread?: boolean;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Generate a ZK proof for a transaction
|
|
118
|
+
*
|
|
119
|
+
* @param input - Proof input data
|
|
120
|
+
* @param circuitName - Circuit name (e.g., 'transaction2' or 'transaction16')
|
|
121
|
+
* @returns Serialized proof as hex string
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* const proof = await prove(proofInput, 'transaction2');
|
|
126
|
+
* // Returns: 0x1234...abcd (256 bytes hex)
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
declare function prove(input: ProofInput, circuitName: string, options?: ProveOptions): Promise<string>;
|
|
130
|
+
/**
|
|
131
|
+
* Get the supported circuit names and their max input counts
|
|
132
|
+
*/
|
|
133
|
+
declare const CIRCUIT_CONFIG: {
|
|
134
|
+
readonly transaction2: {
|
|
135
|
+
readonly maxInputs: 2;
|
|
136
|
+
readonly maxOutputs: 2;
|
|
137
|
+
};
|
|
138
|
+
readonly transaction16: {
|
|
139
|
+
readonly maxInputs: 16;
|
|
140
|
+
readonly maxOutputs: 2;
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Select the appropriate circuit based on input count
|
|
145
|
+
*
|
|
146
|
+
* @param inputCount - Number of input UTXOs
|
|
147
|
+
* @returns Circuit name to use
|
|
148
|
+
*/
|
|
149
|
+
declare function selectCircuit(inputCount: number): string;
|
|
150
|
+
|
|
76
151
|
/**
|
|
77
152
|
* Type definitions for Veil SDK
|
|
78
153
|
*/
|
|
@@ -274,6 +349,13 @@ interface BuildWithdrawProofOptions {
|
|
|
274
349
|
pool?: RelayPool;
|
|
275
350
|
/** Optional RPC URL */
|
|
276
351
|
rpcUrl?: string;
|
|
352
|
+
/**
|
|
353
|
+
* Optional proving key directory/base URL or resolver.
|
|
354
|
+
*
|
|
355
|
+
* Browsers default to `/keys`, expecting files like
|
|
356
|
+
* `/keys/transaction2.wasm` and `/keys/transaction2.zkey`.
|
|
357
|
+
*/
|
|
358
|
+
provingKeyPath?: ProvingKeyPath;
|
|
277
359
|
/** Progress callback */
|
|
278
360
|
onProgress?: (stage: string, detail?: string) => void;
|
|
279
361
|
}
|
|
@@ -291,6 +373,13 @@ interface BuildTransferProofOptions {
|
|
|
291
373
|
pool?: RelayPool;
|
|
292
374
|
/** Optional RPC URL */
|
|
293
375
|
rpcUrl?: string;
|
|
376
|
+
/**
|
|
377
|
+
* Optional proving key directory/base URL or resolver.
|
|
378
|
+
*
|
|
379
|
+
* Browsers default to `/keys`, expecting files like
|
|
380
|
+
* `/keys/transaction2.wasm` and `/keys/transaction2.zkey`.
|
|
381
|
+
*/
|
|
382
|
+
provingKeyPath?: ProvingKeyPath;
|
|
294
383
|
/** Progress callback */
|
|
295
384
|
onProgress?: (stage: string, detail?: string) => void;
|
|
296
385
|
}
|
|
@@ -485,6 +574,13 @@ interface SubaccountMergeOptions {
|
|
|
485
574
|
rpcUrl?: string;
|
|
486
575
|
/** Optional relay URL */
|
|
487
576
|
relayUrl?: string;
|
|
577
|
+
/**
|
|
578
|
+
* Optional proving key directory/base URL or resolver.
|
|
579
|
+
*
|
|
580
|
+
* Browsers default to `/keys`, expecting files like
|
|
581
|
+
* `/keys/transaction2.wasm` and `/keys/transaction2.zkey`.
|
|
582
|
+
*/
|
|
583
|
+
provingKeyPath?: ProvingKeyPath;
|
|
488
584
|
/** Progress callback */
|
|
489
585
|
onProgress?: (stage: string, detail?: string) => void;
|
|
490
586
|
}
|
|
@@ -931,11 +1027,6 @@ declare function buildWithdrawProof(options: BuildWithdrawProofOptions): Promise
|
|
|
931
1027
|
*/
|
|
932
1028
|
declare function withdraw(options: BuildWithdrawProofOptions): Promise<WithdrawResult>;
|
|
933
1029
|
|
|
934
|
-
/**
|
|
935
|
-
* Transfer functions for Veil SDK
|
|
936
|
-
* Build ZK proofs to transfer funds privately within the pool
|
|
937
|
-
*/
|
|
938
|
-
|
|
939
1030
|
/**
|
|
940
1031
|
* Check if a recipient is registered and get their deposit key
|
|
941
1032
|
*
|
|
@@ -1022,6 +1113,7 @@ declare function mergeUtxos(options: {
|
|
|
1022
1113
|
keypair: Keypair;
|
|
1023
1114
|
pool?: RelayPool;
|
|
1024
1115
|
rpcUrl?: string;
|
|
1116
|
+
provingKeyPath?: ProvingKeyPath;
|
|
1025
1117
|
onProgress?: (stage: string, detail?: string) => void;
|
|
1026
1118
|
}): Promise<TransferResult>;
|
|
1027
1119
|
|
|
@@ -1077,6 +1169,8 @@ interface PrepareTransactionParams {
|
|
|
1077
1169
|
relayer?: string | bigint | number;
|
|
1078
1170
|
/** Optional progress callback */
|
|
1079
1171
|
onProgress?: (stage: string, detail?: string) => void;
|
|
1172
|
+
/** Optional proving key directory/base URL or circuit path resolver */
|
|
1173
|
+
provingKeyPath?: ProvingKeyPath;
|
|
1080
1174
|
}
|
|
1081
1175
|
/**
|
|
1082
1176
|
* Prepare a transaction (withdrawal or transfer)
|
|
@@ -1108,7 +1202,7 @@ interface PrepareTransactionParams {
|
|
|
1108
1202
|
* });
|
|
1109
1203
|
* ```
|
|
1110
1204
|
*/
|
|
1111
|
-
declare function prepareTransaction({ commitments, inputs, outputs, fee, recipient, relayer, onProgress, }: PrepareTransactionParams): Promise<TransactionResult>;
|
|
1205
|
+
declare function prepareTransaction({ commitments, inputs, outputs, fee, recipient, relayer, onProgress, provingKeyPath, }: PrepareTransactionParams): Promise<TransactionResult>;
|
|
1112
1206
|
|
|
1113
1207
|
/**
|
|
1114
1208
|
* Merkle tree utilities for Veil SDK
|
|
@@ -1146,63 +1240,6 @@ declare function getMerklePath(tree: MerkleTree, commitment: bigint | string): {
|
|
|
1146
1240
|
pathIndices: number;
|
|
1147
1241
|
};
|
|
1148
1242
|
|
|
1149
|
-
/**
|
|
1150
|
-
* ZK Proof generation for Veil SDK
|
|
1151
|
-
* Uses snarkjs groth16 to generate proofs for transactions
|
|
1152
|
-
*/
|
|
1153
|
-
/**
|
|
1154
|
-
* Input data for ZK proof generation
|
|
1155
|
-
*/
|
|
1156
|
-
interface ProofInput {
|
|
1157
|
-
root: bigint;
|
|
1158
|
-
inputNullifier: bigint[];
|
|
1159
|
-
outputCommitment: bigint[];
|
|
1160
|
-
publicAmount: string;
|
|
1161
|
-
extDataHash: bigint;
|
|
1162
|
-
inAmount: bigint[];
|
|
1163
|
-
inPrivateKey: (string | null)[];
|
|
1164
|
-
inBlinding: bigint[];
|
|
1165
|
-
inPathIndices: number[];
|
|
1166
|
-
inPathElements: (bigint | number)[][];
|
|
1167
|
-
outAmount: bigint[];
|
|
1168
|
-
outBlinding: bigint[];
|
|
1169
|
-
outPubkey: bigint[];
|
|
1170
|
-
}
|
|
1171
|
-
/**
|
|
1172
|
-
* Generate a ZK proof for a transaction
|
|
1173
|
-
*
|
|
1174
|
-
* @param input - Proof input data
|
|
1175
|
-
* @param circuitName - Circuit name (e.g., 'transaction2' or 'transaction16')
|
|
1176
|
-
* @returns Serialized proof as hex string
|
|
1177
|
-
*
|
|
1178
|
-
* @example
|
|
1179
|
-
* ```typescript
|
|
1180
|
-
* const proof = await prove(proofInput, 'transaction2');
|
|
1181
|
-
* // Returns: 0x1234...abcd (256 bytes hex)
|
|
1182
|
-
* ```
|
|
1183
|
-
*/
|
|
1184
|
-
declare function prove(input: ProofInput, circuitName: string): Promise<string>;
|
|
1185
|
-
/**
|
|
1186
|
-
* Get the supported circuit names and their max input counts
|
|
1187
|
-
*/
|
|
1188
|
-
declare const CIRCUIT_CONFIG: {
|
|
1189
|
-
readonly transaction2: {
|
|
1190
|
-
readonly maxInputs: 2;
|
|
1191
|
-
readonly maxOutputs: 2;
|
|
1192
|
-
};
|
|
1193
|
-
readonly transaction16: {
|
|
1194
|
-
readonly maxInputs: 16;
|
|
1195
|
-
readonly maxOutputs: 2;
|
|
1196
|
-
};
|
|
1197
|
-
};
|
|
1198
|
-
/**
|
|
1199
|
-
* Select the appropriate circuit based on input count
|
|
1200
|
-
*
|
|
1201
|
-
* @param inputCount - Number of input UTXOs
|
|
1202
|
-
* @returns Circuit name to use
|
|
1203
|
-
*/
|
|
1204
|
-
declare function selectCircuit(inputCount: number): string;
|
|
1205
|
-
|
|
1206
1243
|
/**
|
|
1207
1244
|
* Contract addresses for Veil on Base
|
|
1208
1245
|
*/
|
|
@@ -2751,6 +2788,7 @@ declare function mergeSubaccount(options: SubaccountMergeOptions): Promise<Subac
|
|
|
2751
2788
|
* Crypto utilities for Veil SDK
|
|
2752
2789
|
* Poseidon hash, hex conversion, and random number generation
|
|
2753
2790
|
*/
|
|
2791
|
+
|
|
2754
2792
|
/**
|
|
2755
2793
|
* SNARK scalar field size
|
|
2756
2794
|
*/
|
|
@@ -2816,4 +2854,4 @@ declare function getExtDataHash(extData: ExtDataInput): bigint;
|
|
|
2816
2854
|
*/
|
|
2817
2855
|
declare function shuffle<T>(array: T[]): T[];
|
|
2818
2856
|
|
|
2819
|
-
export { ADDRESSES, type BuildTransferProofOptions, type BuildWithdrawProofOptions, CIRCUIT_CONFIG, type DepositTxOptions, ENTRY_ABI, ERC20_ABI, type EncryptedMessage, type ExtData, type ExtDataInput, FIELD_SIZE, FORWARDER_ABI, FORWARDER_CONTRACT_VERSION, FORWARDER_FACTORY_ABI, Keypair, MAX_SUBACCOUNT_SLOTS, MERKLE_TREE_HEIGHT, type MessageSigner, type NetworkAddresses, POOL_ABI, POOL_CONFIG, type PendingDeposit, type PoolConfig, type PrepareTransactionParams, type PrivateBalanceResult, type ProgressCallback, type ProofArgs, type ProofBuildResult, type ProofInput, QUEUE_ABI, type QueueBalanceResult, type RegisterTxOptions, RelayError, type RelayErrorResponse, type RelayExtData, type RelayMetadata, type RelayPool, type RelayProofArgs, type RelayRequest, type RelayResponse, type RelayType, type SubaccountAsset, type SubaccountAssetBalance, type SubaccountBalances, type SubaccountDeployRequest, type SubaccountMergeOptions, type SubaccountMergeResult, type SubaccountPrivateBalanceStatus, type SubaccountPrivateBalances, type SubaccountQueueStatus, type SubaccountRecoveryResult, type SubaccountRelayResult, type SubaccountSlot, type SubaccountStatusResult, type SubaccountSweepRequest, type SubaccountWithdrawTypedData, type SubmitRelayOptions, type Token, type TransactionData, type TransactionResult, type TransferResult, Utxo, type UtxoInfo, type UtxoParams, type UtxoSelectionResult, VEIL_SIGNED_MESSAGE, type WithdrawResult, buildApproveUSDCTx, buildChangeDepositKeyTx, buildDepositETHTx, buildDepositTx, buildDepositUSDCTx, buildMerkleTree, buildRegisterTx, buildSubaccountRecoveryTx, buildSubaccountWithdrawTypedData, buildTransferProof, buildWithdrawProof, checkRecipientRegistration, checkRelayHealth, deploySubaccountForwarder, deriveSubaccountChildDepositKey, deriveSubaccountChildOwner, deriveSubaccountChildPrivateKey, deriveSubaccountSalt, deriveSubaccountSlot, findNextSubaccountWithdrawNonce, getAddresses, getDailyFreeRemaining, getExtDataHash, getForwarderFactoryAddress, getMerklePath, getPoolAddress, getPrivateBalance, getQueueAddress, getQueueBalance, getRelayInfo, getRelayUrl, getSubaccountPrivateBalance, getSubaccountStatus, isSubaccountForwarderDeployed, isSubaccountWithdrawNonceUsed, mergeSubaccount, mergeUtxos, packEncryptedMessage, poseidonHash, poseidonHash2, predictSubaccountForwarder, prepareTransaction, prove, randomBN, selectCircuit, selectUtxosForWithdraw, shuffle, signSubaccountWithdraw, submitRelay, sweepSubaccountForwarder, toBuffer, toFixedHex, transfer, unpackEncryptedMessage, withdraw };
|
|
2857
|
+
export { ADDRESSES, type BuildTransferProofOptions, type BuildWithdrawProofOptions, CIRCUIT_CONFIG, type DepositTxOptions, ENTRY_ABI, ERC20_ABI, type EncryptedMessage, type ExtData, type ExtDataInput, FIELD_SIZE, FORWARDER_ABI, FORWARDER_CONTRACT_VERSION, FORWARDER_FACTORY_ABI, Keypair, MAX_SUBACCOUNT_SLOTS, MERKLE_TREE_HEIGHT, type MessageSigner, type NetworkAddresses, POOL_ABI, POOL_CONFIG, type PendingDeposit, type PoolConfig, type PrepareTransactionParams, type PrivateBalanceResult, type ProgressCallback, type ProofArgs, type ProofBuildResult, type ProofInput, type ProveOptions, type ProvingKeyPath, QUEUE_ABI, type QueueBalanceResult, type RegisterTxOptions, RelayError, type RelayErrorResponse, type RelayExtData, type RelayMetadata, type RelayPool, type RelayProofArgs, type RelayRequest, type RelayResponse, type RelayType, type SubaccountAsset, type SubaccountAssetBalance, type SubaccountBalances, type SubaccountDeployRequest, type SubaccountMergeOptions, type SubaccountMergeResult, type SubaccountPrivateBalanceStatus, type SubaccountPrivateBalances, type SubaccountQueueStatus, type SubaccountRecoveryResult, type SubaccountRelayResult, type SubaccountSlot, type SubaccountStatusResult, type SubaccountSweepRequest, type SubaccountWithdrawTypedData, type SubmitRelayOptions, type Token, type TransactionData, type TransactionResult, type TransferResult, Utxo, type UtxoInfo, type UtxoParams, type UtxoSelectionResult, VEIL_SIGNED_MESSAGE, type WithdrawResult, buildApproveUSDCTx, buildChangeDepositKeyTx, buildDepositETHTx, buildDepositTx, buildDepositUSDCTx, buildMerkleTree, buildRegisterTx, buildSubaccountRecoveryTx, buildSubaccountWithdrawTypedData, buildTransferProof, buildWithdrawProof, checkRecipientRegistration, checkRelayHealth, deploySubaccountForwarder, deriveSubaccountChildDepositKey, deriveSubaccountChildOwner, deriveSubaccountChildPrivateKey, deriveSubaccountSalt, deriveSubaccountSlot, findNextSubaccountWithdrawNonce, getAddresses, getDailyFreeRemaining, getExtDataHash, getForwarderFactoryAddress, getMerklePath, getPoolAddress, getPrivateBalance, getQueueAddress, getQueueBalance, getRelayInfo, getRelayUrl, getSubaccountPrivateBalance, getSubaccountStatus, isSubaccountForwarderDeployed, isSubaccountWithdrawNonceUsed, mergeSubaccount, mergeUtxos, packEncryptedMessage, poseidonHash, poseidonHash2, predictSubaccountForwarder, prepareTransaction, prove, randomBN, selectCircuit, selectUtxosForWithdraw, shuffle, signSubaccountWithdraw, submitRelay, sweepSubaccountForwarder, toBuffer, toFixedHex, transfer, unpackEncryptedMessage, withdraw };
|