@orbinum/sdk 0.8.1 → 0.10.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
@@ -542,6 +542,35 @@ interface SpentNullifier {
542
542
  txType: 'unshield' | 'private_transfer';
543
543
  timestampMs: number | null;
544
544
  }
545
+ /** One sealed, immutable chunk of the spent-nullifier set (manifest entry). */
546
+ interface NullifierChunkInfo {
547
+ idx: number;
548
+ /** Exact number of nullifiers in the chunk. */
549
+ count: number;
550
+ /** sha256 (hex) of the chunk's nullifier hexes sorted ascending — goes in the chunk URL. */
551
+ digest: string;
552
+ }
553
+ /**
554
+ * Universal index of the sealed nullifier chunks — identical for every caller.
555
+ * No client-supplied position parameter exists anywhere in the chunk flow, so
556
+ * the PIR-A property of `/nullifiers/all` is preserved while transfers become
557
+ * incremental (clients persist chunks locally and only fetch new ones).
558
+ */
559
+ interface NullifierManifest {
560
+ /** Bumped by the operator on semantic corrections; a change means: resync from zero. */
561
+ generation: string;
562
+ /** Target chunk size (informational; each chunk's exact size is its `count`). */
563
+ chunkSize: number;
564
+ chunks: NullifierChunkInfo[];
565
+ /** Σ sealed counts + current tail size. */
566
+ total: number;
567
+ }
568
+ /** The mutable remainder of the nullifier set after the last sealed chunk. */
569
+ interface NullifierTail {
570
+ /** Number of sealed chunks the tail starts after (detects a chunk sealed mid-sync). */
571
+ afterChunks: number;
572
+ data: string[];
573
+ }
545
574
  /** Temporal metadata for a private transfer. No graph data (inputs ↔ outputs) exposed. */
