@orbinum/sdk 0.4.2 → 0.6.0

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.d.mts CHANGED
@@ -1,8 +1,10 @@
1
1
  import * as polkadot_api from 'polkadot-api';
2
- import { PolkadotClient, TxFinalizedPayload, PolkadotSigner } from 'polkadot-api';
2
+ import { PolkadotClient, TxFinalizedPayload, PolkadotSigner, TxOptions } from 'polkadot-api';
3
3
  export { PolkadotSigner, getSs58AddressInfo } from 'polkadot-api';
4
4
  import { getDynamicBuilder } from '@polkadot-api/metadata-builders';
5
5
  import { getExtrinsicDecoder } from '@polkadot-api/tx-utils';
6
+ import { ArtifactProvider, ProofResult } from '@orbinum/proof-generator';
7
+ export { ArtifactProvider, CircuitType, ProofResult, WebArtifactProvider } from '@orbinum/proof-generator';
6
8
  export { AccountId, Blake2256, Keccak256, Storage, u128, u64 } from '@polkadot-api/substrate-bindings';
7
9
  export { base58 } from '@scure/base';
8
10
  export { getPolkadotSigner } from 'polkadot-api/signer';
@@ -179,6 +181,12 @@ declare class SubstrateClient {
179
181
  * Events: TxSigned → TxBroadcasted → TxBestBlocksState → TxFinalized
180
182
  */
181
183
  submitAndWatch(signedHex: string): ReturnType<PolkadotClient['submitAndWatch']>;
184
+ /**
185
+ * Submits a bare (unsigned) extrinsic hex and waits for finalization.
186
+ * Used for gasless private_transfer and unshield transactions.
187
+ * The bare tx hex is produced by `tx.getBareTx()` from polkadot-api.
188
+ */
189
+ submitUnsignedAndWatch(bareTxHex: string): Promise<TxFinalizedPayload>;
182
190
  /**
183
191
  * Convenience: wrap raw call bytes and sign+submit in one step.
184
192
  */
@@ -213,13 +221,16 @@ declare class SubstrateClient {
213
221
  */
214
222
  declare class EvmClient {
215
223
  private readonly rpcUrl;
224
+ /** @param rpcUrl - HTTP URL of the EVM JSON-RPC endpoint (e.g. `"http://localhost:9933"`). */
216
225
  constructor(rpcUrl: string);
217
226
  /**
218
- * Performs a single JSON-RPC call.
227
+ * Performs a single JSON-RPC call and returns the typed result.
228
+ * Throws on HTTP errors, RPC-level errors, or a `null` result.
219
229
  */
220
230
  request<T>(method: string, params?: unknown[]): Promise<T>;
221
231
  /**
222
232
  * Performs multiple JSON-RPC calls in a single HTTP request (batch).
233
+ * Results are returned in the same order as `calls`, as a typed tuple.
223
234
  */
224
235
  batchRequest<T extends unknown[]>(calls: Array<{
225
236
  method: string;
@@ -235,100 +246,166 @@ declare class EvmClient {
235
246
  getTransactionCount(address: string): Promise<number>;
236
247
  /** Returns the current gas price in wei. */
237
248
  getGasPrice(): Promise<bigint>;
238
- /**
239
- * Submits a signed raw transaction. Returns the transaction hash.
240
- */
249
+ /** Submits a signed raw transaction. Returns the transaction hash. */
241
250
  sendRawTransaction(signedHex: string): Promise<string>;
242
- /**
243
- * Executes a read-only call without creating a transaction.
244
- */
251
+ /** Executes a read-only call without creating a transaction. Returns the raw ABI-encoded response. */
245
252
  call(to: string, data: string, from?: string): Promise<string>;
246
- /**
247
- * Estimates the gas for a transaction.
248
- */
253
+ /** Estimates the gas required for a transaction. Returns the estimate in wei as a `bigint`. */
249
254
  estimateGas(params: {
250
255
  from?: string;
251
256
  to: string;
252
257
  data?: string;
253
258
  value?: string;
254
259
  }): Promise<bigint>;
260
+ /** Returns a transaction receipt by hash, or `null` if the transaction has not been mined yet. */
261
+ getTransactionReceipt(txHash: string): Promise<Record<string, unknown> | null>;
255
262
  /**
256
- * Returns a transaction receipt by hash, or null if not yet mined.
263
+ * Polls `eth_getTransactionReceipt` until the transaction is included in a block.
264
+ *
265
+ * @param txHash - The transaction hash to wait for.
266
+ * @param intervalMs - Polling interval in milliseconds (default: 500).
267
+ * @param timeoutMs - Maximum time to wait in milliseconds (default: 60_000).
268
+ * @returns The transaction receipt once mined.
269
+ * @throws If the transaction is not mined within `timeoutMs` or if it reverted (`status == 0x0`).
257
270
  */
258
- getTransactionReceipt(txHash: string): Promise<Record<string, unknown> | null>;
271
+ waitForReceipt(txHash: string, intervalMs?: number, timeoutMs?: number): Promise<Record<string, unknown>>;
259
272
  }
260
273
 
261
274
  /** Enriched EVM transaction model for explorer UIs. */
262
275
  interface EvmTransaction {
276
+ /** 0x-prefixed transaction hash. */
263
277
  hash: string;
278
+ /** Block number in which the transaction was included. */
264
279
  blockNumber: number;
280
+ /** 0x-prefixed hash of the containing block. Only present when fetched with block context. */
265
281
  blockHash?: string;
282
+ /** Sender address (checksummed or lowercase hex). */
266
283
  from: string;
284
+ /** Recipient address, or `null` for contract-creation transactions. */
267
285
  to: string | null;
286
+ /** Native token value transferred, as a 0x-prefixed hex string (wei). */
268
287
  value: string;
288
+ /** Gas actually consumed by the transaction, as a decimal string. */
269
289
  gasUsed: string;
290
+ /** Gas price in wei, as a decimal string. */
270
291
  gasPrice: string;
292
+ /** Sender nonce at the time of submission. */
271
293
  nonce: number;
294
+ /** ABI-encoded call data (0x-prefixed hex). `'0x'` for plain transfers. */
272
295
  input: string;
296
+ /** `1` for success, `0` for revert. */
273
297
  status: number;
298
+ /** Deployed contract address for contract-creation transactions; `null` otherwise. */
274
299
  contractAddress: string | null;
300
+ /** Unix timestamp (seconds) of the containing block, or `null` if unavailable. */
275
301
  timestamp: number | null;
276
302
  }
303
+ /** A single EVM event log entry. */
277
304
  interface EvmLog {
305
+ /** Address of the contract that emitted the log. */
278
306
  address: string;
307
+ /** Indexed event topics; `topics[0]` is the event signature hash. */
279
308
  topics: string[];
309
+ /** ABI-encoded non-indexed event data (0x-prefixed hex). */
280
310
  data: string;
311
+ /** Block number in which the log was emitted. */
281
312
  blockNumber: number;
313
+ /** Hash of the transaction that emitted the log. */
282
314
  transactionHash: string;
315
+ /** Position of this log within the block. */
283
316
  logIndex: number;
284
317
  }
318
+ /** Aggregated on-chain information about an EVM address. */
285
319
  interface EvmAddressInfo {
320
+ /** The queried address (as provided, not normalised). */
286
321
  address: string;
322
+ /** `true` when the address has deployed bytecode. */
287
323
  isContract: boolean;
324
+ /** Native token balance as a 0x-prefixed hex string (wei). */
288
325
  balance: string;
326
+ /** Current transaction count (nonce). */
289
327
  nonce: number;
328
+ /** Deployed bytecode size in bytes (`0` for EOAs). */
290
329
  codeSize: number;
330
+ /** Deployed bytecode (truncated to 100 bytes + ellipsis for display). `'0x'` for EOAs. */
291
331
  code: string;
332
+ /** Up to 50 most recent logs emitted by or received by this address. */
292
333
  recentLogs: EvmLog[];
293
334
  }
335
+ /** EVM block header with transaction hashes (not full tx objects). */
294
336
  interface EvmBlock {
337
+ /** 0x-prefixed block hash. */
295
338
  hash: string;
339
+ /** Block number. */
296
340
  number: number;
341
+ /** Unix timestamp (seconds) from the block header. */
297
342
  timestamp: number;
343
+ /** Ordered list of transaction hashes included in the block. */
298
344
  transactions: string[];
345
+ /** Actual gas consumed by all transactions, as a decimal string. */
299
346
  gasUsed: string;
347
+ /** Block gas limit, as a decimal string. */
300
348
  gasLimit: string;
349
+ /** Address of the block author / fee recipient. */
301
350
  miner: string;
351
+ /** 0x-prefixed hash of the parent block. */
302
352
  parentHash: string;
303
353
  }
354
+ /** Lightweight transaction summary used in address and block listing views. */
304
355
  interface EvmTxSummary {
356
+ /** 0x-prefixed transaction hash. */
305
357
  hash: string;
358
+ /** Block number in which the transaction was included. */
306
359
  blockNumber: number;
360
+ /** Unix timestamp (seconds) of the containing block, or `null` if unavailable. */
307
361
  timestamp: number | null;
362
+ /** Sender address. */
308
363
  from: string;
364
+ /** Recipient address, or `null` for contract-creation transactions. */
309
365
  to: string | null;
366
+ /** Native token value transferred, as a 0x-prefixed hex string (wei). */
310
367
  value: string;
368
+ /** ABI-encoded call data (0x-prefixed hex). */
311
369
  input: string;
370
+ /** Gas actually consumed by the transaction. */
312
371
  gasUsed: number;
372
+ /** Gas price in wei, as a 0x-prefixed hex string. */
313
373
  gasPrice: string;
374
+ /** `true` when the transaction succeeded (receipt status `0x1`). */
314
375
  status: boolean;
376
+ /** `true` when the transaction created a new contract (`to` is `null`). */
315
377
  isContractCreation: boolean;
378
+ /** Deployed contract address for contract-creation transactions; `null` otherwise. */
316
379
  contractAddress: string | null;
317
380
  }
381
+ /** ERC-20 token metadata fetched via ABI calls (`name`, `symbol`, `decimals`, `totalSupply`). */
318
382
  interface TokenInfo {
383
+ /** Checksummed contract address (lowercased as returned by the node). */
319
384
  address: string;
385
+ /** Token name (decoded from ABI). Empty string when unavailable. */
320
386
  name: string;
387
+ /** Token symbol (decoded from ABI). Empty string when unavailable. */
321
388
  symbol: string;
389
+ /** Number of decimal places. Defaults to `18` when not readable from the contract. */
322
390
  decimals: number;
391
+ /** Total supply as a 0x-prefixed hex string. */
323
392
  totalSupply: string;
393
+ /** `true` when the contract exposes a non-zero `totalSupply`, `symbol`, and `decimals`. */
324
394
  isErc20: boolean;
325
395
  }
396
+ /** A single ERC-20 `Transfer` event decoded from an EVM log. */
326
397
  interface TokenTransfer {
398
+ /** Hash of the transaction that emitted the transfer event. */
327
399
  transactionHash: string;
400
+ /** Block number in which the transfer was included. */
328
401
  blockNumber: number;
402
+ /** Sender address (decoded from `topics[1]`). */
329
403
  from: string;
404
+ /** Recipient address (decoded from `topics[2]`). */
330
405
  to: string;
406
+ /** Transferred amount as a 0x-prefixed hex string (raw `data` field). */
331
407
  value: string;
408
+ /** Position of the log within the block. */
332
409
  logIndex: number;
333
410
  }
334
411
 
@@ -338,25 +415,60 @@ interface TokenTransfer {
338
415
  */
339
416
  declare class EvmExplorer {
340
417
  private readonly evm;
418
+ /** @param evm - Underlying `EvmClient` used for all RPC calls. */
341
419
  constructor(evm: EvmClient);
420
+ /** Returns the `count` most recent blocks in descending order (latest first). */
342
421
  getLatestBlocks(count?: number): Promise<EvmBlock[]>;
422
+ /** Returns a single block by number or hash, or `null` if not found. */
343
423
  getBlock(hashOrNumber: string | number): Promise<EvmBlock | null>;
424
+ /** Returns all transactions in a block (with receipts), or `[]` if the block is not found. */
344
425
  getBlockTransactions(hashOrNumber: string | number): Promise<EvmTransaction[]>;
426
+ /** Returns a single transaction with its receipt, or `null` if not found. */
345
427
  getTransaction(hash: string): Promise<EvmTransaction | null>;
428
+ /**
429
+ * Returns lightweight summaries of all transactions sent from or to `address`
430
+ * within the last `maxBlocks` blocks, sorted by block number descending.
431
+ */
346
432
  getTransactionsByAddress(address: string, maxBlocks?: number): Promise<EvmTxSummary[]>;
433
+ /**
434
+ * Returns aggregated on-chain data for an EVM address: balance, nonce,
435
+ * bytecode (truncated), and up to 50 recent logs from the last 5 000 blocks.
436
+ */
347
437
  getAddressInfo(address: string): Promise<EvmAddressInfo>;
438
+ /** Returns the native token balance of `address`, formatted as a decimal string (no symbol). */
348
439
  getBalance(address: string): Promise<string>;
440
+ /** Returns the current transaction count (nonce) for `address`, or `0` on error. */
349
441
  getNonce(address: string): Promise<number>;
442
+ /** Returns `true` when `address` has non-empty deployed bytecode. */
350
443
  getIsContract(address: string): Promise<boolean>;
444
+ /**
445
+ * Fetches ERC-20 metadata for a token contract via ABI calls.
446
+ * Returns `null` when the address does not look like an ERC-20 token.
447
+ */
351
448
  getTokenInfo(address: string): Promise<TokenInfo | null>;
449
+ /**
450
+ * Returns ERC-20 `Transfer` events for `address` from the last 5 000 blocks.
451
+ * When `holderAddress` is provided, restricts results to transfers sent or received by that address.
452
+ */
352
453
  getTokenTransfers(address: string, holderAddress?: string): Promise<TokenTransfer[]>;
454
+ /** Returns the raw ERC-20 balance of `holderAddress` for the token at `tokenAddress` (0x-prefixed hex). */
353
455
  getTokenBalance(tokenAddress: string, holderAddress: string): Promise<string>;
456
+ /** Maps a raw RPC block object to the public `EvmBlock` shape. */
354
457
  private parseBlock;
458
+ /** Maps a raw RPC transaction + optional receipt to the public `EvmTransaction` shape. */
355
459
  private parseTx;
460
+ /**
461
+ * Fetches a raw block by number or hash. Accepts a plain integer, a decimal string,
462
+ * or a 0x-prefixed hash. Returns `null` on any RPC error.
463
+ */
356
464
  private fetchBlock;
465
+ /** Executes a read-only `eth_call` and returns the raw hex result, or `null` on error. */
357
466
  private ethCall;
467
+ /** Decodes an ABI-encoded `string` return value from a raw 0x-prefixed hex string. */
358
468
  private static decodeAbiString;
469
+ /** Decodes an ABI-encoded `uint256` return value to a `bigint`. */
359
470
  private static decodeAbiUint;
471
+ /** Converts a 0x-prefixed hex number to its decimal string representation. Returns `'0'` on parse error. */
360
472
  private static hexToDecimalStr;
361
473
  }
362
474
 
@@ -384,6 +496,8 @@ interface ShieldedCommitment {
384
496
  leafIndex: number;
385
497
  /** Asset ID as decimal string (e.g. "0"). */
386
498
  assetId: string;
499
+ /** Origin of the commitment: direct shield, output of private transfer, or change from unshield. */
500
+ source: 'shield' | 'transfer' | 'unshield';
387
501
  /** SS58 or 0x-prefixed depositor address, null if not tracked. */
388
502
  sender: string | null;
389
503
  /** 0x-prefixed encrypted memo hex, null if not present. */
@@ -398,18 +512,12 @@ interface SpentNullifier {
398
512
  txType: 'unshield' | 'private_transfer';
399
513
  timestampMs: number | null;
400
514
  }
401
- /** A private transfer event stored by the indexer. */
402
- interface PrivateTransfer {
403
- /** "{blockNumber}-{extrinsicIndex}" */
404
- id: string;
515
+ /** Temporal metadata for a private transfer. No graph data (inputs ↔ outputs) exposed. */
516
+ interface PrivateTransferTimestamp {
405
517
  blockNumber: number;
406
518
  extrinsicIndex: number | null;
407
- /** JSON-encoded array of nullifier hex strings. */
408
- inputNullifiersJson: string;
409
- /** JSON-encoded array of commitment hex strings. */
410
- outputCommitmentsJson: string;
411
- /** JSON-encoded array of leaf index numbers. */
412
- leafIndicesJson: string;
519
+ /** Blake2-256 hash of the raw extrinsic, 0x-prefixed. Null if the extrinsic was not decoded. */
520
+ hash: string | null;
413
521
  timestampMs: number | null;
414
522
  }
415
523
  /** An unshield event stored by the indexer. */
@@ -418,6 +526,8 @@ interface Unshield {
418
526
  id: string;
419
527
  blockNumber: number;
420
528
  extrinsicIndex: number | null;
529
+ /** Blake2-256 hash of the raw extrinsic, 0x-prefixed. Null if the extrinsic was not decoded. */
530
+ hash: string | null;
421
531
  nullifierHex: string;
422
532
  /** Asset ID as decimal string. */
423
533
  assetId: string;
@@ -509,11 +619,56 @@ interface IndexerStats {
509
619
  merkleRoot: string | null;
510
620
  treeSize: number | null;
511
621
  };
622
+ relayers: {
623
+ active: number;
624
+ };
512
625
  zkVerifier: {
513
626
  total: number;
514
627
  successful: number;
515
628
  };
516
629
  }
630
+ /** A registered relayer stored by the indexer. */
631
+ interface Relayer {
632
+ evmAddress: string;
633
+ account: string;
634
+ active: boolean;
635
+ registeredAtBlock: number;
636
+ unregisteredAtBlock: number | null;
637
+ timestampMs: number | null;
638
+ }
639
+ /** A relay fee accumulation or consumption event stored by the indexer. */
640
+ interface RelayFeeEvent {
641
+ id: number;
642
+ relayer: string;
643
+ assetId: string;
644
+ /** Amount as decimal string (bigint-safe). */
645
+ amount: string;
646
+ eventType: 'accumulated' | 'consumed';
647
+ blockNumber: number;
648
+ timestampMs: number | null;
649
+ }
650
+ /** Aggregated relay fee balance per asset for a given relayer. */
651
+ interface RelayFeeSummaryEntry {
652
+ assetId: string;
653
+ /** Total accumulated (bigint string). */
654
+ accumulated: string;
655
+ /** Total consumed (bigint string). */
656
+ consumed: string;
657
+ /** pending = accumulated − consumed (bigint string). */
658
+ pending: string;
659
+ }
660
+ /** A registered asset stored by the indexer. */
661
+ interface RegisteredAsset {
662
+ assetId: string;
663
+ name: string | null;
664
+ symbol: string | null;
665
+ decimals: number | null;
666
+ contractAddress: string | null;
667
+ /** Whether the asset is verified by the protocol. */
668
+ verified: boolean;
669
+ registeredAtBlock: number;
670
+ timestampMs: number | null;
671
+ }
517
672
  /**
518
673
  * A single shielded activity event tied to an address.
519
674
  * The `kind` discriminant identifies whether it is a shield (commitment),
@@ -525,7 +680,24 @@ type ShieldedAddressEvent = ({
525
680
  kind: 'unshield';
526
681
  } & Unshield) | ({
527
682
  kind: 'transfer';
528
- } & PrivateTransfer);
683
+ } & PrivateTransferTimestamp);
684
+ /**
685
+ * Lightweight hint returned by the stealth scan endpoint.
686
+ * Contains only the fields required for a wallet to:
687
+ * 1. Compute ECDH shared secret: ephPkHex × ivsk
688
+ * 2. Attempt ChaCha20-Poly1305 decryption of encryptedMemo
689
+ * Ordered ascending by leafIndex for incremental cursor compatibility.
690
+ */
691
+ interface StealthScanHint {
692
+ leafIndex: number;
693
+ commitmentHex: string;
694
+ /** Asset ID as decimal string (e.g. "0"). */
695
+ assetId: string;
696
+ /** Ephemeral public key (last 32 bytes of encrypted_memo), 0x-prefixed. null if memo absent. */
697
+ ephPkHex: string | null;
698
+ /** Full 168-byte encrypted memo (0x-prefixed hex). null if not present. */
699
+ encryptedMemo: string | null;
700
+ }
529
701
 
530
702
  /**
531
703
  * HTTP client for the Orbinum indexer REST API.
@@ -539,6 +711,7 @@ declare class IndexerClient {
539
711
  constructor(config: IndexerClientConfig);
540
712
  private _fetchResponse;
541
713
  private get;
714
+ private post;
542
715
  private getOrNull;
543
716
  private buildQuery;
544
717
  /** Returns the total count of shielded commitments. */
@@ -551,6 +724,18 @@ declare class IndexerClient {
551
724
  }): Promise<PaginatedResult<ShieldedCommitment>>;
552
725
  /** Returns a single commitment by its hex string, or null if not found. */
553
726
  getCommitmentByHex(hex: string): Promise<ShieldedCommitment | null>;
727
+ /**
728
+ * Returns a paginated list of stealth scan hints ordered ascending by leafIndex.
729
+ * Each hint contains only the fields required for ECDH triage and decryption:
730
+ * leafIndex, commitmentHex, assetId, ephPkHex, encryptedMemo.
731
+ *
732
+ * Use `sinceLeafIndex` for incremental scans (cursor = last seen leafIndex + 1).
733
+ */
734
+ getScanHints(params?: {
735
+ page?: number;
736
+ limit?: number;
737
+ sinceLeafIndex?: number;
738
+ }): Promise<PaginatedResult<StealthScanHint>>;
554
739
  /** Returns a paginated list of spent nullifiers. */
555
740
  getNullifiers(params?: {
556
741
  page?: number;
@@ -558,11 +743,26 @@ declare class IndexerClient {
558
743
  }): Promise<PaginatedResult<SpentNullifier>>;
559
744
  /** Returns the spent/unspent status of a nullifier. */
560
745
  getNullifierStatus(hex: string): Promise<NullifierStatusResult>;
561
- /** Returns a paginated list of private transfer events. */
562
- getTransfers(params?: {
563
- page?: number;
564
- limit?: number;
565
- }): Promise<PaginatedResult<PrivateTransfer>>;
746
+ /**
747
+ * Batch-checks which of the given nullifiers are spent.
748
+ * Returns only the nullifiers that exist in the spent set.
749
+ * Accepts up to 100 nullifiers (0x-prefixed hex).
750
+ */
751
+ getNullifiersBatch(nullifiers: string[]): Promise<SpentNullifier[]>;
752
+ /**
753
+ * Returns temporal metadata for private transfers that spent any of the given nullifiers.
754
+ * Only blockNumber, extrinsicIndex, timestampMs, and hash are returned — no cross-link
755
+ * between inputs and outputs to prevent graph reconstruction.
756
+ * Accepts up to 50 nullifiers (0x-prefixed hex).
757
+ */
758
+ getTransfersByNullifiers(nullifiers: string[]): Promise<PrivateTransferTimestamp[]>;
759
+ /**
760
+ * Returns temporal metadata for private transfers that produced any of the given commitments.
761
+ * Only blockNumber, extrinsicIndex, timestampMs, and hash are returned — no cross-link
762
+ * between outputs and inputs to prevent graph reconstruction.
763
+ * Accepts up to 50 commitments (0x-prefixed hex).
764
+ */
765
+ getTransfersByCommitments(commitments: string[]): Promise<PrivateTransferTimestamp[]>;
566
766
  /** Returns a paginated list of unshield events. */
567
767
  getUnshields(params?: {
568
768
  page?: number;
@@ -601,6 +801,14 @@ declare class IndexerClient {
601
801
  page?: number;
602
802
  limit?: number;
603
803
  }): Promise<PaginatedResult<ShieldedCommitment>>;
804
+ /**
805
+ * Returns a paginated list of unshield events where the given address is the recipient.
806
+ * Accepts a 0x-prefixed EVM address or an SS58 Substrate address.
807
+ */
808
+ getAddressUnshields(address: string, params?: {
809
+ page?: number;
810
+ limit?: number;
811
+ }): Promise<PaginatedResult<Unshield>>;
604
812
  /**
605
813
  * Returns a paginated list of all shielded activity (commitments, unshields,
606
814
  * private transfers) associated with the given address.
@@ -610,32 +818,65 @@ declare class IndexerClient {
610
818
  page?: number;
611
819
  limit?: number;
612
820
  }): Promise<PaginatedResult<ShieldedAddressEvent>>;
821
+ /** Returns a paginated list of relayers. Filter by active status with `active`. */
822
+ getRelayers(params?: {
823
+ page?: number;
824
+ limit?: number;
825
+ active?: boolean;
826
+ }): Promise<PaginatedResult<Relayer>>;
827
+ /** Returns a single relayer by EVM address, or null if not found. */
828
+ getRelayer(evmAddress: string): Promise<Relayer | null>;
829
+ /** Returns a paginated list of relay fee events. */
830
+ getRelayFees(params?: {
831
+ page?: number;
832
+ limit?: number;
833
+ relayer?: string;
834
+ type?: 'accumulated' | 'consumed';
835
+ }): Promise<PaginatedResult<RelayFeeEvent>>;
836
+ /** Returns aggregated relay fee balances per asset for a given relayer account. */
837
+ getRelayFeesSummary(relayer: string): Promise<RelayFeeSummaryEntry[]>;
838
+ /** Returns a paginated list of assets registered via register_asset. */
839
+ getRegisteredAssets(params?: {
840
+ page?: number;
841
+ limit?: number;
842
+ }): Promise<PaginatedResult<RegisteredAsset>>;
843
+ /** Returns a single registered asset by its ID, or null if not found. */
844
+ getRegisteredAsset(assetId: string): Promise<RegisteredAsset | null>;
613
845
  /** Returns aggregated indexer statistics. */
614
846
  getStats(): Promise<IndexerStats>;
615
847
  /** Returns true if the indexer health endpoint responds OK. */
616
848
  isHealthy(): Promise<boolean>;
617
849
  }
618
850
 
851
+ /** Configuration passed to `OrbinumClient.connect()`. */
619
852
  type OrbinumClientConfig = {
620
- /** WebSocket URL of the Orbinum node (e.g. "ws://localhost:9944") */
853
+ /** WebSocket URL of the Orbinum Substrate node (e.g. `"ws://localhost:9944"`). */
621
854
  substrateWs: string;
622
- /** HTTP URL of the EVM JSON-RPC endpoint (e.g. "http://localhost:9933") */
855
+ /** HTTP URL of the EVM JSON-RPC endpoint (e.g. `"http://localhost:9933"`). Omit to disable EVM support. */
623
856
  evmRpc?: string;
624
- /** Base URL of the Orbinum indexer REST API (e.g. "https://indexer.orbinum.io") */
857
+ /** Base URL of the Orbinum indexer REST API (e.g. `"https://indexer.orbinum.io"`). Omit to disable indexer support. */
625
858
  indexerUrl?: string;
626
- /** Connection timeout in ms. Default: 15_000 */
859
+ /** Timeout for the initial WebSocket handshake in milliseconds. Default: `15_000`. */
627
860
  connectTimeoutMs?: number;
628
861
  };
862
+ /** Result returned by extrinsic-submitting methods (shield, unshield, transfer, …). */
629
863
  type TxResult = {
864
+ /** 0x-prefixed hash of the submitted extrinsic. */
630
865
  txHash: string;
866
+ /** 0x-prefixed hash of the block that included the extrinsic. */
631
867
  blockHash: string;
868
+ /** Number of the block that included the extrinsic. */
632
869
  blockNumber: number;
633
- /** Whether the extrinsic succeeded (no ExtrinsicFailed event). */
870
+ /** `true` when the extrinsic succeeded (no `ExtrinsicFailed` event emitted). */
634
871
  ok: boolean;
635
- /** Dispatch error type string when ok = false. */
872
+ /** Dispatch error type string. Only present when `ok` is `false`. */
636
873
  error?: string;
637
874
  };
638
875
 
876
+ /** Opciones de transacción compatibles con el UnsafeApi de PAPI (sin asset tipado). */
877
+ type UnsafeTxOptions = TxOptions<void, Record<string, unknown>>;
878
+ declare function toTxResult(payload: TxFinalizedPayload): TxResult;
879
+
639
880
  type MerkleTreeInfo = {
640
881
  root: string;
641
882
  treeSize: number;
@@ -651,14 +892,16 @@ type DecryptedMemo = {
651
892
  ownerPk: bigint;
652
893
  blinding: bigint;
653
894
  assetId: bigint;
895
+ /** Counterparty BabyJubJub Ax coordinate. Zero for shield/unshield notes. */
896
+ counterpartyPk: bigint;
654
897
  };
655
898
  type ShieldParams = {
656
899
  assetId: number;
657
900
  amount: bigint;
658
901
  /** 0x-prefixed 32-byte commitment hex */
659
902
  commitment: string;
660
- /** Optional encrypted memo bytes. Auto-generates a dummy memo if absent. */
661
- encryptedMemo?: Uint8Array;
903
+ /** Encrypted memo bytes (168 bytes). Required notes without valid memos are irrecoverable. */
904
+ encryptedMemo: Uint8Array;
662
905
  };
663
906
  type UnshieldParams = {
664
907
  /** ZK proof bytes */
@@ -668,9 +911,24 @@ type UnshieldParams = {
668
911
  /** 0x-prefixed nullifier hex */
669
912
  nullifier: string;
670
913
  assetId: number;
914
+ /** Net amount recipient receives (planck) */
671
915
  amount: bigint;
672
916
  /** SS58 or 0x-prefixed 32-byte address */
673
917
  recipientAddress: string;
918
+ /** Gasless fee in planck (default 0n; note_value == amount + fee + changeValue in circuit) */
919
+ fee?: bigint;
920
+ /**
921
+ * 0x-prefixed 32-byte change note commitment hex.
922
+ * Pass the value returned by generateUnshieldProof().changeCommitment (converted to hex).
923
+ * Omit or use all-zero hex for total unshield (no change note).
924
+ */
925
+ changeCommitment?: string;
926
+ /**
927
+ * Encrypted memo for the change note (176 bytes).
928
+ * Required for partial unshield so the change note can be recovered via blockchain scan.
929
+ * Omit for total unshield.
930
+ */
931
+ changeEncryptedMemo?: Uint8Array;
674
932
  };
675
933
  type PrivateTransferInput = {
676
934
  /** 0x-prefixed nullifier hex */
@@ -681,7 +939,8 @@ type PrivateTransferInput = {
681
939
  type PrivateTransferOutput = {
682
940
  /** 0x-prefixed commitment hex */
683
941
  commitment: string;
684
- encryptedMemo?: Uint8Array;
942
+ /** Encrypted memo bytes (168 bytes). Required — notes without valid memos are irrecoverable. */
943
+ encryptedMemo: Uint8Array;
685
944
  };
686
945
  type PrivateTransferParams = {
687
946
  inputs: PrivateTransferInput[];
@@ -690,6 +949,11 @@ type PrivateTransferParams = {
690
949
  proof: Uint8Array;
691
950
  /** 0x-prefixed merkle root hex */
692
951
  merkleRoot: string;
952
+ /** Asset ID being transferred (public input of the proof) */
953
+ assetId: number;
954
+ /** Gasless fee in planck (default 0n; input_sum == output_sum + fee in circuit).
955
+ * The fee is paid to the block author (validator) by the pallet runtime. */
956
+ fee?: bigint;
693
957
  };
694
958
  /** Input params for NoteBuilder.build(). All fields except value have defaults. */
695
959
  type NoteInput = {
@@ -704,11 +968,20 @@ type NoteInput = {
704
968
  /** Secret spending key used to derive the nullifier. Default 0n. */
705
969
  spendingKey?: bigint;
706
970
  /**
707
- * 32-byte recipient viewing key used to encrypt the memo (ChaCha20-Poly1305).
708
- * When provided, NoteBuilder.build() will auto-generate the 104-byte encrypted memo.
971
+ * 32-byte LE-encoded packed BJJ viewing public key of the recipient (from their privacy address).
972
+ * When provided, NoteBuilder.build() will auto-generate the 168-byte ECDH-encrypted memo.
709
973
  * Omit to skip memo generation (use buildMemo() separately if needed).
710
974
  */
711
- viewingKey?: Uint8Array;
975
+ viewingPublicKey?: Uint8Array;
976
+ /**
977
+ * BabyJubJub Ax coordinate of the recipient (from their privacy address).
978
+ * Required together with viewingPublicKey to enable stealth address derivation:
979
+ * the commitment will use stealthOwnerPk instead of ownerPk, making each
980
+ * transaction unlinkable even when the same privacy address is reused.
981
+ */
982
+ recipientOwnerPk?: bigint;
983
+ /** Counterparty BabyJubJub Ax coordinate. Zero for shield/unshield notes. Default 0n. */
984
+ counterpartyPk?: bigint;
712
985
  };
713
986
  /**
714
987
  * Computed ZK note (commitment + nullifier). Built entirely off-chain.
@@ -735,15 +1008,12 @@ type ZkNote = {
735
1008
  /** 0x-prefixed 32-byte little-endian hex nullifier. */
736
1009
  nullifierHex: string;
737
1010
  /**
738
- * 104-byte encrypted memo (ChaCha20-Poly1305) as number[] for SCALE encoding.
739
- * Always populated: uses a dummy memo when no viewingKey is provided.
1011
+ * 168-byte encrypted memo (ChaCha20-Poly1305 ECDH) as number[] for SCALE encoding.
1012
+ * Always populated: uses a dummy memo when no viewingPublicKey is provided.
740
1013
  */
741
1014
  memo: number[];
742
- };
743
- /** Result of buildAndShield: the submitted tx and the note to keep safe. */
744
- type ShieldResult = {
745
- txResult: TxResult;
746
- note: ZkNote;
1015
+ /** Counterparty BabyJubJub Ax coordinate. Zero for shield/unshield notes. */
1016
+ counterpartyPk: bigint;
747
1017
  };
748
1018
  /** Parameters for a single item in a shield_batch extrinsic. */
749
1019
  type ShieldBatchItem = {
@@ -751,13 +1021,34 @@ type ShieldBatchItem = {
751
1021
  amount: bigint;
752
1022
  /** 0x-prefixed 32-byte commitment hex */
753
1023
  commitment: string;
754
- /** Optional encrypted memo bytes. Auto-generates a dummy memo if absent. */
755
- encryptedMemo?: Uint8Array;
1024
+ /** Encrypted memo bytes (168 bytes). Required notes without valid memos are irrecoverable. */
1025
+ encryptedMemo: Uint8Array;
756
1026
  };
757
1027
  /** Parameters for shieldedPool.shieldBatch — deposits up to 20 notes in one extrinsic. */
758
1028
  type ShieldBatchParams = {
759
1029
  items: ShieldBatchItem[];
760
1030
  };
1031
+ /**
1032
+ * Parameters for shieldedPool.claimShieldedFees —
1033
+ * claims accrued relay fees into the shielded pool.
1034
+ *
1035
+ * The relayer must supply a ZK value proof that binds the commitment to the
1036
+ * exact amount and asset_id, preventing fee inflation attacks.
1037
+ */
1038
+ type ClaimShieldedFeesParams = {
1039
+ /** 0x-prefixed 32-byte commitment hex (Poseidon of value, assetId, ownerPk, blinding) */
1040
+ commitment: string;
1041
+ /** Amount to claim in planck (must match the circuit's public input) */
1042
+ amount: bigint;
1043
+ /** Asset ID being claimed */
1044
+ assetId: number;
1045
+ /** 128-byte Groth16 proof bytes */
1046
+ proof: Uint8Array;
1047
+ /** 76-byte public signals buffer (commitment || amount_u64_le || assetId_u32_le || owner_hash) */
1048
+ publicSignals: Uint8Array;
1049
+ /** Encrypted memo bytes (168 bytes). Required — notes without valid memos are irrecoverable. */
1050
+ encryptedMemo: Uint8Array;
1051
+ };
761
1052
 
762
1053
  /**
763
1054
  * High-level module for Orbinum shielded-pool operations.
@@ -774,42 +1065,38 @@ declare class ShieldedPoolModule {
774
1065
  /**
775
1066
  * Deposits tokens into the shielded pool.
776
1067
  * Extrinsic: shieldedPool.shield(assetId, amount, commitment, encryptedMemo)
777
- */
778
- shield(params: ShieldParams, signer: PolkadotSigner): Promise<TxResult>;
779
- /**
780
- * Build a ZkNote locally and submit shieldedPool.shield in one call.
781
1068
  *
782
- * Returns both the on-chain result and the note **save the note locally**,
783
- * it cannot be recovered after the fact.
784
- *
785
- * @param params.value Amount in planck (required).
786
- * @param params.assetId Asset ID — default 0 (native ORB-Privacy).
787
- * @param params.ownerPk BabyJubJub Ax (default 0n).
788
- * @param params.blinding Random blinding scalar (default BigInt(Date.now())).
789
- * @param params.spendingKey Secret spending key (default 0n).
790
- */
791
- buildAndShield(params: {
792
- value: bigint;
793
- assetId?: number;
794
- ownerPk?: bigint;
795
- blinding?: bigint;
796
- spendingKey?: bigint;
797
- }, signer: PolkadotSigner): Promise<ShieldResult>;
1069
+ * Shield is always a signed (public) transaction — the caller's address
1070
+ * appears on-chain as the depositor.
1071
+ */
1072
+ shield(params: ShieldParams, signer: PolkadotSigner, txOptions?: UnsafeTxOptions): Promise<TxResult>;
798
1073
  /**
799
1074
  * Withdraws tokens from the shielded pool to a public address.
800
- * Extrinsic: shieldedPool.unshield(proof, merkleRoot, nullifier, assetId, amount, recipient)
1075
+ * Submits as an UNSIGNED (gasless) transaction fee is embedded in the ZK proof.
1076
+ * Pass a `signer` to fall back to signed submission (e.g. for testing).
1077
+ * Extrinsic: shieldedPool.unshield(proof, merkleRoot, nullifier, assetId, amount, recipient, fee)
801
1078
  */
802
- unshield(params: UnshieldParams, signer: PolkadotSigner): Promise<TxResult>;
1079
+ unshield(params: UnshieldParams, signer?: PolkadotSigner, txOptions?: UnsafeTxOptions): Promise<TxResult>;
803
1080
  /**
804
1081
  * Performs a private (shielded) transfer between two notes.
805
- * Extrinsic: shieldedPool.privateTransfer(inputs, outputs, proof, merkleRoot)
1082
+ * Submits as an UNSIGNED (gasless) transaction — fee is embedded in the ZK proof.
1083
+ * Pass a `signer` to fall back to signed submission (e.g. for testing).
1084
+ * Extrinsic: shieldedPool.privateTransfer(proof, merkleRoot, nullifiers, commitments, memos, assetId, fee)
806
1085
  */
807
- privateTransfer(params: PrivateTransferParams, signer: PolkadotSigner): Promise<TxResult>;
1086
+ privateTransfer(params: PrivateTransferParams, signer?: PolkadotSigner, txOptions?: UnsafeTxOptions): Promise<TxResult>;
808
1087
  /**
809
1088
  * Deposits multiple notes into the shielded pool in a single extrinsic.
810
1089
  * Extrinsic: shieldedPool.shieldBatch(operations) — max 20 items.
811
1090
  */
812
- shieldBatch(params: ShieldBatchParams, signer: PolkadotSigner): Promise<TxResult>;
1091
+ shieldBatch(params: ShieldBatchParams, signer: PolkadotSigner, txOptions?: UnsafeTxOptions): Promise<TxResult>;
1092
+ /**
1093
+ * Claims accrued relay fees into the shielded pool.
1094
+ * This is a SIGNED transaction — the relayer must sign it with their wallet.
1095
+ * Before calling this, generate a ZK value proof with generateFeeClaimProof() (not yet implemented).
1096
+ *
1097
+ * Extrinsic: shieldedPool.claim_shielded_fees(commitment, amount, asset_id, memo, proof, public_signals)
1098
+ */
1099
+ claimShieldedFees(params: ClaimShieldedFeesParams, signer: PolkadotSigner, txOptions?: UnsafeTxOptions): Promise<TxResult>;
813
1100
  }
814
1101
 
815
1102
  /**
@@ -1064,7 +1351,6 @@ type RpcV2MerkleProof = {
1064
1351
  leafIndex: number;
1065
1352
  treeDepth: number;
1066
1353
  };
1067
- /** Prueba Merkle enriquecida con el `root` actual del árbol. Devuelta por `getMerkleProofByCommitment`. */
1068
1354
  type PrivacyMerkleProof = RpcV2MerkleProof & {
1069
1355
  root: string;
1070
1356
  };
@@ -1074,13 +1360,12 @@ type RpcV2NullifierStatus = {
1074
1360
  };
1075
1361
  type RpcV2PoolAssetBalance = {
1076
1362
  assetId: number;
1077
- /** Balance serializado como string decimal para preservar `u128`. */
1078
1363
  balance: string;
1079
1364
  };
1080
1365
  type RpcV2PoolStats = {
1081
1366
  merkleRoot: string;
1082
1367
  commitmentCount: number;
1083
- /** Total pool balance serializado como string decimal para preservar `u128`. */
1368
+ nullifierCount: number;
1084
1369
  totalBalance: string;
1085
1370
  assetBalances: RpcV2PoolAssetBalance[];
1086
1371
  treeDepth: number;
@@ -1098,7 +1383,11 @@ declare class PrivacyModule {
1098
1383
  getMerkleProof(leafIndex: number | string): Promise<RpcV2MerkleProof>;
1099
1384
  /**
1100
1385
  * Returns the Merkle inclusion proof for a given commitment hex,
1101
- * bundled with the current Merkle root.
1386
+ * bundled with the Merkle root.
1387
+ *
1388
+ * Uses `privacy_getMerkleProofByCommitment` which resolves root and proof
1389
+ * under the **same block hash**, guaranteeing that the returned path is
1390
+ * consistent with the returned root.
1102
1391
  */
1103
1392
  getMerkleProofByCommitment(commitmentHex: string): Promise<PrivacyMerkleProof>;
1104
1393
  /** Returns the spend status of a nullifier. */
@@ -1154,6 +1443,43 @@ declare class ZkVerifierModule {
1154
1443
  getCircuitVersionInfo(circuitId: number): Promise<ZkVerifierCircuitVersionInfo | null>;
1155
1444
  }
1156
1445
 
1446
+ /**
1447
+ * Status info for a registered relayer account.
1448
+ */
1449
+ interface RelayerInfo {
1450
+ /** Whether the account is a registered relayer. */
1451
+ isRelayer: boolean;
1452
+ /** The registered EVM address (0x-prefixed), or null if not registered. */
1453
+ evmAddress: string | null;
1454
+ }
1455
+ /**
1456
+ * Typed client for `relayer_*` JSON-RPC endpoints.
1457
+ *
1458
+ * Exposes read-only queries for relayer registry and pending fee data.
1459
+ */
1460
+ declare class RelayerStatusModule {
1461
+ private readonly substrate;
1462
+ constructor(substrate: SubstrateClient);
1463
+ /**
1464
+ * Returns true if the given SS58 address is a registered relayer.
1465
+ */
1466
+ isRelayer(ss58Address: string): Promise<boolean>;
1467
+ /**
1468
+ * Returns the pending fees (in planck) for the given account and asset.
1469
+ * The node returns the value as a decimal string to avoid u128 overflow.
1470
+ */
1471
+ pendingFees(ss58Address: string, assetId: number): Promise<bigint>;
1472
+ /**
1473
+ * Returns the registered EVM address (0x-prefixed) for the given account,
1474
+ * or null if the account is not a registered relayer.
1475
+ */
1476
+ registeredEvmAddress(ss58Address: string): Promise<string | null>;
1477
+ /**
1478
+ * Convenience method: returns relayer registry info for an account.
1479
+ */
1480
+ getRelayerInfo(ss58Address: string): Promise<RelayerInfo>;
1481
+ }
1482
+
1157
1483
  /** EVM transaction request passed to an `EvmSigner` callback. */
1158
1484
  type EvmTxRequest = {
1159
1485
  to: string;
@@ -1176,27 +1502,6 @@ interface KnownPrecompileInfo {
1176
1502
  functions: Record<string, string>;
1177
1503
  }
1178
1504
 
1179
- /**
1180
- * Converts a Uint8Array or number[] to a 0x-prefixed lowercase hex string.
1181
- */
1182
- declare function toHex(bytes: Uint8Array | number[]): string;
1183
- /**
1184
- * Decodes a hex string (with or without 0x prefix) to Uint8Array.
1185
- */
1186
- declare function fromHex(hex: string): Uint8Array;
1187
- /**
1188
- * Ensures a hex string has the 0x prefix.
1189
- */
1190
- declare function ensureHexPrefix(hex: string): string;
1191
- /**
1192
- * Converts a 0x-prefixed hex string (as returned by JSON-RPC) to a number.
1193
- */
1194
- declare function hexToNumber(hex: string): number;
1195
- /**
1196
- * Converts a 0x-prefixed hex string (as returned by JSON-RPC) to a bigint.
1197
- */
1198
- declare function hexToBigint(hex: string): bigint;
1199
-
1200
1505
  /**
1201
1506
  * Bindings for the `ShieldedPoolPrecompile` at address `0x...0801`.
1202
1507
  *
@@ -1218,22 +1523,27 @@ declare class ShieldedPoolPrecompile {
1218
1523
  private readonly addr;
1219
1524
  constructor(evm: EvmClient);
1220
1525
  /**
1221
- * Returns the ABI-encoded calldata for `shield(uint32, uint256, bytes32, bytes)`.
1222
- * Useful when you need to inspect or batch the calldata before sending.
1526
+ * Returns the ABI-encoded calldata for `shield(uint32, bytes32, bytes)`.
1527
+ * The token amount must be sent as `msg.value` (the `value` field of the EVM
1528
+ * transaction) — this is what MetaMask and other wallets display to the user.
1223
1529
  */
1224
1530
  buildShieldCalldata(params: ShieldParams): string;
1225
1531
  /**
1226
- * Deposits tokens into the shielded pool from an EVM transaction.
1532
+ * Deposits tokens into the shielded pool from a payable EVM transaction.
1227
1533
  *
1228
- * The EVM caller's address is deterministically mapped to a Substrate
1229
- * AccountId32 (`H160 ++ [0x00; 12]`). The pool deducts from that account.
1534
+ * The token amount is sent as `msg.value` so EVM wallets (MetaMask, etc.) display
1535
+ * the correct amount on the confirmation screen. The precompile dispatches
1536
+ * `shieldedPool.shield` with its own address as origin, so the funds flow:
1537
+ * caller → precompile (via msg.value, handled by EVM)
1538
+ * precompile → pool (via pallet transfer)
1539
+ * This avoids double-deduction while keeping the displayed amount accurate.
1230
1540
  *
1231
1541
  * Extrinsic: `shieldedPool.shield(assetId, amount, commitment, encryptedMemo)`
1232
1542
  */
1233
1543
  shield(params: ShieldParams, signer: EvmSigner): Promise<string>;
1234
1544
  /**
1235
1545
  * Returns the ABI-encoded calldata for
1236
- * `privateTransfer(bytes, bytes32, bytes32[], bytes32[], bytes[])`.
1546
+ * `privateTransfer(bytes, bytes32, bytes32[], bytes32[], bytes[], uint32, uint256)`.
1237
1547
  */
1238
1548
  buildPrivateTransferCalldata(params: PrivateTransferParams): string;
1239
1549
  /**
@@ -1274,6 +1584,43 @@ declare class ShieldedPoolPrecompile {
1274
1584
  * Estimates the EVM gas for an `unshield` call.
1275
1585
  */
1276
1586
  estimateUnshieldGas(params: UnshieldParams, from: string): Promise<bigint>;
1587
+ /**
1588
+ * Returns the ABI-encoded calldata for
1589
+ * `claimShieldedFees(bytes32,uint256,uint32,bytes,bytes,bytes)`.
1590
+ *
1591
+ * ABI layout (params after selector):
1592
+ * - `commitment` — bytes32 (fixed)
1593
+ * - `amount` — uint256 (fixed)
1594
+ * - `asset_id` — uint32 (fixed, right-aligned)
1595
+ * - `memo` — bytes (dynamic)
1596
+ * - `proof` — bytes (dynamic, 128 bytes Groth16)
1597
+ * - `publicSignals` — bytes (dynamic, 76 bytes)
1598
+ *
1599
+ * The validator identity is derived from `msg.sender` in the precompile —
1600
+ * do NOT include it in the calldata.
1601
+ */
1602
+ buildClaimShieldedFeesCalldata(params: ClaimShieldedFeesParams): string;
1603
+ /**
1604
+ * Claims accumulated relay fees as a private shielded note.
1605
+ *
1606
+ * This extrinsic is for **validators/relayers** who have accrued fees in
1607
+ * `pallet-relayer` and want to receive them privately inside the shielded pool
1608
+ * instead of as a public balance credit.
1609
+ *
1610
+ * The ZK `value_proof` binds `commitment` to `(amount, assetId, ownerPk, blinding)`
1611
+ * so the runtime can verify the note encodes exactly the claimed fee amount,
1612
+ * preventing a malicious relayer from inflating the withdrawal.
1613
+ *
1614
+ * The `msg.sender` EVM address is used as the validator identity; it must match
1615
+ * the address that has pending relay fees in `pallet-relayer`.
1616
+ *
1617
+ * Extrinsic: `shieldedPool.claim_shielded_fees(commitment, amount, assetId, memo, proof, publicSignals)`
1618
+ */
1619
+ claimShieldedFees(params: ClaimShieldedFeesParams, signer: EvmSigner): Promise<string>;
1620
+ /**
1621
+ * Estimates the EVM gas for a `claimShieldedFees` call.
1622
+ */
1623
+ estimateClaimShieldedFeesGas(params: ClaimShieldedFeesParams, from: string): Promise<bigint>;
1277
1624
  }
1278
1625
 
1279
1626
  /**
@@ -1527,65 +1874,85 @@ declare class CryptoPrecompiles {
1527
1874
  * ```
1528
1875
  */
1529
1876
  declare class OrbinumClient {
1530
- /** Raw access to the Substrate WebSocket connection and RPC. */
1877
+ /** Raw Substrate WebSocket connection use for custom RPC calls or low-level access. */
1531
1878
  readonly substrate: SubstrateClient;
1532
- /** Raw access to the EVM HTTP JSON-RPC endpoint (if configured). */
1879
+ /** Raw EVM HTTP JSON-RPC client. `null` when `evmRpc` is not configured. */
1533
1880
  readonly evm: EvmClient | null;
1534
1881
  /**
1535
- * High-level EVM block and transaction explorer (if `evmRpc` is configured).
1882
+ * High-level EVM block and transaction explorer.
1536
1883
  * Provides enriched queries for blocks, transactions, addresses, and token transfers.
1884
+ * `null` when `evmRpc` is not configured.
1537
1885
  */
1538
1886
  readonly evmExplorer: EvmExplorer | null;
1539
1887
  /**
1540
- * HTTP client for the Orbinum indexer REST API (if `indexerUrl` is configured).
1888
+ * HTTP client for the Orbinum indexer REST API.
1541
1889
  * Provides paginated access to indexed blocks, extrinsics, shielded events, and nullifiers.
1890
+ * `null` when `indexerUrl` is not configured.
1542
1891
  */
1543
1892
  readonly indexer: IndexerClient | null;
1544
- /** Shielded-pool operations: shield, unshield, privateTransfer, and merkle queries. */
1893
+ /** Shielded-pool extrinsics and Merkle tree queries (`shield`, `unshield`, `privateTransfer`, …). */
1545
1894
  readonly shieldedPool: ShieldedPoolModule;
1546
- /** Account mapping: aliases, chain links, metadata, marketplace, and identity extrinsics. */
1895
+ /** Account-mapping extrinsics: aliases, chain links, metadata, marketplace, and identity. */
1547
1896
  readonly accountMapping: AccountMappingModule;
1548
- /** Typed access to Orbinum `privacy_*` RPC endpoints. */
1897
+ /** Typed access to `privacy_*` custom RPC endpoints. */
1549
1898
  readonly privacy: PrivacyModule;
1550
- /** Typed access to zkVerifier_* RPC endpoints. */
1899
+ /** Typed access to `zkVerifier_*` custom RPC endpoints. */
1551
1900
  readonly zkVerifier: ZkVerifierModule;
1901
+ /** Typed access to `relayer_*` RPC endpoints (registry lookup and pending fee queries). */
1902
+ readonly relayerStatus: RelayerStatusModule;
1552
1903
  /**
1553
- * EVM precompiles: shielded pool + account mapping callable from an EVM wallet.
1554
- * Only available when `evmRpc` is configured. Methods throw if `evm` is null.
1904
+ * Precompile modules for interacting with Orbinum contracts from an EVM wallet.
1905
+ * `null` when `evmRpc` is not configured. Methods on each sub-module throw if `evm` is `null`.
1555
1906
  */
1556
1907
  readonly precompiles: {
1557
- /** `ShieldedPoolPrecompile` (0x0801): shield/unshield/transfer via EVM wallet. */
1908
+ /** `ShieldedPoolPrecompile` at `0x0801`: shield / unshield / transfer via EVM wallet. */
1558
1909
  shieldedPool: ShieldedPoolPrecompile;
1559
- /** `AccountMappingPrecompile` (0x0800): identity management via EVM wallet. */
1910
+ /** `AccountMappingPrecompile` at `0x0800`: identity management via EVM wallet. */
1560
1911
  accountMapping: AccountMappingPrecompile;
1561
- /** Cryptographic precompiles: ECRecover, Keccak-256, Curve25519. */
1912
+ /** Built-in cryptographic precompiles: ECRecover, Keccak-256, Curve25519. */
1562
1913
  crypto: CryptoPrecompiles;
1563
1914
  } | null;
1915
+ /** @internal Use `OrbinumClient.connect()` to obtain an instance. */
1564
1916
  private constructor();
1565
1917
  /**
1566
- * Connects to an Orbinum node and returns a ready-to-use `OrbinumClient`.
1567
- * Throws if the Substrate node is unreachable within `connectTimeoutMs`.
1918
+ * Creates and connects an `OrbinumClient` from the given configuration.
1919
+ *
1920
+ * Establishes the Substrate WebSocket connection and, if configured, instantiates
1921
+ * the EVM and indexer clients. Throws if the node is unreachable within `connectTimeoutMs`.
1568
1922
  */
1569
1923
  static connect(config: OrbinumClientConfig): Promise<OrbinumClient>;
1570
- /** Closes the WebSocket connection to the Substrate node. */
1924
+ /** Closes the underlying Substrate WebSocket connection and releases all resources. */
1571
1925
  destroy(): void;
1572
1926
  }
1573
1927
 
1928
+ /** Lifecycle state of the provider's underlying `OrbinumClient` connection. */
1574
1929
  type ConnectionStatus = 'idle' | 'connecting' | 'connected' | 'disconnected' | 'reconnecting';
1930
+ /** Payload emitted to every `StatusListener` on each status transition. */
1575
1931
  type StatusChangeEvent = {
1932
+ /** The new connection status. */
1576
1933
  status: ConnectionStatus;
1934
+ /** Human-readable error description. Only present on `'disconnected'` transitions. */
1577
1935
  error?: string;
1578
1936
  };
1937
+ /** Callback invoked whenever the provider's `ConnectionStatus` changes. */
1579
1938
  type StatusListener = (event: StatusChangeEvent) => void;
1939
+ /** Configuration for `OrbinumClientProvider`. Extends `OrbinumClientConfig` with reconnection and heartbeat tuning. */
1580
1940
  interface ClientProviderConfig {
1941
+ /** WebSocket URL of the Orbinum Substrate node (e.g. `"ws://localhost:9944"`). */
1581
1942
  substrateWs: string;
1943
+ /** HTTP URL of the EVM JSON-RPC endpoint (e.g. `"http://localhost:9933"`). Omit to disable EVM support. */
1582
1944
  evmRpc?: string;
1583
- /** Base URL of the Orbinum indexer REST API (e.g. "https://indexer.orbinum.io") */
1945
+ /** Base URL of the Orbinum indexer REST API (e.g. `"https://indexer.orbinum.io"`). Omit to disable indexer support. */
1584
1946
  indexerUrl?: string;
1947
+ /** Timeout for the initial WebSocket handshake in milliseconds. Default: `8_000`. */
1585
1948
  connectTimeoutMs?: number;
1949
+ /** Interval between heartbeat probes in milliseconds. Default: `5_000`. */
1586
1950
  heartbeatIntervalMs?: number;
1951
+ /** Maximum time to wait for a heartbeat response before treating the node as unreachable. Default: `4_000`. */
1587
1952
  heartbeatTimeoutMs?: number;
1953
+ /** Initial reconnect delay in milliseconds (doubles on each failure). Default: `3_000`. */
1588
1954
  reconnectBaseMs?: number;
1955
+ /** Maximum reconnect delay cap in milliseconds. Default: `30_000`. */
1589
1956
  reconnectMaxMs?: number;
1590
1957
  }
1591
1958
  /**
@@ -1621,24 +1988,78 @@ declare class OrbinumClientProvider {
1621
1988
  private _reconnectTimer;
1622
1989
  private _reconnectAttempt;
1623
1990
  private _listeners;
1991
+ /** Creates a new provider with the given configuration. Does not connect automatically — call `connect()` to initiate. */
1624
1992
  constructor(config: ClientProviderConfig);
1993
+ /** Current connection status. Reflects the last state set by the provider internals. */
1625
1994
  get status(): ConnectionStatus;
1995
+ /** Updates internal status and notifies all registered listeners. Swallows listener exceptions to avoid cascading failures. */
1626
1996
  private setStatus;
1997
+ /**
1998
+ * Registers a listener that is called on every status transition.
1999
+ * Returns an unsubscribe function — call it to stop receiving events.
2000
+ */
1627
2001
  onStatusChange(listener: StatusListener): () => void;
2002
+ /**
2003
+ * Initiates the first connection attempt. No-op if the provider is not in `'idle'` state.
2004
+ * Call this once after constructing the provider.
2005
+ */
1628
2006
  connect(): void;
2007
+ /**
2008
+ * Tears down the active client and any pending reconnect timers,
2009
+ * then resets the provider back to `'idle'` so `connect()` can be called again.
2010
+ */
1629
2011
  reset(): void;
2012
+ /** Transitions to `'connecting'`, kicks off `attemptConnect`, and schedules a reconnect if it fails. */
1630
2013
  private startConnectAttempt;
2014
+ /**
2015
+ * Performs a single connection attempt race against `connectTimeoutMs`.
2016
+ * On success: stores the client, starts the heartbeat, and returns it.
2017
+ * On failure: destroys any orphaned client and transitions to `'disconnected'`.
2018
+ */
1631
2019
  private attemptConnect;
2020
+ /** Starts the periodic heartbeat loop. Replaces any existing timer. */
1632
2021
  private startHeartbeat;
2022
+ /** Clears the heartbeat interval timer if active. */
1633
2023
  private stopHeartbeat;
2024
+ /**
2025
+ * Sends a `system_health` RPC ping and waits up to `heartbeatTimeoutMs`.
2026
+ * Returns `true` if the node responds in time, `false` otherwise.
2027
+ */
1634
2028
  private probe;
2029
+ /**
2030
+ * Schedules the next connection attempt using exponential backoff
2031
+ * (capped at `reconnectMaxMs`), then transitions to `'reconnecting'`.
2032
+ */
1635
2033
  private scheduleReconnect;
2034
+ /** Clears any pending reconnect timer without triggering a new attempt. */
1636
2035
  private cancelReconnect;
2036
+ /** Stops the heartbeat, destroys the active client, and clears all in-progress promises. */
1637
2037
  private teardownClient;
2038
+ /**
2039
+ * Returns the active `OrbinumClient`, or awaits the in-progress connection attempt.
2040
+ * Throws if the provider is `'idle'`, `'disconnected'`, or `'reconnecting'`.
2041
+ */
1638
2042
  getOrbinumClient(): Promise<OrbinumClient>;
2043
+ /**
2044
+ * Same as `getOrbinumClient()` but returns `null` instead of throwing.
2045
+ * Useful in contexts where a missing client is an acceptable no-op.
2046
+ */
1639
2047
  tryGetOrbinumClient(): Promise<OrbinumClient | null>;
2048
+ /**
2049
+ * Sends a single Substrate JSON-RPC request and returns the typed result.
2050
+ * Waits for the client to be ready before dispatching.
2051
+ */
1640
2052
  rpcSend<T>(method: string, params?: unknown[]): Promise<T>;
2053
+ /**
2054
+ * Sends a single EVM JSON-RPC request and returns the typed result.
2055
+ * Throws if `evmRpc` was not configured.
2056
+ */
1641
2057
  evmRpc<T>(method: string, params?: unknown[]): Promise<T>;
2058
+ /**
2059
+ * Sends multiple EVM JSON-RPC calls as a single batch request.
2060
+ * Returns a tuple of typed results in the same order as `calls`.
2061
+ * Throws if `evmRpc` was not configured.
2062
+ */
1642
2063
  evmRpcBatch<T extends unknown[]>(calls: Array<{
1643
2064
  method: string;
1644
2065
  params?: unknown[];
@@ -1655,31 +2076,44 @@ declare class OrbinumClientProvider {
1655
2076
  * nullifier = Poseidon(commitment, spendingKey)
1656
2077
  *
1657
2078
  * Memo scheme (EncryptedMemo — native TypeScript, no WASM):
1658
- * ChaCha20-Poly1305 with key = SHA256(recipientVk || commitment || domain)
1659
- * Result: nonce(12) || ciphertext(76 + 16 MAC) = 104 bytes
2079
+ * ChaCha20-Poly1305 with ECDH ephemeral key SHA256(sharedSecret || commitment || domain)
2080
+ * Result: nonce(12) || ciphertext(108 + 16 MAC) || ephPk(32) = 168 bytes
2081
+ *
2082
+ * Stealth scheme (when viewingPublicKey + recipientOwnerPk are both provided):
2083
+ * ephSk is generated once and shared between the ECDH memo and the stealth Pk derivation.
2084
+ * The commitment uses stealthOwnerPk instead of the recipient's global ownerPk, making
2085
+ * each transfer unlinkable even when the same privacy address is reused.
2086
+ * stealthOwnerPk = stealthScalar × Base8 + ownerPkPoint
2087
+ * stealthScalar = HKDF(sharedSecret, salt=ownerPk_LE, info="orbinum-stealth-v1") % suborder
1660
2088
  */
1661
2089
  declare class NoteBuilder {
1662
2090
  /**
1663
2091
  * Build a ZkNote from the given inputs.
1664
2092
  *
1665
- * @param input.value Amount in planck (required).
1666
- * @param input.assetId Asset ID — default 0n (native ORB-Privacy).
1667
- * @param input.ownerPk BabyJubJub Ax — default 0n.
1668
- * @param input.blinding Random scalar — defaults to BigInt(Date.now()).
1669
- * @param input.spendingKey Secret key for nullifier — default 0n.
2093
+ * @param input.value Amount in planck (required).
2094
+ * @param input.assetId Asset ID — default 0n (native ORB-Privacy).
2095
+ * @param input.ownerPk Sender's or recipient's global BabyJubJub Ax — default 0n.
2096
+ * @param input.blinding Random scalar — defaults to BigInt(Date.now()).
2097
+ * @param input.spendingKey Secret key for nullifier — default 0n.
2098
+ * @param input.viewingPublicKey Recipient's 32-byte LE packed BJJ ivk. Triggers memo encryption.
2099
+ * @param input.recipientOwnerPk Recipient's global ownerPk. Required with viewingPublicKey
2100
+ * to enable stealth address derivation. Without it, the
2101
+ * commitment uses ownerPk directly (no stealth).
1670
2102
  */
1671
2103
  static build(input: NoteInput): Promise<ZkNote>;
1672
2104
  /**
1673
- * Build the 104-byte encrypted memo for a note.
2105
+ * Build the 168-byte ECDH-encrypted memo for a note.
1674
2106
  *
1675
2107
  * Pure TypeScript implementation — no WASM dependency.
1676
- * Uses ChaCha20-Poly1305 with SHA-256 key derivation.
2108
+ * Uses ChaCha20-Poly1305 with ECDH key agreement (BabyJubJub ephemeral keypair).
1677
2109
  *
1678
- * @param note The ZkNote whose fields populate the plaintext.
1679
- * @param recipientVk 32-byte recipient viewing key.
1680
- * Pass `new Uint8Array(32)` (default) for a public/dummy memo.
2110
+ * @param note The ZkNote whose fields populate the plaintext.
2111
+ * @param recipientIvkPacked 32-byte LE packed BJJ viewing public key of the recipient.
2112
+ * Pass `new Uint8Array(32)` (default) for a public/dummy memo.
2113
+ * @param counterpartyPk 32-byte counterparty BabyJubJub Ax.
2114
+ * Pass `new Uint8Array(32)` (default) for no counterparty.
1681
2115
  */
1682
- static buildMemo(note: ZkNote, recipientVk?: Uint8Array): Uint8Array;
2116
+ static buildMemo(note: ZkNote, recipientIvkPacked?: Uint8Array, counterpartyPk?: Uint8Array): Uint8Array;
1683
2117
  }
1684
2118
 
1685
2119
  /**
@@ -1687,52 +2121,91 @@ declare class NoteBuilder {
1687
2121
  *
1688
2122
  * Mirrors primitives/encrypted-memo in the node repository; no WASM required.
1689
2123
  *
1690
- * Layout (104 bytes):
1691
- * nonce(12) || ciphertext(76 + 16 MAC) = 104
2124
+ * Layout (176 bytes, ECDH):
2125
+ * nonce(12) || ciphertext+MAC(132) || ephPk_packed(32) = 176
2126
+ *
2127
+ * Plaintext layout (116 bytes):
2128
+ * value_lo(8 LE) || value_hi(8 LE) || owner_pk(32) || blinding(32) || asset_id(4 LE) || counterparty_pk(32)
1692
2129
  *
1693
- * Plaintext layout (76 bytes):
1694
- * value(8 LE) || owner_pk(32) || blinding(32) || asset_id(4 LE)
2130
+ * value is stored as a 128-bit LE unsigned integer (two uint64 words), supporting
2131
+ * amounts up to ~3.4 × 10^38 planck — well above any realistic token supply.
1695
2132
  *
1696
- * Key derivation:
1697
- * key = SHA256(viewing_key || commitment || "orbinum-note-encryption-v1")
2133
+ * v2 key derivation (ECDH):
2134
+ * ephSk = random scalar in [1, BABYJUB_SUBORDER)
2135
+ * ephPk = mulPointEscalar(Base8, ephSk)
2136
+ * sharedPoint = mulPointEscalar(recipientIvk, ephSk) ← or mulPointEscalar(ephPk, ivsk)
2137
+ * sharedSecret = bigintTo32Le(sharedPoint[0]) ← Ax coordinate, 32 bytes LE
2138
+ * key = SHA256(sharedSecret || commitment || "orbinum-note-encryption-v1")
1698
2139
  *
1699
2140
  * Cipher: ChaCha20-Poly1305 (IETF, 96-bit nonce)
1700
2141
  */
1701
2142
 
2143
+ /** Memo size: nonce(12) + ciphertext+MAC(132) + ephPk(32) = 176 */
2144
+ declare const ENCRYPTED_MEMO_SIZE: number;
1702
2145
  declare const EncryptedMemo: {
1703
2146
  /**
1704
- * Build and encrypt a memo for a note.
2147
+ * Build and encrypt a memo for a note using ECDH (v2, 168 bytes).
1705
2148
  *
1706
- * @param value Note value in planck.
1707
- * @param ownerPk 32-byte owner public key (little-endian).
1708
- * @param blinding 32-byte blinding scalar (little-endian).
1709
- * @param assetId Asset identifier.
1710
- * @param commitment 32-byte commitment bytes (little-endian).
1711
- * @param recipientVk 32-byte recipient viewing key pass `new Uint8Array(32)`
1712
- * for a publicly-readable (dummy) memo.
1713
- * @returns 104-byte encrypted memo (nonce || ciphertext).
2149
+ * @param value Note value in planck.
2150
+ * @param ownerPk 32-byte owner public key (LE).
2151
+ * @param blinding 32-byte blinding scalar (LE).
2152
+ * @param assetId Asset identifier.
2153
+ * @param commitment 32-byte commitment bytes (LE).
2154
+ * @param recipientIvkPacked 32-byte LE-encoded packed BJJ viewing public key
2155
+ * (from PrivacyKeyManager.getViewingPublicKeyPacked() or
2156
+ * decoded from a privacy address).
2157
+ * Pass `new Uint8Array(32)` (all zeros) for a publicly-readable memo.
2158
+ * @param counterpartyPk 32-byte counterparty BJJ Ax. Default: all zeros.
2159
+ * @returns 168-byte encrypted memo: nonce(12) || ciphertext+MAC(124) || ephPk(32).
1714
2160
  */
1715
- encrypt(value: bigint, ownerPk: Uint8Array, blinding: Uint8Array, assetId: number, commitment: Uint8Array, recipientVk: Uint8Array): Uint8Array;
2161
+ encrypt(value: bigint, ownerPk: Uint8Array, blinding: Uint8Array, assetId: number, commitment: Uint8Array, recipientIvkPacked: Uint8Array, counterpartyPk?: Uint8Array, ephSkOverride?: Uint8Array): Uint8Array;
1716
2162
  /**
1717
- * Returns a 104-byte public memo with a zero recipient viewing key.
1718
- * The memo is still readable by anyone who holds the viewing key (zeros).
2163
+ * Returns a 168-byte public memo encrypted with a zero viewing key.
2164
+ * Decryptable by anyone with `decrypt(memo, commitment, new Uint8Array(32))`.
2165
+ * Convenience alias for `encrypt(..., new Uint8Array(32))`.
1719
2166
  */
1720
2167
  encryptPublic(value: bigint, ownerPk: Uint8Array, blinding: Uint8Array, assetId: number, commitment: Uint8Array): Uint8Array;
1721
2168
  /**
1722
- * Returns a 104-byte zeroed dummy memo (no information, always valid on-chain).
2169
+ * Returns a 168-byte zeroed dummy memo (no information, always valid on-chain).
1723
2170
  */
1724
2171
  dummy(): Uint8Array;
1725
2172
  /**
1726
- * Decrypt an on-chain EncryptedMemo.
2173
+ * Validates that `bytes` is a properly-sized encrypted memo.
2174
+ * Throws an Error if the length is not ENCRYPTED_MEMO_SIZE (168 bytes).
2175
+ *
2176
+ * Call this at system boundaries (extrinsic builders, precompile encoders)
2177
+ * to catch malformed memos before they reach the chain and fail on-chain.
2178
+ *
2179
+ * @param bytes The memo bytes to validate.
2180
+ * @param context Optional context string included in the error (e.g. 'shield', 'output[0]').
2181
+ */
2182
+ validate(bytes: Uint8Array, context?: string): void;
2183
+ /**
2184
+ * Decrypt an on-chain EncryptedMemo using the recipient's viewing secret key.
2185
+ * Returns null if decryption fails — wrong key, bad MAC, or malformed memo.
2186
+ * Never throws; safe for scan loops.
2187
+ *
2188
+ * @param memoBytes 168-byte encrypted memo.
2189
+ * @param commitment 32-byte note commitment (LE).
2190
+ * @param viewingSecretKey 32-byte HKDF viewing secret key from deriveViewingSecretKey().
2191
+ */
2192
+ decrypt(memoBytes: Uint8Array, commitment: Uint8Array, viewingSecretKey: Uint8Array): DecryptedMemo | null;
2193
+ /**
2194
+ * Extract the ECDH shared secret from an encrypted memo using the recipient's viewing secret key.
1727
2195
  *
1728
- * Returns `null` if decryption fails wrong key, bad MAC, or malformed memo.
2196
+ * Used by NoteDecryptor to obtain the shared secret needed for stealth address derivation
2197
+ * without re-running the full decrypt path. Safe to call on any 168-byte memo.
2198
+ *
2199
+ * Returns `new Uint8Array(32)` (all zeros) for public/dummy memos (zero ephPk).
2200
+ * Returns `null` if the memo is malformed or the ephPk is not a valid BJJ point.
1729
2201
  * Never throws; safe for scan loops.
1730
2202
  *
1731
- * @param memoBytes 104-byte encrypted memo.
1732
- * @param commitment 32-byte note commitment (little-endian).
1733
- * @param recipientVk 32-byte recipient viewing key.
2203
+ * @param memoBytes 168-byte encrypted memo.
2204
+ * @param viewingSecretKey 32-byte HKDF viewing secret key from deriveViewingSecretKey().
1734
2205
  */
1735
- decrypt(memoBytes: Uint8Array, commitment: Uint8Array, recipientVk: Uint8Array): DecryptedMemo | null;
2206
+ extractSharedSecret(memoBytes: Uint8Array, viewingSecretKey: Uint8Array): Uint8Array | null;
2207
+ /** @internal */
2208
+ _decrypt(memoBytes: Uint8Array, commitment: Uint8Array, viewingSecretKey: Uint8Array): DecryptedMemo | null;
1736
2209
  };
1737
2210
 
1738
2211
  /**
@@ -1751,127 +2224,399 @@ declare const EncryptedMemo: {
1751
2224
  */
1752
2225
 
1753
2226
  /**
1754
- * Attempt to decrypt an on-chain commitment using a viewing key.
2227
+ * Computes the nullifier for a note.
2228
+ * nullifier = Poseidon2(commitment, spendingKey)
2229
+ *
2230
+ * spendingKey must already be in [1, BABYJUB_SUBORDER) as returned by
2231
+ * deriveSpendingKeyFromSignature.
2232
+ */
2233
+ declare function computeNullifier(commitment: bigint, spendingKey: bigint): bigint;
2234
+ /**
2235
+ * Attempt to decrypt an on-chain commitment using the recipient's viewing secret key.
1755
2236
  *
1756
2237
  * Returns a fully populated ZkNote if the memo decrypts correctly and the
1757
2238
  * recomputed commitment matches the on-chain value.
1758
2239
  * Returns null when the note does not belong to this viewer (wrong key, no memo,
1759
2240
  * or commitment mismatch).
1760
2241
  *
1761
- * @param commitment On-chain commitment record from the indexer.
1762
- * @param viewingKey 32-byte viewing key (from deriveViewingKey).
1763
- * @param spendingKey Spending key bigint (for nullifier computation).
2242
+ * @param commitment On-chain commitment record from the indexer.
2243
+ * @param viewingSecretKey 32-byte viewing secret key (from deriveViewingSecretKey / getViewingSecretKey).
2244
+ * @param spendingKey Spending key bigint (for nullifier computation).
2245
+ * @param ownOwnerPk The viewer's global BabyJubJub Ax (ownerPk). Required for stealth detection.
2246
+ * Pass 0n to disable stealth detection (legacy/own-note-only scanning).
1764
2247
  */
1765
- declare function tryDecryptNote(commitment: ScanCommitment, viewingKey: Uint8Array, spendingKey: bigint): ZkNote | null;
2248
+ declare function tryDecryptNote(commitment: ScanCommitment, viewingSecretKey: Uint8Array, spendingKey: bigint, ownOwnerPk?: bigint): ZkNote | null;
2249
+ /**
2250
+ * Like tryDecryptNote but also returns a human-readable reason for failure.
2251
+ * Useful for debugging scan issues (wrong key, corrupted memo, commitment mismatch).
2252
+ */
2253
+ declare function tryDecryptNoteVerbose(commitment: ScanCommitment, viewingSecretKey: Uint8Array, spendingKey: bigint, ownOwnerPk?: bigint): {
2254
+ note: ZkNote | null;
2255
+ reason?: string;
2256
+ };
1766
2257
 
1767
2258
  /**
1768
- * PrivacyKeys
2259
+ * NoteDisclosure
1769
2260
  *
1770
- * Pure cryptographic derivation functions for the Orbinum shielded pool identity.
1771
- * These are protocol-level operations independent of storage, UI, or session.
2261
+ * Utilities for creating and decoding single-note disclosure keys.
2262
+ * A disclosure key is a compact, shareable string encoding the plaintext
2263
+ * preimage of one specific note commitment. Anyone with the key can verify
2264
+ * the note's value and asset — without gaining any spending capability.
1772
2265
  *
1773
- * Derivation scheme:
1774
- * viewingKey = HKDF-SHA256(ikm=spendingKey_bytes, info="orbinum-ivk-v1") → 32 bytes
1775
- * ownerPk = BabyJubJub Ax from (spendingKey * Base8) → bigint
2266
+ * Format: "orbdisc:<base64url(JSON)>"
1776
2267
  *
1777
- * Spending key derivation (from wallet signature):
1778
- * message = "orbinum-spending-key-v1\n${chainId}\n${address.toLowerCase()}"
1779
- * skBytes = HKDF-SHA256(ikm=sig_bytes, salt=empty, info="orbinum-sk-v1:${chainId}:${address}")
1780
- * spendingKey = BigInt(skBytes_as_big_endian) % BN254_R (if 0 → 1)
2268
+ * Revealed by the key:
2269
+ * - value, assetId, ownerPk (BJJ Ax — not linked to EVM address), blinding
2270
+ * - commitment (cryptographically verified via Poseidon4)
1781
2271
  *
1782
- * The viewingKey is the symmetric key used by EncryptedMemo (ChaCha20-Poly1305).
1783
- * The ownerPk (x-coordinate) is included in note commitments.
2272
+ * NOT revealed by the key:
2273
+ * - spendingKey, nullifier, viewingSecretKey
2274
+ * - any other note belonging to the same user
2275
+ *
2276
+ * Security: the commitment verification in decodeNoteDisclosureKey is a
2277
+ * cryptographic proof-of-knowledge of the preimage. A forged key (mismatched
2278
+ * preimage) will fail verification and return null.
1784
2279
  */
2280
+
1785
2281
  /**
1786
- * Returns the message string the user must sign with their wallet to derive
1787
- * a deterministic Orbinum spending key.
2282
+ * Decoded and cryptographically verified contents of a note disclosure key.
2283
+ *
2284
+ * The `commitment` field is guaranteed to equal Poseidon4(value, assetId, ownerPk, blinding)
2285
+ * — this is verified by decodeNoteDisclosureKey before returning.
1788
2286
  */
1789
- declare function deriveSpendingKeyMessage(chainId: number, address: string): string;
2287
+ interface NoteDisclosure {
2288
+ /** Poseidon4(value, assetId, ownerPk, blinding) — matches the on-chain commitment. */
2289
+ commitment: bigint;
2290
+ /** Note value in the smallest unit (e.g. attoORB). */
2291
+ value: bigint;
2292
+ /** Asset ID as registered in the shielded pool. */
2293
+ assetId: bigint;
2294
+ /** BabyJubJub Ax coordinate of the note owner (not directly linkable to an EVM address). */
2295
+ ownerPk: bigint;
2296
+ /** Random blinding scalar chosen at note creation. */
2297
+ blinding: bigint;
2298
+ }
1790
2299
  /**
1791
- * Derives an Orbinum spending key from a wallet signature.
2300
+ * Encodes a single ZkNote's plaintext preimage into a shareable disclosure key.
1792
2301
  *
1793
- * Uses HKDF-SHA256(ikm=sigBytes, salt=empty, info="orbinum-sk-v1:{chainId}:{address}")
1794
- * and reduces the resulting 32-byte value modulo BN254_R.
2302
+ * The key does NOT include the spendingKey or nullifier. It is safe to share
2303
+ * with any party that should be able to verify the note's value and asset
2304
+ * without being able to spend it.
1795
2305
  *
1796
- * @param signatureHex 0x-prefixed or bare hex of the wallet signature.
1797
- * @param chainId Chain ID used when building the signing message.
1798
- * @param address Signer address (EVM or SS58) used in the signing message.
1799
- * @returns bigint in [1, BN254_R)
2306
+ * @param note A fully populated ZkNote (as returned by the vault / rescan).
2307
+ * @returns A "orbdisc:…" string suitable for copy-paste or QR encoding.
1800
2308
  */
1801
- declare function deriveSpendingKeyFromSignature(signatureHex: string, chainId: number, address: string): Promise<bigint>;
2309
+ declare function createNoteDisclosureKey(note: ZkNote): string;
2310
+ /**
2311
+ * Decodes and cryptographically verifies a note disclosure key.
2312
+ *
2313
+ * Verification: recomputes Poseidon4(value, assetId, ownerPk, blinding) and
2314
+ * asserts it equals the embedded commitment. This ensures the preimage is
2315
+ * consistent and cannot be tampered with.
2316
+ *
2317
+ * @param key A "orbdisc:…" string produced by createNoteDisclosureKey.
2318
+ * @returns The verified NoteDisclosure, or null if the key is malformed,
2319
+ * has an unknown version, or fails Poseidon4 verification.
2320
+ */
2321
+ declare function decodeNoteDisclosureKey(key: string): NoteDisclosure | null;
2322
+
2323
+ /** A single input note for a private transfer. */
2324
+ interface TransferInputNote {
2325
+ nullifier: bigint;
2326
+ /** Note value (planck). */
2327
+ value: bigint;
2328
+ assetId: bigint;
2329
+ ownerPk: bigint;
2330
+ blinding: bigint;
2331
+ spendingKey: bigint;
2332
+ /** Sibling hashes (0x-prefixed, 32-byte LE). */
2333
+ pathSiblings: string[];
2334
+ leafIndex: number;
2335
+ }
2336
+ /** A single output note for a private transfer. */
2337
+ interface TransferOutputNote {
2338
+ /** Commitment as bigint. */
2339
+ commitment: bigint;
2340
+ value: bigint;
2341
+ assetId: bigint;
2342
+ ownerPk: bigint;
2343
+ blinding: bigint;
2344
+ }
1802
2345
  /**
1803
- * Derive a 32-byte viewing key from a spending key.
1804
- * viewingKey = HKDF-SHA256(ikm=spendingKey_bytes, info="orbinum-ivk-v1")
2346
+ * Inputs required to generate a PrivateTransfer proof.
2347
+ * Supports exactly 2 inputs and 2 recipient outputs (circuit constraint).
2348
+ * The fee is paid to the block author (validator) by the pallet runtime.
1805
2349
  */
1806
- declare function deriveViewingKey(spendingKey: bigint): Uint8Array;
2350
+ interface PrivateTransferProofInputs {
2351
+ merkleRoot: string;
2352
+ inputs: [TransferInputNote, TransferInputNote];
2353
+ outputs: [TransferOutputNote, TransferOutputNote];
2354
+ /** Gasless fee in planck (default 0n). Must satisfy: input_sum == output_sum + fee */
2355
+ fee?: bigint;
2356
+ }
1807
2357
  /**
1808
- * Derive the BabyJubJub Ax (x-coordinate of the public key) from a spending key.
1809
- * ownerPk = (spendingKey * BabyJubJub.Base8)[0]
1810
- *
1811
- * Returns 0n if BabyJubJub computation fails (e.g. invalid scalar).
2358
+ * Generate a Groth16 proof for a PrivateTransfer operation.
1812
2359
  */
1813
- declare function deriveOwnerPk(spendingKey: bigint): bigint;
2360
+ declare function generateTransferProof(params: PrivateTransferProofInputs, options?: {
2361
+ provider?: ArtifactProvider;
2362
+ verbose?: boolean;
2363
+ }): Promise<ProofResult>;
1814
2364
 
1815
2365
  /**
1816
- * PrivacyKeyManager
2366
+ * Selects up to 2 unspent notes that together cover `needed` planck.
1817
2367
  *
1818
- * In-memory manager for the user's Orbinum shielded-pool identity.
1819
- * Protocol-level module no UI, no localStorage, no sessionStorage dependencies.
2368
+ * Priority:
2369
+ * 1. A single note whose value >= needed → [note, null] (second input will be a dummy)
2370
+ * 2. The smallest pair whose sum >= needed → [noteA, noteB]
2371
+ * 3. No combination covers needed → null (consolidation via merge required)
1820
2372
  *
1821
- * Create one instance per user session:
1822
- * const pkm = new PrivacyKeyManager();
1823
- * await pkm.load(spendingKey);
2373
+ * Only unspent notes with value > 0 are considered.
2374
+ */
2375
+ declare function selectNotes(notes: ZkNote[], needed: bigint): [ZkNote, ZkNote | null] | null;
2376
+ /**
2377
+ * Builds a dummy `TransferInputNote` for use as the second input in a single-note transfer.
1824
2378
  *
1825
- * The caller (application layer) is responsible for key persistence and session
1826
- * caching. Each instance holds independent state safe for multi-wallet use.
2379
+ * The modified transfer circuit exempts inputs with `value == 0` from Merkle membership,
2380
+ * nullifier derivation, and EdDSA signature checks (Constraints 1–3 are conditional on
2381
+ * `is_dummy[i].out == 0`). Constraint 9 forces the public nullifier to 0 for dummy inputs.
2382
+ *
2383
+ * Security: `IsZero` is a deterministic R1CS gadget — a prover cannot make it return 1
2384
+ * for a non-zero `input_values[i]` without breaking the constraint system.
1827
2385
  *
1828
- * Derivation scheme:
1829
- * spendingKey (bigint, BN254 scalar)
1830
- * └── viewingKey = HKDF-SHA256(spendingKey_bytes, info="orbinum-ivk-v1") → 32 bytes
1831
- * └── ownerPk = BabyJubJub Ax from (spendingKey * Base8) → bigint
2386
+ * @param assetId - Must equal the real input note's assetId (circuit Constraint 7).
1832
2387
  */
1833
- declare class PrivacyKeyManager {
1834
- private _state;
2388
+ declare function buildDummyTransferInput(assetId: bigint): TransferInputNote;
2389
+
2390
+ /**
2391
+ * BN254 (alt_bn128) scalar field prime.
2392
+ *
2393
+ * Used as the modulus for Poseidon blinding factors: blinding ∈ [1, BN254_R).
2394
+ * A random 32-byte value reduced mod BN254_R gives a uniform blinding factor.
2395
+ */
2396
+ declare const BN254_R = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
2397
+ /**
2398
+ * Baby JubJub prime subgroup order.
2399
+ *
2400
+ * Spending keys (circuit scalars) MUST be in [1, BABYJUB_SUBORDER).
2401
+ * circomlib's BabyPbk uses Num2Bits(253) which asserts sk < 2^253.
2402
+ * BABYJUB_SUBORDER < 2^252 < 2^253 satisfies both the curve arithmetic
2403
+ * requirement and the circuit constraint.
2404
+ */
2405
+ declare const BABYJUB_SUBORDER = 2736030358979909402780800718157159386076813972158567259200215660948447373041n;
2406
+
2407
+ /**
2408
+ * Generate a cryptographically random Poseidon blinding factor.
2409
+ *
2410
+ * Produces a uniform random value in [1, BN254_R) by reading 32 random bytes
2411
+ * and reducing mod BN254_R. The zero case is mapped to 1 to guarantee the
2412
+ * blinding factor is never zero.
2413
+ */
2414
+ declare function randomBlinding(): bigint;
2415
+
2416
+ /**
2417
+ * PrivacyKeys
2418
+ *
2419
+ * Pure cryptographic derivation functions for the Orbinum shielded pool identity.
2420
+ * These are protocol-level operations — independent of storage, UI, or session.
2421
+ *
2422
+ * Derivation scheme (ECDH viewing key — v2):
2423
+ * viewingSecretKey (ivsk) = HKDF-SHA256(ikm=spendingKey_bytes, info="orbinum-ivk-v1") → 32 bytes
2424
+ * ivsk_scalar = BigInt(ivsk_BE) % BABYJUB_SUBORDER (clamped to [1, ∞))
2425
+ * viewingPublicKey (ivk) = BJJ_mul(Base8, ivsk_scalar) → packPoint([Ax, Ay]) → 32-byte bigint stored LE
2426
+ * ownerPk = BabyJubJub Ax from (spendingKey * Base8) → bigint
2427
+ *
2428
+ * Spending key derivation (from wallet signature):
2429
+ * message = "orbinum-spending-key-v1\n${chainId}\n${address.toLowerCase()}"
2430
+ * skBytes = HKDF-SHA256(ikm=sig_bytes, salt=empty, info="orbinum-sk-v1:${chainId}:${address}")
2431
+ * spendingKey = BigInt(skBytes_as_big_endian) % BABYJUB_SUBORDER (if 0 → 1)
2432
+ *
2433
+ * IMPORTANT: must reduce mod BABYJUB_SUBORDER (not BN254_R). circomlib's BabyPbk uses
2434
+ * Num2Bits(253) which asserts spending_key < 2^253. BABYJUB_SUBORDER < 2^252 satisfies
2435
+ * this. BN254_R ≈ 2^254.8 does not — ~34% of values would exceed 2^253 at runtime.
2436
+ */
2437
+ /**
2438
+ * Returns the message string the user must sign with their wallet to derive
2439
+ * a deterministic Orbinum spending key.
2440
+ */
2441
+ declare function deriveSpendingKeyMessage(chainId: number, address: string): string;
2442
+ /**
2443
+ * Derives the 32-byte master key bytes from a wallet signature.
2444
+ *
2445
+ * masterBytes = HKDF-SHA256(ikm=sigBytes, salt=empty, info="orbinum-sk-v1:{chainId}:{address}")
2446
+ *
2447
+ * These bytes are the stable root for ALL derived keys:
2448
+ * - spendingKey (circuit scalar) = BigInt(masterBytes) % BABYJUB_SUBORDER
2449
+ * - viewingSecretKey = HKDF(bigintTo32Le(spendingKey), info="orbinum-ivk-v1")
2450
+ * - vaultKey = HKDF(masterBytes, info="orbinum-vault-key-v1")
2451
+ *
2452
+ * Separating masterBytes from the circuit scalar means the viewingSecretKey and
2453
+ * vault key are STABLE across any future change to the modulus — they never
2454
+ * depend on which prime field the circuit uses.
2455
+ */
2456
+ declare function deriveMasterKeyBytes(signatureHex: string, chainId: number, address: string): Promise<Uint8Array>;
2457
+ /**
2458
+ * Derives an Orbinum spending key from a wallet signature.
2459
+ *
2460
+ * Uses HKDF-SHA256(ikm=sigBytes, salt=empty, info="orbinum-sk-v1:{chainId}:{address}")
2461
+ * and reduces the resulting 32-byte value modulo BABYJUB_SUBORDER.
2462
+ *
2463
+ * IMPORTANT: viewingSecretKey and vaultKey must be derived from masterBytes (via
2464
+ * deriveMasterKeyBytes), NOT from this spending key scalar. This ensures those
2465
+ * keys remain stable if the circuit's modulus ever changes again.
2466
+ *
2467
+ * @param signatureHex 0x-prefixed or bare hex of the wallet signature.
2468
+ * @param chainId Chain ID used when building the signing message.
2469
+ * @param address Signer address (EVM or SS58) used in the signing message.
2470
+ * @returns bigint in [1, BABYJUB_SUBORDER)
2471
+ */
2472
+ declare function deriveSpendingKeyFromSignature(signatureHex: string, chainId: number, address: string): Promise<bigint>;
2473
+ /**
2474
+ * Derive a 32-byte viewing secret key (ivsk) from the spending key.
2475
+ * ivsk = HKDF-SHA256(ikm=bigintTo32Le(spendingKey), info="orbinum-ivk-v1")
2476
+ *
2477
+ * The ivsk is intentionally derived from the already-reduced spending key scalar
2478
+ * (not from masterBytes) so that it stays bound to the specific key identity
2479
+ * loaded in this session. The spendingKey must already be in [1, BABYJUB_SUBORDER).
2480
+ *
2481
+ * SECURITY: This is a symmetric secret — never embed it in a shareable address.
2482
+ * Use deriveViewingPublicKey() to obtain the public component for sharing.
2483
+ */
2484
+ declare function deriveViewingSecretKey(spendingKey: bigint): Uint8Array;
2485
+ /**
2486
+ * Derive the packed BabyJubJub viewing public key (ivk) from ivsk bytes.
2487
+ *
2488
+ * ivsk_scalar = BigInt(ivsk_bytes_BE) % BABYJUB_SUBORDER (clamped to [1, ∞))
2489
+ * ivk_point = mulPointEscalar(Base8, ivsk_scalar) → [Ax, Ay]
2490
+ * result = bigintTo32Le(packPoint([Ax, Ay])) → 32-byte Uint8Array (LE)
2491
+ *
2492
+ * The packed bigint is stored in little-endian so it is consistent with the
2493
+ * rest of the SDK's 32-byte scalar encoding (bigintTo32Le / bytesToBigintLE).
2494
+ *
2495
+ * @param ivsk 32-byte HKDF output from deriveViewingSecretKey().
2496
+ * @returns 32-byte LE-encoded packed BJJ point (goes in the privacy address).
2497
+ */
2498
+ declare function deriveViewingPublicKey(ivsk: Uint8Array): Uint8Array;
2499
+ /**
2500
+ * Derive the BabyJubJub Ax (x-coordinate of the public key) from a spending key.
2501
+ * ownerPk = (spendingKey * BabyJubJub.Base8)[0]
2502
+ *
2503
+ * Returns 0n if BabyJubJub computation fails (e.g. invalid scalar).
2504
+ */
2505
+ declare function deriveOwnerPk(spendingKey: bigint): bigint;
2506
+
2507
+ /**
2508
+ * PrivacyKeyManager
2509
+ *
2510
+ * In-memory manager for the user's Orbinum shielded-pool identity.
2511
+ * Protocol-level module — no UI, no localStorage, no sessionStorage dependencies.
2512
+ *
2513
+ * Create one instance per user session:
2514
+ * const pkm = new PrivacyKeyManager();
2515
+ * await pkm.load(spendingKey, masterBytes);
2516
+ *
2517
+ * The caller (application layer) is responsible for key persistence and session
2518
+ * caching. Each instance holds independent state — safe for multi-wallet use.
2519
+ *
2520
+ * Derivation scheme (from wallet signature):
2521
+ * sig → HKDF → masterBytes (32 bytes, stable root for all derived keys)
2522
+ * ├── spendingKey = BigInt(masterBytes) % BABYJUB_SUBORDER (circuit scalar)
2523
+ * ├── viewingSecretKey = HKDF(bigintTo32Le(spendingKey), info="orbinum-ivk-v1") ← NEVER shared
2524
+ * ├── viewingPublicKey = packPoint(BJJ_mul(Base8, ivsk_scalar)) ← embedded in privacy address
2525
+ * ├── ownerPk = BabyJubJub Ax from (spendingKey × Base8)
2526
+ * └── vaultKey = HKDF(masterBytes, info="orbinum-vault-key-v1") ← stable
2527
+ *
2528
+ * Cache format: "mk:0x{masterBytes_hex}" — storing masterBytes (not the sk scalar)
2529
+ * ensures the vault key remains stable if the circuit modulus ever changes.
2530
+ */
2531
+ declare class PrivacyKeyManager {
2532
+ private _state;
1835
2533
  /**
1836
- * Load a spending key into the in-memory session.
1837
- * Derives viewingKey and ownerPk immediately.
2534
+ * Load a spending key and its corresponding master bytes into the in-memory session.
2535
+ * Derives viewingSecretKey, viewingPublicKeyPacked, and ownerPk immediately.
1838
2536
  * Replaces any previously loaded key.
2537
+ *
2538
+ * @param spendingKey Circuit scalar: BigInt(masterBytes) % BABYJUB_SUBORDER, clamped to [1, ∞).
2539
+ * @param masterBytes Raw 32-byte HKDF output before modular reduction. Used to derive
2540
+ * the stable vault key (HKDF(masterBytes, info="orbinum-vault-key-v1")).
1839
2541
  */
1840
- load(spendingKey: bigint): Promise<void>;
2542
+ load(spendingKey: bigint, masterBytes: Uint8Array): Promise<void>;
1841
2543
  /** Clear all key material from memory. Call on vault lock / sign-out. */
1842
2544
  clear(): void;
1843
2545
  /** Returns true if a spending key has been loaded. */
1844
2546
  isLoaded(): boolean;
1845
2547
  /** Returns the spending key. Throws if not loaded. */
1846
2548
  getSpendingKey(): bigint;
1847
- /** Returns the 32-byte viewing key. Throws if not loaded. */
1848
- getViewingKey(): Uint8Array;
2549
+ /**
2550
+ * Returns the 32-byte viewing secret key (ivsk).
2551
+ * Used internally for decrypting received notes during rescan.
2552
+ * SECURITY: never expose this in addresses or network requests.
2553
+ * Throws if not loaded.
2554
+ */
2555
+ getViewingSecretKey(): Uint8Array;
2556
+ /**
2557
+ * Returns the 32-byte LE-encoded packed BJJ viewing public key (ivk).
2558
+ * This is the component embedded in the privacy address and passed to senders
2559
+ * so they can encrypt memos only the recipient can decrypt.
2560
+ * Throws if not loaded.
2561
+ */
2562
+ getViewingPublicKeyPacked(): Uint8Array;
1849
2563
  /** Returns the BabyJubJub owner public key (x-coordinate). Throws if not loaded. */
1850
2564
  getOwnerPk(): bigint;
1851
2565
  /** Returns the spending key as a 32-byte little-endian Uint8Array. Throws if not loaded. */
1852
2566
  getSpendingKeyBytes(): Uint8Array;
1853
- /** Exports the spending key as a 0x-prefixed 64-char hex string. Throws if not loaded. */
2567
+ /**
2568
+ * Returns the 32-byte master key bytes (pre-modulus HKDF output).
2569
+ * Used to derive the stable vault AES key. Throws if not loaded.
2570
+ */
2571
+ getMasterBytes(): Uint8Array;
2572
+ /**
2573
+ * Exports the master key bytes as a "mk:0x{hex}" string.
2574
+ * Storing masterBytes (not the sk scalar) ensures the vault key and
2575
+ * rescan can always be reconstructed regardless of any future modulus change.
2576
+ * Throws if not loaded.
2577
+ */
1854
2578
  exportHex(): string;
1855
2579
  /**
1856
- * Load a spending key from a 0x-prefixed or bare hex string.
1857
- * Validates the key is in the valid range [1, BN254_R).
2580
+ * Exports a shareable privacy address encoding the owner public key and
2581
+ * viewing PUBLIC key of the currently loaded identity.
2582
+ *
2583
+ * Format: `orbpriv1:{ownerPk_hex}:{viewingPublicKey_hex}`
2584
+ *
2585
+ * The recipient uses this address so the sender can:
2586
+ * 1. Embed `ownerPk` in the note commitment (Poseidon4 input).
2587
+ * 2. Encrypt the memo via ECDH with the recipient's `viewingPublicKey`.
2588
+ *
2589
+ * SECURITY: Only the viewing PUBLIC key is embedded — the viewing secret key
2590
+ * (used for decryption) is never exported. Holders of this address cannot
2591
+ * decrypt the recipient's notes.
2592
+ *
2593
+ * Throws if no key is loaded.
2594
+ */
2595
+ encodePrivacyAddress(): string;
2596
+ /**
2597
+ * Decode a privacy address of the form `orbpriv1:{ownerPk_hex}:{viewingPublicKey_hex}`.
2598
+ * Returns `{ ownerPkHex, viewingPublicKeyHex }` on success, or `null` if the input
2599
+ * does not match the expected format.
2600
+ */
2601
+ static decodePrivacyAddress(address: string): {
2602
+ ownerPkHex: string;
2603
+ viewingPublicKeyHex: string;
2604
+ } | null;
2605
+ /**
2606
+ * Load keys from a cached "mk:0x{masterBytes_hex}" string produced by exportHex().
2607
+ * Throws if the format is invalid or masterBytes length is not 32 bytes.
1858
2608
  */
1859
2609
  importFromHex(hex: string): Promise<void>;
1860
2610
  }
1861
2611
 
1862
2612
  /**
1863
- * VaultCrypto
2613
+ * VaultJson
1864
2614
  *
1865
- * WebCrypto-based encryption utilities for protecting Orbinum vault data.
1866
- * Works in browser and Node.js 18+ (both expose the WebCrypto API as `crypto`).
1867
- * Pure functions — no state, no side effects.
1868
- *
1869
- * Key derivation: HKDF-SHA-256(ikm=spendingKeyBytes, salt=empty, info="orbinum-vault-key-v1")
1870
- * Cipher: AES-GCM 256
2615
+ * BigInt-safe JSON helpers for Orbinum vault payloads.
1871
2616
  *
1872
- * BigInt serialisation uses `{ __bigint: "<decimal string>" }` so plain
1873
- * `JSON.stringify` never receives a bigint. Use `vaultReplacer` / `vaultReviver`
1874
- * for all vault payloads.
2617
+ * BigInt values are serialised as `{ __bigint: "<decimal string>" }` so that
2618
+ * `JSON.stringify` never receives a native bigint (which it cannot handle).
2619
+ * Use `vaultReplacer` / `vaultReviver` for every vault read/write operation.
1875
2620
  */
1876
2621
  /**
1877
2622
  * `JSON.stringify` replacer that serialises bigint values as
@@ -1883,14 +2628,27 @@ declare function vaultReplacer(_key: string, value: unknown): unknown;
1883
2628
  * back into native bigint values.
1884
2629
  */
1885
2630
  declare function vaultReviver(_key: string, value: unknown): unknown;
2631
+
1886
2632
  /**
1887
- * Derives an AES-GCM-256 CryptoKey from spending key bytes using HKDF-SHA-256.
1888
- * The spending key carries ≥256 bits of entropy so no salt / iteration
1889
- * stretching is required.
2633
+ * VaultCrypto
2634
+ *
2635
+ * WebCrypto-based encryption utilities for protecting Orbinum vault data.
2636
+ * Works in browser and Node.js 18+ (both expose the WebCrypto API as `crypto`).
2637
+ * Pure functions — no state, no side effects.
2638
+ *
2639
+ * Key derivation: HKDF-SHA-256(ikm=masterBytes, salt=empty, info="orbinum-vault-key-v1")
2640
+ * Cipher: AES-GCM 256
2641
+ */
2642
+ /**
2643
+ * Derives an AES-GCM-256 CryptoKey from master key bytes using HKDF-SHA-256.
2644
+ *
2645
+ * IMPORTANT: pass masterBytes from deriveMasterKeyBytes(), NOT bigintTo32Le(spendingKey).
2646
+ * The vault key must be stable across circuit field changes — it depends only on
2647
+ * the wallet signature, never on the modulus used to reduce the circuit scalar.
1890
2648
  *
1891
- * @param spendingKeyBytes 32-byte spending key (little-endian bigint representation).
2649
+ * @param masterBytes 32-byte pre-modulus key material from deriveMasterKeyBytes().
1892
2650
  */
1893
- declare function deriveVaultKey(spendingKeyBytes: Uint8Array): Promise<CryptoKey>;
2651
+ declare function deriveVaultKey(masterBytes: Uint8Array): Promise<CryptoKey>;
1894
2652
  /**
1895
2653
  * Serialises `payload` to JSON (bigint-safe) and encrypts it with AES-GCM.
1896
2654
  * Returns base64-encoded `iv` and `ciphertext`.
@@ -1905,8 +2663,198 @@ declare function encryptJson(key: CryptoKey, payload: unknown): Promise<{
1905
2663
  */
1906
2664
  declare function decryptJson(key: CryptoKey, iv: string, ciphertext: string): Promise<unknown>;
1907
2665
 
1908
- declare function toBase64(buf: ArrayBuffer | Uint8Array): string;
1909
- declare function fromBase64(b64: string): Uint8Array;
2666
+ /**
2667
+ * Vault protocol types.
2668
+ *
2669
+ * These types define the storage contract for vault note records.
2670
+ * Any backend (IndexedDB, SQLite, remote…) must produce/consume this shape
2671
+ * so that encryptNote / decryptNoteRecord work without modification.
2672
+ */
2673
+ /** A single encrypted note record as stored in the vault backend. */
2674
+ interface EncryptedNoteRecord {
2675
+ /** Primary key — note commitmentHex */
2676
+ commitmentHex: string;
2677
+ /** AES-GCM IV for this record — base64 */
2678
+ iv: string;
2679
+ /** AES-GCM ciphertext of the full ZkNote JSON — base64 */
2680
+ ciphertext: string;
2681
+ /** Unencrypted nullifierHex for quick spent-check without unlocking */
2682
+ nullifierHex: string;
2683
+ /** Unencrypted assetId (string form of bigint) for filtering */
2684
+ assetId: string;
2685
+ /** Whether the note has already been spent/nullified on-chain. */
2686
+ spent?: boolean;
2687
+ /** When the app marked the note as spent locally, if known. */
2688
+ spentAt?: number | null;
2689
+ updatedAt: number;
2690
+ }
2691
+ /** Partial update applied to a note's spent status without re-encrypting the full payload. */
2692
+ interface NoteStatusUpdate {
2693
+ spent?: boolean;
2694
+ spentAt?: number | null;
2695
+ }
2696
+
2697
+ /**
2698
+ * Vault protocol errors.
2699
+ */
2700
+ /** Thrown when a vault operation is attempted while the vault is locked. */
2701
+ declare class VaultLockedError extends Error {
2702
+ constructor(message?: string);
2703
+ }
2704
+
2705
+ /**
2706
+ * noteOps
2707
+ *
2708
+ * Pure protocol-level operations on vault notes.
2709
+ * No Zustand, no IndexedDB — pure data transformations.
2710
+ */
2711
+
2712
+ /**
2713
+ * Merges a NoteStatusUpdate into a ZkNote, applying defaults for missing fields.
2714
+ * Returns a new note object — does not mutate the original.
2715
+ */
2716
+ declare function applyNoteStatus(note: ZkNote, status?: NoteStatusUpdate): ZkNote;
2717
+ /**
2718
+ * Encrypts a ZkNote into an EncryptedNoteRecord using AES-GCM.
2719
+ * The commitmentHex, nullifierHex, and assetId are stored in plaintext
2720
+ * for efficient filtering without requiring vault unlock.
2721
+ */
2722
+ declare function encryptNote(key: CryptoKey, note: ZkNote): Promise<EncryptedNoteRecord>;
2723
+ /**
2724
+ * Decrypts an EncryptedNoteRecord back into a ZkNote using AES-GCM.
2725
+ * Applies the record's spent/spentAt metadata onto the decrypted note.
2726
+ * Throws DOMException on authentication failure (wrong key or corrupted data).
2727
+ */
2728
+ declare function decryptNoteRecord(key: CryptoKey, rec: EncryptedNoteRecord): Promise<ZkNote>;
2729
+
2730
+ /**
2731
+ * Inputs required to generate an Unshield proof.
2732
+ *
2733
+ * All BigInt values must be BN254 scalar field elements.
2734
+ * All hex strings must be 0x-prefixed 32-byte little-endian values (as
2735
+ * returned by the node RPC).
2736
+ */
2737
+ interface UnshieldProofInputs {
2738
+ /** Merkle root (0x-prefixed, 32-byte LE). */
2739
+ merkleRoot: string;
2740
+ /** Nullifier as bigint. */
2741
+ nullifier: bigint;
2742
+ /** Net withdrawal amount (recipient receives this, planck). */
2743
+ amount: bigint;
2744
+ /** Asset ID. */
2745
+ assetId: bigint;
2746
+ /**
2747
+ * Recipient encoded as a BN254 field element.
2748
+ * For Substrate addresses: Poseidon(le32(accountId32)).
2749
+ */
2750
+ recipient: bigint;
2751
+ /** Note blinding factor. */
2752
+ blinding: bigint;
2753
+ /** Spending key used to derive the nullifier. */
2754
+ spendingKey: bigint;
2755
+ /** Sibling hashes (0x-prefixed, 32-byte LE), one per tree level. */
2756
+ pathSiblings: string[];
2757
+ /** Leaf index of the commitment in the Merkle tree. */
2758
+ leafIndex: number;
2759
+ /** Gasless fee in planck (default 0n). note_value == amount + fee + changeValue in circuit. */
2760
+ fee?: bigint;
2761
+ /**
2762
+ * Value of the change note in planck (default 0n = total unshield).
2763
+ * Must satisfy: note_value == amount + fee + changeValue.
2764
+ */
2765
+ changeValue?: bigint;
2766
+ /**
2767
+ * Blinding scalar for the change note commitment.
2768
+ * Auto-generated with CSPRNG when changeValue > 0n and not provided.
2769
+ */
2770
+ changeBlinding?: bigint;
2771
+ /**
2772
+ * BabyJubJub Ax coordinate of the change note owner (default: derived from spendingKey,
2773
+ * i.e. the change stays with the same owner).
2774
+ */
2775
+ changeOwnerPubkey?: bigint;
2776
+ }
2777
+ /**
2778
+ * Result of `generateUnshieldProof`.
2779
+ *
2780
+ * Extends `ProofResult` with the change note commitment, value, blinding, and owner pubkey
2781
+ * so the caller can pass them directly to the `unshield` extrinsic and generate the
2782
+ * encrypted memo for change note recovery.
2783
+ */
2784
+ interface UnshieldProofResult extends ProofResult {
2785
+ /** Poseidon4(changeValue, assetId, changeOwnerPubkey, changeBlinding). 0n for total unshield. */
2786
+ changeCommitment: bigint;
2787
+ /** Change value used (mirrors inputs.changeValue ?? 0n). */
2788
+ changeValue: bigint;
2789
+ /** Blinding factor for the change note (0n for total unshield). */
2790
+ changeBlinding: bigint;
2791
+ /** Owner pubkey for the change note (derived from spendingKey if not provided). */
2792
+ changeOwnerPubkey: bigint;
2793
+ }
2794
+ /**
2795
+ * Generate a Groth16 proof for an Unshield operation.
2796
+ *
2797
+ * @param inputs - All private and public inputs for the unshield circuit.
2798
+ * @param options.provider - Override the artifact provider (default: CDN).
2799
+ * @param options.verbose - Log proof generation steps to console.
2800
+ */
2801
+ declare function generateUnshieldProof(inputs: UnshieldProofInputs, options?: {
2802
+ provider?: ArtifactProvider;
2803
+ verbose?: boolean;
2804
+ }): Promise<UnshieldProofResult>;
2805
+
2806
+ /**
2807
+ * Inputs required to generate a fee-claim proof.
2808
+ *
2809
+ * The proof demonstrates that the caller knows the preimage of `commitment`,
2810
+ * specifically that `commitment = Poseidon4(amount, assetId, ownerPubkey, blinding)`.
2811
+ * Both `amount` and `assetId` are revealed as public signals so the pallet can
2812
+ * verify consistency with the extrinsic arguments.
2813
+ */
2814
+ interface FeeClaimProofInputs {
2815
+ /** Fee amount to claim in planck (must fit in u64). */
2816
+ amount: bigint;
2817
+ /** Asset ID of the fee note. */
2818
+ assetId: bigint;
2819
+ /** Owner public key (BabyJubJub Ax component). */
2820
+ ownerPubkey: bigint;
2821
+ /** Note blinding factor. */
2822
+ blinding: bigint;
2823
+ /** Note commitment as bigint (Poseidon4(amount, assetId, ownerPubkey, blinding)). */
2824
+ commitment: bigint;
2825
+ }
2826
+ /**
2827
+ * Proof output ready to submit with `claim_shielded_fees`.
2828
+ */
2829
+ interface FeeClaimProofOutput {
2830
+ /** 128-byte compressed Groth16 proof as 0x-prefixed hex. */
2831
+ proof: string;
2832
+ /**
2833
+ * Compact 76-byte public signals as `number[]` (SCALE-compatible).
2834
+ *
2835
+ * Layout: commitment[0..32] | value[32..40] | asset_id[40..44] | owner_hash[44..76]
2836
+ *
2837
+ * Pass directly as the `public_signals` argument of `claim_shielded_fees`.
2838
+ */
2839
+ publicSignals: number[];
2840
+ }
2841
+ /**
2842
+ * Generate a Groth16 fee-claim proof using the value_proof circuit.
2843
+ *
2844
+ * The resulting proof convinces the pallet that:
2845
+ * 1. The caller knows (amount, assetId, ownerPubkey, blinding) such that
2846
+ * `commitment = Poseidon4(amount, assetId, ownerPubkey, blinding)`.
2847
+ * 2. The revealed `amount` and `assetId` match what will be submitted
2848
+ * on-chain, preventing inflation attacks.
2849
+ *
2850
+ * @param inputs - Note preimage and commitment.
2851
+ * @param options.provider - Override the artifact provider (default: CDN).
2852
+ * @param options.verbose - Log proof generation steps to console.
2853
+ */
2854
+ declare function generateFeeClaimProof(inputs: FeeClaimProofInputs, options?: {
2855
+ provider?: ArtifactProvider;
2856
+ verbose?: boolean;
2857
+ }): Promise<FeeClaimProofOutput>;
1910
2858
 
1911
2859
  /**
1912
2860
  * Contract addresses and function selectors for all Orbinum EVM precompiles.
@@ -1986,14 +2934,21 @@ type ShieldedEvent = {
1986
2934
  leafIndex: number;
1987
2935
  };
1988
2936
  /**
1989
- * Emitted by `private_transfer()`.
1990
- * Rust variant: `PrivateTransfer { nullifiers, commitments, encrypted_memos, leaf_indices }`
1991
- * Max 2 inputs / 2 outputs.
2937
+ * Emitted by `private_transfer()` when input nullifiers are spent.
2938
+ * Rust variant: `NullifiersSpent { nullifiers }`
2939
+ * Emitted independently of CommitmentsInserted to prevent graph correlation.
1992
2940
  */
1993
- type PrivateTransferEvent = {
1994
- /** Input nullifiers — max 2. 0x-prefixed 32-byte hex each. */
2941
+ type NullifiersSpentEvent = {
2942
+ /** Input nullifiers consumed — max 2. 0x-prefixed 32-byte hex each. */
1995
2943
  nullifiers: string[];
1996
- /** Output commitments — max 2. 0x-prefixed 32-byte hex each. */
2944
+ };
2945
+ /**
2946
+ * Emitted by `private_transfer()` when output commitments are inserted.
2947
+ * Rust variant: `CommitmentsInserted { commitments, encrypted_memos, leaf_indices }`
2948
+ * Emitted independently of NullifiersSpent to prevent graph correlation.
2949
+ */
2950
+ type CommitmentsInsertedEvent = {
2951
+ /** Output commitments created — max 2. 0x-prefixed 32-byte hex each. */
1997
2952
  commitments: string[];
1998
2953
  /** Encrypted memos for each output — max 2. */
1999
2954
  encryptedMemos: string[];
@@ -2002,7 +2957,7 @@ type PrivateTransferEvent = {
2002
2957
  };
2003
2958
  /**
2004
2959
  * Emitted by `unshield()` when a note is withdrawn to the public chain.
2005
- * Rust variant: `Unshielded { nullifier, amount, recipient }`
2960
+ * Rust variant: `Unshielded { nullifier, amount, recipient, change_commitment }`
2006
2961
  */
2007
2962
  type UnshieldedEvent = {
2008
2963
  /** 0x-prefixed 32-byte Poseidon nullifier (LE). */
@@ -2010,6 +2965,11 @@ type UnshieldedEvent = {
2010
2965
  amount: bigint;
2011
2966
  /** SS58 AccountId of the recipient. */
2012
2967
  recipient: string;
2968
+ /**
2969
+ * 0x-prefixed 32-byte change note commitment (LE), or null for total unshield.
2970
+ * When present, the commitment has been inserted into the Merkle tree.
2971
+ */
2972
+ changeCommitment: string | null;
2013
2973
  };
2014
2974
  /**
2015
2975
  * Emitted after every Merkle tree update (shield / transfer / unshield).
@@ -2023,72 +2983,6 @@ type MerkleRootUpdatedEvent = {
2023
2983
  /** Total number of leaves after the update. */
2024
2984
  treeSize: number;
2025
2985
  };
2026
- /**
2027
- * Emitted by `set_audit_policy()` when an account sets or updates its audit policy.
2028
- * Rust variant: `AuditPolicySet { account, version }`
2029
- */
2030
- type AuditPolicySetEvent = {
2031
- /** SS58 AccountId of the policy owner. */
2032
- account: string;
2033
- /** Policy version number (monotonically increasing). */
2034
- version: number;
2035
- };
2036
- /**
2037
- * Emitted by `disclose()` when a note is disclosed.
2038
- * Rust variant: `Disclosed { who, commitment, auditor }`
2039
- */
2040
- type DisclosedEvent = {
2041
- /** SS58 AccountId of the discloser. */
2042
- who: string;
2043
- /** 0x-prefixed 32-byte commitment of the disclosed note. */
2044
- commitment: string;
2045
- /** SS58 AccountId of the auditor, or null for voluntary disclosure. */
2046
- auditor: string | null;
2047
- };
2048
- /**
2049
- * Emitted by `request_disclosure()` when an auditor requests a note disclosure.
2050
- * Rust variant: `DisclosureRequested { target, auditor, reason }`
2051
- */
2052
- type DisclosureRequestedEvent = {
2053
- /** SS58 AccountId of the note owner (disclosure target). */
2054
- target: string;
2055
- /** SS58 AccountId of the requesting auditor. */
2056
- auditor: string;
2057
- /** Reason string (max 256 bytes, UTF-8). */
2058
- reason: string;
2059
- };
2060
- /**
2061
- * Emitted by `reject_disclosure()` when a note owner rejects a disclosure request.
2062
- * Rust variant: `DisclosureRejected { target, auditor, reason }`
2063
- */
2064
- type DisclosureRejectedEvent = {
2065
- /** SS58 AccountId of the note owner. */
2066
- target: string;
2067
- /** SS58 AccountId of the auditor whose request was rejected. */
2068
- auditor: string;
2069
- /** Rejection reason string (max 256 bytes, UTF-8). */
2070
- reason: string;
2071
- };
2072
- /**
2073
- * Emitted when a pending disclosure request expires (on_finalize pruning).
2074
- * Rust variant: `DisclosureRequestExpired { target, auditor }`
2075
- */
2076
- type DisclosureRequestExpiredEvent = {
2077
- /** SS58 AccountId of the note owner. */
2078
- target: string;
2079
- /** SS58 AccountId of the auditor. */
2080
- auditor: string;
2081
- };
2082
- /**
2083
- * Emitted by `revoke_disclosure_record()` when an account revokes a previous disclosure.
2084
- * Rust variant: `DisclosureRecordRevoked { who, commitment }`
2085
- */
2086
- type DisclosureRecordRevokedEvent = {
2087
- /** SS58 AccountId of the note owner. */
2088
- who: string;
2089
- /** 0x-prefixed 32-byte commitment of the revoked note. */
2090
- commitment: string;
2091
- };
2092
2986
  /**
2093
2987
  * Emitted by `register_asset()` when a new asset is registered in the pool.
2094
2988
  * Rust variant: `AssetRegistered { asset_id }`
@@ -2115,32 +3009,17 @@ type ShieldedPoolEvent = {
2115
3009
  type: 'Shielded';
2116
3010
  data: ShieldedEvent;
2117
3011
  } | {
2118
- type: 'PrivateTransfer';
2119
- data: PrivateTransferEvent;
3012
+ type: 'NullifiersSpent';
3013
+ data: NullifiersSpentEvent;
3014
+ } | {
3015
+ type: 'CommitmentsInserted';
3016
+ data: CommitmentsInsertedEvent;
2120
3017
  } | {
2121
3018
  type: 'Unshielded';
2122
3019
  data: UnshieldedEvent;
2123
3020
  } | {
2124
3021
  type: 'MerkleRootUpdated';
2125
3022
  data: MerkleRootUpdatedEvent;
2126
- } | {
2127
- type: 'AuditPolicySet';
2128
- data: AuditPolicySetEvent;
2129
- } | {
2130
- type: 'Disclosed';
2131
- data: DisclosedEvent;
2132
- } | {
2133
- type: 'DisclosureRequested';
2134
- data: DisclosureRequestedEvent;
2135
- } | {
2136
- type: 'DisclosureRejected';
2137
- data: DisclosureRejectedEvent;
2138
- } | {
2139
- type: 'DisclosureRequestExpired';
2140
- data: DisclosureRequestExpiredEvent;
2141
- } | {
2142
- type: 'DisclosureRecordRevoked';
2143
- data: DisclosureRecordRevokedEvent;
2144
3023
  } | {
2145
3024
  type: 'AssetRegistered';
2146
3025
  data: AssetRegisteredEvent;
@@ -2171,14 +3050,14 @@ type CircuitId = (typeof CircuitId)[keyof typeof CircuitId];
2171
3050
  * |--------------|-------|---------------------------------|
2172
3051
  * | Transfer | 1 | 2-in-2-out private transfer |
2173
3052
  * | Unshield | 2 | Withdrawal from the pool |
2174
- * | Disclosure | 3 | Selective disclosure |
2175
- * | PrivateLink | 4 | Private chain-link proof |
3053
+ * | ValueProof | 4 | Note value binding (fee-claim) |
3054
+ * | PrivateLink | 5 | Private chain-link proof |
2176
3055
  */
2177
3056
  declare const CircuitId: {
2178
3057
  readonly Transfer: 1;
2179
3058
  readonly Unshield: 2;
2180
- readonly Disclosure: 3;
2181
- readonly PrivateLink: 4;
3059
+ readonly ValueProof: 4;
3060
+ readonly PrivateLink: 5;
2182
3061
  };
2183
3062
  /**
2184
3063
  * A single verification key registration entry used in batch operations.
@@ -2233,7 +3112,7 @@ type VerifyProofArgs = {
2233
3112
  * Number and meaning of inputs depends on the circuit:
2234
3113
  * - Transfer: [merkle_root, nullifier_0, nullifier_1, commitment_0, commitment_1]
2235
3114
  * - Unshield: [merkle_root, nullifier, amount_fe, recipient_hash, asset_id_fe]
2236
- * - Disclosure: [commitment, revealed_value_fe, revealed_asset_id_fe, owner_hash]
3115
+ * - ValueProof: [commitment, value, asset_id, owner_hash]
2237
3116
  * - PrivateLink: [commitment, call_hash_fe]
2238
3117
  */
2239
3118
  publicInputs: number[][];
@@ -2819,52 +3698,10 @@ type AccountMappingEvent = {
2819
3698
  */
2820
3699
  type Bytes32 = number[];
2821
3700
  /**
2822
- * Structured disclosure public signals — exactly 76 bytes:
2823
- * commitment[0..32] | revealed_value[32..40] | revealed_asset_id[40..44] | owner_hash[44..76]
3701
+ * 176-byte encrypted memo (ChaCha20-Poly1305 ECDH).
3702
+ * Layout: nonce(12) || ciphertext(132) || tag(16) || ephPk(32) = 176 bytes.
2824
3703
  */
2825
- type DisclosurePublicSignals = number[];
2826
- /**
2827
- * A single auditor entry in an audit policy.
2828
- * Maps to `Auditor<AccountId>` in Rust.
2829
- */
2830
- type Auditor = {
2831
- /** SS58 or 0x-prefixed AccountId of the authorized auditor. */
2832
- account: string;
2833
- };
2834
- /**
2835
- * A condition that must be satisfied before disclosure is permitted.
2836
- * Maps to `DisclosureCondition` in Rust. Max 10 conditions per policy.
2837
- */
2838
- type DisclosureCondition = {
2839
- type: 'MinValue';
2840
- value: bigint;
2841
- } | {
2842
- type: 'MaxValue';
2843
- value: bigint;
2844
- } | {
2845
- type: 'AssetId';
2846
- assetId: number;
2847
- } | {
2848
- type: 'RecipientIs';
2849
- recipient: string;
2850
- } | {
2851
- type: 'Custom';
2852
- encoded: number[];
2853
- };
2854
- /**
2855
- * A single entry in a batch disclosure proof submission.
2856
- * Maps to `BatchDisclosureSubmission<AccountId>` in Rust.
2857
- */
2858
- type BatchDisclosureSubmission = {
2859
- /** 32-byte commitment (LE). */
2860
- commitment: Bytes32;
2861
- /** Groth16 proof bytes — max 256 bytes. */
2862
- proof: number[];
2863
- /** 76-byte public signals: commitment(32) | value(8) | asset_id(4) | owner_hash(32). */
2864
- publicSignals: DisclosurePublicSignals;
2865
- /** Optional auditor AccountId. Null = voluntary disclosure. */
2866
- auditor: string | null;
2867
- };
3704
+ type Bytes176 = number[];
2868
3705
  /**
2869
3706
  * A single shield operation for use in `shield_batch`.
2870
3707
  */
@@ -2910,9 +3747,10 @@ type RawTransferOutput = {
2910
3747
  memo: number[];
2911
3748
  };
2912
3749
  /**
2913
- * Call index 1 — `private_transfer` (Signed origin)
3750
+ * Call index 1 — `private_transfer` (Unsigned/gasless origin)
2914
3751
  * Transfers value between notes without revealing sender, recipient or amount.
2915
- * Accepts 1–2 inputs and 1–2 outputs; total input value must equal total output value.
3752
+ * Fee is embedded in the ZK proof: input_sum == output_sum + fee.
3753
+ * The fee is paid to the block author (validator) by the pallet runtime.
2916
3754
  */
2917
3755
  type PrivateTransferArgs = {
2918
3756
  /** Groth16 proof bytes — max 512 bytes. */
@@ -2922,10 +3760,15 @@ type PrivateTransferArgs = {
2922
3760
  nullifiers: RawTransferInput[];
2923
3761
  outputs: RawTransferOutput[];
2924
3762
  encryptedMemos: number[][];
3763
+ /** Asset ID being transferred (public input of the proof). */
3764
+ assetId: number;
3765
+ /** Gasless fee in planck. Paid to the block author (validator). */
3766
+ fee: bigint;
2925
3767
  };
2926
3768
  /**
2927
- * Call index 2 — `unshield` (Signed origin)
3769
+ * Call index 2 — `unshield` (Unsigned/gasless origin)
2928
3770
  * Withdraws a note from the pool to a public account.
3771
+ * Fee is embedded in the ZK proof: note_value == amount + fee + changeValue.
2929
3772
  */
2930
3773
  type UnshieldArgs = {
2931
3774
  /** Groth16 proof bytes — max 512 bytes. */
@@ -2935,64 +3778,23 @@ type UnshieldArgs = {
2935
3778
  /** 32-byte nullifier of the spent note (LE). */
2936
3779
  nullifier: Bytes32;
2937
3780
  assetId: number;
3781
+ /** Net amount recipient receives (planck). */
2938
3782
  amount: bigint;
2939
3783
  /** SS58 or 0x-prefixed AccountId of the recipient. */
2940
3784
  recipient: string;
2941
- };
2942
- /**
2943
- * Call index 4 — `set_audit_policy` (Signed origin)
2944
- * Registers or replaces the caller's audit policy for selective disclosure.
2945
- */
2946
- type SetAuditPolicyArgs = {
2947
- /** Up to 10 authorized auditors. */
2948
- auditors: Auditor[];
2949
- /** Up to 10 disclosure conditions. */
2950
- conditions: DisclosureCondition[];
2951
- /** Minimum blocks between disclosures to the same auditor. Null = no limit. */
2952
- maxFrequency: number | null;
2953
- /** Block after which the policy expires. Null = no expiry. */
2954
- validUntil: number | null;
2955
- };
2956
- /**
2957
- * Call index 5 — `request_disclosure` (Signed origin)
2958
- * Auditor requests selective disclosure from a target account.
2959
- */
2960
- type RequestDisclosureArgs = {
2961
- /** AccountId of the disclosure target. */
2962
- target: string;
2963
- /** Human-readable request reason — max 256 bytes UTF-8. */
2964
- reason: string;
2965
- };
2966
- /**
2967
- * Call index 6 — `disclose` (Signed origin)
2968
- * Submit a Groth16 disclosure proof for a commitment.
2969
- */
2970
- type DiscloseArgs = {
2971
- /** 32-byte note commitment to disclose (LE). */
2972
- commitment: Bytes32;
2973
- /** Groth16 proof bytes — max 256 bytes. */
2974
- proofBytes: number[];
2975
- /** 76-byte public signals: commitment(32) | value(8) | asset_id(4) | owner_hash(32). */
2976
- publicSignals: DisclosurePublicSignals;
2977
- /** Target auditor AccountId. Null = voluntary public disclosure. */
2978
- auditor: string | null;
2979
- };
2980
- /**
2981
- * Call index 7 — `reject_disclosure` (Signed origin)
2982
- * Disclosure target rejects a pending request from an auditor.
2983
- */
2984
- type RejectDisclosureArgs = {
2985
- /** AccountId of the auditor whose request is rejected. */
2986
- auditor: string;
2987
- /** Rejection reason — max 256 bytes UTF-8. */
2988
- reason: string;
2989
- };
2990
- /**
2991
- * Call index 13 — `batch_submit_disclosure_proofs` (Signed origin)
2992
- * Submit up to 10 disclosure proofs in one extrinsic.
2993
- */
2994
- type BatchSubmitDisclosureProofsArgs = {
2995
- submissions: BatchDisclosureSubmission[];
3785
+ /** Gasless fee in planck. */
3786
+ fee: bigint;
3787
+ /**
3788
+ * 32-byte change note commitment (LE). All zeros for total unshield.
3789
+ * Must equal NoteCommitment(changeValue, assetId, changeOwnerPk, changeBlinding)
3790
+ * when changeValue > 0 — enforced by the ZK circuit.
3791
+ */
3792
+ changeCommitment: Bytes32;
3793
+ /**
3794
+ * Encrypted memo for the change note (176 bytes, empty for total unshield).
3795
+ * Enables note recovery via blockchain scan for partial unshield.
3796
+ */
3797
+ changeEncryptedMemo?: Bytes176;
2996
3798
  };
2997
3799
  /**
2998
3800
  * Call index 9 — `register_asset` (Root origin)
@@ -3022,24 +3824,6 @@ type VerifyAssetArgs = {
3022
3824
  type UnverifyAssetArgs = {
3023
3825
  assetId: number;
3024
3826
  };
3025
- /**
3026
- * Call index 14 — `prune_expired_request` (Signed origin)
3027
- * Cleans up a disclosure request that has passed its expiration block.
3028
- */
3029
- type PruneExpiredRequestArgs = {
3030
- /** AccountId of the disclosure target. */
3031
- target: string;
3032
- /** AccountId of the auditor. */
3033
- auditor: string;
3034
- };
3035
- /**
3036
- * Call index 15 — `revoke_disclosure_record` (Signed origin)
3037
- * Allows the note owner to revoke a previously submitted disclosure record.
3038
- */
3039
- type RevokeDisclosureRecordArgs = {
3040
- /** 32-byte commitment whose disclosure record should be revoked (LE). */
3041
- commitment: Bytes32;
3042
- };
3043
3827
  /** All pallet-shielded-pool calls as a discriminated union. */
3044
3828
  type ShieldedPoolCall = {
3045
3829
  type: 'shield';
@@ -3053,21 +3837,6 @@ type ShieldedPoolCall = {
3053
3837
  } | {
3054
3838
  type: 'unshield';
3055
3839
  args: UnshieldArgs;
3056
- } | {
3057
- type: 'setAuditPolicy';
3058
- args: SetAuditPolicyArgs;
3059
- } | {
3060
- type: 'requestDisclosure';
3061
- args: RequestDisclosureArgs;
3062
- } | {
3063
- type: 'disclose';
3064
- args: DiscloseArgs;
3065
- } | {
3066
- type: 'rejectDisclosure';
3067
- args: RejectDisclosureArgs;
3068
- } | {
3069
- type: 'batchSubmitDisclosureProofs';
3070
- args: BatchSubmitDisclosureProofsArgs;
3071
3840
  } | {
3072
3841
  type: 'registerAsset';
3073
3842
  args: RegisterAssetArgs;
@@ -3077,12 +3846,6 @@ type ShieldedPoolCall = {
3077
3846
  } | {
3078
3847
  type: 'unverifyAsset';
3079
3848
  args: UnverifyAssetArgs;
3080
- } | {
3081
- type: 'pruneExpiredRequest';
3082
- args: PruneExpiredRequestArgs;
3083
- } | {
3084
- type: 'revokeDisclosureRecord';
3085
- args: RevokeDisclosureRecordArgs;
3086
3849
  };
3087
3850
 
3088
3851
  /**
@@ -3138,7 +3901,73 @@ declare function truncateMiddle(str: string, start: number, end: number): string
3138
3901
  /** Shorten a hash for compact inline display. */
3139
3902
  declare function shortHash(h: string, start?: number, end?: number): string;
3140
3903
 
3141
- declare function toTxResult(payload: TxFinalizedPayload): TxResult;
3904
+ /**
3905
+ * Converts a Uint8Array or number[] to a 0x-prefixed lowercase hex string.
3906
+ */
3907
+ declare function toHex(bytes: Uint8Array | number[]): string;
3908
+ /**
3909
+ * Decodes a hex string (with or without 0x prefix) to Uint8Array.
3910
+ */
3911
+ declare function fromHex(hex: string): Uint8Array;
3912
+ /**
3913
+ * Ensures a hex string has the 0x prefix.
3914
+ */
3915
+ declare function ensureHexPrefix(hex: string): string;
3916
+ /**
3917
+ * Converts a 0x-prefixed hex string (as returned by JSON-RPC) to a number.
3918
+ */
3919
+ declare function hexToNumber(hex: string): number;
3920
+ /**
3921
+ * Converts a 0x-prefixed hex string (as returned by JSON-RPC) to a bigint.
3922
+ */
3923
+ declare function hexToBigint(hex: string): bigint;
3924
+
3925
+ declare function toBase64(buf: ArrayBuffer | Uint8Array): string;
3926
+ declare function fromBase64(b64: string): Uint8Array;
3927
+
3928
+ /**
3929
+ * Derive the stealth owner public key (Ax) for a recipient note.
3930
+ *
3931
+ * stealthScalar = HKDF(sharedSecret, salt=ownerPk_LE, info="orbinum-stealth-v1") % suborder
3932
+ * stealthPoint = stealthScalar × Base8 + ownerPkPoint
3933
+ * return stealthPoint[0] (Ax coordinate)
3934
+ *
3935
+ * The sender calls this with sharedSecret from ECDH (EncryptedMemo.encrypt side).
3936
+ * The recipient calls this with sharedSecret from EncryptedMemo.extractSharedSecret.
3937
+ *
3938
+ * @param sharedSecret 32-byte LE Ax of the ECDH shared point.
3939
+ * @param ownerPkBigint Recipient's global ownerPk (BJJ Ax as bigint).
3940
+ * @param ownerPkPoint Recipient's global BJJ point [Ax, Ay]. Must match ownerPkBigint.
3941
+ * @returns Stealth owner public key (Ax bigint). Used as ownerPk in the note commitment.
3942
+ */
3943
+ declare function deriveStealthOwnerPk(sharedSecret: Uint8Array, ownerPkBigint: bigint, ownerPkPoint: [bigint, bigint]): bigint;
3944
+ /**
3945
+ * Derive the stealth spending key for a received note.
3946
+ *
3947
+ * stealthScalar = HKDF(sharedSecret, salt=ownerPk_LE, info="orbinum-stealth-v1") % suborder
3948
+ * stealthSk = (stealthScalar + spendingKey) % BABYJUB_SUBORDER (|| 1n)
3949
+ *
3950
+ * Security property: BabyPbk(stealthSk).Ax == deriveStealthOwnerPk(sharedSecret, ownerPkBigint, ownerPkPoint)
3951
+ * This means the ZK circuit validates ownership correctly without modification.
3952
+ *
3953
+ * @param sharedSecret 32-byte LE Ax of the ECDH shared point.
3954
+ * @param ownerPkBigint Recipient's global ownerPk (BJJ Ax as bigint) — used as HKDF salt.
3955
+ * @param spendingKey Recipient's global spending key scalar.
3956
+ * @returns Stealth spending key — use as ZkNote.spendingKey for received notes.
3957
+ */
3958
+ declare function deriveStealthSk(sharedSecret: Uint8Array, ownerPkBigint: bigint, spendingKey: bigint): bigint;
3959
+
3960
+ /**
3961
+ * Recover the BabyJubJub [Ax, Ay] point from an Ax coordinate.
3962
+ *
3963
+ * Uses the standard twisted Edwards curve equation: a*x² + y² = 1 + d*x²*y²
3964
+ * with a=168700, d=168696 (same as @zk-kit/baby-jubjub). Solving for y²:
3965
+ * y² = (1 - a*x²) / (1 - d*x²) mod P
3966
+ *
3967
+ * The square root is computed via Tonelli-Shanks (required since P ≡ 1 mod 4).
3968
+ * Returns the point with the canonical (smaller) y, or null if Ax is not on the curve.
3969
+ */
3970
+ declare function recoverOwnerPkPoint(ax: bigint): [bigint, bigint] | null;
3142
3971
 
3143
3972
  /**
3144
3973
  * Serialises a bigint as a 32-byte little-endian Uint8Array.
@@ -3321,38 +4150,6 @@ interface DecodedUnshieldArgs {
3321
4150
  amount: string;
3322
4151
  recipient: string;
3323
4152
  }
3324
- interface DecodedSetAuditPolicyArgs {
3325
- auditors: string[];
3326
- conditions: unknown;
3327
- max_frequency: number;
3328
- }
3329
- interface DecodedRequestDisclosureArgs {
3330
- target: string;
3331
- reason: string;
3332
- evidence?: string;
3333
- }
3334
- interface DecodedApproveDisclosureArgs {
3335
- auditor: string;
3336
- commitment: string;
3337
- proof: string;
3338
- public_signals: string[];
3339
- extra_data: unknown;
3340
- }
3341
- interface DecodedRejectDisclosureArgs {
3342
- auditor: string;
3343
- reason: string;
3344
- }
3345
- interface DecodedSubmitDisclosureArgs {
3346
- commitment: string;
3347
- proof: string;
3348
- public_signals: string[];
3349
- partial_data: unknown;
3350
- auditor: string;
3351
- }
3352
- interface DecodedBatchSubmitDisclosureArgs {
3353
- count: number;
3354
- submissions: DecodedSubmitDisclosureArgs[];
3355
- }
3356
4153
  interface DecodedTransferArgs {
3357
4154
  dest: string;
3358
4155
  value: string;
@@ -3435,8 +4232,10 @@ interface ShieldedEventData {
3435
4232
  memo: string;
3436
4233
  index: number;
3437
4234
  }
3438
- interface PrivateTransferEventData {
4235
+ interface NullifiersSpentEventData {
3439
4236
  nullifiers: string[];
4237
+ }
4238
+ interface CommitmentsInsertedEventData {
3440
4239
  commitments: string[];
3441
4240
  memos: string[];
3442
4241
  indices: number[];
@@ -3451,45 +4250,6 @@ interface MerkleRootUpdatedData {
3451
4250
  new_root: string;
3452
4251
  size: number;
3453
4252
  }
3454
- interface AuditPolicySetData {
3455
- who: string;
3456
- auditors: string[];
3457
- version: number;
3458
- }
3459
- interface DisclosureRequestedData {
3460
- requestor: string;
3461
- target: string;
3462
- commitment: string;
3463
- reason?: string;
3464
- }
3465
- interface DisclosureApprovedData {
3466
- who: string;
3467
- commitment: string;
3468
- auditor: string;
3469
- }
3470
- interface DisclosureRejectedData {
3471
- who: string;
3472
- auditor: string;
3473
- reason: string;
3474
- }
3475
- interface DisclosureSubmittedData {
3476
- who: string;
3477
- commitment: string;
3478
- proof_size: number;
3479
- auditor: string;
3480
- }
3481
- interface DisclosureVerifiedData {
3482
- who: string;
3483
- commitment: string;
3484
- verified: boolean;
3485
- }
3486
- interface AuditTrailRecordedData {
3487
- account: string;
3488
- auditor: string;
3489
- commitment: string;
3490
- trail_hash: string;
3491
- trail_id: string;
3492
- }
3493
4253
  interface TransferEventData {
3494
4254
  from: string;
3495
4255
  to: string;
@@ -3560,4 +4320,4 @@ interface ExtrinsicFailedData {
3560
4320
  dispatch_info: DispatchInfo;
3561
4321
  }
3562
4322
 
3563
- export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, type AddChainLinkArgs, type AddChainLinkParams, type AddSupportedChainArgs, type AliasFullIdentity, type AliasInfo, type AliasListedForSaleEvent, type AliasOnSaleData, type AliasRegisteredData, type AliasRegisteredEvent, type AliasReleasedEvent, type AliasSaleCancelledEvent, type AliasSoldData, type AliasSoldEvent, type AliasTransferredData, type AliasTransferredEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, type AuditPolicySetData, type AuditPolicySetEvent, type AuditTrailRecordedData, type Auditor, type BatchDisclosureSubmission, type BatchRegisterVerificationKeysArgs, type BatchSubmitDisclosureProofsArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type BuyAliasArgs, type Bytes32, type ChainInfo, type ChainLink, type ChainLinkAddedEvent, type ChainLinkRemovedEvent, CircuitId, CircuitId as CircuitIdType, type ClientProviderConfig, type ConnectionStatus, CryptoPrecompiles, type DecodedAddChainLinkArgs, type DecodedApproveDisclosureArgs, type DecodedBatchArgs, type DecodedBatchSubmitDisclosureArgs, type DecodedDispatchAsPrivateLinkArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedPutAliasForSaleArgs, type DecodedRegisterAliasArgs, type DecodedRejectDisclosureArgs, type DecodedRemarkArgs, type DecodedRequestDisclosureArgs, type DecodedRevealPrivateLinkArgs, type DecodedSetAccountMetadataArgs, type DecodedSetAuditPolicyArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSubmitDisclosureArgs, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, type DiscloseArgs, type DisclosedEvent, type DisclosureApprovedData, type DisclosureCondition, type DisclosurePublicSignals, type DisclosureRecordRevokedEvent, type DisclosureRejectedData, type DisclosureRejectedEvent, type DisclosureRequestExpiredEvent, type DisclosureRequestedData, type DisclosureRequestedEvent, type DisclosureSubmittedData, type DisclosureVerifiedData, type DispatchAsLinkedAccountArgs, type DispatchAsLinkedParams, type DispatchAsPrivateLinkArgs, type DispatchError, type DispatchInfo, type DynamicBuilder, EncryptedMemo, type EndowedEventData, type EthereumExecutedData, type EventData, type EventPhase, type EventRecord, type EvmAddressInfo, type EvmBlock, EvmClient, type EvmExecutedData, type EvmExitReason, EvmExplorer, type EvmLog, type EvmSigner, type EvmTransaction, type EvmTxRequest, type EvmTxSummary, type ExtrinsicDecoder, type ExtrinsicFailedData, type ExtrinsicSuccessData, type FormatOptions, type IndexedBlock, type IndexedEvmTx, type IndexedExtrinsic, IndexerClient, type IndexerClientConfig, type IndexerStats, KNOWN_PRECOMPILES, type KnownPrecompileInfo, type ListingInfo, type MerkleRoot, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, type MetadataUpdatedEvent, NoteBuilder, type NoteInput, type NullifierStatusResult, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, type PaginatedResult, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateChainLinkAddedEvent, type PrivateChainLinkRemovedEvent, type PrivateChainLinkRevealedEvent, type PrivateLink, type PrivateLinkDispatchExecutedEvent, type PrivateTransfer, type PrivateTransferArgs, type PrivateTransferEvent, type PrivateTransferEventData, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type ProxyCallExecutedEvent, type PruneExpiredRequestArgs, type PutAliasOnSaleArgs, type PutOnSaleParams, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAliasArgs, type RegisterAssetArgs, type RegisterPrivateLinkArgs, type RegisterVerificationKeyArgs, type RejectDisclosureArgs, type RemoveChainLinkArgs, type RemovePrivateLinkArgs, type RemoveSupportedChainArgs, type RemoveVerificationKeyArgs, type RequestDisclosureArgs, type ReservedEventData, type ResolvedAlias, type RevealPrivateLinkArgs, type RevokeDisclosureRecordArgs, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SLIP0044_NAMESPACE, type ScanCommitment, type SetAccountMetadataArgs, type SetActiveVersionArgs, type SetAuditPolicyArgs, type SetMetadataParams, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldResult, type ShieldedAddressEvent, type ShieldedCommitment, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SignatureScheme, type SpentNullifier, type StatusChangeEvent, type StatusListener, SubstrateClient, type SupportedChain, type SupportedChainAddedEvent, type SupportedChainRemovedEvent, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferAliasArgs, type TransferEventData, type TxResult, type Unshield, type UnshieldArgs, type UnshieldParams, type UnshieldedEvent, type UnshieldedEventData, type UnverifyAssetArgs, type VerificationKeyRegisteredEvent, type VerificationKeyRemovedEvent, type VerifyAssetArgs, type VerifyProofArgs, type VkEntry, type ZkNote, type ZkVerifierCall, type ZkVerifierCircuitVersionInfo, type ZkVerifierEvent, type ZkVerifierHistoricalVersion, ZkVerifierModule, type ZkVerifierVersionStats, type ZkVerifierVkHash, accountIdHexToSs58, addressToAccountIdHex, bigintTo32Be, bigintTo32Le, bigintTo32LeArr, bytesToBigintLE, computePathIndices, decodePrecompileCalldata, decryptJson, deriveOwnerPk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessage, deriveVaultKey, deriveViewingKey, encryptJson, ensureHexPrefix, evmAddressToAccountId, evmToImplicitSubstrate, evmToMappedAccountHex, evmToSubstrate, formatBalance, formatORB, fromBase64, fromHex, getPrecompileLabel, hexToBigint, hexToNumber, implicitSubstrateToEvm, isEvmAddress, isImplicitEvmAccount, isSs58, isSubstrateAddress, isUnifiedAddress, leHexToBigint, mapExtrinsicArgs, mapZkEventData, normalizeEvmAddress, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, truncateMiddle, tryDecryptNote, vaultReplacer, vaultReviver };
4323
+ export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, type AddChainLinkArgs, type AddChainLinkParams, type AddSupportedChainArgs, type AliasFullIdentity, type AliasInfo, type AliasListedForSaleEvent, type AliasOnSaleData, type AliasRegisteredData, type AliasRegisteredEvent, type AliasReleasedEvent, type AliasSaleCancelledEvent, type AliasSoldData, type AliasSoldEvent, type AliasTransferredData, type AliasTransferredEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type BuyAliasArgs, type Bytes32, type ChainInfo, type ChainLink, type ChainLinkAddedEvent, type ChainLinkRemovedEvent, CircuitId, CircuitId as CircuitIdType, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedAddChainLinkArgs, type DecodedBatchArgs, type DecodedDispatchAsPrivateLinkArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedPutAliasForSaleArgs, type DecodedRegisterAliasArgs, type DecodedRemarkArgs, type DecodedRevealPrivateLinkArgs, type DecodedSetAccountMetadataArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, type DispatchAsLinkedAccountArgs, type DispatchAsLinkedParams, type DispatchAsPrivateLinkArgs, type DispatchError, type DispatchInfo, type DynamicBuilder, ENCRYPTED_MEMO_SIZE, EncryptedMemo, type EncryptedNoteRecord, type EndowedEventData, type EthereumExecutedData, type EventData, type EventPhase, type EventRecord, type EvmAddressInfo, type EvmBlock, EvmClient, type EvmExecutedData, type EvmExitReason, EvmExplorer, type EvmLog, type EvmSigner, type EvmTransaction, type EvmTxRequest, type EvmTxSummary, type ExtrinsicDecoder, type ExtrinsicFailedData, type ExtrinsicSuccessData, type FeeClaimProofInputs, type FormatOptions, type IndexedBlock, type IndexedEvmTx, type IndexedExtrinsic, IndexerClient, type IndexerClientConfig, type IndexerStats, KNOWN_PRECOMPILES, type KnownPrecompileInfo, type ListingInfo, type MerkleRoot, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, type MetadataUpdatedEvent, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifierStatusResult, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, type PaginatedResult, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateChainLinkAddedEvent, type PrivateChainLinkRemovedEvent, type PrivateChainLinkRevealedEvent, type PrivateLink, type PrivateLinkDispatchExecutedEvent, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type PrivateTransferTimestamp, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type ProxyCallExecutedEvent, type PutAliasOnSaleArgs, type PutOnSaleParams, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAliasArgs, type RegisterAssetArgs, type RegisterPrivateLinkArgs, type RegisterVerificationKeyArgs, type RegisteredAsset, type RelayFeeEvent, type RelayFeeSummaryEntry, type Relayer, type RelayerInfo, RelayerStatusModule, type RemoveChainLinkArgs, type RemovePrivateLinkArgs, type RemoveSupportedChainArgs, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedAlias, type RevealPrivateLinkArgs, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SLIP0044_NAMESPACE, type ScanCommitment, type SetAccountMetadataArgs, type SetActiveVersionArgs, type SetMetadataParams, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedAddressEvent, type ShieldedCommitment, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SignatureScheme, type SpentNullifier, type StatusChangeEvent, type StatusListener, type StealthScanHint, SubstrateClient, type SupportedChain, type SupportedChainAddedEvent, type SupportedChainRemovedEvent, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferAliasArgs, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TxResult, type UnsafeTxOptions, type Unshield, type UnshieldArgs, type UnshieldParams, type UnshieldProofInputs, type UnshieldedEvent, type UnshieldedEventData, type UnverifyAssetArgs, VaultLockedError, type VerificationKeyRegisteredEvent, type VerificationKeyRemovedEvent, type VerifyAssetArgs, type VerifyProofArgs, type VkEntry, type ZkNote, type ZkVerifierCall, type ZkVerifierCircuitVersionInfo, type ZkVerifierEvent, type ZkVerifierHistoricalVersion, ZkVerifierModule, type ZkVerifierVersionStats, type ZkVerifierVkHash, accountIdHexToSs58, addressToAccountIdHex, applyNoteStatus, bigintTo32Be, bigintTo32Le, bigintTo32LeArr, buildDummyTransferInput, bytesToBigintLE, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessage, deriveStealthOwnerPk, deriveStealthSk, deriveVaultKey, deriveViewingPublicKey, deriveViewingSecretKey, encryptJson, encryptNote, ensureHexPrefix, evmAddressToAccountId, evmToImplicitSubstrate, evmToMappedAccountHex, evmToSubstrate, formatBalance, formatORB, fromBase64, fromHex, generateFeeClaimProof, generateTransferProof, generateUnshieldProof, getPrecompileLabel, hexToBigint, hexToNumber, implicitSubstrateToEvm, isEvmAddress, isImplicitEvmAccount, isSs58, isSubstrateAddress, isUnifiedAddress, leHexToBigint, mapExtrinsicArgs, mapZkEventData, normalizeEvmAddress, randomBlinding, recoverOwnerPkPoint, selectNotes, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };