@orbinum/sdk 0.24.0 → 0.25.1

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
@@ -4,7 +4,7 @@ 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
6
  import { CircuitType, ArtifactProvider, ProofResult } from '@orbinum/proof-generator';
7
- export { ArtifactProvider, CircuitType, ProofResult, WebArtifactProvider } from '@orbinum/proof-generator';
7
+ export { ArtifactProvider, CircuitType, ProofResult, WebArtifactProvider, shouldProveSingleThreaded } from '@orbinum/proof-generator';
8
8
  export { AccountId, Blake2256, Keccak256, Storage, u128, u64 } from '@polkadot-api/substrate-bindings';
9
9
  export { base58 } from '@scure/base';
10
10
  export { getPolkadotSigner } from 'polkadot-api/signer';
@@ -1718,6 +1718,46 @@ interface SelfEphWindowEntry {
1718
1718
  */
1719
1719
  declare function selfEphWindow(spendingKey: bigint, ivkPacked: Uint8Array, from: number, count: number): SelfEphWindowEntry[];
1720
1720
 
1721
+ /**
1722
+ * The secret shared by a sender/receiver pair: ECDH between one side's viewing
1723
+ * SECRET key and the other side's viewing PUBLIC key. Symmetric — both parties
1724
+ * compute the same 32 bytes from opposite inputs, which is what lets the
1725
+ * sender choose an ephemeral the receiver can predict.
1726
+ *
1727
+ * @param myViewingSk 32-byte viewing secret key (from `deriveViewingSecretKey`).
1728
+ * @param theirIvkPacked 32-byte LE packed viewing public key of the other party.
1729
+ */
1730
+ declare function derivePairwiseSharedSecret(myViewingSk: Uint8Array, theirIvkPacked: Uint8Array): Uint8Array;
1731
+ /**
1732
+ * The ephemeral secret for the `index`-th note between this pair. Feed it to
1733
+ * `EncryptedMemo.encrypt` / `NoteBuilder.build` as `ephSkOverride`.
1734
+ */
1735
+ declare function derivePairwiseEphSk(pairSecret: Uint8Array, index: number): Uint8Array;
1736
+ /** One precomputed pairwise window entry — same shape as `SelfEphWindowEntry`. */
1737
+ interface PairwiseEphWindowEntry {
1738
+ index: number;
1739
+ /** 0x-prefixed LE-packed ephPk — byte-identical to the memo's last 32 bytes. */
1740
+ ephPkHex: string;
1741
+ /** ECDH shared secret vs the RECEIVER's ivk — feeds decryptWithSharedSecret. */
1742
+ sharedSecret: Uint8Array;
1743
+ }
1744
+ /**
1745
+ * Precomputes the discovery window [from, from+count) for one counterparty:
1746
+ * for each index, the ephPk that party would publish and the secret needed to
1747
+ * open the memo. One EC pass per sender up front; the scan then matches by hex
1748
+ * equality with no per-hint EC work.
1749
+ *
1750
+ * The cost is paid once per sender and reused across every page of the scan,
1751
+ * which is what makes it worth building — unlike a per-hint precompute, which
1752
+ * measured 26× SLOWER than just doing the multiplication.
1753
+ *
1754
+ * @param pairSecret From `derivePairwiseSharedSecret`.
1755
+ * @param receiverIvkPacked The RECEIVER's packed viewing public key — the memo
1756
+ * is encrypted to it, so the shared secret is against
1757
+ * that key regardless of which side is precomputing.
1758
+ */
1759
+ declare function pairwiseEphWindow(pairSecret: Uint8Array, receiverIvkPacked: Uint8Array, from: number, count: number): PairwiseEphWindowEntry[];
1760
+
1721
1761
  /**
1722
1762
  * NoteDecryptor
1723
1763
  *
@@ -1857,6 +1897,35 @@ declare function createNoteDisclosureKey(note: ZkNote): string;
1857
1897
  */
1858
1898
  declare function decodeNoteDisclosureKey(key: string): NoteDisclosure | null;
1859
1899
 
1900
+ /**
1901
+ * The options every proof entry point accepts.
1902
+ *
1903
+ * One declaration instead of the same inline object repeated per circuit: the
1904
+ * three generators differ in their INPUTS, never in how a caller configures
1905
+ * proving, and a shape written three times drifts on the fourth.
1906
+ */
1907
+
1908
+ interface ProofOptions {
1909
+ /** Where circuit artifacts come from. Defaults to the web provider. */
1910
+ provider?: ArtifactProvider;
1911
+ verbose?: boolean;
1912
+ /**
1913
+ * Prove on ONE thread instead of a Web Worker per logical core.
1914
+ *
1915
+ * Omit this. Left absent, `@orbinum/proof-generator` decides from the
1916
+ * device — and getting it wrong on a phone is not a slow proof but no proof
1917
+ * at all: `ffjavascript` spawns one worker per core, each with its own
1918
+ * `WebAssembly.Memory`, and a mobile browser's per-tab budget cannot hold
1919
+ * them. The transfer of the WASM buffer then fails with
1920
+ * `Data cannot be cloned, out of memory`.
1921
+ *
1922
+ * Pass it only when the host knows better than the heuristic — a desktop
1923
+ * app certain of its environment, or a benchmark pinning one mode. The
1924
+ * proof is byte-identical either way; only the wall-clock changes.
1925
+ */
1926
+ singleThread?: boolean;
1927
+ }
1928
+
1860
1929
  /** A single input note for a private transfer. */
1861
1930
  interface TransferInputNote {
1862
1931
  nullifier: bigint;
@@ -1894,10 +1963,7 @@ interface PrivateTransferProofInputs {
1894
1963
  /**
1895
1964
  * Generate a Groth16 proof for a PrivateTransfer operation.
1896
1965
  */
1897
- declare function generateTransferProof(params: PrivateTransferProofInputs, options?: {
1898
- provider?: ArtifactProvider;
1899
- verbose?: boolean;
1900
- }): Promise<ProofResult>;
1966
+ declare function generateTransferProof(params: PrivateTransferProofInputs, options?: ProofOptions): Promise<ProofResult>;
1901
1967
 
1902
1968
  /**
1903
1969
  * Forest tree a note belongs to.
@@ -2550,10 +2616,7 @@ interface UnshieldProofResult extends ProofResult {
2550
2616
  * @param options.provider - Override the artifact provider (default: CDN).
2551
2617
  * @param options.verbose - Log proof generation steps to console.
2552
2618
  */
2553
- declare function generateUnshieldProof(inputs: UnshieldProofInputs, options?: {
2554
- provider?: ArtifactProvider;
2555
- verbose?: boolean;
2556
- }): Promise<UnshieldProofResult>;
2619
+ declare function generateUnshieldProof(inputs: UnshieldProofInputs, options?: ProofOptions): Promise<UnshieldProofResult>;
2557
2620
 
2558
2621
  /**
2559
2622
  * Inputs required to generate a fee-claim proof.
@@ -2603,10 +2666,7 @@ interface FeeClaimProofOutput {
2603
2666
  * @param options.provider - Override the artifact provider (default: CDN).
2604
2667
  * @param options.verbose - Log proof generation steps to console.
2605
2668
  */
2606
- declare function generateFeeClaimProof(inputs: FeeClaimProofInputs, options?: {
2607
- provider?: ArtifactProvider;
2608
- verbose?: boolean;
2609
- }): Promise<FeeClaimProofOutput>;
2669
+ declare function generateFeeClaimProof(inputs: FeeClaimProofInputs, options?: ProofOptions): Promise<FeeClaimProofOutput>;
2610
2670
 
2611
2671
  /**
2612
2672
  * Contract addresses and function selectors for all Orbinum EVM precompiles.
@@ -3564,4 +3624,4 @@ interface ExtrinsicFailedData {
3564
3624
  dispatch_info: DispatchInfo;
3565
3625
  }
3566
3626
 
3567
- export { type ActiveVersionSetEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type Bytes32, CURRENT_CIRCUIT_VERSION, type ChainInfo, CircuitId, CircuitId as CircuitIdType, CircuitVersionResolver, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedBatchArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedRemarkArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, 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, KNOWN_PRECOMPILES, type KnownPrecompileInfo, MIN_SIGNATURE_BYTES, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAssetArgs, type RegisterVerificationKeyArgs, type RelayerInfo, RelayerStatusModule, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedSpendVersion, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SPENDING_KEY_VERIFYING_CONTRACT, SPENDING_KEY_WARNING, type ScanCommitment, type SelfEphWindowEntry, type SetActiveVersionArgs, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, type SpendingKeyTypedData, type StatusChangeEvent, type StatusListener, SubstrateClient, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TryDecryptOptions, type TxResult, type UnsafeTxOptions, 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, blindTag, buildDummyTransferInput, bytesToBigintLE, canonicalAccountId, computeNoteCommitment, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, deriveSelfEphSk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessageV2, deriveSpendingKeyTypedData, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, deriveVaultKey, deriveViewTag, 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, noteBlindTag, randomBlinding, recoverOwnerPkPoint, selectNotes, selfEphWindow, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, treeIdOf, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
3627
+ export { type ActiveVersionSetEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type Bytes32, CURRENT_CIRCUIT_VERSION, type ChainInfo, CircuitId, CircuitId as CircuitIdType, CircuitVersionResolver, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedBatchArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedRemarkArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, 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, KNOWN_PRECOMPILES, type KnownPrecompileInfo, MIN_SIGNATURE_BYTES, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, type PairwiseEphWindowEntry, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type ProofOptions, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAssetArgs, type RegisterVerificationKeyArgs, type RelayerInfo, RelayerStatusModule, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedSpendVersion, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SPENDING_KEY_VERIFYING_CONTRACT, SPENDING_KEY_WARNING, type ScanCommitment, type SelfEphWindowEntry, type SetActiveVersionArgs, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, type SpendingKeyTypedData, type StatusChangeEvent, type StatusListener, SubstrateClient, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TryDecryptOptions, type TxResult, type UnsafeTxOptions, 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, blindTag, buildDummyTransferInput, bytesToBigintLE, canonicalAccountId, computeNoteCommitment, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, derivePairwiseEphSk, derivePairwiseSharedSecret, deriveSelfEphSk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessageV2, deriveSpendingKeyTypedData, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, deriveVaultKey, deriveViewTag, 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, noteBlindTag, pairwiseEphWindow, randomBlinding, recoverOwnerPkPoint, selectNotes, selfEphWindow, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, treeIdOf, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ 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
6
  import { CircuitType, ArtifactProvider, ProofResult } from '@orbinum/proof-generator';
7
- export { ArtifactProvider, CircuitType, ProofResult, WebArtifactProvider } from '@orbinum/proof-generator';
7
+ export { ArtifactProvider, CircuitType, ProofResult, WebArtifactProvider, shouldProveSingleThreaded } from '@orbinum/proof-generator';
8
8
  export { AccountId, Blake2256, Keccak256, Storage, u128, u64 } from '@polkadot-api/substrate-bindings';
9
9
  export { base58 } from '@scure/base';
10
10
  export { getPolkadotSigner } from 'polkadot-api/signer';
@@ -1718,6 +1718,46 @@ interface SelfEphWindowEntry {
1718
1718
  */
1719
1719
  declare function selfEphWindow(spendingKey: bigint, ivkPacked: Uint8Array, from: number, count: number): SelfEphWindowEntry[];
1720
1720
 
1721
+ /**
1722
+ * The secret shared by a sender/receiver pair: ECDH between one side's viewing
1723
+ * SECRET key and the other side's viewing PUBLIC key. Symmetric — both parties
1724
+ * compute the same 32 bytes from opposite inputs, which is what lets the
1725
+ * sender choose an ephemeral the receiver can predict.
1726
+ *
1727
+ * @param myViewingSk 32-byte viewing secret key (from `deriveViewingSecretKey`).
1728
+ * @param theirIvkPacked 32-byte LE packed viewing public key of the other party.
1729
+ */
1730
+ declare function derivePairwiseSharedSecret(myViewingSk: Uint8Array, theirIvkPacked: Uint8Array): Uint8Array;
1731
+ /**
1732
+ * The ephemeral secret for the `index`-th note between this pair. Feed it to
1733
+ * `EncryptedMemo.encrypt` / `NoteBuilder.build` as `ephSkOverride`.
1734
+ */
1735
+ declare function derivePairwiseEphSk(pairSecret: Uint8Array, index: number): Uint8Array;
1736
+ /** One precomputed pairwise window entry — same shape as `SelfEphWindowEntry`. */
1737
+ interface PairwiseEphWindowEntry {
1738
+ index: number;
1739
+ /** 0x-prefixed LE-packed ephPk — byte-identical to the memo's last 32 bytes. */
1740
+ ephPkHex: string;
1741
+ /** ECDH shared secret vs the RECEIVER's ivk — feeds decryptWithSharedSecret. */
1742
+ sharedSecret: Uint8Array;
1743
+ }
1744
+ /**
1745
+ * Precomputes the discovery window [from, from+count) for one counterparty:
1746
+ * for each index, the ephPk that party would publish and the secret needed to
1747
+ * open the memo. One EC pass per sender up front; the scan then matches by hex
1748
+ * equality with no per-hint EC work.
1749
+ *
1750
+ * The cost is paid once per sender and reused across every page of the scan,
1751
+ * which is what makes it worth building — unlike a per-hint precompute, which
1752
+ * measured 26× SLOWER than just doing the multiplication.
1753
+ *
1754
+ * @param pairSecret From `derivePairwiseSharedSecret`.
1755
+ * @param receiverIvkPacked The RECEIVER's packed viewing public key — the memo
1756
+ * is encrypted to it, so the shared secret is against
1757
+ * that key regardless of which side is precomputing.
1758
+ */
1759
+ declare function pairwiseEphWindow(pairSecret: Uint8Array, receiverIvkPacked: Uint8Array, from: number, count: number): PairwiseEphWindowEntry[];
1760
+
1721
1761
  /**
1722
1762
  * NoteDecryptor
1723
1763
  *
@@ -1857,6 +1897,35 @@ declare function createNoteDisclosureKey(note: ZkNote): string;
1857
1897
  */
1858
1898
  declare function decodeNoteDisclosureKey(key: string): NoteDisclosure | null;
1859
1899
 
1900
+ /**
1901
+ * The options every proof entry point accepts.
1902
+ *
1903
+ * One declaration instead of the same inline object repeated per circuit: the
1904
+ * three generators differ in their INPUTS, never in how a caller configures
1905
+ * proving, and a shape written three times drifts on the fourth.
1906
+ */
1907
+
1908
+ interface ProofOptions {
1909
+ /** Where circuit artifacts come from. Defaults to the web provider. */
1910
+ provider?: ArtifactProvider;
1911
+ verbose?: boolean;
1912
+ /**
1913
+ * Prove on ONE thread instead of a Web Worker per logical core.
1914
+ *
1915
+ * Omit this. Left absent, `@orbinum/proof-generator` decides from the
1916
+ * device — and getting it wrong on a phone is not a slow proof but no proof
1917
+ * at all: `ffjavascript` spawns one worker per core, each with its own
1918
+ * `WebAssembly.Memory`, and a mobile browser's per-tab budget cannot hold
1919
+ * them. The transfer of the WASM buffer then fails with
1920
+ * `Data cannot be cloned, out of memory`.
1921
+ *
1922
+ * Pass it only when the host knows better than the heuristic — a desktop
1923
+ * app certain of its environment, or a benchmark pinning one mode. The
1924
+ * proof is byte-identical either way; only the wall-clock changes.
1925
+ */
1926
+ singleThread?: boolean;
1927
+ }
1928
+
1860
1929
  /** A single input note for a private transfer. */
1861
1930
  interface TransferInputNote {
1862
1931
  nullifier: bigint;
@@ -1894,10 +1963,7 @@ interface PrivateTransferProofInputs {
1894
1963
  /**
1895
1964
  * Generate a Groth16 proof for a PrivateTransfer operation.
1896
1965
  */
1897
- declare function generateTransferProof(params: PrivateTransferProofInputs, options?: {
1898
- provider?: ArtifactProvider;
1899
- verbose?: boolean;
1900
- }): Promise<ProofResult>;
1966
+ declare function generateTransferProof(params: PrivateTransferProofInputs, options?: ProofOptions): Promise<ProofResult>;
1901
1967
 
1902
1968
  /**
1903
1969
  * Forest tree a note belongs to.
@@ -2550,10 +2616,7 @@ interface UnshieldProofResult extends ProofResult {
2550
2616
  * @param options.provider - Override the artifact provider (default: CDN).
2551
2617
  * @param options.verbose - Log proof generation steps to console.
2552
2618
  */
2553
- declare function generateUnshieldProof(inputs: UnshieldProofInputs, options?: {
2554
- provider?: ArtifactProvider;
2555
- verbose?: boolean;
2556
- }): Promise<UnshieldProofResult>;
2619
+ declare function generateUnshieldProof(inputs: UnshieldProofInputs, options?: ProofOptions): Promise<UnshieldProofResult>;
2557
2620
 
2558
2621
  /**
2559
2622
  * Inputs required to generate a fee-claim proof.
@@ -2603,10 +2666,7 @@ interface FeeClaimProofOutput {
2603
2666
  * @param options.provider - Override the artifact provider (default: CDN).
2604
2667
  * @param options.verbose - Log proof generation steps to console.
2605
2668
  */
2606
- declare function generateFeeClaimProof(inputs: FeeClaimProofInputs, options?: {
2607
- provider?: ArtifactProvider;
2608
- verbose?: boolean;
2609
- }): Promise<FeeClaimProofOutput>;
2669
+ declare function generateFeeClaimProof(inputs: FeeClaimProofInputs, options?: ProofOptions): Promise<FeeClaimProofOutput>;
2610
2670
 
2611
2671
  /**
2612
2672
  * Contract addresses and function selectors for all Orbinum EVM precompiles.
@@ -3564,4 +3624,4 @@ interface ExtrinsicFailedData {
3564
3624
  dispatch_info: DispatchInfo;
3565
3625
  }
3566
3626
 
3567
- export { type ActiveVersionSetEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type Bytes32, CURRENT_CIRCUIT_VERSION, type ChainInfo, CircuitId, CircuitId as CircuitIdType, CircuitVersionResolver, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedBatchArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedRemarkArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, 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, KNOWN_PRECOMPILES, type KnownPrecompileInfo, MIN_SIGNATURE_BYTES, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAssetArgs, type RegisterVerificationKeyArgs, type RelayerInfo, RelayerStatusModule, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedSpendVersion, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SPENDING_KEY_VERIFYING_CONTRACT, SPENDING_KEY_WARNING, type ScanCommitment, type SelfEphWindowEntry, type SetActiveVersionArgs, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, type SpendingKeyTypedData, type StatusChangeEvent, type StatusListener, SubstrateClient, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TryDecryptOptions, type TxResult, type UnsafeTxOptions, 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, blindTag, buildDummyTransferInput, bytesToBigintLE, canonicalAccountId, computeNoteCommitment, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, deriveSelfEphSk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessageV2, deriveSpendingKeyTypedData, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, deriveVaultKey, deriveViewTag, 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, noteBlindTag, randomBlinding, recoverOwnerPkPoint, selectNotes, selfEphWindow, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, treeIdOf, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
3627
+ export { type ActiveVersionSetEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type Bytes32, CURRENT_CIRCUIT_VERSION, type ChainInfo, CircuitId, CircuitId as CircuitIdType, CircuitVersionResolver, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedBatchArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedRemarkArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, 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, KNOWN_PRECOMPILES, type KnownPrecompileInfo, MIN_SIGNATURE_BYTES, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, type PairwiseEphWindowEntry, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type ProofOptions, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAssetArgs, type RegisterVerificationKeyArgs, type RelayerInfo, RelayerStatusModule, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedSpendVersion, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SPENDING_KEY_VERIFYING_CONTRACT, SPENDING_KEY_WARNING, type ScanCommitment, type SelfEphWindowEntry, type SetActiveVersionArgs, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, type SpendingKeyTypedData, type StatusChangeEvent, type StatusListener, SubstrateClient, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TryDecryptOptions, type TxResult, type UnsafeTxOptions, 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, blindTag, buildDummyTransferInput, bytesToBigintLE, canonicalAccountId, computeNoteCommitment, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, derivePairwiseEphSk, derivePairwiseSharedSecret, deriveSelfEphSk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessageV2, deriveSpendingKeyTypedData, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, deriveVaultKey, deriveViewTag, 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, noteBlindTag, pairwiseEphWindow, randomBlinding, recoverOwnerPkPoint, selectNotes, selfEphWindow, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, treeIdOf, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
package/dist/index.js CHANGED
@@ -74,6 +74,8 @@ __export(index_exports, {
74
74
  decryptNoteRecord: () => decryptNoteRecord,
75
75
  deriveMasterKeyBytes: () => deriveMasterKeyBytes,
76
76
  deriveOwnerPk: () => deriveOwnerPk,
77
+ derivePairwiseEphSk: () => derivePairwiseEphSk,
78
+ derivePairwiseSharedSecret: () => derivePairwiseSharedSecret,
77
79
  deriveSelfEphSk: () => deriveSelfEphSk,
78
80
  deriveSpendingKeyFromSignature: () => deriveSpendingKeyFromSignature,
79
81
  deriveSpendingKeyMessageV2: () => deriveSpendingKeyMessageV2,
@@ -117,11 +119,13 @@ __export(index_exports, {
117
119
  mapZkEventData: () => mapZkEventData,
118
120
  normalizeEvmAddress: () => normalizeEvmAddress,
119
121
  noteBlindTag: () => noteBlindTag,
122
+ pairwiseEphWindow: () => pairwiseEphWindow,
120
123
  randomBlinding: () => randomBlinding,
121
124
  recoverOwnerPkPoint: () => recoverOwnerPkPoint,
122
125
  selectNotes: () => selectNotes,
123
126
  selfEphWindow: () => selfEphWindow,
124
127
  shortHash: () => shortHash,
128
+ shouldProveSingleThreaded: () => import_proof_generator5.shouldProveSingleThreaded,
125
129
  substrateSs58ToAccountIdHex: () => substrateSs58ToAccountIdHex,
126
130
  substrateToEvm: () => substrateToEvm,
127
131
  toBase64: () => toBase64,
@@ -3307,6 +3311,42 @@ function selfEphWindow(spendingKey, ivkPacked, from, count) {
3307
3311
  return entries;
3308
3312
  }
3309
3313
 
3314
+ // src/shielded-pool/protocol/pairwiseEph.ts
3315
+ var import_sha24 = require("@noble/hashes/sha2.js");
3316
+ var import_baby_jubjub6 = require("@zk-kit/baby-jubjub");
3317
+ var PAIRWISE_EPH_DOMAIN = new TextEncoder().encode("orbinum-pairwise-eph-v1");
3318
+ function derivePairwiseSharedSecret(myViewingSk, theirIvkPacked) {
3319
+ const theirPoint = (0, import_baby_jubjub6.unpackPoint)(bytesToBigintLE(theirIvkPacked));
3320
+ if (!theirPoint) throw new Error("derivePairwiseSharedSecret: invalid viewing public key");
3321
+ const shared = fastMulPoint(theirPoint, bytesToBjjScalar(myViewingSk));
3322
+ return bigintTo32Le(shared[0]);
3323
+ }
3324
+ function derivePairwiseEphSk(pairSecret, index) {
3325
+ const h = import_sha24.sha256.create();
3326
+ h.update(PAIRWISE_EPH_DOMAIN);
3327
+ h.update(pairSecret);
3328
+ const idx = new Uint8Array(4);
3329
+ new DataView(idx.buffer).setUint32(0, index >>> 0, true);
3330
+ h.update(idx);
3331
+ return h.digest();
3332
+ }
3333
+ function pairwiseEphWindow(pairSecret, receiverIvkPacked, from, count) {
3334
+ const ivkPoint = (0, import_baby_jubjub6.unpackPoint)(bytesToBigintLE(receiverIvkPacked));
3335
+ if (!ivkPoint) throw new Error("pairwiseEphWindow: invalid viewing public key");
3336
+ const entries = [];
3337
+ for (let i = from; i < from + count; i++) {
3338
+ const scalar = bytesToBjjScalar(derivePairwiseEphSk(pairSecret, i));
3339
+ const ephPk = fastMulBase(scalar);
3340
+ const sharedPoint = fastMulPoint(ivkPoint, scalar);
3341
+ entries.push({
3342
+ index: i,
3343
+ ephPkHex: toHex(bigintTo32Le((0, import_baby_jubjub6.packPoint)(ephPk))),
3344
+ sharedSecret: bigintTo32Le(sharedPoint[0])
3345
+ });
3346
+ }
3347
+ return entries;
3348
+ }
3349
+
3310
3350
  // src/shielded-pool/protocol/NoteDecryptor.ts
3311
3351
  var import_poseidon_lite2 = require("poseidon-lite");
3312
3352
  function computeNullifier(commitment, spendingKey) {
@@ -3539,8 +3579,8 @@ ${canonicalAccountId(address)}`;
3539
3579
 
3540
3580
  // src/privacy-keys/PrivacyKeys.ts
3541
3581
  var import_hkdf2 = require("@noble/hashes/hkdf.js");
3542
- var import_sha24 = require("@noble/hashes/sha2.js");
3543
- var import_baby_jubjub6 = require("@zk-kit/baby-jubjub");
3582
+ var import_sha25 = require("@noble/hashes/sha2.js");
3583
+ var import_baby_jubjub7 = require("@zk-kit/baby-jubjub");
3544
3584
  var IVK_DOMAIN = new TextEncoder().encode("orbinum-ivk-v1");
3545
3585
  var KEY_VERSION = "v2";
3546
3586
  var MIN_SIGNATURE_BYTES = 32;
@@ -3557,7 +3597,7 @@ async function deriveMasterKeyBytes(signatureHex, chainId, address) {
3557
3597
  const info = new TextEncoder().encode(
3558
3598
  `orbinum-sk-${KEY_VERSION}:${chainId}:${canonicalAccountId(address)}`
3559
3599
  );
3560
- return (0, import_hkdf2.hkdf)(import_sha24.sha256, sigBytes, new Uint8Array(0), info, 32);
3600
+ return (0, import_hkdf2.hkdf)(import_sha25.sha256, sigBytes, new Uint8Array(0), info, 32);
3561
3601
  }
3562
3602
  async function deriveSpendingKeyFromSignature(signatureHex, chainId, address) {
3563
3603
  const masterBytes = await deriveMasterKeyBytes(signatureHex, chainId, address);
@@ -3566,12 +3606,12 @@ async function deriveSpendingKeyFromSignature(signatureHex, chainId, address) {
3566
3606
  }
3567
3607
  function deriveViewingSecretKey(spendingKey) {
3568
3608
  const ikm = bigintTo32Le(spendingKey);
3569
- return (0, import_hkdf2.hkdf)(import_sha24.sha256, ikm, void 0, IVK_DOMAIN, 32);
3609
+ return (0, import_hkdf2.hkdf)(import_sha25.sha256, ikm, void 0, IVK_DOMAIN, 32);
3570
3610
  }
3571
3611
  function deriveViewingPublicKey(ivsk) {
3572
3612
  const ivskScalar = BigInt(toHex(ivsk)) % BABYJUB_SUBORDER || 1n;
3573
3613
  const ivkPoint = fastMulBase(ivskScalar);
3574
- const packed = (0, import_baby_jubjub6.packPoint)(ivkPoint);
3614
+ const packed = (0, import_baby_jubjub7.packPoint)(ivkPoint);
3575
3615
  return bigintTo32Le(packed);
3576
3616
  }
3577
3617
  function deriveOwnerPk(spendingKey) {
@@ -3885,7 +3925,7 @@ async function noteBlindTag(blindKey, hex) {
3885
3925
  // src/proof-generator/unshield.ts
3886
3926
  var import_proof_generator2 = require("@orbinum/proof-generator");
3887
3927
  var import_utils3 = require("@noble/ciphers/utils.js");
3888
- var import_baby_jubjub7 = require("@zk-kit/baby-jubjub");
3928
+ var import_baby_jubjub8 = require("@zk-kit/baby-jubjub");
3889
3929
  var import_poseidon_lite4 = require("poseidon-lite");
3890
3930
 
3891
3931
  // src/proof-generator/merkle.ts
@@ -3896,6 +3936,15 @@ function merkleProofToCircuit(siblings, leafIndex) {
3896
3936
  return { elements, indices };
3897
3937
  }
3898
3938
 
3939
+ // src/proof-generator/options.ts
3940
+ function toGenerateOptions(provider, options) {
3941
+ return {
3942
+ provider,
3943
+ ...options.verbose !== void 0 ? { verbose: options.verbose } : {},
3944
+ ...options.singleThread !== void 0 ? { singleThread: options.singleThread } : {}
3945
+ };
3946
+ }
3947
+
3899
3948
  // src/proof-generator/unshield.ts
3900
3949
  async function generateUnshieldProof(inputs, options = {}) {
3901
3950
  const { elements, indices } = merkleProofToCircuit(inputs.pathSiblings, inputs.leafIndex);
@@ -3908,7 +3957,7 @@ async function generateUnshieldProof(inputs, options = {}) {
3908
3957
  if (changeValue < 0n) {
3909
3958
  throw new Error("changeValue must be >= 0.");
3910
3959
  }
3911
- const changeOwnerPubkey = inputs.changeOwnerPubkey ?? (0, import_baby_jubjub7.mulPointEscalar)(import_baby_jubjub7.Base8, inputs.spendingKey)[0];
3960
+ const changeOwnerPubkey = inputs.changeOwnerPubkey ?? (0, import_baby_jubjub8.mulPointEscalar)(import_baby_jubjub8.Base8, inputs.spendingKey)[0];
3912
3961
  const changeBlinding = inputs.changeBlinding ?? (changeValue > 0n ? bytesToBigintLE((0, import_utils3.randomBytes)(32)) : 0n);
3913
3962
  const changeCommitment = changeValue > 0n ? (0, import_poseidon_lite4.poseidon4)([changeValue, inputs.assetId, changeOwnerPubkey, changeBlinding]) : 0n;
3914
3963
  const circuitInputs = {
@@ -3930,8 +3979,7 @@ async function generateUnshieldProof(inputs, options = {}) {
3930
3979
  change_owner_pubkey: changeOwnerPubkey.toString()
3931
3980
  };
3932
3981
  const provider = options.provider ?? new import_proof_generator2.WebArtifactProvider();
3933
- const opts = { provider };
3934
- if (options.verbose !== void 0) opts.verbose = options.verbose;
3982
+ const opts = toGenerateOptions(provider, options);
3935
3983
  const proofResult = await (0, import_proof_generator2.generateProof)(import_proof_generator2.CircuitType.Unshield, circuitInputs, opts);
3936
3984
  return { ...proofResult, changeCommitment, changeValue, changeBlinding, changeOwnerPubkey };
3937
3985
  }
@@ -3963,8 +4011,7 @@ async function generateTransferProof(params, options = {}) {
3963
4011
  output_blindings: [o0.blinding.toString(), o1.blinding.toString()]
3964
4012
  };
3965
4013
  const provider = options.provider ?? new import_proof_generator3.WebArtifactProvider();
3966
- const opts = { provider };
3967
- if (options.verbose !== void 0) opts.verbose = options.verbose;
4014
+ const opts = toGenerateOptions(provider, options);
3968
4015
  return (0, import_proof_generator3.generateProof)(import_proof_generator3.CircuitType.Transfer, circuitInputs, opts);
3969
4016
  }
3970
4017
 
@@ -3982,8 +4029,7 @@ async function generateFeeClaimProof(inputs, options = {}) {
3982
4029
  blinding: inputs.blinding.toString()
3983
4030
  };
3984
4031
  const provider = options.provider ?? new import_proof_generator4.WebArtifactProvider();
3985
- const opts = { provider };
3986
- if (options.verbose !== void 0) opts.verbose = options.verbose;
4032
+ const opts = toGenerateOptions(provider, options);
3987
4033
  const proofResult = await (0, import_proof_generator4.generateProof)(import_proof_generator4.CircuitType.ValueProof, circuitInputs, opts);
3988
4034
  const [sigCommitment, sigValue, sigAssetId, sigOwnerHash] = proofResult.publicSignals.map(BigInt);
3989
4035
  const buf = new Uint8Array(76);
@@ -3997,6 +4043,9 @@ async function generateFeeClaimProof(inputs, options = {}) {
3997
4043
  };
3998
4044
  }
3999
4045
 
4046
+ // src/proof-generator/index.ts
4047
+ var import_proof_generator5 = require("@orbinum/proof-generator");
4048
+
4000
4049
  // src/precompiles/decode.ts
4001
4050
  function decodePrecompileCalldata(address, input) {
4002
4051
  const info = KNOWN_PRECOMPILES[address.toLowerCase()];
@@ -4619,6 +4668,8 @@ var import_polkadot_api4 = require("polkadot-api");
4619
4668
  decryptNoteRecord,
4620
4669
  deriveMasterKeyBytes,
4621
4670
  deriveOwnerPk,
4671
+ derivePairwiseEphSk,
4672
+ derivePairwiseSharedSecret,
4622
4673
  deriveSelfEphSk,
4623
4674
  deriveSpendingKeyFromSignature,
4624
4675
  deriveSpendingKeyMessageV2,
@@ -4662,11 +4713,13 @@ var import_polkadot_api4 = require("polkadot-api");
4662
4713
  mapZkEventData,
4663
4714
  normalizeEvmAddress,
4664
4715
  noteBlindTag,
4716
+ pairwiseEphWindow,
4665
4717
  randomBlinding,
4666
4718
  recoverOwnerPkPoint,
4667
4719
  selectNotes,
4668
4720
  selfEphWindow,
4669
4721
  shortHash,
4722
+ shouldProveSingleThreaded,
4670
4723
  substrateSs58ToAccountIdHex,
4671
4724
  substrateToEvm,
4672
4725
  toBase64,
package/dist/index.mjs CHANGED
@@ -3173,6 +3173,42 @@ function selfEphWindow(spendingKey, ivkPacked, from, count) {
3173
3173
  return entries;
3174
3174
  }
3175
3175
 
3176
+ // src/shielded-pool/protocol/pairwiseEph.ts
3177
+ import { sha256 as sha2564 } from "@noble/hashes/sha2.js";
3178
+ import { packPoint as packPoint3, unpackPoint as unpackPoint4 } from "@zk-kit/baby-jubjub";
3179
+ var PAIRWISE_EPH_DOMAIN = new TextEncoder().encode("orbinum-pairwise-eph-v1");
3180
+ function derivePairwiseSharedSecret(myViewingSk, theirIvkPacked) {
3181
+ const theirPoint = unpackPoint4(bytesToBigintLE(theirIvkPacked));
3182
+ if (!theirPoint) throw new Error("derivePairwiseSharedSecret: invalid viewing public key");
3183
+ const shared = fastMulPoint(theirPoint, bytesToBjjScalar(myViewingSk));
3184
+ return bigintTo32Le(shared[0]);
3185
+ }
3186
+ function derivePairwiseEphSk(pairSecret, index) {
3187
+ const h = sha2564.create();
3188
+ h.update(PAIRWISE_EPH_DOMAIN);
3189
+ h.update(pairSecret);
3190
+ const idx = new Uint8Array(4);
3191
+ new DataView(idx.buffer).setUint32(0, index >>> 0, true);
3192
+ h.update(idx);
3193
+ return h.digest();
3194
+ }
3195
+ function pairwiseEphWindow(pairSecret, receiverIvkPacked, from, count) {
3196
+ const ivkPoint = unpackPoint4(bytesToBigintLE(receiverIvkPacked));
3197
+ if (!ivkPoint) throw new Error("pairwiseEphWindow: invalid viewing public key");
3198
+ const entries = [];
3199
+ for (let i = from; i < from + count; i++) {
3200
+ const scalar = bytesToBjjScalar(derivePairwiseEphSk(pairSecret, i));
3201
+ const ephPk = fastMulBase(scalar);
3202
+ const sharedPoint = fastMulPoint(ivkPoint, scalar);
3203
+ entries.push({
3204
+ index: i,
3205
+ ephPkHex: toHex(bigintTo32Le(packPoint3(ephPk))),
3206
+ sharedSecret: bigintTo32Le(sharedPoint[0])
3207
+ });
3208
+ }
3209
+ return entries;
3210
+ }
3211
+
3176
3212
  // src/shielded-pool/protocol/NoteDecryptor.ts
3177
3213
  import { poseidon2 as poseidon22, poseidon4 as poseidon42 } from "poseidon-lite";
3178
3214
  function computeNullifier(commitment, spendingKey) {
@@ -3405,8 +3441,8 @@ ${canonicalAccountId(address)}`;
3405
3441
 
3406
3442
  // src/privacy-keys/PrivacyKeys.ts
3407
3443
  import { hkdf as hkdf2 } from "@noble/hashes/hkdf.js";
3408
- import { sha256 as sha2564 } from "@noble/hashes/sha2.js";
3409
- import { packPoint as packPoint3 } from "@zk-kit/baby-jubjub";
3444
+ import { sha256 as sha2565 } from "@noble/hashes/sha2.js";
3445
+ import { packPoint as packPoint4 } from "@zk-kit/baby-jubjub";
3410
3446
  var IVK_DOMAIN = new TextEncoder().encode("orbinum-ivk-v1");
3411
3447
  var KEY_VERSION = "v2";
3412
3448
  var MIN_SIGNATURE_BYTES = 32;
@@ -3423,7 +3459,7 @@ async function deriveMasterKeyBytes(signatureHex, chainId, address) {
3423
3459
  const info = new TextEncoder().encode(
3424
3460
  `orbinum-sk-${KEY_VERSION}:${chainId}:${canonicalAccountId(address)}`
3425
3461
  );
3426
- return hkdf2(sha2564, sigBytes, new Uint8Array(0), info, 32);
3462
+ return hkdf2(sha2565, sigBytes, new Uint8Array(0), info, 32);
3427
3463
  }
3428
3464
  async function deriveSpendingKeyFromSignature(signatureHex, chainId, address) {
3429
3465
  const masterBytes = await deriveMasterKeyBytes(signatureHex, chainId, address);
@@ -3432,12 +3468,12 @@ async function deriveSpendingKeyFromSignature(signatureHex, chainId, address) {
3432
3468
  }
3433
3469
  function deriveViewingSecretKey(spendingKey) {
3434
3470
  const ikm = bigintTo32Le(spendingKey);
3435
- return hkdf2(sha2564, ikm, void 0, IVK_DOMAIN, 32);
3471
+ return hkdf2(sha2565, ikm, void 0, IVK_DOMAIN, 32);
3436
3472
  }
3437
3473
  function deriveViewingPublicKey(ivsk) {
3438
3474
  const ivskScalar = BigInt(toHex(ivsk)) % BABYJUB_SUBORDER || 1n;
3439
3475
  const ivkPoint = fastMulBase(ivskScalar);
3440
- const packed = packPoint3(ivkPoint);
3476
+ const packed = packPoint4(ivkPoint);
3441
3477
  return bigintTo32Le(packed);
3442
3478
  }
3443
3479
  function deriveOwnerPk(spendingKey) {
@@ -3766,6 +3802,15 @@ function merkleProofToCircuit(siblings, leafIndex) {
3766
3802
  return { elements, indices };
3767
3803
  }
3768
3804
 
3805
+ // src/proof-generator/options.ts
3806
+ function toGenerateOptions(provider, options) {
3807
+ return {
3808
+ provider,
3809
+ ...options.verbose !== void 0 ? { verbose: options.verbose } : {},
3810
+ ...options.singleThread !== void 0 ? { singleThread: options.singleThread } : {}
3811
+ };
3812
+ }
3813
+
3769
3814
  // src/proof-generator/unshield.ts
3770
3815
  async function generateUnshieldProof(inputs, options = {}) {
3771
3816
  const { elements, indices } = merkleProofToCircuit(inputs.pathSiblings, inputs.leafIndex);
@@ -3800,8 +3845,7 @@ async function generateUnshieldProof(inputs, options = {}) {
3800
3845
  change_owner_pubkey: changeOwnerPubkey.toString()
3801
3846
  };
3802
3847
  const provider = options.provider ?? new WebArtifactProvider2();
3803
- const opts = { provider };
3804
- if (options.verbose !== void 0) opts.verbose = options.verbose;
3848
+ const opts = toGenerateOptions(provider, options);
3805
3849
  const proofResult = await generateProof(CircuitType2.Unshield, circuitInputs, opts);
3806
3850
  return { ...proofResult, changeCommitment, changeValue, changeBlinding, changeOwnerPubkey };
3807
3851
  }
@@ -3837,8 +3881,7 @@ async function generateTransferProof(params, options = {}) {
3837
3881
  output_blindings: [o0.blinding.toString(), o1.blinding.toString()]
3838
3882
  };
3839
3883
  const provider = options.provider ?? new WebArtifactProvider3();
3840
- const opts = { provider };
3841
- if (options.verbose !== void 0) opts.verbose = options.verbose;
3884
+ const opts = toGenerateOptions(provider, options);
3842
3885
  return generateProof2(CircuitType3.Transfer, circuitInputs, opts);
3843
3886
  }
3844
3887
 
@@ -3860,8 +3903,7 @@ async function generateFeeClaimProof(inputs, options = {}) {
3860
3903
  blinding: inputs.blinding.toString()
3861
3904
  };
3862
3905
  const provider = options.provider ?? new WebArtifactProvider4();
3863
- const opts = { provider };
3864
- if (options.verbose !== void 0) opts.verbose = options.verbose;
3906
+ const opts = toGenerateOptions(provider, options);
3865
3907
  const proofResult = await generateProof3(CircuitType4.ValueProof, circuitInputs, opts);
3866
3908
  const [sigCommitment, sigValue, sigAssetId, sigOwnerHash] = proofResult.publicSignals.map(BigInt);
3867
3909
  const buf = new Uint8Array(76);
@@ -3875,6 +3917,9 @@ async function generateFeeClaimProof(inputs, options = {}) {
3875
3917
  };
3876
3918
  }
3877
3919
 
3920
+ // src/proof-generator/index.ts
3921
+ import { shouldProveSingleThreaded } from "@orbinum/proof-generator";
3922
+
3878
3923
  // src/precompiles/decode.ts
3879
3924
  function decodePrecompileCalldata(address, input) {
3880
3925
  const info = KNOWN_PRECOMPILES[address.toLowerCase()];
@@ -4507,6 +4552,8 @@ export {
4507
4552
  decryptNoteRecord,
4508
4553
  deriveMasterKeyBytes,
4509
4554
  deriveOwnerPk,
4555
+ derivePairwiseEphSk,
4556
+ derivePairwiseSharedSecret,
4510
4557
  deriveSelfEphSk,
4511
4558
  deriveSpendingKeyFromSignature,
4512
4559
  deriveSpendingKeyMessageV2,
@@ -4550,11 +4597,13 @@ export {
4550
4597
  mapZkEventData,
4551
4598
  normalizeEvmAddress,
4552
4599
  noteBlindTag,
4600
+ pairwiseEphWindow,
4553
4601
  randomBlinding,
4554
4602
  recoverOwnerPkPoint,
4555
4603
  selectNotes,
4556
4604
  selfEphWindow,
4557
4605
  shortHash,
4606
+ shouldProveSingleThreaded,
4558
4607
  substrateSs58ToAccountIdHex,
4559
4608
  substrateToEvm,
4560
4609
  toBase64,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbinum/sdk",
3
- "version": "0.24.0",
3
+ "version": "0.25.1",
4
4
  "description": "Official TypeScript SDK for Orbinum.",
5
5
  "author": "Orbinum",
6
6
  "license": "MIT",
@@ -48,7 +48,7 @@
48
48
  "@noble/ciphers": "2.2.0",
49
49
  "@noble/curves": "^2.2.0",
50
50
  "@noble/hashes": "2.2.0",
51
- "@orbinum/proof-generator": "5.0.0",
51
+ "@orbinum/proof-generator": "5.1.0",
52
52
  "@polkadot-api/metadata-builders": "0.14.2",
53
53
  "@polkadot-api/substrate-bindings": "0.20.2",
54
54
  "@polkadot-api/tx-utils": "0.3.2",