546
575
  interface PrivateTransferTimestamp {
547
576
  blockNumber: number;
@@ -840,10 +869,32 @@ declare class IndexerClient {
840
869
  * The server sees an identical GET request regardless of which notes the wallet holds —
841
870
  * the intersection is computed locally (PIR-A privacy model).
842
871
  *
843
- * Suitable for wallets with up to ~1M spent nullifiers (~70 MB raw, <20 MB gzip).
844
- * For the current Orbinum testnet/mainnet scale this is the recommended approach.
872
+ * Kept as the FALLBACK for readers that don't serve sealed chunks yet (and for
873
+ * small sets). New integrations should prefer the incremental chunk flow:
874
+ * `getNullifierManifest` → `getNullifierChunk` for missing chunks →
875
+ * `getNullifierTail`, persisting the set locally between rescans.
845
876
  */
846
877
  getAllSpentNullifiers(): Promise<Set<string>>;
878
+ /**
879
+ * Universal index of the sealed nullifier chunks — identical request and
880
+ * response for every caller (no client-supplied position: PIR-A preserved).
881
+ *
882
+ * Returns `null` when the reader does not serve chunks yet (404) — the
883
+ * caller should fall back to `getAllSpentNullifiers`.
884
+ */
885
+ getNullifierManifest(): Promise<NullifierManifest | null>;
886
+ /**
887
+ * One sealed, immutable chunk of the spent-nullifier set (ascending hex,
888
+ * lowercased). The digest comes from the manifest and lives in the URL, so
889
+ * a corrected chunk is a different URL — safe to cache forever client-side.
890
+ */
891
+ getNullifierChunk(idx: number, digest: string): Promise<string[]>;
892
+ /**
893
+ * The mutable remainder of the nullifier set after the last sealed chunk.
894
+ * Identical request for every caller (no input). `afterChunks` lets the
895
+ * client detect a chunk sealed between its manifest fetch and this one.
896
+ */
897
+ getNullifierTail(): Promise<NullifierTail>;
847
898
  /** Server-enforced max items per by-nullifiers / by-commitments request. */
848
899
  private static readonly TRANSFER_LOOKUP_CHUNK;
849
900
  /**
@@ -2820,6 +2871,25 @@ declare function vaultReviver(_key: string, value: unknown): unknown;
2820
2871
  * @param masterBytes 32-byte pre-modulus key material from deriveMasterKeyBytes().
2821
2872
  */
2822
2873
  declare function deriveVaultKey(masterBytes: Uint8Array): Promise<CryptoKey>;
2874
+ /**
2875
+ * Derives an HMAC-SHA-256 key ("blind key") from the same master key bytes,
2876
+ * for deterministically tagging note identifiers (commitment/nullifier) in the
2877
+ * vault WITHOUT storing them in plaintext.
2878
+ *
2879
+ * The tag `HMAC(blindKey, hex)` is stable, so equality lookups still work
2880
+ * (find a note by commitment/nullifier), but a raw storage dump reveals no
2881
+ * on-chain identifiers — an attacker with disk access can't link the vault to
2882
+ * chain activity. Derived from masterBytes, so it's device-independent and
2883
+ * survives reload (unlike a random per-session salt).
2884
+ *
2885
+ * @param masterBytes 32-byte pre-modulus key material from deriveMasterKeyBytes().
2886
+ */
2887
+ declare function deriveVaultBlindKey(masterBytes: Uint8Array): Promise<CryptoKey>;
2888
+ /**
2889
+ * Deterministic tag for a note identifier hex, as `0x`-prefixed HMAC-SHA-256.
2890
+ * Used as the blinded storage key for commitment / nullifier / assetId.
2891
+ */
2892
+ declare function blindTag(blindKey: CryptoKey, value: string): Promise<string>;
2823
2893
  /**
2824
2894
  * Serialises `payload` to JSON (bigint-safe) and encrypts it with AES-GCM.
2825
2895
  * Returns base64-encoded `iv` and `ciphertext`.
@@ -2841,18 +2911,26 @@ declare function decryptJson(key: CryptoKey, iv: string, ciphertext: string): Pr
2841
2911
  * Any backend (IndexedDB, SQLite, remote…) must produce/consume this shape
2842
2912
  * so that encryptNote / decryptNoteRecord work without modification.
2843
2913
  */
2844
- /** A single encrypted note record as stored in the vault backend. */
2914
+ /**
2915
+ * A single encrypted note record as stored in the vault backend.
2916
+ *
2917
+ * Note identifiers are BLINDED — stored as HMAC tags derived from the vault
2918
+ * blind key, not the raw on-chain hex. A storage dump reveals no
2919
+ * commitment/nullifier/asset that could be linked to chain activity, yet
2920
+ * equality lookups (find-my-note) still work by comparing tags. `spent` /
2921
+ * `spentAt` stay plaintext: they're local flags with no on-chain linkage.
2922
+ */
2845
2923
  interface EncryptedNoteRecord {
2846
- /** Primary key — note commitmentHex */
2847
- commitmentHex: string;
2924
+ /** Primary key — blinded commitment tag: HMAC(blindKey, commitmentHex). */
2925
+ commitmentTag: string;
2848
2926
  /** AES-GCM IV for this record — base64 */
2849
2927
  iv: string;
2850
2928
  /** AES-GCM ciphertext of the full ZkNote JSON — base64 */
2851
2929
  ciphertext: string;
2852
- /** Unencrypted nullifierHex for quick spent-check without unlocking */
2853
- nullifierHex: string;
2854
- /** Unencrypted assetId (string form of bigint) for filtering */
2855
- assetId: string;
2930
+ /** Blinded nullifier tag: HMAC(blindKey, nullifierHex). Quick spent-check. */
2931
+ nullifierTag: string;
2932
+ /** Blinded asset tag: HMAC(blindKey, assetId). Filter by asset without unlock. */
2933
+ assetTag: string;
2856
2934
  /** Whether the note has already been spent/nullified on-chain. */
2857
2935
  spent?: boolean;
2858
2936
  /** When the app marked the note as spent locally, if known. */
@@ -2886,17 +2964,25 @@ declare class VaultLockedError extends Error {
2886
2964
  */
2887
2965
  declare function applyNoteStatus(note: ZkNote, status?: NoteStatusUpdate): ZkNote;
2888
2966
  /**
2889
- * Encrypts a ZkNote into an EncryptedNoteRecord using AES-GCM.
2890
- * The commitmentHex, nullifierHex, and assetId are stored in plaintext
2891
- * for efficient filtering without requiring vault unlock.
2967
+ * Encrypts a ZkNote into a v2 EncryptedNoteRecord.
2968
+ *
2969
+ * The full note (values, secrets) is AES-GCM encrypted under `key`; the note
2970
+ * identifiers (commitment, nullifier, asset) are stored as BLIND TAGS under
2971
+ * `blindKey` instead of plaintext — a storage dump reveals nothing linkable to
2972
+ * chain activity, while equality lookups still work (compare tags).
2892
2973
  */
2893
- declare function encryptNote(key: CryptoKey, note: ZkNote): Promise<EncryptedNoteRecord>;
2974
+ declare function encryptNote(key: CryptoKey, blindKey: CryptoKey, note: ZkNote): Promise<EncryptedNoteRecord>;
2894
2975
  /**
2895
- * Decrypts an EncryptedNoteRecord back into a ZkNote using AES-GCM.
2976
+ * Decrypts a note record back into a ZkNote.
2896
2977
  * Applies the record's spent/spentAt metadata onto the decrypted note.
2897
2978
  * Throws DOMException on authentication failure (wrong key or corrupted data).
2898
2979
  */
2899
2980
  declare function decryptNoteRecord(key: CryptoKey, rec: EncryptedNoteRecord): Promise<ZkNote>;
2981
+ /**
2982
+ * Blind tag for a note identifier hex — use to build the storage key or to
2983
+ * look a record up by commitment/nullifier without exposing the raw hex.
2984
+ */
2985
+ declare function noteBlindTag(blindKey: CryptoKey, hex: string): Promise<string>;
2900
2986
 
2901
2987
  /**
2902
2988
  * Inputs required to generate an Unshield proof.
@@ -4491,4 +4577,4 @@ interface ExtrinsicFailedData {
4491
4577
  dispatch_info: DispatchInfo;
4492
4578
  }
4493
4579
 
4494
- export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, type ActivityBucket, 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, type IndexedSession, type IndexedValidator, type IndexerActivity, 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 };
4580
+ export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, type ActivityBucket, 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, type IndexedSession, type IndexedValidator, type IndexerActivity, 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 NullifierChunkInfo, type NullifierManifest, type NullifierStatusResult, type NullifierTail, 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, blindTag, buildDummyTransferInput, bytesToBigintLE, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessage, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, 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, noteBlindTag, randomBlinding, recoverOwnerPkPoint, selectNotes, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
package/dist/index.d.ts CHANGED
@@ -542,6 +542,35 @@ interface SpentNullifier {
542
542
  txType: 'unshield' | 'private_transfer';
543
543
  timestampMs: number | null;
544
544
  }
545
+ /** One sealed, immutable chunk of the spent-nullifier set (manifest entry). */
546
+ interface NullifierChunkInfo {
547
+ idx: number;
548
+ /** Exact number of nullifiers in the chunk. */
549
+ count: number;
550
+ /** sha256 (hex) of the chunk's nullifier hexes sorted ascending — goes in the chunk URL. */
551
+ digest: string;
552
+ }
553
+ /**
554
+ * Universal index of the sealed nullifier chunks — identical for every caller.
555
+ * No client-supplied position parameter exists anywhere in the chunk flow, so
556
+ * the PIR-A property of `/nullifiers/all` is preserved while transfers become
557
+ * incremental (clients persist chunks locally and only fetch new ones).
558
+ */
559
+ interface NullifierManifest {
560
+ /** Bumped by the operator on semantic corrections; a change means: resync from zero. */
561
+ generation: string;
562
+ /** Target chunk size (informational; each chunk's exact size is its `count`). */
563
+ chunkSize: number;
564
+ chunks: NullifierChunkInfo[];
565
+ /** Σ sealed counts + current tail size. */
566
+ total: number;
567
+ }
568
+ /** The mutable remainder of the nullifier set after the last sealed chunk. */
569
+ interface NullifierTail {
570
+ /** Number of sealed chunks the tail starts after (detects a chunk sealed mid-sync). */
571
+ afterChunks: number;
572
+ data: string[];
573
+ }
545
574
  /** Temporal metadata for a private transfer. No graph data (inputs ↔ outputs) exposed. */
546
575
  interface PrivateTransferTimestamp {
547
576
  blockNumber: number;
@@ -840,10 +869,32 @@ declare class IndexerClient {
840
869
  * The server sees an identical GET request regardless of which notes the wallet holds —
841
870
  * the intersection is computed locally (PIR-A privacy model).
842
871
  *
843
- * Suitable for wallets with up to ~1M spent nullifiers (~70 MB raw, <20 MB gzip).
844
- * For the current Orbinum testnet/mainnet scale this is the recommended approach.
872
+ * Kept as the FALLBACK for readers that don't serve sealed chunks yet (and for
873
+ * small sets). New integrations should prefer the incremental chunk flow:
874
+ * `getNullifierManifest` → `getNullifierChunk` for missing chunks →
875
+ * `getNullifierTail`, persisting the set locally between rescans.
845
876
  */
846
877
  getAllSpentNullifiers(): Promise<Set<string>>;
878
+ /**
879
+ * Universal index of the sealed nullifier chunks — identical request and
880
+ * response for every caller (no client-supplied position: PIR-A preserved).
881
+ *
882
+ * Returns `null` when the reader does not serve chunks yet (404) — the
883
+ * caller should fall back to `getAllSpentNullifiers`.
884
+ */
885
+ getNullifierManifest(): Promise<NullifierManifest | null>;
886
+ /**
887
+ * One sealed, immutable chunk of the spent-nullifier set (ascending hex,
888
+ * lowercased). The digest comes from the manifest and lives in the URL, so
889
+ * a corrected chunk is a different URL — safe to cache forever client-side.
890
+ */
891
+ getNullifierChunk(idx: number, digest: string): Promise<string[]>;
892
+ /**
893
+ * The mutable remainder of the nullifier set after the last sealed chunk.
894
+ * Identical request for every caller (no input). `afterChunks` lets the
895
+ * client detect a chunk sealed between its manifest fetch and this one.
896
+ */
897
+ getNullifierTail(): Promise<NullifierTail>;
847
898
  /** Server-enforced max items per by-nullifiers / by-commitments request. */
848
899
  private static readonly TRANSFER_LOOKUP_CHUNK;
849
900
  /**
@@ -2820,6 +2871,25 @@ declare function vaultReviver(_key: string, value: unknown): unknown;
2820
2871
  * @param masterBytes 32-byte pre-modulus key material from deriveMasterKeyBytes().
2821
2872
  */
2822
2873
  declare function deriveVaultKey(masterBytes: Uint8Array): Promise<CryptoKey>;
2874
+ /**
2875
+ * Derives an HMAC-SHA-256 key ("blind key") from the same master key bytes,
2876
+ * for deterministically tagging note identifiers (commitment/nullifier) in the
2877
+ * vault WITHOUT storing them in plaintext.
2878
+ *
2879
+ * The tag `HMAC(blindKey, hex)` is stable, so equality lookups still work
2880
+ * (find a note by commitment/nullifier), but a raw storage dump reveals no
2881
+ * on-chain identifiers — an attacker with disk access can't link the vault to
2882
+ * chain activity. Derived from masterBytes, so it's device-independent and
2883
+ * survives reload (unlike a random per-session salt).
2884
+ *
2885
+ * @param masterBytes 32-byte pre-modulus key material from deriveMasterKeyBytes().
2886
+ */
2887
+ declare function deriveVaultBlindKey(masterBytes: Uint8Array): Promise<CryptoKey>;
2888
+ /**
2889
+ * Deterministic tag for a note identifier hex, as `0x`-prefixed HMAC-SHA-256.
2890
+ * Used as the blinded storage key for commitment / nullifier / assetId.
2891
+ */
2892
+ declare function blindTag(blindKey: CryptoKey, value: string): Promise<string>;
2823
2893
  /**
2824
2894
  * Serialises `payload` to JSON (bigint-safe) and encrypts it with AES-GCM.
2825
2895
  * Returns base64-encoded `iv` and `ciphertext`.
@@ -2841,18 +2911,26 @@ declare function decryptJson(key: CryptoKey, iv: string, ciphertext: string): Pr
2841
2911
  * Any backend (IndexedDB, SQLite, remote…) must produce/consume this shape
2842
2912
  * so that encryptNote / decryptNoteRecord work without modification.
2843
2913
  */
2844
- /** A single encrypted note record as stored in the vault backend. */
2914
+ /**
2915
+ * A single encrypted note record as stored in the vault backend.
2916
+ *
2917
+ * Note identifiers are BLINDED — stored as HMAC tags derived from the vault
2918
+ * blind key, not the raw on-chain hex. A storage dump reveals no
2919
+ * commitment/nullifier/asset that could be linked to chain activity, yet
2920
+ * equality lookups (find-my-note) still work by comparing tags. `spent` /
2921
+ * `spentAt` stay plaintext: they're local flags with no on-chain linkage.
2922
+ */
2845
2923
  interface EncryptedNoteRecord {
2846
- /** Primary key — note commitmentHex */
2847
- commitmentHex: string;
2924
+ /** Primary key — blinded commitment tag: HMAC(blindKey, commitmentHex). */
2925
+ commitmentTag: string;
2848
2926
  /** AES-GCM IV for this record — base64 */
2849
2927
  iv: string;
2850
2928
  /** AES-GCM ciphertext of the full ZkNote JSON — base64 */
2851
2929
  ciphertext: string;
2852
- /** Unencrypted nullifierHex for quick spent-check without unlocking */
2853
- nullifierHex: string;
2854
- /** Unencrypted assetId (string form of bigint) for filtering */
2855
- assetId: string;
2930
+ /** Blinded nullifier tag: HMAC(blindKey, nullifierHex). Quick spent-check. */
2931
+ nullifierTag: string;
2932
+ /** Blinded asset tag: HMAC(blindKey, assetId). Filter by asset without unlock. */
2933
+ assetTag: string;
2856
2934
  /** Whether the note has already been spent/nullified on-chain. */
2857
2935
  spent?: boolean;
2858
2936
  /** When the app marked the note as spent locally, if known. */
@@ -2886,17 +2964,25 @@ declare class VaultLockedError extends Error {
2886
2964
  */
2887
2965
  declare function applyNoteStatus(note: ZkNote, status?: NoteStatusUpdate): ZkNote;
2888
2966
  /**
2889
- * Encrypts a ZkNote into an EncryptedNoteRecord using AES-GCM.
2890
- * The commitmentHex, nullifierHex, and assetId are stored in plaintext
2891
- * for efficient filtering without requiring vault unlock.
2967
+ * Encrypts a ZkNote into a v2 EncryptedNoteRecord.
2968
+ *
2969
+ * The full note (values, secrets) is AES-GCM encrypted under `key`; the note
2970
+ * identifiers (commitment, nullifier, asset) are stored as BLIND TAGS under
2971
+ * `blindKey` instead of plaintext — a storage dump reveals nothing linkable to
2972
+ * chain activity, while equality lookups still work (compare tags).
2892
2973
  */
2893
- declare function encryptNote(key: CryptoKey, note: ZkNote): Promise<EncryptedNoteRecord>;
2974
+ declare function encryptNote(key: CryptoKey, blindKey: CryptoKey, note: ZkNote): Promise<EncryptedNoteRecord>;
2894
2975
  /**
2895
- * Decrypts an EncryptedNoteRecord back into a ZkNote using AES-GCM.
2976
+ * Decrypts a note record back into a ZkNote.
2896
2977
  * Applies the record's spent/spentAt metadata onto the decrypted note.
2897
2978
  * Throws DOMException on authentication failure (wrong key or corrupted data).
2898
2979
  */
2899
2980
  declare function decryptNoteRecord(key: CryptoKey, rec: EncryptedNoteRecord): Promise<ZkNote>;
2981
+ /**
2982
+ * Blind tag for a note identifier hex — use to build the storage key or to
2983
+ * look a record up by commitment/nullifier without exposing the raw hex.
2984
+ */
2985
+ declare function noteBlindTag(blindKey: CryptoKey, hex: string): Promise<string>;
2900
2986
 
2901
2987
  /**
2902
2988
  * Inputs required to generate an Unshield proof.
@@ -4491,4 +4577,4 @@ interface ExtrinsicFailedData {
4491
4577
  dispatch_info: DispatchInfo;
4492
4578
  }
4493
4579
 
4494
- export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, type ActivityBucket, 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, type IndexedSession, type IndexedValidator, type IndexerActivity, 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 };
4580
+ export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, type ActivityBucket, 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, type IndexedSession, type IndexedValidator, type IndexerActivity, 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 NullifierChunkInfo, type NullifierManifest, type NullifierStatusResult, type NullifierTail, 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, blindTag, buildDummyTransferInput, bytesToBigintLE, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessage, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, 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, noteBlindTag, randomBlinding, recoverOwnerPkPoint, selectNotes, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
package/dist/index.js CHANGED
@@ -59,6 +59,7 @@ __export(index_exports, {
59
59
  bigintTo32Be: () => bigintTo32Be,
60
60
  bigintTo32Le: () => bigintTo32Le,
61
61
  bigintTo32LeArr: () => bigintTo32LeArr,
62
+ blindTag: () => blindTag,
62
63
  buildDummyTransferInput: () => buildDummyTransferInput,
63
64
  bytesToBigintLE: () => bytesToBigintLE,
64
65
  computeNullifier: () => computeNullifier,
@@ -75,6 +76,7 @@ __export(index_exports, {
75
76
  deriveSpendingKeyMessage: () => deriveSpendingKeyMessage,
76
77
  deriveStealthOwnerPk: () => deriveStealthOwnerPk,
77
78
  deriveStealthSk: () => deriveStealthSk,
79
+ deriveVaultBlindKey: () => deriveVaultBlindKey,
78
80
  deriveVaultKey: () => deriveVaultKey,
79
81
  deriveViewingPublicKey: () => deriveViewingPublicKey,
80
82
  deriveViewingSecretKey: () => deriveViewingSecretKey,
@@ -109,6 +111,7 @@ __export(index_exports, {
109
111
  mapExtrinsicArgs: () => mapExtrinsicArgs,
110
112
  mapZkEventData: () => mapZkEventData,
111
113
  normalizeEvmAddress: () => normalizeEvmAddress,
114
+ noteBlindTag: () => noteBlindTag,
112
115
  randomBlinding: () => randomBlinding,
113
116
  recoverOwnerPkPoint: () => recoverOwnerPkPoint,
114
117
  selectNotes: () => selectNotes,
@@ -1239,13 +1242,45 @@ var IndexerClient = class _IndexerClient {
1239
1242
  * The server sees an identical GET request regardless of which notes the wallet holds —
1240
1243
  * the intersection is computed locally (PIR-A privacy model).
1241
1244
  *
1242
- * Suitable for wallets with up to ~1M spent nullifiers (~70 MB raw, <20 MB gzip).
1243
- * For the current Orbinum testnet/mainnet scale this is the recommended approach.
1245
+ * Kept as the FALLBACK for readers that don't serve sealed chunks yet (and for
1246
+ * small sets). New integrations should prefer the incremental chunk flow:
1247
+ * `getNullifierManifest` → `getNullifierChunk` for missing chunks →
1248
+ * `getNullifierTail`, persisting the set locally between rescans.
1244
1249
  */
1245
1250
  async getAllSpentNullifiers() {
1246
1251
  const res = await this.get("/shielded/nullifiers/all");
1247
1252
  return new Set(res.data.map((h) => h.toLowerCase()));
1248
1253
  }
1254
+ /**
1255
+ * Universal index of the sealed nullifier chunks — identical request and
1256
+ * response for every caller (no client-supplied position: PIR-A preserved).
1257
+ *
1258
+ * Returns `null` when the reader does not serve chunks yet (404) — the
1259
+ * caller should fall back to `getAllSpentNullifiers`.
1260
+ */
1261
+ async getNullifierManifest() {
1262
+ return this.getOrNull("/shielded/nullifiers/manifest");
1263
+ }
1264
+ /**
1265
+ * One sealed, immutable chunk of the spent-nullifier set (ascending hex,
1266
+ * lowercased). The digest comes from the manifest and lives in the URL, so
1267
+ * a corrected chunk is a different URL — safe to cache forever client-side.
1268
+ */
1269
+ async getNullifierChunk(idx, digest) {
1270
+ const res = await this.get(
1271
+ `/shielded/nullifiers/chunks/${idx}/${encodeURIComponent(digest)}`
1272
+ );
1273
+ return res.data.map((h) => h.toLowerCase());
1274
+ }
1275
+ /**
1276
+ * The mutable remainder of the nullifier set after the last sealed chunk.
1277
+ * Identical request for every caller (no input). `afterChunks` lets the
1278
+ * client detect a chunk sealed between its manifest fetch and this one.
1279
+ */
1280
+ async getNullifierTail() {
1281
+ const res = await this.get("/shielded/nullifiers/tail");
1282
+ return { afterChunks: res.afterChunks, data: res.data.map((h) => h.toLowerCase()) };
1283
+ }
1249
1284
  // ─── Private transfers ─────────────────────────────────────────────────────
1250
1285
  /** Server-enforced max items per by-nullifiers / by-commitments request. */
1251
1286
  static TRANSFER_LOOKUP_CHUNK = 50;
@@ -4484,6 +4519,7 @@ function fromBase64(b64) {
4484
4519
 
4485
4520
  // src/vault/VaultCrypto.ts
4486
4521
  var VAULT_KEY_INFO = new TextEncoder().encode("orbinum-vault-key-v1");
4522
+ var VAULT_BLIND_INFO = new TextEncoder().encode("orbinum-vault-blind-v1");
4487
4523
  var IV_BYTES = 12;
4488
4524
  async function deriveVaultKey(masterBytes) {
4489
4525
  const keyMaterial = await crypto.subtle.importKey("raw", masterBytes.slice(0), "HKDF", false, [
@@ -4502,6 +4538,28 @@ async function deriveVaultKey(masterBytes) {
4502
4538
  ["encrypt", "decrypt"]
4503
4539
  );
4504
4540
  }
4541
+ async function deriveVaultBlindKey(masterBytes) {
4542
+ const keyMaterial = await crypto.subtle.importKey("raw", masterBytes.slice(0), "HKDF", false, [
4543
+ "deriveKey"
4544
+ ]);
4545
+ return crypto.subtle.deriveKey(
4546
+ {
4547
+ name: "HKDF",
4548
+ hash: "SHA-256",
4549
+ salt: new Uint8Array(0),
4550
+ info: VAULT_BLIND_INFO
4551
+ },
4552
+ keyMaterial,
4553
+ { name: "HMAC", hash: "SHA-256", length: 256 },
4554
+ false,
4555
+ ["sign"]
4556
+ );
4557
+ }
4558
+ async function blindTag(blindKey, value) {
4559
+ const data = new TextEncoder().encode(value.toLowerCase());
4560
+ const sig = await crypto.subtle.sign("HMAC", blindKey, data);
4561
+ return "0x" + toBase64(sig).replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
4562
+ }
4505
4563
  async function encryptJson(key, payload) {
4506
4564
  const iv = crypto.getRandomValues(new Uint8Array(IV_BYTES));
4507
4565
  const plaintext = new TextEncoder().encode(JSON.stringify(payload, vaultReplacer));
@@ -4533,14 +4591,19 @@ function applyNoteStatus(note, status) {
4533
4591
  spentAt: status?.spentAt ?? note.spentAt ?? null
4534
4592
  };
4535
4593
  }
4536
- async function encryptNote(key, note) {
4594
+ async function encryptNote(key, blindKey, note) {
4537
4595
  const { iv, ciphertext } = await encryptJson(key, note);
4596
+ const [commitmentTag, nullifierTag, assetTag] = await Promise.all([
4597
+ blindTag(blindKey, note.commitmentHex),
4598
+ blindTag(blindKey, note.nullifierHex),
4599
+ blindTag(blindKey, note.assetId.toString())
4600
+ ]);
4538
4601
  return {
4539
- commitmentHex: note.commitmentHex,
4602
+ commitmentTag,
4540
4603
  iv,
4541
4604
  ciphertext,
4542
- nullifierHex: note.nullifierHex,
4543
- assetId: note.assetId.toString(),
4605
+ nullifierTag,
4606
+ assetTag,
4544
4607
  spent: note.spent,
4545
4608
  spentAt: note.spentAt,
4546
4609
  updatedAt: Date.now()
@@ -4553,6 +4616,9 @@ async function decryptNoteRecord(key, rec) {
4553
4616
  spentAt: rec.spentAt ?? null
4554
4617
  });
4555
4618
  }
4619
+ async function noteBlindTag(blindKey, hex) {
4620
+ return blindTag(blindKey, hex);
4621
+ }
4556
4622
 
4557
4623
  // src/proof-generator/unshield.ts
4558
4624
  var import_proof_generator = require("@orbinum/proof-generator");
@@ -5459,6 +5525,7 @@ var import_polkadot_api4 = require("polkadot-api");
5459
5525
  bigintTo32Be,
5460
5526
  bigintTo32Le,
5461
5527
  bigintTo32LeArr,
5528
+ blindTag,
5462
5529
  buildDummyTransferInput,
5463
5530
  bytesToBigintLE,
5464
5531
  computeNullifier,
@@ -5475,6 +5542,7 @@ var import_polkadot_api4 = require("polkadot-api");
5475
5542
  deriveSpendingKeyMessage,
5476
5543
  deriveStealthOwnerPk,
5477
5544
  deriveStealthSk,
5545
+ deriveVaultBlindKey,
5478
5546
  deriveVaultKey,
5479
5547
  deriveViewingPublicKey,
5480
5548
  deriveViewingSecretKey,
@@ -5509,6 +5577,7 @@ var import_polkadot_api4 = require("polkadot-api");
5509
5577
  mapExtrinsicArgs,
5510
5578
  mapZkEventData,
5511
5579
  normalizeEvmAddress,
5580
+ noteBlindTag,
5512
5581
  randomBlinding,
5513
5582
  recoverOwnerPkPoint,
5514
5583
  selectNotes,
package/dist/index.mjs CHANGED
@@ -1112,13 +1112,45 @@ var IndexerClient = class _IndexerClient {
1112
1112
  * The server sees an identical GET request regardless of which notes the wallet holds —
1113
1113
  * the intersection is computed locally (PIR-A privacy model).
1114
1114
  *
1115
- * Suitable for wallets with up to ~1M spent nullifiers (~70 MB raw, <20 MB gzip).
1116
- * For the current Orbinum testnet/mainnet scale this is the recommended approach.
1115
+ * Kept as the FALLBACK for readers that don't serve sealed chunks yet (and for
1116
+ * small sets). New integrations should prefer the incremental chunk flow:
1117
+ * `getNullifierManifest` → `getNullifierChunk` for missing chunks →
1118
+ * `getNullifierTail`, persisting the set locally between rescans.
1117
1119
  */
1118
1120
  async getAllSpentNullifiers() {
1119
1121
  const res = await this.get("/shielded/nullifiers/all");
1120
1122
  return new Set(res.data.map((h) => h.toLowerCase()));
1121
1123
  }
1124
+ /**
1125
+ * Universal index of the sealed nullifier chunks — identical request and
1126
+ * response for every caller (no client-supplied position: PIR-A preserved).
1127
+ *
1128
+ * Returns `null` when the reader does not serve chunks yet (404) — the
1129
+ * caller should fall back to `getAllSpentNullifiers`.
1130
+ */
1131
+ async getNullifierManifest() {
1132
+ return this.getOrNull("/shielded/nullifiers/manifest");
1133
+ }
1134
+ /**
1135
+ * One sealed, immutable chunk of the spent-nullifier set (ascending hex,
1136
+ * lowercased). The digest comes from the manifest and lives in the URL, so
1137
+ * a corrected chunk is a different URL — safe to cache forever client-side.
1138
+ */
1139
+ async getNullifierChunk(idx, digest) {
1140
+ const res = await this.get(
1141
+ `/shielded/nullifiers/chunks/${idx}/${encodeURIComponent(digest)}`
1142
+ );
1143
+ return res.data.map((h) => h.toLowerCase());
1144
+ }
1145
+ /**
1146
+ * The mutable remainder of the nullifier set after the last sealed chunk.
1147
+ * Identical request for every caller (no input). `afterChunks` lets the
1148
+ * client detect a chunk sealed between its manifest fetch and this one.
1149
+ */
1150
+ async getNullifierTail() {
1151
+ const res = await this.get("/shielded/nullifiers/tail");
1152
+ return { afterChunks: res.afterChunks, data: res.data.map((h) => h.toLowerCase()) };
1153
+ }
1122
1154
  // ─── Private transfers ─────────────────────────────────────────────────────
1123
1155
  /** Server-enforced max items per by-nullifiers / by-commitments request. */
1124
1156
  static TRANSFER_LOOKUP_CHUNK = 50;
@@ -4357,6 +4389,7 @@ function fromBase64(b64) {
4357
4389
 
4358
4390
  // src/vault/VaultCrypto.ts
4359
4391
  var VAULT_KEY_INFO = new TextEncoder().encode("orbinum-vault-key-v1");
4392
+ var VAULT_BLIND_INFO = new TextEncoder().encode("orbinum-vault-blind-v1");
4360
4393
  var IV_BYTES = 12;
4361
4394
  async function deriveVaultKey(masterBytes) {
4362
4395
  const keyMaterial = await crypto.subtle.importKey("raw", masterBytes.slice(0), "HKDF", false, [
@@ -4375,6 +4408,28 @@ async function deriveVaultKey(masterBytes) {
4375
4408
  ["encrypt", "decrypt"]
4376
4409
  );
4377
4410
  }
4411
+ async function deriveVaultBlindKey(masterBytes) {
4412
+ const keyMaterial = await crypto.subtle.importKey("raw", masterBytes.slice(0), "HKDF", false, [
4413
+ "deriveKey"
4414
+ ]);
4415
+ return crypto.subtle.deriveKey(
4416
+ {
4417
+ name: "HKDF",
4418
+ hash: "SHA-256",
4419
+ salt: new Uint8Array(0),
4420
+ info: VAULT_BLIND_INFO
4421
+ },
4422
+ keyMaterial,
4423
+ { name: "HMAC", hash: "SHA-256", length: 256 },
4424
+ false,
4425
+ ["sign"]
4426
+ );
4427
+ }
4428
+ async function blindTag(blindKey, value) {
4429
+ const data = new TextEncoder().encode(value.toLowerCase());
4430
+ const sig = await crypto.subtle.sign("HMAC", blindKey, data);
4431
+ return "0x" + toBase64(sig).replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
4432
+ }
4378
4433
  async function encryptJson(key, payload) {
4379
4434
  const iv = crypto.getRandomValues(new Uint8Array(IV_BYTES));
4380
4435
  const plaintext = new TextEncoder().encode(JSON.stringify(payload, vaultReplacer));
@@ -4406,14 +4461,19 @@ function applyNoteStatus(note, status) {
4406
4461
  spentAt: status?.spentAt ?? note.spentAt ?? null
4407
4462
  };
4408
4463
  }
4409
- async function encryptNote(key, note) {
4464
+ async function encryptNote(key, blindKey, note) {
4410
4465
  const { iv, ciphertext } = await encryptJson(key, note);
4466
+ const [commitmentTag, nullifierTag, assetTag] = await Promise.all([
4467
+ blindTag(blindKey, note.commitmentHex),
4468
+ blindTag(blindKey, note.nullifierHex),
4469
+ blindTag(blindKey, note.assetId.toString())
4470
+ ]);
4411
4471
  return {
4412
- commitmentHex: note.commitmentHex,
4472
+ commitmentTag,
4413
4473
  iv,
4414
4474
  ciphertext,
4415
- nullifierHex: note.nullifierHex,
4416
- assetId: note.assetId.toString(),
4475
+ nullifierTag,
4476
+ assetTag,
4417
4477
  spent: note.spent,
4418
4478
  spentAt: note.spentAt,
4419
4479
  updatedAt: Date.now()
@@ -4426,6 +4486,9 @@ async function decryptNoteRecord(key, rec) {
4426
4486
  spentAt: rec.spentAt ?? null
4427
4487
  });
4428
4488
  }
4489
+ async function noteBlindTag(blindKey, hex) {
4490
+ return blindTag(blindKey, hex);
4491
+ }
4429
4492
 
4430
4493
  // src/proof-generator/unshield.ts
4431
4494
  import {
@@ -5354,6 +5417,7 @@ export {
5354
5417
  bigintTo32Be,
5355
5418
  bigintTo32Le,
5356
5419
  bigintTo32LeArr,
5420
+ blindTag,
5357
5421
  buildDummyTransferInput,
5358
5422
  bytesToBigintLE,
5359
5423
  computeNullifier,
@@ -5370,6 +5434,7 @@ export {
5370
5434
  deriveSpendingKeyMessage,
5371
5435
  deriveStealthOwnerPk,
5372
5436
  deriveStealthSk,
5437
+ deriveVaultBlindKey,
5373
5438
  deriveVaultKey,
5374
5439
  deriveViewingPublicKey,
5375
5440
  deriveViewingSecretKey,
@@ -5404,6 +5469,7 @@ export {
5404
5469
  mapExtrinsicArgs,
5405
5470
  mapZkEventData,
5406
5471
  normalizeEvmAddress,
5472
+ noteBlindTag,
5407
5473
  randomBlinding,
5408
5474
  recoverOwnerPkPoint,
5409
5475
  selectNotes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbinum/sdk",
3
- "version": "0.8.1",
3
+ "version": "0.10.0",
4
4
  "description": "Official TypeScript SDK for Orbinum.",
5
5
  "author": "Orbinum",
6
6
  "license": "MIT",