@orbinum/sdk 1.0.1 → 1.1.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 +79 -1
- package/dist/index.d.ts +79 -1
- package/dist/index.js +74 -0
- package/dist/index.mjs +70 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -4779,6 +4779,84 @@ 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
|
+
interface NoteBackup {
|
|
4824
|
+
v: typeof NOTE_BACKUP_VERSION;
|
|
4825
|
+
/** Export time (ms). Informational. */
|
|
4826
|
+
ts: number;
|
|
4827
|
+
notes: NoteBackupEntry[];
|
|
4828
|
+
}
|
|
4829
|
+
/** Keys the importer needs to prove ownership by decrypting each memo. */
|
|
4830
|
+
interface BackupImportKeys {
|
|
4831
|
+
/** 32-byte viewing secret key (ivsk). */
|
|
4832
|
+
viewingSecretKey: Uint8Array;
|
|
4833
|
+
/** Spending key scalar — folded into the derived stealth key / nullifier. */
|
|
4834
|
+
spendingKey: bigint;
|
|
4835
|
+
/** The importer's global owner pk (Ax), for stealth detection. */
|
|
4836
|
+
ownerPk: bigint;
|
|
4837
|
+
}
|
|
4838
|
+
/**
|
|
4839
|
+
* Encode notes into a closed JSON backup. Carries the memo, not the keys.
|
|
4840
|
+
* `now` is injectable for a deterministic export (tests).
|
|
4841
|
+
*/
|
|
4842
|
+
declare function encodeNoteBackup(notes: ZkNote[], options?: {
|
|
4843
|
+
now?: () => number;
|
|
4844
|
+
}): NoteBackup;
|
|
4845
|
+
/**
|
|
4846
|
+
* Decode a JSON backup (string or object) into entries. Strict: a malformed
|
|
4847
|
+
* payload is rejected rather than partially imported.
|
|
4848
|
+
*/
|
|
4849
|
+
declare function decodeNoteBackup(json: string | object): NoteBackupEntry[];
|
|
4850
|
+
/**
|
|
4851
|
+
* Import a closed backup: decrypt each entry's memo with the importer's keys and
|
|
4852
|
+
* return the notes that belong to them as full, spendable `ZkNote`s.
|
|
4853
|
+
*
|
|
4854
|
+
* Ownership is proven by decryption — an entry whose memo does not open under
|
|
4855
|
+
* these keys is silently skipped (it is not this user's note). No chain access:
|
|
4856
|
+
* only the backup's own memos are tried.
|
|
4857
|
+
*/
|
|
4858
|
+
declare function importNotesFromBackup(entries: NoteBackupEntry[], keys: BackupImportKeys): ZkNote[];
|
|
4859
|
+
|
|
4782
4860
|
/**
|
|
4783
4861
|
* The steps every spend shares, in the order a spend performs them.
|
|
4784
4862
|
*
|
|
@@ -5386,4 +5464,4 @@ declare class OrbinumWallet {
|
|
|
5386
5464
|
private requireKey;
|
|
5387
5465
|
}
|
|
5388
5466
|
|
|
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 };
|
|
5467
|
+
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,84 @@ 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
|
+
interface NoteBackup {
|
|
4824
|
+
v: typeof NOTE_BACKUP_VERSION;
|
|
4825
|
+
/** Export time (ms). Informational. */
|
|
4826
|
+
ts: number;
|
|
4827
|
+
notes: NoteBackupEntry[];
|
|
4828
|
+
}
|
|
4829
|
+
/** Keys the importer needs to prove ownership by decrypting each memo. */
|
|
4830
|
+
interface BackupImportKeys {
|
|
4831
|
+
/** 32-byte viewing secret key (ivsk). */
|
|
4832
|
+
viewingSecretKey: Uint8Array;
|
|
4833
|
+
/** Spending key scalar — folded into the derived stealth key / nullifier. */
|
|
4834
|
+
spendingKey: bigint;
|
|
4835
|
+
/** The importer's global owner pk (Ax), for stealth detection. */
|
|
4836
|
+
ownerPk: bigint;
|
|
4837
|
+
}
|
|
4838
|
+
/**
|
|
4839
|
+
* Encode notes into a closed JSON backup. Carries the memo, not the keys.
|
|
4840
|
+
* `now` is injectable for a deterministic export (tests).
|
|
4841
|
+
*/
|
|
4842
|
+
declare function encodeNoteBackup(notes: ZkNote[], options?: {
|
|
4843
|
+
now?: () => number;
|
|
4844
|
+
}): NoteBackup;
|
|
4845
|
+
/**
|
|
4846
|
+
* Decode a JSON backup (string or object) into entries. Strict: a malformed
|
|
4847
|
+
* payload is rejected rather than partially imported.
|
|
4848
|
+
*/
|
|
4849
|
+
declare function decodeNoteBackup(json: string | object): NoteBackupEntry[];
|
|
4850
|
+
/**
|
|
4851
|
+
* Import a closed backup: decrypt each entry's memo with the importer's keys and
|
|
4852
|
+
* return the notes that belong to them as full, spendable `ZkNote`s.
|
|
4853
|
+
*
|
|
4854
|
+
* Ownership is proven by decryption — an entry whose memo does not open under
|
|
4855
|
+
* these keys is silently skipped (it is not this user's note). No chain access:
|
|
4856
|
+
* only the backup's own memos are tried.
|
|
4857
|
+
*/
|
|
4858
|
+
declare function importNotesFromBackup(entries: NoteBackupEntry[], keys: BackupImportKeys): ZkNote[];
|
|
4859
|
+
|
|
4782
4860
|
/**
|
|
4783
4861
|
* The steps every spend shares, in the order a spend performs them.
|
|
4784
4862
|
*
|
|
@@ -5386,4 +5464,4 @@ declare class OrbinumWallet {
|
|
|
5386
5464
|
private requireKey;
|
|
5387
5465
|
}
|
|
5388
5466
|
|
|
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 };
|
|
5467
|
+
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,72 @@ 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
|
+
};
|
|
6341
|
+
}
|
|
6342
|
+
function encodeNoteBackup(notes, options = {}) {
|
|
6343
|
+
const now = options.now ?? Date.now;
|
|
6344
|
+
return {
|
|
6345
|
+
v: NOTE_BACKUP_VERSION,
|
|
6346
|
+
ts: now(),
|
|
6347
|
+
notes: notes.map(noteToBackupEntry)
|
|
6348
|
+
};
|
|
6349
|
+
}
|
|
6350
|
+
function decodeNoteBackup(json) {
|
|
6351
|
+
let payload;
|
|
6352
|
+
if (typeof json === "string") {
|
|
6353
|
+
try {
|
|
6354
|
+
payload = JSON.parse(json);
|
|
6355
|
+
} catch {
|
|
6356
|
+
throw new Error("Note backup is not valid JSON.");
|
|
6357
|
+
}
|
|
6358
|
+
} else {
|
|
6359
|
+
payload = json;
|
|
6360
|
+
}
|
|
6361
|
+
const p = payload;
|
|
6362
|
+
if (p.v !== NOTE_BACKUP_VERSION) {
|
|
6363
|
+
throw new Error(`Unsupported note-backup version: ${String(p.v)}.`);
|
|
6364
|
+
}
|
|
6365
|
+
if (!Array.isArray(p.notes) || p.notes.some((n) => !isEntry2(n))) {
|
|
6366
|
+
throw new Error("Note backup is missing required fields.");
|
|
6367
|
+
}
|
|
6368
|
+
return p.notes;
|
|
6369
|
+
}
|
|
6370
|
+
function importNotesFromBackup(entries, keys) {
|
|
6371
|
+
const out = [];
|
|
6372
|
+
for (const entry of entries) {
|
|
6373
|
+
const commitment = {
|
|
6374
|
+
commitmentHex: entry.commitmentHex,
|
|
6375
|
+
leafIndex: entry.leafIndex ?? -1,
|
|
6376
|
+
encryptedMemo: entry.encryptedMemo
|
|
6377
|
+
};
|
|
6378
|
+
const note = tryDecryptNote(
|
|
6379
|
+
commitment,
|
|
6380
|
+
keys.viewingSecretKey,
|
|
6381
|
+
keys.spendingKey,
|
|
6382
|
+
keys.ownerPk
|
|
6383
|
+
);
|
|
6384
|
+
if (note) out.push(note);
|
|
6385
|
+
}
|
|
6386
|
+
return out;
|
|
6387
|
+
}
|
|
6388
|
+
function isEntry2(value) {
|
|
6389
|
+
if (typeof value !== "object" || value === null) return false;
|
|
6390
|
+
const e = value;
|
|
6391
|
+
if (typeof e["commitmentHex"] !== "string" || e["commitmentHex"].length === 0) return false;
|
|
6392
|
+
if (typeof e["encryptedMemo"] !== "string" || e["encryptedMemo"].length === 0) return false;
|
|
6393
|
+
if ("leafIndex" in e && e["leafIndex"] !== void 0 && typeof e["leafIndex"] !== "number") {
|
|
6394
|
+
return false;
|
|
6395
|
+
}
|
|
6396
|
+
return true;
|
|
6397
|
+
}
|
|
6398
|
+
|
|
6329
6399
|
// src/wallet/ops/spend/transfer.ts
|
|
6330
6400
|
var import_proof_generator6 = require("@orbinum/proof-generator");
|
|
6331
6401
|
|
|
@@ -7414,6 +7484,7 @@ var OrbinumWallet = class {
|
|
|
7414
7484
|
MIN_SIGNATURE_BYTES,
|
|
7415
7485
|
MemoryVaultStorage,
|
|
7416
7486
|
NATIVE_ASSET_ID,
|
|
7487
|
+
NOTE_BACKUP_VERSION,
|
|
7417
7488
|
NOTE_BIGINT_FIELDS,
|
|
7418
7489
|
NOTE_TRANSFER_URI_SCHEME,
|
|
7419
7490
|
NoteBuilder,
|
|
@@ -7489,6 +7560,7 @@ var OrbinumWallet = class {
|
|
|
7489
7560
|
createNotesCache,
|
|
7490
7561
|
createWalletSession,
|
|
7491
7562
|
createWorkerPool,
|
|
7563
|
+
decodeNoteBackup,
|
|
7492
7564
|
decodeNoteDisclosureKey,
|
|
7493
7565
|
decodeNoteTransferPage,
|
|
7494
7566
|
decodePrecompileCalldata,
|
|
@@ -7512,6 +7584,7 @@ var OrbinumWallet = class {
|
|
|
7512
7584
|
deriveViewingPublicKey,
|
|
7513
7585
|
deriveViewingSecretKey,
|
|
7514
7586
|
detectCommitmentMismatch,
|
|
7587
|
+
encodeNoteBackup,
|
|
7515
7588
|
encodeNoteTransferPages,
|
|
7516
7589
|
encryptJson,
|
|
7517
7590
|
encryptNote,
|
|
@@ -7548,6 +7621,7 @@ var OrbinumWallet = class {
|
|
|
7548
7621
|
hexToNumber,
|
|
7549
7622
|
implicitSubstrateToEvm,
|
|
7550
7623
|
importDeviceKey,
|
|
7624
|
+
importNotesFromBackup,
|
|
7551
7625
|
isAbortError,
|
|
7552
7626
|
isAlreadySpentError,
|
|
7553
7627
|
isConnectionLossError,
|
package/dist/index.mjs
CHANGED
|
@@ -5226,6 +5226,72 @@ 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
|
+
};
|
|
5237
|
+
}
|
|
5238
|
+
function encodeNoteBackup(notes, options = {}) {
|
|
5239
|
+
const now = options.now ?? Date.now;
|
|
5240
|
+
return {
|
|
5241
|
+
v: NOTE_BACKUP_VERSION,
|
|
5242
|
+
ts: now(),
|
|
5243
|
+
notes: notes.map(noteToBackupEntry)
|
|
5244
|
+
};
|
|
5245
|
+
}
|
|
5246
|
+
function decodeNoteBackup(json) {
|
|
5247
|
+
let payload;
|
|
5248
|
+
if (typeof json === "string") {
|
|
5249
|
+
try {
|
|
5250
|
+
payload = JSON.parse(json);
|
|
5251
|
+
} catch {
|
|
5252
|
+
throw new Error("Note backup is not valid JSON.");
|
|
5253
|
+
}
|
|
5254
|
+
} else {
|
|
5255
|
+
payload = json;
|
|
5256
|
+
}
|
|
5257
|
+
const p = payload;
|
|
5258
|
+
if (p.v !== NOTE_BACKUP_VERSION) {
|
|
5259
|
+
throw new Error(`Unsupported note-backup version: ${String(p.v)}.`);
|
|
5260
|
+
}
|
|
5261
|
+
if (!Array.isArray(p.notes) || p.notes.some((n) => !isEntry2(n))) {
|
|
5262
|
+
throw new Error("Note backup is missing required fields.");
|
|
5263
|
+
}
|
|
5264
|
+
return p.notes;
|
|
5265
|
+
}
|
|
5266
|
+
function importNotesFromBackup(entries, keys) {
|
|
5267
|
+
const out = [];
|
|
5268
|
+
for (const entry of entries) {
|
|
5269
|
+
const commitment = {
|
|
5270
|
+
commitmentHex: entry.commitmentHex,
|
|
5271
|
+
leafIndex: entry.leafIndex ?? -1,
|
|
5272
|
+
encryptedMemo: entry.encryptedMemo
|
|
5273
|
+
};
|
|
5274
|
+
const note = tryDecryptNote(
|
|
5275
|
+
commitment,
|
|
5276
|
+
keys.viewingSecretKey,
|
|
5277
|
+
keys.spendingKey,
|
|
5278
|
+
keys.ownerPk
|
|
5279
|
+
);
|
|
5280
|
+
if (note) out.push(note);
|
|
5281
|
+
}
|
|
5282
|
+
return out;
|
|
5283
|
+
}
|
|
5284
|
+
function isEntry2(value) {
|
|
5285
|
+
if (typeof value !== "object" || value === null) return false;
|
|
5286
|
+
const e = value;
|
|
5287
|
+
if (typeof e["commitmentHex"] !== "string" || e["commitmentHex"].length === 0) return false;
|
|
5288
|
+
if (typeof e["encryptedMemo"] !== "string" || e["encryptedMemo"].length === 0) return false;
|
|
5289
|
+
if ("leafIndex" in e && e["leafIndex"] !== void 0 && typeof e["leafIndex"] !== "number") {
|
|
5290
|
+
return false;
|
|
5291
|
+
}
|
|
5292
|
+
return true;
|
|
5293
|
+
}
|
|
5294
|
+
|
|
5229
5295
|
// src/wallet/ops/spend/transfer.ts
|
|
5230
5296
|
import { CircuitType as CircuitType5 } from "@orbinum/proof-generator";
|
|
5231
5297
|
|
|
@@ -6036,6 +6102,7 @@ export {
|
|
|
6036
6102
|
MIN_SIGNATURE_BYTES,
|
|
6037
6103
|
MemoryVaultStorage,
|
|
6038
6104
|
NATIVE_ASSET_ID,
|
|
6105
|
+
NOTE_BACKUP_VERSION,
|
|
6039
6106
|
NOTE_BIGINT_FIELDS,
|
|
6040
6107
|
NOTE_TRANSFER_URI_SCHEME,
|
|
6041
6108
|
NoteBuilder,
|
|
@@ -6111,6 +6178,7 @@ export {
|
|
|
6111
6178
|
createNotesCache,
|
|
6112
6179
|
createWalletSession,
|
|
6113
6180
|
createWorkerPool,
|
|
6181
|
+
decodeNoteBackup,
|
|
6114
6182
|
decodeNoteDisclosureKey,
|
|
6115
6183
|
decodeNoteTransferPage,
|
|
6116
6184
|
decodePrecompileCalldata,
|
|
@@ -6134,6 +6202,7 @@ export {
|
|
|
6134
6202
|
deriveViewingPublicKey,
|
|
6135
6203
|
deriveViewingSecretKey,
|
|
6136
6204
|
detectCommitmentMismatch,
|
|
6205
|
+
encodeNoteBackup,
|
|
6137
6206
|
encodeNoteTransferPages,
|
|
6138
6207
|
encryptJson,
|
|
6139
6208
|
encryptNote,
|
|
@@ -6170,6 +6239,7 @@ export {
|
|
|
6170
6239
|
hexToNumber,
|
|
6171
6240
|
implicitSubstrateToEvm,
|
|
6172
6241
|
importDeviceKey,
|
|
6242
|
+
importNotesFromBackup,
|
|
6173
6243
|
isAbortError,
|
|
6174
6244
|
isAlreadySpentError,
|
|
6175
6245
|
isConnectionLossError,
|