@orbinum/sdk 1.0.0 → 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 +91 -5
- package/dist/index.d.ts +91 -5
- package/dist/index.js +110 -13
- package/dist/index.mjs +106 -13
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1809,12 +1809,15 @@ declare class PrivacyKeyManager {
|
|
|
1809
1809
|
* Exports a shareable privacy address encoding the owner public key and
|
|
1810
1810
|
* viewing PUBLIC key of the currently loaded identity.
|
|
1811
1811
|
*
|
|
1812
|
-
* Format: `
|
|
1812
|
+
* Format: `orbpriv2:{ownerPk_hex}:{viewingPublicKey_hex}:{checksum}`
|
|
1813
1813
|
*
|
|
1814
1814
|
* The recipient uses this address so the sender can:
|
|
1815
1815
|
* 1. Embed `ownerPk` in the note commitment (Poseidon4 input).
|
|
1816
1816
|
* 2. Encrypt the memo via ECDH with the recipient's `viewingPublicKey`.
|
|
1817
1817
|
*
|
|
1818
|
+
* The trailing checksum (see `privacyAddressChecksum`) makes a corrupted
|
|
1819
|
+
* paste fail to decode rather than pay into an unspendable note.
|
|
1820
|
+
*
|
|
1818
1821
|
* SECURITY: Only the viewing PUBLIC key is embedded — the viewing secret key
|
|
1819
1822
|
* (used for decryption) is never exported. Holders of this address cannot
|
|
1820
1823
|
* decrypt the recipient's notes.
|
|
@@ -1823,9 +1826,14 @@ declare class PrivacyKeyManager {
|
|
|
1823
1826
|
*/
|
|
1824
1827
|
encodePrivacyAddress(): string;
|
|
1825
1828
|
/**
|
|
1826
|
-
* Decode a privacy address
|
|
1827
|
-
*
|
|
1828
|
-
*
|
|
1829
|
+
* Decode a privacy address into `{ ownerPkHex, viewingPublicKeyHex }`, or
|
|
1830
|
+
* `null` if it does not parse.
|
|
1831
|
+
*
|
|
1832
|
+
* Accepts both:
|
|
1833
|
+
* - `orbpriv2:{ownerPk}:{ivk}:{checksum}` — checksum verified; a mismatch
|
|
1834
|
+
* (corrupted paste) returns null.
|
|
1835
|
+
* - `orbpriv1:{ownerPk}:{ivk}` — legacy, no checksum. Still read so addresses
|
|
1836
|
+
* shared before v2 keep resolving; only v2 is emitted.
|
|
1829
1837
|
*/
|
|
1830
1838
|
static decodePrivacyAddress(address: string): {
|
|
1831
1839
|
ownerPkHex: string;
|
|
@@ -4771,6 +4779,84 @@ declare function decodeNoteTransferPage(uri: string): NoteTransferPayload;
|
|
|
4771
4779
|
*/
|
|
4772
4780
|
declare function assembleNoteTransfer(pages: NoteTransferPayload[]): NoteTransferEntry[];
|
|
4773
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
|
+
|
|
4774
4860
|
/**
|
|
4775
4861
|
* The steps every spend shares, in the order a spend performs them.
|
|
4776
4862
|
*
|
|
@@ -5378,4 +5464,4 @@ declare class OrbinumWallet {
|
|
|
5378
5464
|
private requireKey;
|
|
5379
5465
|
}
|
|
5380
5466
|
|
|
5381
|
-
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
|
@@ -1809,12 +1809,15 @@ declare class PrivacyKeyManager {
|
|
|
1809
1809
|
* Exports a shareable privacy address encoding the owner public key and
|
|
1810
1810
|
* viewing PUBLIC key of the currently loaded identity.
|
|
1811
1811
|
*
|
|
1812
|
-
* Format: `
|
|
1812
|
+
* Format: `orbpriv2:{ownerPk_hex}:{viewingPublicKey_hex}:{checksum}`
|
|
1813
1813
|
*
|
|
1814
1814
|
* The recipient uses this address so the sender can:
|
|
1815
1815
|
* 1. Embed `ownerPk` in the note commitment (Poseidon4 input).
|
|
1816
1816
|
* 2. Encrypt the memo via ECDH with the recipient's `viewingPublicKey`.
|
|
1817
1817
|
*
|
|
1818
|
+
* The trailing checksum (see `privacyAddressChecksum`) makes a corrupted
|
|
1819
|
+
* paste fail to decode rather than pay into an unspendable note.
|
|
1820
|
+
*
|
|
1818
1821
|
* SECURITY: Only the viewing PUBLIC key is embedded — the viewing secret key
|
|
1819
1822
|
* (used for decryption) is never exported. Holders of this address cannot
|
|
1820
1823
|
* decrypt the recipient's notes.
|
|
@@ -1823,9 +1826,14 @@ declare class PrivacyKeyManager {
|
|
|
1823
1826
|
*/
|
|
1824
1827
|
encodePrivacyAddress(): string;
|
|
1825
1828
|
/**
|
|
1826
|
-
* Decode a privacy address
|
|
1827
|
-
*
|
|
1828
|
-
*
|
|
1829
|
+
* Decode a privacy address into `{ ownerPkHex, viewingPublicKeyHex }`, or
|
|
1830
|
+
* `null` if it does not parse.
|
|
1831
|
+
*
|
|
1832
|
+
* Accepts both:
|
|
1833
|
+
* - `orbpriv2:{ownerPk}:{ivk}:{checksum}` — checksum verified; a mismatch
|
|
1834
|
+
* (corrupted paste) returns null.
|
|
1835
|
+
* - `orbpriv1:{ownerPk}:{ivk}` — legacy, no checksum. Still read so addresses
|
|
1836
|
+
* shared before v2 keep resolving; only v2 is emitted.
|
|
1829
1837
|
*/
|
|
1830
1838
|
static decodePrivacyAddress(address: string): {
|
|
1831
1839
|
ownerPkHex: string;
|
|
@@ -4771,6 +4779,84 @@ declare function decodeNoteTransferPage(uri: string): NoteTransferPayload;
|
|
|
4771
4779
|
*/
|
|
4772
4780
|
declare function assembleNoteTransfer(pages: NoteTransferPayload[]): NoteTransferEntry[];
|
|
4773
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
|
+
|
|
4774
4860
|
/**
|
|
4775
4861
|
* The steps every spend shares, in the order a spend performs them.
|
|
4776
4862
|
*
|
|
@@ -5378,4 +5464,4 @@ declare class OrbinumWallet {
|
|
|
5378
5464
|
private requireKey;
|
|
5379
5465
|
}
|
|
5380
5466
|
|
|
5381
|
-
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,
|
|
@@ -1574,6 +1578,12 @@ function deriveOwnerPk(spendingKey) {
|
|
|
1574
1578
|
}
|
|
1575
1579
|
|
|
1576
1580
|
// src/protocol/keys/PrivacyKeyManager.ts
|
|
1581
|
+
var import_sha26 = require("@noble/hashes/sha2.js");
|
|
1582
|
+
function privacyAddressChecksum(ownerPkHex, ivkHex) {
|
|
1583
|
+
const body = `orbpriv2:${ownerPkHex}:${ivkHex}`;
|
|
1584
|
+
const digest = (0, import_sha26.sha256)(new TextEncoder().encode(body));
|
|
1585
|
+
return toHex(digest.slice(0, 4)).slice(2);
|
|
1586
|
+
}
|
|
1577
1587
|
var PrivacyKeyManager = class {
|
|
1578
1588
|
_state = {
|
|
1579
1589
|
spendingKey: null,
|
|
@@ -1683,12 +1693,15 @@ var PrivacyKeyManager = class {
|
|
|
1683
1693
|
* Exports a shareable privacy address encoding the owner public key and
|
|
1684
1694
|
* viewing PUBLIC key of the currently loaded identity.
|
|
1685
1695
|
*
|
|
1686
|
-
* Format: `
|
|
1696
|
+
* Format: `orbpriv2:{ownerPk_hex}:{viewingPublicKey_hex}:{checksum}`
|
|
1687
1697
|
*
|
|
1688
1698
|
* The recipient uses this address so the sender can:
|
|
1689
1699
|
* 1. Embed `ownerPk` in the note commitment (Poseidon4 input).
|
|
1690
1700
|
* 2. Encrypt the memo via ECDH with the recipient's `viewingPublicKey`.
|
|
1691
1701
|
*
|
|
1702
|
+
* The trailing checksum (see `privacyAddressChecksum`) makes a corrupted
|
|
1703
|
+
* paste fail to decode rather than pay into an unspendable note.
|
|
1704
|
+
*
|
|
1692
1705
|
* SECURITY: Only the viewing PUBLIC key is embedded — the viewing secret key
|
|
1693
1706
|
* (used for decryption) is never exported. Holders of this address cannot
|
|
1694
1707
|
* decrypt the recipient's notes.
|
|
@@ -1700,21 +1713,35 @@ var PrivacyKeyManager = class {
|
|
|
1700
1713
|
const ivkPacked = this.getViewingPublicKeyPacked();
|
|
1701
1714
|
const ownerPkHex = scalarToHex(ownerPk);
|
|
1702
1715
|
const ivkHex = toHex(ivkPacked);
|
|
1703
|
-
|
|
1716
|
+
const checksum = privacyAddressChecksum(ownerPkHex, ivkHex);
|
|
1717
|
+
return `orbpriv2:${ownerPkHex}:${ivkHex}:${checksum}`;
|
|
1704
1718
|
}
|
|
1705
1719
|
/**
|
|
1706
|
-
* Decode a privacy address
|
|
1707
|
-
*
|
|
1708
|
-
*
|
|
1720
|
+
* Decode a privacy address into `{ ownerPkHex, viewingPublicKeyHex }`, or
|
|
1721
|
+
* `null` if it does not parse.
|
|
1722
|
+
*
|
|
1723
|
+
* Accepts both:
|
|
1724
|
+
* - `orbpriv2:{ownerPk}:{ivk}:{checksum}` — checksum verified; a mismatch
|
|
1725
|
+
* (corrupted paste) returns null.
|
|
1726
|
+
* - `orbpriv1:{ownerPk}:{ivk}` — legacy, no checksum. Still read so addresses
|
|
1727
|
+
* shared before v2 keep resolving; only v2 is emitted.
|
|
1709
1728
|
*/
|
|
1710
1729
|
static decodePrivacyAddress(address) {
|
|
1711
|
-
if (!address.startsWith("orbpriv1:")) return null;
|
|
1712
1730
|
const parts = address.split(":");
|
|
1713
|
-
if (parts
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1731
|
+
if (parts[0] === "orbpriv2") {
|
|
1732
|
+
if (parts.length !== 4) return null;
|
|
1733
|
+
const [, ownerPkHex, viewingPublicKeyHex, checksum] = parts;
|
|
1734
|
+
if (!ownerPkHex || !viewingPublicKeyHex || !checksum) return null;
|
|
1735
|
+
if (privacyAddressChecksum(ownerPkHex, viewingPublicKeyHex) !== checksum) return null;
|
|
1736
|
+
return { ownerPkHex, viewingPublicKeyHex };
|
|
1737
|
+
}
|
|
1738
|
+
if (parts[0] === "orbpriv1") {
|
|
1739
|
+
if (parts.length !== 3) return null;
|
|
1740
|
+
const [, ownerPkHex, viewingPublicKeyHex] = parts;
|
|
1741
|
+
if (!ownerPkHex || !viewingPublicKeyHex) return null;
|
|
1742
|
+
return { ownerPkHex, viewingPublicKeyHex };
|
|
1743
|
+
}
|
|
1744
|
+
return null;
|
|
1718
1745
|
}
|
|
1719
1746
|
/**
|
|
1720
1747
|
* Load keys from a cached "mk:0x{masterBytes_hex}" string produced by exportHex().
|
|
@@ -1740,7 +1767,7 @@ var PrivacyKeyManager = class {
|
|
|
1740
1767
|
|
|
1741
1768
|
// src/protocol/keys/spendingKeyDerivation.ts
|
|
1742
1769
|
var import_hkdf3 = require("@noble/hashes/hkdf.js");
|
|
1743
|
-
var
|
|
1770
|
+
var import_sha27 = require("@noble/hashes/sha2.js");
|
|
1744
1771
|
var MIN_SIGNATURE_BYTES = 32;
|
|
1745
1772
|
var MIN_DISTINCT_BYTES = 8;
|
|
1746
1773
|
function assertUsableSignature(sigBytes) {
|
|
@@ -1762,7 +1789,7 @@ async function deriveMasterKeyBytes(signatureHex, chainId, address) {
|
|
|
1762
1789
|
const info = new TextEncoder().encode(
|
|
1763
1790
|
`orbinum-sk-${KEY_VERSION}:${chainId}:${canonicalAccountId(address)}`
|
|
1764
1791
|
);
|
|
1765
|
-
return (0, import_hkdf3.hkdf)(
|
|
1792
|
+
return (0, import_hkdf3.hkdf)(import_sha27.sha256, sigBytes, new Uint8Array(0), info, 32);
|
|
1766
1793
|
}
|
|
1767
1794
|
async function deriveSpendingKeyFromSignature(signatureHex, chainId, address) {
|
|
1768
1795
|
return deriveSpendingKeyFromMaster(await deriveMasterKeyBytes(signatureHex, chainId, address));
|
|
@@ -6303,6 +6330,72 @@ function assembleNoteTransfer(pages) {
|
|
|
6303
6330
|
return [...pages].sort((a, b) => a.p - b.p).flatMap((p) => p.notes);
|
|
6304
6331
|
}
|
|
6305
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
|
+
|
|
6306
6399
|
// src/wallet/ops/spend/transfer.ts
|
|
6307
6400
|
var import_proof_generator6 = require("@orbinum/proof-generator");
|
|
6308
6401
|
|
|
@@ -7391,6 +7484,7 @@ var OrbinumWallet = class {
|
|
|
7391
7484
|
MIN_SIGNATURE_BYTES,
|
|
7392
7485
|
MemoryVaultStorage,
|
|
7393
7486
|
NATIVE_ASSET_ID,
|
|
7487
|
+
NOTE_BACKUP_VERSION,
|
|
7394
7488
|
NOTE_BIGINT_FIELDS,
|
|
7395
7489
|
NOTE_TRANSFER_URI_SCHEME,
|
|
7396
7490
|
NoteBuilder,
|
|
@@ -7466,6 +7560,7 @@ var OrbinumWallet = class {
|
|
|
7466
7560
|
createNotesCache,
|
|
7467
7561
|
createWalletSession,
|
|
7468
7562
|
createWorkerPool,
|
|
7563
|
+
decodeNoteBackup,
|
|
7469
7564
|
decodeNoteDisclosureKey,
|
|
7470
7565
|
decodeNoteTransferPage,
|
|
7471
7566
|
decodePrecompileCalldata,
|
|
@@ -7489,6 +7584,7 @@ var OrbinumWallet = class {
|
|
|
7489
7584
|
deriveViewingPublicKey,
|
|
7490
7585
|
deriveViewingSecretKey,
|
|
7491
7586
|
detectCommitmentMismatch,
|
|
7587
|
+
encodeNoteBackup,
|
|
7492
7588
|
encodeNoteTransferPages,
|
|
7493
7589
|
encryptJson,
|
|
7494
7590
|
encryptNote,
|
|
@@ -7525,6 +7621,7 @@ var OrbinumWallet = class {
|
|
|
7525
7621
|
hexToNumber,
|
|
7526
7622
|
implicitSubstrateToEvm,
|
|
7527
7623
|
importDeviceKey,
|
|
7624
|
+
importNotesFromBackup,
|
|
7528
7625
|
isAbortError,
|
|
7529
7626
|
isAlreadySpentError,
|
|
7530
7627
|
isConnectionLossError,
|
package/dist/index.mjs
CHANGED
|
@@ -463,6 +463,12 @@ ${canonicalAccountId(address)}`;
|
|
|
463
463
|
}
|
|
464
464
|
|
|
465
465
|
// src/protocol/keys/PrivacyKeyManager.ts
|
|
466
|
+
import { sha256 } from "@noble/hashes/sha2.js";
|
|
467
|
+
function privacyAddressChecksum(ownerPkHex, ivkHex) {
|
|
468
|
+
const body = `orbpriv2:${ownerPkHex}:${ivkHex}`;
|
|
469
|
+
const digest = sha256(new TextEncoder().encode(body));
|
|
470
|
+
return toHex(digest.slice(0, 4)).slice(2);
|
|
471
|
+
}
|
|
466
472
|
var PrivacyKeyManager = class {
|
|
467
473
|
_state = {
|
|
468
474
|
spendingKey: null,
|
|
@@ -572,12 +578,15 @@ var PrivacyKeyManager = class {
|
|
|
572
578
|
* Exports a shareable privacy address encoding the owner public key and
|
|
573
579
|
* viewing PUBLIC key of the currently loaded identity.
|
|
574
580
|
*
|
|
575
|
-
* Format: `
|
|
581
|
+
* Format: `orbpriv2:{ownerPk_hex}:{viewingPublicKey_hex}:{checksum}`
|
|
576
582
|
*
|
|
577
583
|
* The recipient uses this address so the sender can:
|
|
578
584
|
* 1. Embed `ownerPk` in the note commitment (Poseidon4 input).
|
|
579
585
|
* 2. Encrypt the memo via ECDH with the recipient's `viewingPublicKey`.
|
|
580
586
|
*
|
|
587
|
+
* The trailing checksum (see `privacyAddressChecksum`) makes a corrupted
|
|
588
|
+
* paste fail to decode rather than pay into an unspendable note.
|
|
589
|
+
*
|
|
581
590
|
* SECURITY: Only the viewing PUBLIC key is embedded — the viewing secret key
|
|
582
591
|
* (used for decryption) is never exported. Holders of this address cannot
|
|
583
592
|
* decrypt the recipient's notes.
|
|
@@ -589,21 +598,35 @@ var PrivacyKeyManager = class {
|
|
|
589
598
|
const ivkPacked = this.getViewingPublicKeyPacked();
|
|
590
599
|
const ownerPkHex = scalarToHex(ownerPk);
|
|
591
600
|
const ivkHex = toHex(ivkPacked);
|
|
592
|
-
|
|
601
|
+
const checksum = privacyAddressChecksum(ownerPkHex, ivkHex);
|
|
602
|
+
return `orbpriv2:${ownerPkHex}:${ivkHex}:${checksum}`;
|
|
593
603
|
}
|
|
594
604
|
/**
|
|
595
|
-
* Decode a privacy address
|
|
596
|
-
*
|
|
597
|
-
*
|
|
605
|
+
* Decode a privacy address into `{ ownerPkHex, viewingPublicKeyHex }`, or
|
|
606
|
+
* `null` if it does not parse.
|
|
607
|
+
*
|
|
608
|
+
* Accepts both:
|
|
609
|
+
* - `orbpriv2:{ownerPk}:{ivk}:{checksum}` — checksum verified; a mismatch
|
|
610
|
+
* (corrupted paste) returns null.
|
|
611
|
+
* - `orbpriv1:{ownerPk}:{ivk}` — legacy, no checksum. Still read so addresses
|
|
612
|
+
* shared before v2 keep resolving; only v2 is emitted.
|
|
598
613
|
*/
|
|
599
614
|
static decodePrivacyAddress(address) {
|
|
600
|
-
if (!address.startsWith("orbpriv1:")) return null;
|
|
601
615
|
const parts = address.split(":");
|
|
602
|
-
if (parts
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
616
|
+
if (parts[0] === "orbpriv2") {
|
|
617
|
+
if (parts.length !== 4) return null;
|
|
618
|
+
const [, ownerPkHex, viewingPublicKeyHex, checksum] = parts;
|
|
619
|
+
if (!ownerPkHex || !viewingPublicKeyHex || !checksum) return null;
|
|
620
|
+
if (privacyAddressChecksum(ownerPkHex, viewingPublicKeyHex) !== checksum) return null;
|
|
621
|
+
return { ownerPkHex, viewingPublicKeyHex };
|
|
622
|
+
}
|
|
623
|
+
if (parts[0] === "orbpriv1") {
|
|
624
|
+
if (parts.length !== 3) return null;
|
|
625
|
+
const [, ownerPkHex, viewingPublicKeyHex] = parts;
|
|
626
|
+
if (!ownerPkHex || !viewingPublicKeyHex) return null;
|
|
627
|
+
return { ownerPkHex, viewingPublicKeyHex };
|
|
628
|
+
}
|
|
629
|
+
return null;
|
|
607
630
|
}
|
|
608
631
|
/**
|
|
609
632
|
* Load keys from a cached "mk:0x{masterBytes_hex}" string produced by exportHex().
|
|
@@ -629,7 +652,7 @@ var PrivacyKeyManager = class {
|
|
|
629
652
|
|
|
630
653
|
// src/protocol/keys/spendingKeyDerivation.ts
|
|
631
654
|
import { hkdf } from "@noble/hashes/hkdf.js";
|
|
632
|
-
import { sha256 } from "@noble/hashes/sha2.js";
|
|
655
|
+
import { sha256 as sha2562 } from "@noble/hashes/sha2.js";
|
|
633
656
|
var MIN_SIGNATURE_BYTES = 32;
|
|
634
657
|
var MIN_DISTINCT_BYTES = 8;
|
|
635
658
|
function assertUsableSignature(sigBytes) {
|
|
@@ -651,7 +674,7 @@ async function deriveMasterKeyBytes(signatureHex, chainId, address) {
|
|
|
651
674
|
const info = new TextEncoder().encode(
|
|
652
675
|
`orbinum-sk-${KEY_VERSION}:${chainId}:${canonicalAccountId(address)}`
|
|
653
676
|
);
|
|
654
|
-
return hkdf(
|
|
677
|
+
return hkdf(sha2562, sigBytes, new Uint8Array(0), info, 32);
|
|
655
678
|
}
|
|
656
679
|
async function deriveSpendingKeyFromSignature(signatureHex, chainId, address) {
|
|
657
680
|
return deriveSpendingKeyFromMaster(await deriveMasterKeyBytes(signatureHex, chainId, address));
|
|
@@ -5203,6 +5226,72 @@ function assembleNoteTransfer(pages) {
|
|
|
5203
5226
|
return [...pages].sort((a, b) => a.p - b.p).flatMap((p) => p.notes);
|
|
5204
5227
|
}
|
|
5205
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
|
+
|
|
5206
5295
|
// src/wallet/ops/spend/transfer.ts
|
|
5207
5296
|
import { CircuitType as CircuitType5 } from "@orbinum/proof-generator";
|
|
5208
5297
|
|
|
@@ -6013,6 +6102,7 @@ export {
|
|
|
6013
6102
|
MIN_SIGNATURE_BYTES,
|
|
6014
6103
|
MemoryVaultStorage,
|
|
6015
6104
|
NATIVE_ASSET_ID,
|
|
6105
|
+
NOTE_BACKUP_VERSION,
|
|
6016
6106
|
NOTE_BIGINT_FIELDS,
|
|
6017
6107
|
NOTE_TRANSFER_URI_SCHEME,
|
|
6018
6108
|
NoteBuilder,
|
|
@@ -6088,6 +6178,7 @@ export {
|
|
|
6088
6178
|
createNotesCache,
|
|
6089
6179
|
createWalletSession,
|
|
6090
6180
|
createWorkerPool,
|
|
6181
|
+
decodeNoteBackup,
|
|
6091
6182
|
decodeNoteDisclosureKey,
|
|
6092
6183
|
decodeNoteTransferPage,
|
|
6093
6184
|
decodePrecompileCalldata,
|
|
@@ -6111,6 +6202,7 @@ export {
|
|
|
6111
6202
|
deriveViewingPublicKey,
|
|
6112
6203
|
deriveViewingSecretKey,
|
|
6113
6204
|
detectCommitmentMismatch,
|
|
6205
|
+
encodeNoteBackup,
|
|
6114
6206
|
encodeNoteTransferPages,
|
|
6115
6207
|
encryptJson,
|
|
6116
6208
|
encryptNote,
|
|
@@ -6147,6 +6239,7 @@ export {
|
|
|
6147
6239
|
hexToNumber,
|
|
6148
6240
|
implicitSubstrateToEvm,
|
|
6149
6241
|
importDeviceKey,
|
|
6242
|
+
importNotesFromBackup,
|
|
6150
6243
|
isAbortError,
|
|
6151
6244
|
isAlreadySpentError,
|
|
6152
6245
|
isConnectionLossError,
|