@orbinum/sdk 1.0.1 → 1.1.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 +92 -1
- package/dist/index.d.ts +92 -1
- package/dist/index.js +82 -0
- package/dist/index.mjs +78 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -4779,6 +4779,97 @@ declare function decodeNoteTransferPage(uri: string): NoteTransferPayload;
|
|
|
4779
4779
|
*/
|
|
4780
4780
|
declare function assembleNoteTransfer(pages: NoteTransferPayload[]): NoteTransferEntry[];
|
|
4781
4781
|
|
|
4782
|
+
/**
|
|
4783
|
+
* CLOSED JSON backup of notes — the same notes moved between a user's devices as
|
|
4784
|
+
* a plain file, WITHOUT exposing any spending key.
|
|
4785
|
+
*
|
|
4786
|
+
* ## The idea
|
|
4787
|
+
*
|
|
4788
|
+
* A backup entry carries only what is already PUBLIC on chain: the commitment and
|
|
4789
|
+
* the encrypted memo. It contains no spending key, so the file is safe to hold
|
|
4790
|
+
* and even share — it grants nothing on its own.
|
|
4791
|
+
*
|
|
4792
|
+
* On import, the recipient DECRYPTS each memo with their own viewing key
|
|
4793
|
+
* (`importNotesFromBackup`). Decryption is the proof of ownership:
|
|
4794
|
+
* - the memo decrypts → the note is theirs → a full spendable `ZkNote` is
|
|
4795
|
+
* reconstructed, spending key and stealth key derived from their identity;
|
|
4796
|
+
* - the memo does not decrypt → the note is someone else's → it is dropped.
|
|
4797
|
+
*
|
|
4798
|
+
* This is NOT a chain scan: only the N memos in the backup are tried, not the
|
|
4799
|
+
* whole pool. It moves notes between devices without re-scanning, and a note that
|
|
4800
|
+
* is not yours simply fails to import.
|
|
4801
|
+
*
|
|
4802
|
+
* ## What travels vs what does not
|
|
4803
|
+
*
|
|
4804
|
+
* Travels: `commitmentHex`, `encryptedMemo`, and `leafIndex` (informational).
|
|
4805
|
+
* Does NOT travel: value, ownerPk, blinding, spendingKey — all recovered by
|
|
4806
|
+
* decrypting the memo. The Merkle proof is re-fetched at spend time.
|
|
4807
|
+
*/
|
|
4808
|
+
|
|
4809
|
+
/** Current backup format version. Bumped only if the entry shape changes. */
|
|
4810
|
+
declare const NOTE_BACKUP_VERSION: 1;
|
|
4811
|
+
/**
|
|
4812
|
+
* One note in a closed backup — public data only. Field names are short but not
|
|
4813
|
+
* cryptic; readability matters more than density in a file (unlike the QR path).
|
|
4814
|
+
*/
|
|
4815
|
+
interface NoteBackupEntry {
|
|
4816
|
+
/** 0x-prefixed 32-byte LE commitment hex. */
|
|
4817
|
+
commitmentHex: string;
|
|
4818
|
+
/** 0x-prefixed encrypted memo hex (180 bytes). Decrypted on import. */
|
|
4819
|
+
encryptedMemo: string;
|
|
4820
|
+
/** Merkle leaf index, when known. Informational — spends re-fetch the proof. */
|
|
4821
|
+
leafIndex?: number;
|
|
4822
|
+
/**
|
|
4823
|
+
* Whether the note was already spent when exported. A local status flag (not
|
|
4824
|
+
* a key or secret), carried so a restored vault separates available from spent
|
|
4825
|
+
* without a chain round-trip. A host may still reconcile against the chain
|
|
4826
|
+
* afterward — this is a fast, possibly-stale hint, not the source of truth.
|
|
4827
|
+
*/
|
|
4828
|
+
spent?: boolean;
|
|
4829
|
+
/** Local timestamp the note was marked spent, when known. */
|
|
4830
|
+
spentAt?: number | null;
|
|
4831
|
+
}
|
|
4832
|
+
interface NoteBackup {
|
|
4833
|
+
v: typeof NOTE_BACKUP_VERSION;
|
|
4834
|
+
/** Export time (ms). Informational. */
|
|
4835
|
+
ts: number;
|
|
4836
|
+
notes: NoteBackupEntry[];
|
|
4837
|
+
}
|
|
4838
|
+
/** Keys the importer needs to prove ownership by decrypting each memo. */
|
|
4839
|
+
interface BackupImportKeys {
|
|
4840
|
+
/** 32-byte viewing secret key (ivsk). */
|
|
4841
|
+
viewingSecretKey: Uint8Array;
|
|
4842
|
+
/** Spending key scalar — folded into the derived stealth key / nullifier. */
|
|
4843
|
+
spendingKey: bigint;
|
|
4844
|
+
/** The importer's global owner pk (Ax), for stealth detection. */
|
|
4845
|
+
ownerPk: bigint;
|
|
4846
|
+
}
|
|
4847
|
+
/**
|
|
4848
|
+
* Encode notes into a closed JSON backup. Carries the memo, not the keys.
|
|
4849
|
+
* `now` is injectable for a deterministic export (tests).
|
|
4850
|
+
*/
|
|
4851
|
+
declare function encodeNoteBackup(notes: ZkNote[], options?: {
|
|
4852
|
+
now?: () => number;
|
|
4853
|
+
}): NoteBackup;
|
|
4854
|
+
/**
|
|
4855
|
+
* Decode a JSON backup (string or object) into entries. Strict: a malformed
|
|
4856
|
+
* payload is rejected rather than partially imported.
|
|
4857
|
+
*/
|
|
4858
|
+
declare function decodeNoteBackup(json: string | object): NoteBackupEntry[];
|
|
4859
|
+
/**
|
|
4860
|
+
* Import a closed backup: decrypt each entry's memo with the importer's keys and
|
|
4861
|
+
* return the notes that belong to them as full, spendable `ZkNote`s.
|
|
4862
|
+
*
|
|
4863
|
+
* Ownership is proven by decryption — an entry whose memo does not open under
|
|
4864
|
+
* these keys is silently skipped (it is not this user's note). No chain access:
|
|
4865
|
+
* only the backup's own memos are tried.
|
|
4866
|
+
*
|
|
4867
|
+
* The decrypted note is reconstructed as unspent; the entry's `spent`/`spentAt`
|
|
4868
|
+
* flags are then applied so a restored vault separates available from spent. A
|
|
4869
|
+
* host may reconcile against the chain afterward if the backup could be stale.
|
|
4870
|
+
*/
|
|
4871
|
+
declare function importNotesFromBackup(entries: NoteBackupEntry[], keys: BackupImportKeys): ZkNote[];
|
|
4872
|
+
|
|
4782
4873
|
/**
|
|
4783
4874
|
* The steps every spend shares, in the order a spend performs them.
|
|
4784
4875
|
*
|
|
@@ -5386,4 +5477,4 @@ declare class OrbinumWallet {
|
|
|
5386
5477
|
private requireKey;
|
|
5387
5478
|
}
|
|
5388
5479
|
|
|
5389
|
-
export { type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BlockInfo, type BuildNoteDeps, type BuildNoteParams, type Bytes32, CachedNullifier, type ChainInfo, ChainModule, type ChunkInfo, CircuitId, CircuitVersionResolver, type ClaimShieldedFeesParams, type ClientProviderConfig, type CoinSelection, type CollectScanEntriesParams, type CommitmentsInsertedEvent, type ConnectionStatus, type CryptoKey$1 as CryptoKey, CryptoPrecompiles, type DecodedPrecompile, DecryptPool, DecryptedMemo, type DynamicBuilder, ENCRYPTED_MEMO_SIZE, EncryptedMemo, EncryptedNoteRecord, EncryptedTxRecord, type EventData, type EventPhase, type EventRecord, type EvmAddressInfo, type EvmBlock, EvmClient, EvmExplorer, type EvmLog, type EvmSigner, type EvmTransaction, type EvmTxRequest, type EvmTxSummary, type ExtrinsicDecoder, type ExtrinsicFacts, type ExtrinsicRecord, type FeeClaimDeps, type FeeClaimParams, type FeeClaimProofInputs, type FeeClaimProofOutput, type FeeClaimStep, type FormatOptions, KNOWN_PALLET_ERRORS, KNOWN_PRECOMPILES, type KnownPrecompileInfo, LEAVES_PER_TREE, MIN_GASLESS_FEE, MIN_SIGNATURE_BYTES, MemoryVaultStorage, type MerkleRootUpdatedEvent, type MutableWalletSession, NATIVE_ASSET_ID, NOTE_BIGINT_FIELDS, NOTE_TRANSFER_URI_SCHEME, type NoteBuildKeys, NoteBuilder, type NoteDisclosure, NoteInput, NoteStatusUpdate, NoteStorage, type NoteTransferEntry, type NoteTransferPayload, type NoteWithMeta, type NotesCache, NullifierCache, type NullifierChunkBody, type NullifierManifest, type NullifierSource, NullifierSyncMeta, type NullifierTail, type NullifiersSpentEvent, type ObservableNotesCache, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, OrbinumWallet, type OrbinumWalletConfig, PAGE_SIZE, PRECOMPILE_ADDR, type PairwiseEphWindowEntry, type PalletErrorKind, type PersistParams, type PrecompileMethod, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type ProofOptions, type ProviderFactory, QR_PAGE_MAX_CHARS, RECOVERED_TX_RESULT, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type ReconstructDeps, type ReconstructedTxRecord, type RegisterAssetArgs, type RelayerInfo, RelayerStatusModule, type ResolveSpentSetParams, type ResolvedProverVersion, type ResolvedSpendVersion, type RpcV2MerkleProof, RpcV2Module, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, type RunScanParams, SPENDING_KEY_CANONICAL_ORIGIN, SPENDING_KEY_VERIFYING_CONTRACT, SPENDING_KEY_WARNING, type ScanChunkManifest, ScanCommitment, type ScanHint, type ScanHintPage, type ScanHintSource, ScanKeys, type ScanOptions, type ScanOutcome, type ScanProgress, type ScanResult, SecretStore, type SelfEphWindowEntry, type SelfStealthKeys, type SessionCacheDeps, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedEvent, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SpendDetails, type SpendPlanProblem, type SpendPrivacyReads, type SpendVault, type SpendableInputsCheck, type SpendingKeyTypedData, type StatusChangeEvent, type StatusListener, SubstrateClient, type SystemHealth, TRANSFER_INPUTS, TRANSFER_OUTPUTS, type TokenInfo, type TokenTransfer, type TransferDeps, type TransferFactsRow, type TransferFactsSource, type TransferInputNote, type TransferOutputNote, type TransferParams, type TransferPlan, type TransferStep, type TransferSubmitRequest, type TxFactsSource, TxHistoryStore, type TxKind, type TxLandingPollOptions, type TxResult, type UnsafeTxOptions, type UnshieldArgs, type UnshieldDeps, type UnshieldNoteParams, type UnshieldParams, type UnshieldPlan, type UnshieldProofInputs, type UnshieldProofResult, type UnshieldStep, type UnshieldSubmitRequest, type UnshieldedEvent, type UnverifyAssetArgs, VAULT_SCHEMA_VERSION, VaultConfigRecord, VaultLockedError, VaultStorage, VaultStore, type VaultStoreDeps, type VaultUnlockOptions, type VerifyAssetArgs, type VersionedArtifactProvider, type WalletScanKeys, type WalletSession, ZkNote, type ZkVerifierCircuitVersionInfo, type ZkVerifierHistoricalVersion, ZkVerifierModule, type ZkVerifierVersionStats, type ZkVerifierVkHash, accountIdHexToSs58, addressToAccountIdHex, addressToFieldElement, applyBatch, applyNoteStatus, assembleNoteTransfer, base64UrlDecode, base64UrlEncode, bigintTo32Be, bigintTo32Le, bigintTo32LeArr, blindTag, buildConfig, buildDummyTransferInput, buildShieldBatchOperations, buildShieldParams, buildZkNote, bytesToBigintLE, bytesToBjjScalar, cacheSession, canPairWith, canonicalAccountId, chainActiveCircuitVersion, checkSpendableInputs, claimFees, classifyChainError, clearSession, collectNullifiersToQuery, collectScanEntries, commitmentHexOf, computeNoteCommitment, computeNullifier, computePathIndices, connectInjectedExtension, createNoteDisclosureKey, createNotesCache, createWalletSession, decodeNoteDisclosureKey, decodeNoteTransferPage, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, derivePairwiseEphSk, derivePairwiseSharedSecret, deriveSelfEphSk, deriveSpendingKeyFromMaster, deriveSpendingKeyFromSignature, deriveSpendingKeyMessageV2, deriveSpendingKeyTypedData, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, deriveVaultKey, deriveViewTag, deriveViewingPublicKey, deriveViewingSecretKey, detectCommitmentMismatch, encodeNoteTransferPages, encryptJson, encryptNote, ensureCreatedAt, ensureHexPrefix, evmAddressToAccountId, evmToImplicitSubstrate, evmToMappedAccountHex, evmToSubstrate, extractPalletError, failed, fastMulBase, fastMulPoint, fetchExtrinsicFacts, formatAmountPlain, formatBalance, formatORB, fromBase64, fromHex, gapMargin, generateFeeClaimProof, generateTransferProof, generateUnshieldProof, getInjectedExtensions, getPrecompileLabel, hasCachedSession, hasInjectedExtensions, hexToBigint, hexToNumber, implicitSubstrateToEvm, isAbortError, isAlreadySpentError, isConnectionLossError, isEvmAddress, isGhostNoteError, isImplicitEvmAccount, isNativeAsset, isNoteSelfConsistent, isSpendable, isSs58, isSubstrateAddress, isUnifiedAddress, isValidLeafIndex, leHexToBigint, mapExtrinsicArgs, mapZkEventData, markInputsSpent, normalizeChainFingerprint, normalizeEvmAddress, normalizeNote, normalizeNotes, noteBlindTag, noteCreatedAt, noteCreatedTxHash, noteMatchesCommitment, noteOrigin, noteSpentTxHash, noteToTransferEntry, noteTxKind, pairwiseEphWindow, palletErrorKind, parseAmount, parseEvmAddress, persistCursor, persistScanResults, planTransfer, planUnshield, randomBlinding, reconstructOutgoingTxRecords, recoverOwnerPkPoint, recoverSelfStealthNote, refuseIfAlreadySpent, removeByCommitment, requireSessionKeys, reservePairwiseIndex, reserveSelfEphIndex, resolveSelfEphCeiling, resolveSpentSet, resolveSpentStatus, restoreSession, runScan, scalarToHex, scanAbortError, selectGhosts, selectNotes, selfEphWindow, serializeMemo, sessionCacheKey, shortHash, signAndSubmitTx, spendableBalance, stampCreatedAt, stampCreatedTxHash, stampSpentTxHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, transferNotes, treeIdOf, treeOf, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, txLandedAfterError, unshieldNote, upsertNote, vaultReplacer, vaultReviver, vaultStorageName, windowSizeForCounter };
|
|
5480
|
+
export { type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BackupImportKeys, type BlockInfo, type BuildNoteDeps, type BuildNoteParams, type Bytes32, CachedNullifier, type ChainInfo, ChainModule, type ChunkInfo, CircuitId, CircuitVersionResolver, type ClaimShieldedFeesParams, type ClientProviderConfig, type CoinSelection, type CollectScanEntriesParams, type CommitmentsInsertedEvent, type ConnectionStatus, type CryptoKey$1 as CryptoKey, CryptoPrecompiles, type DecodedPrecompile, DecryptPool, DecryptedMemo, type DynamicBuilder, ENCRYPTED_MEMO_SIZE, EncryptedMemo, EncryptedNoteRecord, EncryptedTxRecord, type EventData, type EventPhase, type EventRecord, type EvmAddressInfo, type EvmBlock, EvmClient, EvmExplorer, type EvmLog, type EvmSigner, type EvmTransaction, type EvmTxRequest, type EvmTxSummary, type ExtrinsicDecoder, type ExtrinsicFacts, type ExtrinsicRecord, type FeeClaimDeps, type FeeClaimParams, type FeeClaimProofInputs, type FeeClaimProofOutput, type FeeClaimStep, type FormatOptions, KNOWN_PALLET_ERRORS, KNOWN_PRECOMPILES, type KnownPrecompileInfo, LEAVES_PER_TREE, MIN_GASLESS_FEE, MIN_SIGNATURE_BYTES, MemoryVaultStorage, type MerkleRootUpdatedEvent, type MutableWalletSession, NATIVE_ASSET_ID, NOTE_BACKUP_VERSION, NOTE_BIGINT_FIELDS, NOTE_TRANSFER_URI_SCHEME, type NoteBackup, type NoteBackupEntry, type NoteBuildKeys, NoteBuilder, type NoteDisclosure, NoteInput, NoteStatusUpdate, NoteStorage, type NoteTransferEntry, type NoteTransferPayload, type NoteWithMeta, type NotesCache, NullifierCache, type NullifierChunkBody, type NullifierManifest, type NullifierSource, NullifierSyncMeta, type NullifierTail, type NullifiersSpentEvent, type ObservableNotesCache, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, OrbinumWallet, type OrbinumWalletConfig, PAGE_SIZE, PRECOMPILE_ADDR, type PairwiseEphWindowEntry, type PalletErrorKind, type PersistParams, type PrecompileMethod, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type ProofOptions, type ProviderFactory, QR_PAGE_MAX_CHARS, RECOVERED_TX_RESULT, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type ReconstructDeps, type ReconstructedTxRecord, type RegisterAssetArgs, type RelayerInfo, RelayerStatusModule, type ResolveSpentSetParams, type ResolvedProverVersion, type ResolvedSpendVersion, type RpcV2MerkleProof, RpcV2Module, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, type RunScanParams, SPENDING_KEY_CANONICAL_ORIGIN, SPENDING_KEY_VERIFYING_CONTRACT, SPENDING_KEY_WARNING, type ScanChunkManifest, ScanCommitment, type ScanHint, type ScanHintPage, type ScanHintSource, ScanKeys, type ScanOptions, type ScanOutcome, type ScanProgress, type ScanResult, SecretStore, type SelfEphWindowEntry, type SelfStealthKeys, type SessionCacheDeps, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedEvent, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SpendDetails, type SpendPlanProblem, type SpendPrivacyReads, type SpendVault, type SpendableInputsCheck, type SpendingKeyTypedData, type StatusChangeEvent, type StatusListener, SubstrateClient, type SystemHealth, TRANSFER_INPUTS, TRANSFER_OUTPUTS, type TokenInfo, type TokenTransfer, type TransferDeps, type TransferFactsRow, type TransferFactsSource, type TransferInputNote, type TransferOutputNote, type TransferParams, type TransferPlan, type TransferStep, type TransferSubmitRequest, type TxFactsSource, TxHistoryStore, type TxKind, type TxLandingPollOptions, type TxResult, type UnsafeTxOptions, type UnshieldArgs, type UnshieldDeps, type UnshieldNoteParams, type UnshieldParams, type UnshieldPlan, type UnshieldProofInputs, type UnshieldProofResult, type UnshieldStep, type UnshieldSubmitRequest, type UnshieldedEvent, type UnverifyAssetArgs, VAULT_SCHEMA_VERSION, VaultConfigRecord, VaultLockedError, VaultStorage, VaultStore, type VaultStoreDeps, type VaultUnlockOptions, type VerifyAssetArgs, type VersionedArtifactProvider, type WalletScanKeys, type WalletSession, ZkNote, type ZkVerifierCircuitVersionInfo, type ZkVerifierHistoricalVersion, ZkVerifierModule, type ZkVerifierVersionStats, type ZkVerifierVkHash, accountIdHexToSs58, addressToAccountIdHex, addressToFieldElement, applyBatch, applyNoteStatus, assembleNoteTransfer, base64UrlDecode, base64UrlEncode, bigintTo32Be, bigintTo32Le, bigintTo32LeArr, blindTag, buildConfig, buildDummyTransferInput, buildShieldBatchOperations, buildShieldParams, buildZkNote, bytesToBigintLE, bytesToBjjScalar, cacheSession, canPairWith, canonicalAccountId, chainActiveCircuitVersion, checkSpendableInputs, claimFees, classifyChainError, clearSession, collectNullifiersToQuery, collectScanEntries, commitmentHexOf, computeNoteCommitment, computeNullifier, computePathIndices, connectInjectedExtension, createNoteDisclosureKey, createNotesCache, createWalletSession, decodeNoteBackup, decodeNoteDisclosureKey, decodeNoteTransferPage, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, derivePairwiseEphSk, derivePairwiseSharedSecret, deriveSelfEphSk, deriveSpendingKeyFromMaster, deriveSpendingKeyFromSignature, deriveSpendingKeyMessageV2, deriveSpendingKeyTypedData, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, deriveVaultKey, deriveViewTag, deriveViewingPublicKey, deriveViewingSecretKey, detectCommitmentMismatch, encodeNoteBackup, encodeNoteTransferPages, encryptJson, encryptNote, ensureCreatedAt, ensureHexPrefix, evmAddressToAccountId, evmToImplicitSubstrate, evmToMappedAccountHex, evmToSubstrate, extractPalletError, failed, fastMulBase, fastMulPoint, fetchExtrinsicFacts, formatAmountPlain, formatBalance, formatORB, fromBase64, fromHex, gapMargin, generateFeeClaimProof, generateTransferProof, generateUnshieldProof, getInjectedExtensions, getPrecompileLabel, hasCachedSession, hasInjectedExtensions, hexToBigint, hexToNumber, implicitSubstrateToEvm, importNotesFromBackup, isAbortError, isAlreadySpentError, isConnectionLossError, isEvmAddress, isGhostNoteError, isImplicitEvmAccount, isNativeAsset, isNoteSelfConsistent, isSpendable, isSs58, isSubstrateAddress, isUnifiedAddress, isValidLeafIndex, leHexToBigint, mapExtrinsicArgs, mapZkEventData, markInputsSpent, normalizeChainFingerprint, normalizeEvmAddress, normalizeNote, normalizeNotes, noteBlindTag, noteCreatedAt, noteCreatedTxHash, noteMatchesCommitment, noteOrigin, noteSpentTxHash, noteToTransferEntry, noteTxKind, pairwiseEphWindow, palletErrorKind, parseAmount, parseEvmAddress, persistCursor, persistScanResults, planTransfer, planUnshield, randomBlinding, reconstructOutgoingTxRecords, recoverOwnerPkPoint, recoverSelfStealthNote, refuseIfAlreadySpent, removeByCommitment, requireSessionKeys, reservePairwiseIndex, reserveSelfEphIndex, resolveSelfEphCeiling, resolveSpentSet, resolveSpentStatus, restoreSession, runScan, scalarToHex, scanAbortError, selectGhosts, selectNotes, selfEphWindow, serializeMemo, sessionCacheKey, shortHash, signAndSubmitTx, spendableBalance, stampCreatedAt, stampCreatedTxHash, stampSpentTxHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, transferNotes, treeIdOf, treeOf, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, txLandedAfterError, unshieldNote, upsertNote, vaultReplacer, vaultReviver, vaultStorageName, windowSizeForCounter };
|
package/dist/index.d.ts
CHANGED
|
@@ -4779,6 +4779,97 @@ declare function decodeNoteTransferPage(uri: string): NoteTransferPayload;
|
|
|
4779
4779
|
*/
|
|
4780
4780
|
declare function assembleNoteTransfer(pages: NoteTransferPayload[]): NoteTransferEntry[];
|
|
4781
4781
|
|
|
4782
|
+
/**
|
|
4783
|
+
* CLOSED JSON backup of notes — the same notes moved between a user's devices as
|
|
4784
|
+
* a plain file, WITHOUT exposing any spending key.
|
|
4785
|
+
*
|
|
4786
|
+
* ## The idea
|
|
4787
|
+
*
|
|
4788
|
+
* A backup entry carries only what is already PUBLIC on chain: the commitment and
|
|
4789
|
+
* the encrypted memo. It contains no spending key, so the file is safe to hold
|
|
4790
|
+
* and even share — it grants nothing on its own.
|
|
4791
|
+
*
|
|
4792
|
+
* On import, the recipient DECRYPTS each memo with their own viewing key
|
|
4793
|
+
* (`importNotesFromBackup`). Decryption is the proof of ownership:
|
|
4794
|
+
* - the memo decrypts → the note is theirs → a full spendable `ZkNote` is
|
|
4795
|
+
* reconstructed, spending key and stealth key derived from their identity;
|
|
4796
|
+
* - the memo does not decrypt → the note is someone else's → it is dropped.
|
|
4797
|
+
*
|
|
4798
|
+
* This is NOT a chain scan: only the N memos in the backup are tried, not the
|
|
4799
|
+
* whole pool. It moves notes between devices without re-scanning, and a note that
|
|
4800
|
+
* is not yours simply fails to import.
|
|
4801
|
+
*
|
|
4802
|
+
* ## What travels vs what does not
|
|
4803
|
+
*
|
|
4804
|
+
* Travels: `commitmentHex`, `encryptedMemo`, and `leafIndex` (informational).
|
|
4805
|
+
* Does NOT travel: value, ownerPk, blinding, spendingKey — all recovered by
|
|
4806
|
+
* decrypting the memo. The Merkle proof is re-fetched at spend time.
|
|
4807
|
+
*/
|
|
4808
|
+
|
|
4809
|
+
/** Current backup format version. Bumped only if the entry shape changes. */
|
|
4810
|
+
declare const NOTE_BACKUP_VERSION: 1;
|
|
4811
|
+
/**
|
|
4812
|
+
* One note in a closed backup — public data only. Field names are short but not
|
|
4813
|
+
* cryptic; readability matters more than density in a file (unlike the QR path).
|
|
4814
|
+
*/
|
|
4815
|
+
interface NoteBackupEntry {
|
|
4816
|
+
/** 0x-prefixed 32-byte LE commitment hex. */
|
|
4817
|
+
commitmentHex: string;
|
|
4818
|
+
/** 0x-prefixed encrypted memo hex (180 bytes). Decrypted on import. */
|
|
4819
|
+
encryptedMemo: string;
|
|
4820
|
+
/** Merkle leaf index, when known. Informational — spends re-fetch the proof. */
|
|
4821
|
+
leafIndex?: number;
|
|
4822
|
+
/**
|
|
4823
|
+
* Whether the note was already spent when exported. A local status flag (not
|
|
4824
|
+
* a key or secret), carried so a restored vault separates available from spent
|
|
4825
|
+
* without a chain round-trip. A host may still reconcile against the chain
|
|
4826
|
+
* afterward — this is a fast, possibly-stale hint, not the source of truth.
|
|
4827
|
+
*/
|
|
4828
|
+
spent?: boolean;
|
|
4829
|
+
/** Local timestamp the note was marked spent, when known. */
|
|
4830
|
+
spentAt?: number | null;
|
|
4831
|
+
}
|
|
4832
|
+
interface NoteBackup {
|
|
4833
|
+
v: typeof NOTE_BACKUP_VERSION;
|
|
4834
|
+
/** Export time (ms). Informational. */
|
|
4835
|
+
ts: number;
|
|
4836
|
+
notes: NoteBackupEntry[];
|
|
4837
|
+
}
|
|
4838
|
+
/** Keys the importer needs to prove ownership by decrypting each memo. */
|
|
4839
|
+
interface BackupImportKeys {
|
|
4840
|
+
/** 32-byte viewing secret key (ivsk). */
|
|
4841
|
+
viewingSecretKey: Uint8Array;
|
|
4842
|
+
/** Spending key scalar — folded into the derived stealth key / nullifier. */
|
|
4843
|
+
spendingKey: bigint;
|
|
4844
|
+
/** The importer's global owner pk (Ax), for stealth detection. */
|
|
4845
|
+
ownerPk: bigint;
|
|
4846
|
+
}
|
|
4847
|
+
/**
|
|
4848
|
+
* Encode notes into a closed JSON backup. Carries the memo, not the keys.
|
|
4849
|
+
* `now` is injectable for a deterministic export (tests).
|
|
4850
|
+
*/
|
|
4851
|
+
declare function encodeNoteBackup(notes: ZkNote[], options?: {
|
|
4852
|
+
now?: () => number;
|
|
4853
|
+
}): NoteBackup;
|
|
4854
|
+
/**
|
|
4855
|
+
* Decode a JSON backup (string or object) into entries. Strict: a malformed
|
|
4856
|
+
* payload is rejected rather than partially imported.
|
|
4857
|
+
*/
|
|
4858
|
+
declare function decodeNoteBackup(json: string | object): NoteBackupEntry[];
|
|
4859
|
+
/**
|
|
4860
|
+
* Import a closed backup: decrypt each entry's memo with the importer's keys and
|
|
4861
|
+
* return the notes that belong to them as full, spendable `ZkNote`s.
|
|
4862
|
+
*
|
|
4863
|
+
* Ownership is proven by decryption — an entry whose memo does not open under
|
|
4864
|
+
* these keys is silently skipped (it is not this user's note). No chain access:
|
|
4865
|
+
* only the backup's own memos are tried.
|
|
4866
|
+
*
|
|
4867
|
+
* The decrypted note is reconstructed as unspent; the entry's `spent`/`spentAt`
|
|
4868
|
+
* flags are then applied so a restored vault separates available from spent. A
|
|
4869
|
+
* host may reconcile against the chain afterward if the backup could be stale.
|
|
4870
|
+
*/
|
|
4871
|
+
declare function importNotesFromBackup(entries: NoteBackupEntry[], keys: BackupImportKeys): ZkNote[];
|
|
4872
|
+
|
|
4782
4873
|
/**
|
|
4783
4874
|
* The steps every spend shares, in the order a spend performs them.
|
|
4784
4875
|
*
|
|
@@ -5386,4 +5477,4 @@ declare class OrbinumWallet {
|
|
|
5386
5477
|
private requireKey;
|
|
5387
5478
|
}
|
|
5388
5479
|
|
|
5389
|
-
export { type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BlockInfo, type BuildNoteDeps, type BuildNoteParams, type Bytes32, CachedNullifier, type ChainInfo, ChainModule, type ChunkInfo, CircuitId, CircuitVersionResolver, type ClaimShieldedFeesParams, type ClientProviderConfig, type CoinSelection, type CollectScanEntriesParams, type CommitmentsInsertedEvent, type ConnectionStatus, type CryptoKey$1 as CryptoKey, CryptoPrecompiles, type DecodedPrecompile, DecryptPool, DecryptedMemo, type DynamicBuilder, ENCRYPTED_MEMO_SIZE, EncryptedMemo, EncryptedNoteRecord, EncryptedTxRecord, type EventData, type EventPhase, type EventRecord, type EvmAddressInfo, type EvmBlock, EvmClient, EvmExplorer, type EvmLog, type EvmSigner, type EvmTransaction, type EvmTxRequest, type EvmTxSummary, type ExtrinsicDecoder, type ExtrinsicFacts, type ExtrinsicRecord, type FeeClaimDeps, type FeeClaimParams, type FeeClaimProofInputs, type FeeClaimProofOutput, type FeeClaimStep, type FormatOptions, KNOWN_PALLET_ERRORS, KNOWN_PRECOMPILES, type KnownPrecompileInfo, LEAVES_PER_TREE, MIN_GASLESS_FEE, MIN_SIGNATURE_BYTES, MemoryVaultStorage, type MerkleRootUpdatedEvent, type MutableWalletSession, NATIVE_ASSET_ID, NOTE_BIGINT_FIELDS, NOTE_TRANSFER_URI_SCHEME, type NoteBuildKeys, NoteBuilder, type NoteDisclosure, NoteInput, NoteStatusUpdate, NoteStorage, type NoteTransferEntry, type NoteTransferPayload, type NoteWithMeta, type NotesCache, NullifierCache, type NullifierChunkBody, type NullifierManifest, type NullifierSource, NullifierSyncMeta, type NullifierTail, type NullifiersSpentEvent, type ObservableNotesCache, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, OrbinumWallet, type OrbinumWalletConfig, PAGE_SIZE, PRECOMPILE_ADDR, type PairwiseEphWindowEntry, type PalletErrorKind, type PersistParams, type PrecompileMethod, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type ProofOptions, type ProviderFactory, QR_PAGE_MAX_CHARS, RECOVERED_TX_RESULT, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type ReconstructDeps, type ReconstructedTxRecord, type RegisterAssetArgs, type RelayerInfo, RelayerStatusModule, type ResolveSpentSetParams, type ResolvedProverVersion, type ResolvedSpendVersion, type RpcV2MerkleProof, RpcV2Module, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, type RunScanParams, SPENDING_KEY_CANONICAL_ORIGIN, SPENDING_KEY_VERIFYING_CONTRACT, SPENDING_KEY_WARNING, type ScanChunkManifest, ScanCommitment, type ScanHint, type ScanHintPage, type ScanHintSource, ScanKeys, type ScanOptions, type ScanOutcome, type ScanProgress, type ScanResult, SecretStore, type SelfEphWindowEntry, type SelfStealthKeys, type SessionCacheDeps, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedEvent, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SpendDetails, type SpendPlanProblem, type SpendPrivacyReads, type SpendVault, type SpendableInputsCheck, type SpendingKeyTypedData, type StatusChangeEvent, type StatusListener, SubstrateClient, type SystemHealth, TRANSFER_INPUTS, TRANSFER_OUTPUTS, type TokenInfo, type TokenTransfer, type TransferDeps, type TransferFactsRow, type TransferFactsSource, type TransferInputNote, type TransferOutputNote, type TransferParams, type TransferPlan, type TransferStep, type TransferSubmitRequest, type TxFactsSource, TxHistoryStore, type TxKind, type TxLandingPollOptions, type TxResult, type UnsafeTxOptions, type UnshieldArgs, type UnshieldDeps, type UnshieldNoteParams, type UnshieldParams, type UnshieldPlan, type UnshieldProofInputs, type UnshieldProofResult, type UnshieldStep, type UnshieldSubmitRequest, type UnshieldedEvent, type UnverifyAssetArgs, VAULT_SCHEMA_VERSION, VaultConfigRecord, VaultLockedError, VaultStorage, VaultStore, type VaultStoreDeps, type VaultUnlockOptions, type VerifyAssetArgs, type VersionedArtifactProvider, type WalletScanKeys, type WalletSession, ZkNote, type ZkVerifierCircuitVersionInfo, type ZkVerifierHistoricalVersion, ZkVerifierModule, type ZkVerifierVersionStats, type ZkVerifierVkHash, accountIdHexToSs58, addressToAccountIdHex, addressToFieldElement, applyBatch, applyNoteStatus, assembleNoteTransfer, base64UrlDecode, base64UrlEncode, bigintTo32Be, bigintTo32Le, bigintTo32LeArr, blindTag, buildConfig, buildDummyTransferInput, buildShieldBatchOperations, buildShieldParams, buildZkNote, bytesToBigintLE, bytesToBjjScalar, cacheSession, canPairWith, canonicalAccountId, chainActiveCircuitVersion, checkSpendableInputs, claimFees, classifyChainError, clearSession, collectNullifiersToQuery, collectScanEntries, commitmentHexOf, computeNoteCommitment, computeNullifier, computePathIndices, connectInjectedExtension, createNoteDisclosureKey, createNotesCache, createWalletSession, decodeNoteDisclosureKey, decodeNoteTransferPage, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, derivePairwiseEphSk, derivePairwiseSharedSecret, deriveSelfEphSk, deriveSpendingKeyFromMaster, deriveSpendingKeyFromSignature, deriveSpendingKeyMessageV2, deriveSpendingKeyTypedData, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, deriveVaultKey, deriveViewTag, deriveViewingPublicKey, deriveViewingSecretKey, detectCommitmentMismatch, encodeNoteTransferPages, encryptJson, encryptNote, ensureCreatedAt, ensureHexPrefix, evmAddressToAccountId, evmToImplicitSubstrate, evmToMappedAccountHex, evmToSubstrate, extractPalletError, failed, fastMulBase, fastMulPoint, fetchExtrinsicFacts, formatAmountPlain, formatBalance, formatORB, fromBase64, fromHex, gapMargin, generateFeeClaimProof, generateTransferProof, generateUnshieldProof, getInjectedExtensions, getPrecompileLabel, hasCachedSession, hasInjectedExtensions, hexToBigint, hexToNumber, implicitSubstrateToEvm, isAbortError, isAlreadySpentError, isConnectionLossError, isEvmAddress, isGhostNoteError, isImplicitEvmAccount, isNativeAsset, isNoteSelfConsistent, isSpendable, isSs58, isSubstrateAddress, isUnifiedAddress, isValidLeafIndex, leHexToBigint, mapExtrinsicArgs, mapZkEventData, markInputsSpent, normalizeChainFingerprint, normalizeEvmAddress, normalizeNote, normalizeNotes, noteBlindTag, noteCreatedAt, noteCreatedTxHash, noteMatchesCommitment, noteOrigin, noteSpentTxHash, noteToTransferEntry, noteTxKind, pairwiseEphWindow, palletErrorKind, parseAmount, parseEvmAddress, persistCursor, persistScanResults, planTransfer, planUnshield, randomBlinding, reconstructOutgoingTxRecords, recoverOwnerPkPoint, recoverSelfStealthNote, refuseIfAlreadySpent, removeByCommitment, requireSessionKeys, reservePairwiseIndex, reserveSelfEphIndex, resolveSelfEphCeiling, resolveSpentSet, resolveSpentStatus, restoreSession, runScan, scalarToHex, scanAbortError, selectGhosts, selectNotes, selfEphWindow, serializeMemo, sessionCacheKey, shortHash, signAndSubmitTx, spendableBalance, stampCreatedAt, stampCreatedTxHash, stampSpentTxHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, transferNotes, treeIdOf, treeOf, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, txLandedAfterError, unshieldNote, upsertNote, vaultReplacer, vaultReviver, vaultStorageName, windowSizeForCounter };
|
|
5480
|
+
export { type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BackupImportKeys, type BlockInfo, type BuildNoteDeps, type BuildNoteParams, type Bytes32, CachedNullifier, type ChainInfo, ChainModule, type ChunkInfo, CircuitId, CircuitVersionResolver, type ClaimShieldedFeesParams, type ClientProviderConfig, type CoinSelection, type CollectScanEntriesParams, type CommitmentsInsertedEvent, type ConnectionStatus, type CryptoKey$1 as CryptoKey, CryptoPrecompiles, type DecodedPrecompile, DecryptPool, DecryptedMemo, type DynamicBuilder, ENCRYPTED_MEMO_SIZE, EncryptedMemo, EncryptedNoteRecord, EncryptedTxRecord, type EventData, type EventPhase, type EventRecord, type EvmAddressInfo, type EvmBlock, EvmClient, EvmExplorer, type EvmLog, type EvmSigner, type EvmTransaction, type EvmTxRequest, type EvmTxSummary, type ExtrinsicDecoder, type ExtrinsicFacts, type ExtrinsicRecord, type FeeClaimDeps, type FeeClaimParams, type FeeClaimProofInputs, type FeeClaimProofOutput, type FeeClaimStep, type FormatOptions, KNOWN_PALLET_ERRORS, KNOWN_PRECOMPILES, type KnownPrecompileInfo, LEAVES_PER_TREE, MIN_GASLESS_FEE, MIN_SIGNATURE_BYTES, MemoryVaultStorage, type MerkleRootUpdatedEvent, type MutableWalletSession, NATIVE_ASSET_ID, NOTE_BACKUP_VERSION, NOTE_BIGINT_FIELDS, NOTE_TRANSFER_URI_SCHEME, type NoteBackup, type NoteBackupEntry, type NoteBuildKeys, NoteBuilder, type NoteDisclosure, NoteInput, NoteStatusUpdate, NoteStorage, type NoteTransferEntry, type NoteTransferPayload, type NoteWithMeta, type NotesCache, NullifierCache, type NullifierChunkBody, type NullifierManifest, type NullifierSource, NullifierSyncMeta, type NullifierTail, type NullifiersSpentEvent, type ObservableNotesCache, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, OrbinumWallet, type OrbinumWalletConfig, PAGE_SIZE, PRECOMPILE_ADDR, type PairwiseEphWindowEntry, type PalletErrorKind, type PersistParams, type PrecompileMethod, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type ProofOptions, type ProviderFactory, QR_PAGE_MAX_CHARS, RECOVERED_TX_RESULT, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type ReconstructDeps, type ReconstructedTxRecord, type RegisterAssetArgs, type RelayerInfo, RelayerStatusModule, type ResolveSpentSetParams, type ResolvedProverVersion, type ResolvedSpendVersion, type RpcV2MerkleProof, RpcV2Module, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, type RunScanParams, SPENDING_KEY_CANONICAL_ORIGIN, SPENDING_KEY_VERIFYING_CONTRACT, SPENDING_KEY_WARNING, type ScanChunkManifest, ScanCommitment, type ScanHint, type ScanHintPage, type ScanHintSource, ScanKeys, type ScanOptions, type ScanOutcome, type ScanProgress, type ScanResult, SecretStore, type SelfEphWindowEntry, type SelfStealthKeys, type SessionCacheDeps, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedEvent, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SpendDetails, type SpendPlanProblem, type SpendPrivacyReads, type SpendVault, type SpendableInputsCheck, type SpendingKeyTypedData, type StatusChangeEvent, type StatusListener, SubstrateClient, type SystemHealth, TRANSFER_INPUTS, TRANSFER_OUTPUTS, type TokenInfo, type TokenTransfer, type TransferDeps, type TransferFactsRow, type TransferFactsSource, type TransferInputNote, type TransferOutputNote, type TransferParams, type TransferPlan, type TransferStep, type TransferSubmitRequest, type TxFactsSource, TxHistoryStore, type TxKind, type TxLandingPollOptions, type TxResult, type UnsafeTxOptions, type UnshieldArgs, type UnshieldDeps, type UnshieldNoteParams, type UnshieldParams, type UnshieldPlan, type UnshieldProofInputs, type UnshieldProofResult, type UnshieldStep, type UnshieldSubmitRequest, type UnshieldedEvent, type UnverifyAssetArgs, VAULT_SCHEMA_VERSION, VaultConfigRecord, VaultLockedError, VaultStorage, VaultStore, type VaultStoreDeps, type VaultUnlockOptions, type VerifyAssetArgs, type VersionedArtifactProvider, type WalletScanKeys, type WalletSession, ZkNote, type ZkVerifierCircuitVersionInfo, type ZkVerifierHistoricalVersion, ZkVerifierModule, type ZkVerifierVersionStats, type ZkVerifierVkHash, accountIdHexToSs58, addressToAccountIdHex, addressToFieldElement, applyBatch, applyNoteStatus, assembleNoteTransfer, base64UrlDecode, base64UrlEncode, bigintTo32Be, bigintTo32Le, bigintTo32LeArr, blindTag, buildConfig, buildDummyTransferInput, buildShieldBatchOperations, buildShieldParams, buildZkNote, bytesToBigintLE, bytesToBjjScalar, cacheSession, canPairWith, canonicalAccountId, chainActiveCircuitVersion, checkSpendableInputs, claimFees, classifyChainError, clearSession, collectNullifiersToQuery, collectScanEntries, commitmentHexOf, computeNoteCommitment, computeNullifier, computePathIndices, connectInjectedExtension, createNoteDisclosureKey, createNotesCache, createWalletSession, decodeNoteBackup, decodeNoteDisclosureKey, decodeNoteTransferPage, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, derivePairwiseEphSk, derivePairwiseSharedSecret, deriveSelfEphSk, deriveSpendingKeyFromMaster, deriveSpendingKeyFromSignature, deriveSpendingKeyMessageV2, deriveSpendingKeyTypedData, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, deriveVaultKey, deriveViewTag, deriveViewingPublicKey, deriveViewingSecretKey, detectCommitmentMismatch, encodeNoteBackup, encodeNoteTransferPages, encryptJson, encryptNote, ensureCreatedAt, ensureHexPrefix, evmAddressToAccountId, evmToImplicitSubstrate, evmToMappedAccountHex, evmToSubstrate, extractPalletError, failed, fastMulBase, fastMulPoint, fetchExtrinsicFacts, formatAmountPlain, formatBalance, formatORB, fromBase64, fromHex, gapMargin, generateFeeClaimProof, generateTransferProof, generateUnshieldProof, getInjectedExtensions, getPrecompileLabel, hasCachedSession, hasInjectedExtensions, hexToBigint, hexToNumber, implicitSubstrateToEvm, importNotesFromBackup, isAbortError, isAlreadySpentError, isConnectionLossError, isEvmAddress, isGhostNoteError, isImplicitEvmAccount, isNativeAsset, isNoteSelfConsistent, isSpendable, isSs58, isSubstrateAddress, isUnifiedAddress, isValidLeafIndex, leHexToBigint, mapExtrinsicArgs, mapZkEventData, markInputsSpent, normalizeChainFingerprint, normalizeEvmAddress, normalizeNote, normalizeNotes, noteBlindTag, noteCreatedAt, noteCreatedTxHash, noteMatchesCommitment, noteOrigin, noteSpentTxHash, noteToTransferEntry, noteTxKind, pairwiseEphWindow, palletErrorKind, parseAmount, parseEvmAddress, persistCursor, persistScanResults, planTransfer, planUnshield, randomBlinding, reconstructOutgoingTxRecords, recoverOwnerPkPoint, recoverSelfStealthNote, refuseIfAlreadySpent, removeByCommitment, requireSessionKeys, reservePairwiseIndex, reserveSelfEphIndex, resolveSelfEphCeiling, resolveSpentSet, resolveSpentStatus, restoreSession, runScan, scalarToHex, scanAbortError, selectGhosts, selectNotes, selfEphWindow, serializeMemo, sessionCacheKey, shortHash, signAndSubmitTx, spendableBalance, stampCreatedAt, stampCreatedTxHash, stampSpentTxHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, transferNotes, treeIdOf, treeOf, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, txLandedAfterError, unshieldNote, upsertNote, vaultReplacer, vaultReviver, vaultStorageName, windowSizeForCounter };
|
package/dist/index.js
CHANGED
|
@@ -45,6 +45,7 @@ __export(index_exports, {
|
|
|
45
45
|
MIN_SIGNATURE_BYTES: () => MIN_SIGNATURE_BYTES,
|
|
46
46
|
MemoryVaultStorage: () => MemoryVaultStorage,
|
|
47
47
|
NATIVE_ASSET_ID: () => NATIVE_ASSET_ID,
|
|
48
|
+
NOTE_BACKUP_VERSION: () => NOTE_BACKUP_VERSION,
|
|
48
49
|
NOTE_BIGINT_FIELDS: () => NOTE_BIGINT_FIELDS,
|
|
49
50
|
NOTE_TRANSFER_URI_SCHEME: () => NOTE_TRANSFER_URI_SCHEME,
|
|
50
51
|
NoteBuilder: () => NoteBuilder,
|
|
@@ -120,6 +121,7 @@ __export(index_exports, {
|
|
|
120
121
|
createNotesCache: () => createNotesCache,
|
|
121
122
|
createWalletSession: () => createWalletSession,
|
|
122
123
|
createWorkerPool: () => createWorkerPool,
|
|
124
|
+
decodeNoteBackup: () => decodeNoteBackup,
|
|
123
125
|
decodeNoteDisclosureKey: () => decodeNoteDisclosureKey,
|
|
124
126
|
decodeNoteTransferPage: () => decodeNoteTransferPage,
|
|
125
127
|
decodePrecompileCalldata: () => decodePrecompileCalldata,
|
|
@@ -143,6 +145,7 @@ __export(index_exports, {
|
|
|
143
145
|
deriveViewingPublicKey: () => deriveViewingPublicKey,
|
|
144
146
|
deriveViewingSecretKey: () => deriveViewingSecretKey,
|
|
145
147
|
detectCommitmentMismatch: () => detectCommitmentMismatch,
|
|
148
|
+
encodeNoteBackup: () => encodeNoteBackup,
|
|
146
149
|
encodeNoteTransferPages: () => encodeNoteTransferPages,
|
|
147
150
|
encryptJson: () => encryptJson,
|
|
148
151
|
encryptNote: () => encryptNote,
|
|
@@ -179,6 +182,7 @@ __export(index_exports, {
|
|
|
179
182
|
hexToNumber: () => hexToNumber,
|
|
180
183
|
implicitSubstrateToEvm: () => implicitSubstrateToEvm,
|
|
181
184
|
importDeviceKey: () => importDeviceKey,
|
|
185
|
+
importNotesFromBackup: () => importNotesFromBackup,
|
|
182
186
|
isAbortError: () => isAbortError,
|
|
183
187
|
isAlreadySpentError: () => isAlreadySpentError,
|
|
184
188
|
isConnectionLossError: () => isConnectionLossError,
|
|
@@ -6326,6 +6330,80 @@ function assembleNoteTransfer(pages) {
|
|
|
6326
6330
|
return [...pages].sort((a, b) => a.p - b.p).flatMap((p) => p.notes);
|
|
6327
6331
|
}
|
|
6328
6332
|
|
|
6333
|
+
// src/wallet/ops/notes/noteBackup.ts
|
|
6334
|
+
var NOTE_BACKUP_VERSION = 1;
|
|
6335
|
+
function noteToBackupEntry(note) {
|
|
6336
|
+
return {
|
|
6337
|
+
commitmentHex: note.commitmentHex,
|
|
6338
|
+
encryptedMemo: toHex(Uint8Array.from(note.memo)),
|
|
6339
|
+
...note.leafIndex !== void 0 ? { leafIndex: note.leafIndex } : {},
|
|
6340
|
+
spent: note.spent,
|
|
6341
|
+
spentAt: note.spentAt
|
|
6342
|
+
};
|
|
6343
|
+
}
|
|
6344
|
+
function encodeNoteBackup(notes, options = {}) {
|
|
6345
|
+
const now = options.now ?? Date.now;
|
|
6346
|
+
return {
|
|
6347
|
+
v: NOTE_BACKUP_VERSION,
|
|
6348
|
+
ts: now(),
|
|
6349
|
+
notes: notes.map(noteToBackupEntry)
|
|
6350
|
+
};
|
|
6351
|
+
}
|
|
6352
|
+
function decodeNoteBackup(json) {
|
|
6353
|
+
let payload;
|
|
6354
|
+
if (typeof json === "string") {
|
|
6355
|
+
try {
|
|
6356
|
+
payload = JSON.parse(json);
|
|
6357
|
+
} catch {
|
|
6358
|
+
throw new Error("Note backup is not valid JSON.");
|
|
6359
|
+
}
|
|
6360
|
+
} else {
|
|
6361
|
+
payload = json;
|
|
6362
|
+
}
|
|
6363
|
+
const p = payload;
|
|
6364
|
+
if (p.v !== NOTE_BACKUP_VERSION) {
|
|
6365
|
+
throw new Error(`Unsupported note-backup version: ${String(p.v)}.`);
|
|
6366
|
+
}
|
|
6367
|
+
if (!Array.isArray(p.notes) || p.notes.some((n) => !isEntry2(n))) {
|
|
6368
|
+
throw new Error("Note backup is missing required fields.");
|
|
6369
|
+
}
|
|
6370
|
+
return p.notes;
|
|
6371
|
+
}
|
|
6372
|
+
function importNotesFromBackup(entries, keys) {
|
|
6373
|
+
const out = [];
|
|
6374
|
+
for (const entry of entries) {
|
|
6375
|
+
const commitment = {
|
|
6376
|
+
commitmentHex: entry.commitmentHex,
|
|
6377
|
+
leafIndex: entry.leafIndex ?? -1,
|
|
6378
|
+
encryptedMemo: entry.encryptedMemo
|
|
6379
|
+
};
|
|
6380
|
+
const note = tryDecryptNote(
|
|
6381
|
+
commitment,
|
|
6382
|
+
keys.viewingSecretKey,
|
|
6383
|
+
keys.spendingKey,
|
|
6384
|
+
keys.ownerPk
|
|
6385
|
+
);
|
|
6386
|
+
if (note) {
|
|
6387
|
+
out.push({
|
|
6388
|
+
...note,
|
|
6389
|
+
spent: entry.spent ?? false,
|
|
6390
|
+
spentAt: entry.spentAt ?? null
|
|
6391
|
+
});
|
|
6392
|
+
}
|
|
6393
|
+
}
|
|
6394
|
+
return out;
|
|
6395
|
+
}
|
|
6396
|
+
function isEntry2(value) {
|
|
6397
|
+
if (typeof value !== "object" || value === null) return false;
|
|
6398
|
+
const e = value;
|
|
6399
|
+
if (typeof e["commitmentHex"] !== "string" || e["commitmentHex"].length === 0) return false;
|
|
6400
|
+
if (typeof e["encryptedMemo"] !== "string" || e["encryptedMemo"].length === 0) return false;
|
|
6401
|
+
if ("leafIndex" in e && e["leafIndex"] !== void 0 && typeof e["leafIndex"] !== "number") {
|
|
6402
|
+
return false;
|
|
6403
|
+
}
|
|
6404
|
+
return true;
|
|
6405
|
+
}
|
|
6406
|
+
|
|
6329
6407
|
// src/wallet/ops/spend/transfer.ts
|
|
6330
6408
|
var import_proof_generator6 = require("@orbinum/proof-generator");
|
|
6331
6409
|
|
|
@@ -7414,6 +7492,7 @@ var OrbinumWallet = class {
|
|
|
7414
7492
|
MIN_SIGNATURE_BYTES,
|
|
7415
7493
|
MemoryVaultStorage,
|
|
7416
7494
|
NATIVE_ASSET_ID,
|
|
7495
|
+
NOTE_BACKUP_VERSION,
|
|
7417
7496
|
NOTE_BIGINT_FIELDS,
|
|
7418
7497
|
NOTE_TRANSFER_URI_SCHEME,
|
|
7419
7498
|
NoteBuilder,
|
|
@@ -7489,6 +7568,7 @@ var OrbinumWallet = class {
|
|
|
7489
7568
|
createNotesCache,
|
|
7490
7569
|
createWalletSession,
|
|
7491
7570
|
createWorkerPool,
|
|
7571
|
+
decodeNoteBackup,
|
|
7492
7572
|
decodeNoteDisclosureKey,
|
|
7493
7573
|
decodeNoteTransferPage,
|
|
7494
7574
|
decodePrecompileCalldata,
|
|
@@ -7512,6 +7592,7 @@ var OrbinumWallet = class {
|
|
|
7512
7592
|
deriveViewingPublicKey,
|
|
7513
7593
|
deriveViewingSecretKey,
|
|
7514
7594
|
detectCommitmentMismatch,
|
|
7595
|
+
encodeNoteBackup,
|
|
7515
7596
|
encodeNoteTransferPages,
|
|
7516
7597
|
encryptJson,
|
|
7517
7598
|
encryptNote,
|
|
@@ -7548,6 +7629,7 @@ var OrbinumWallet = class {
|
|
|
7548
7629
|
hexToNumber,
|
|
7549
7630
|
implicitSubstrateToEvm,
|
|
7550
7631
|
importDeviceKey,
|
|
7632
|
+
importNotesFromBackup,
|
|
7551
7633
|
isAbortError,
|
|
7552
7634
|
isAlreadySpentError,
|
|
7553
7635
|
isConnectionLossError,
|
package/dist/index.mjs
CHANGED
|
@@ -5226,6 +5226,80 @@ function assembleNoteTransfer(pages) {
|
|
|
5226
5226
|
return [...pages].sort((a, b) => a.p - b.p).flatMap((p) => p.notes);
|
|
5227
5227
|
}
|
|
5228
5228
|
|
|
5229
|
+
// src/wallet/ops/notes/noteBackup.ts
|
|
5230
|
+
var NOTE_BACKUP_VERSION = 1;
|
|
5231
|
+
function noteToBackupEntry(note) {
|
|
5232
|
+
return {
|
|
5233
|
+
commitmentHex: note.commitmentHex,
|
|
5234
|
+
encryptedMemo: toHex(Uint8Array.from(note.memo)),
|
|
5235
|
+
...note.leafIndex !== void 0 ? { leafIndex: note.leafIndex } : {},
|
|
5236
|
+
spent: note.spent,
|
|
5237
|
+
spentAt: note.spentAt
|
|
5238
|
+
};
|
|
5239
|
+
}
|
|
5240
|
+
function encodeNoteBackup(notes, options = {}) {
|
|
5241
|
+
const now = options.now ?? Date.now;
|
|
5242
|
+
return {
|
|
5243
|
+
v: NOTE_BACKUP_VERSION,
|
|
5244
|
+
ts: now(),
|
|
5245
|
+
notes: notes.map(noteToBackupEntry)
|
|
5246
|
+
};
|
|
5247
|
+
}
|
|
5248
|
+
function decodeNoteBackup(json) {
|
|
5249
|
+
let payload;
|
|
5250
|
+
if (typeof json === "string") {
|
|
5251
|
+
try {
|
|
5252
|
+
payload = JSON.parse(json);
|
|
5253
|
+
} catch {
|
|
5254
|
+
throw new Error("Note backup is not valid JSON.");
|
|
5255
|
+
}
|
|
5256
|
+
} else {
|
|
5257
|
+
payload = json;
|
|
5258
|
+
}
|
|
5259
|
+
const p = payload;
|
|
5260
|
+
if (p.v !== NOTE_BACKUP_VERSION) {
|
|
5261
|
+
throw new Error(`Unsupported note-backup version: ${String(p.v)}.`);
|
|
5262
|
+
}
|
|
5263
|
+
if (!Array.isArray(p.notes) || p.notes.some((n) => !isEntry2(n))) {
|
|
5264
|
+
throw new Error("Note backup is missing required fields.");
|
|
5265
|
+
}
|
|
5266
|
+
return p.notes;
|
|
5267
|
+
}
|
|
5268
|
+
function importNotesFromBackup(entries, keys) {
|
|
5269
|
+
const out = [];
|
|
5270
|
+
for (const entry of entries) {
|
|
5271
|
+
const commitment = {
|
|
5272
|
+
commitmentHex: entry.commitmentHex,
|
|
5273
|
+
leafIndex: entry.leafIndex ?? -1,
|
|
5274
|
+
encryptedMemo: entry.encryptedMemo
|
|
5275
|
+
};
|
|
5276
|
+
const note = tryDecryptNote(
|
|
5277
|
+
commitment,
|
|
5278
|
+
keys.viewingSecretKey,
|
|
5279
|
+
keys.spendingKey,
|
|
5280
|
+
keys.ownerPk
|
|
5281
|
+
);
|
|
5282
|
+
if (note) {
|
|
5283
|
+
out.push({
|
|
5284
|
+
...note,
|
|
5285
|
+
spent: entry.spent ?? false,
|
|
5286
|
+
spentAt: entry.spentAt ?? null
|
|
5287
|
+
});
|
|
5288
|
+
}
|
|
5289
|
+
}
|
|
5290
|
+
return out;
|
|
5291
|
+
}
|
|
5292
|
+
function isEntry2(value) {
|
|
5293
|
+
if (typeof value !== "object" || value === null) return false;
|
|
5294
|
+
const e = value;
|
|
5295
|
+
if (typeof e["commitmentHex"] !== "string" || e["commitmentHex"].length === 0) return false;
|
|
5296
|
+
if (typeof e["encryptedMemo"] !== "string" || e["encryptedMemo"].length === 0) return false;
|
|
5297
|
+
if ("leafIndex" in e && e["leafIndex"] !== void 0 && typeof e["leafIndex"] !== "number") {
|
|
5298
|
+
return false;
|
|
5299
|
+
}
|
|
5300
|
+
return true;
|
|
5301
|
+
}
|
|
5302
|
+
|
|
5229
5303
|
// src/wallet/ops/spend/transfer.ts
|
|
5230
5304
|
import { CircuitType as CircuitType5 } from "@orbinum/proof-generator";
|
|
5231
5305
|
|
|
@@ -6036,6 +6110,7 @@ export {
|
|
|
6036
6110
|
MIN_SIGNATURE_BYTES,
|
|
6037
6111
|
MemoryVaultStorage,
|
|
6038
6112
|
NATIVE_ASSET_ID,
|
|
6113
|
+
NOTE_BACKUP_VERSION,
|
|
6039
6114
|
NOTE_BIGINT_FIELDS,
|
|
6040
6115
|
NOTE_TRANSFER_URI_SCHEME,
|
|
6041
6116
|
NoteBuilder,
|
|
@@ -6111,6 +6186,7 @@ export {
|
|
|
6111
6186
|
createNotesCache,
|
|
6112
6187
|
createWalletSession,
|
|
6113
6188
|
createWorkerPool,
|
|
6189
|
+
decodeNoteBackup,
|
|
6114
6190
|
decodeNoteDisclosureKey,
|
|
6115
6191
|
decodeNoteTransferPage,
|
|
6116
6192
|
decodePrecompileCalldata,
|
|
@@ -6134,6 +6210,7 @@ export {
|
|
|
6134
6210
|
deriveViewingPublicKey,
|
|
6135
6211
|
deriveViewingSecretKey,
|
|
6136
6212
|
detectCommitmentMismatch,
|
|
6213
|
+
encodeNoteBackup,
|
|
6137
6214
|
encodeNoteTransferPages,
|
|
6138
6215
|
encryptJson,
|
|
6139
6216
|
encryptNote,
|
|
@@ -6170,6 +6247,7 @@ export {
|
|
|
6170
6247
|
hexToNumber,
|
|
6171
6248
|
implicitSubstrateToEvm,
|
|
6172
6249
|
importDeviceKey,
|
|
6250
|
+
importNotesFromBackup,
|
|
6173
6251
|
isAbortError,
|
|
6174
6252
|
isAlreadySpentError,
|
|
6175
6253
|
isConnectionLossError,
|