@orbinum/sdk 0.8.1 → 0.9.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 +48 -13
- package/dist/index.d.ts +48 -13
- package/dist/index.js +41 -4
- package/dist/index.mjs +38 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2820,6 +2820,25 @@ declare function vaultReviver(_key: string, value: unknown): unknown;
|
|
|
2820
2820
|
* @param masterBytes 32-byte pre-modulus key material from deriveMasterKeyBytes().
|
|
2821
2821
|
*/
|
|
2822
2822
|
declare function deriveVaultKey(masterBytes: Uint8Array): Promise<CryptoKey>;
|
|
2823
|
+
/**
|
|
2824
|
+
* Derives an HMAC-SHA-256 key ("blind key") from the same master key bytes,
|
|
2825
|
+
* for deterministically tagging note identifiers (commitment/nullifier) in the
|
|
2826
|
+
* vault WITHOUT storing them in plaintext.
|
|
2827
|
+
*
|
|
2828
|
+
* The tag `HMAC(blindKey, hex)` is stable, so equality lookups still work
|
|
2829
|
+
* (find a note by commitment/nullifier), but a raw storage dump reveals no
|
|
2830
|
+
* on-chain identifiers — an attacker with disk access can't link the vault to
|
|
2831
|
+
* chain activity. Derived from masterBytes, so it's device-independent and
|
|
2832
|
+
* survives reload (unlike a random per-session salt).
|
|
2833
|
+
*
|
|
2834
|
+
* @param masterBytes 32-byte pre-modulus key material from deriveMasterKeyBytes().
|
|
2835
|
+
*/
|
|
2836
|
+
declare function deriveVaultBlindKey(masterBytes: Uint8Array): Promise<CryptoKey>;
|
|
2837
|
+
/**
|
|
2838
|
+
* Deterministic tag for a note identifier hex, as `0x`-prefixed HMAC-SHA-256.
|
|
2839
|
+
* Used as the blinded storage key for commitment / nullifier / assetId.
|
|
2840
|
+
*/
|
|
2841
|
+
declare function blindTag(blindKey: CryptoKey, value: string): Promise<string>;
|
|
2823
2842
|
/**
|
|
2824
2843
|
* Serialises `payload` to JSON (bigint-safe) and encrypts it with AES-GCM.
|
|
2825
2844
|
* Returns base64-encoded `iv` and `ciphertext`.
|
|
@@ -2841,18 +2860,26 @@ declare function decryptJson(key: CryptoKey, iv: string, ciphertext: string): Pr
|
|
|
2841
2860
|
* Any backend (IndexedDB, SQLite, remote…) must produce/consume this shape
|
|
2842
2861
|
* so that encryptNote / decryptNoteRecord work without modification.
|
|
2843
2862
|
*/
|
|
2844
|
-
/**
|
|
2863
|
+
/**
|
|
2864
|
+
* A single encrypted note record as stored in the vault backend.
|
|
2865
|
+
*
|
|
2866
|
+
* Note identifiers are BLINDED — stored as HMAC tags derived from the vault
|
|
2867
|
+
* blind key, not the raw on-chain hex. A storage dump reveals no
|
|
2868
|
+
* commitment/nullifier/asset that could be linked to chain activity, yet
|
|
2869
|
+
* equality lookups (find-my-note) still work by comparing tags. `spent` /
|
|
2870
|
+
* `spentAt` stay plaintext: they're local flags with no on-chain linkage.
|
|
2871
|
+
*/
|
|
2845
2872
|
interface EncryptedNoteRecord {
|
|
2846
|
-
/** Primary key —
|
|
2847
|
-
|
|
2873
|
+
/** Primary key — blinded commitment tag: HMAC(blindKey, commitmentHex). */
|
|
2874
|
+
commitmentTag: string;
|
|
2848
2875
|
/** AES-GCM IV for this record — base64 */
|
|
2849
2876
|
iv: string;
|
|
2850
2877
|
/** AES-GCM ciphertext of the full ZkNote JSON — base64 */
|
|
2851
2878
|
ciphertext: string;
|
|
2852
|
-
/**
|
|
2853
|
-
|
|
2854
|
-
/**
|
|
2855
|
-
|
|
2879
|
+
/** Blinded nullifier tag: HMAC(blindKey, nullifierHex). Quick spent-check. */
|
|
2880
|
+
nullifierTag: string;
|
|
2881
|
+
/** Blinded asset tag: HMAC(blindKey, assetId). Filter by asset without unlock. */
|
|
2882
|
+
assetTag: string;
|
|
2856
2883
|
/** Whether the note has already been spent/nullified on-chain. */
|
|
2857
2884
|
spent?: boolean;
|
|
2858
2885
|
/** When the app marked the note as spent locally, if known. */
|
|
@@ -2886,17 +2913,25 @@ declare class VaultLockedError extends Error {
|
|
|
2886
2913
|
*/
|
|
2887
2914
|
declare function applyNoteStatus(note: ZkNote, status?: NoteStatusUpdate): ZkNote;
|
|
2888
2915
|
/**
|
|
2889
|
-
* Encrypts a ZkNote into
|
|
2890
|
-
*
|
|
2891
|
-
*
|
|
2916
|
+
* Encrypts a ZkNote into a v2 EncryptedNoteRecord.
|
|
2917
|
+
*
|
|
2918
|
+
* The full note (values, secrets) is AES-GCM encrypted under `key`; the note
|
|
2919
|
+
* identifiers (commitment, nullifier, asset) are stored as BLIND TAGS under
|
|
2920
|
+
* `blindKey` instead of plaintext — a storage dump reveals nothing linkable to
|
|
2921
|
+
* chain activity, while equality lookups still work (compare tags).
|
|
2892
2922
|
*/
|
|
2893
|
-
declare function encryptNote(key: CryptoKey, note: ZkNote): Promise<EncryptedNoteRecord>;
|
|
2923
|
+
declare function encryptNote(key: CryptoKey, blindKey: CryptoKey, note: ZkNote): Promise<EncryptedNoteRecord>;
|
|
2894
2924
|
/**
|
|
2895
|
-
* Decrypts
|
|
2925
|
+
* Decrypts a note record back into a ZkNote.
|
|
2896
2926
|
* Applies the record's spent/spentAt metadata onto the decrypted note.
|
|
2897
2927
|
* Throws DOMException on authentication failure (wrong key or corrupted data).
|
|
2898
2928
|
*/
|
|
2899
2929
|
declare function decryptNoteRecord(key: CryptoKey, rec: EncryptedNoteRecord): Promise<ZkNote>;
|
|
2930
|
+
/**
|
|
2931
|
+
* Blind tag for a note identifier hex — use to build the storage key or to
|
|
2932
|
+
* look a record up by commitment/nullifier without exposing the raw hex.
|
|
2933
|
+
*/
|
|
2934
|
+
declare function noteBlindTag(blindKey: CryptoKey, hex: string): Promise<string>;
|
|
2900
2935
|
|
|
2901
2936
|
/**
|
|
2902
2937
|
* Inputs required to generate an Unshield proof.
|
|
@@ -4491,4 +4526,4 @@ interface ExtrinsicFailedData {
|
|
|
4491
4526
|
dispatch_info: DispatchInfo;
|
|
4492
4527
|
}
|
|
4493
4528
|
|
|
4494
|
-
export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, type ActivityBucket, type AddChainLinkArgs, type AddChainLinkParams, type AddSupportedChainArgs, type AliasFullIdentity, type AliasInfo, type AliasListedForSaleEvent, type AliasOnSaleData, type AliasRegisteredData, type AliasRegisteredEvent, type AliasReleasedEvent, type AliasSaleCancelledEvent, type AliasSoldData, type AliasSoldEvent, type AliasTransferredData, type AliasTransferredEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type BuyAliasArgs, type Bytes32, type ChainInfo, type ChainLink, type ChainLinkAddedEvent, type ChainLinkRemovedEvent, CircuitId, CircuitId as CircuitIdType, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedAddChainLinkArgs, type DecodedBatchArgs, type DecodedDispatchAsPrivateLinkArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedPutAliasForSaleArgs, type DecodedRegisterAliasArgs, type DecodedRemarkArgs, type DecodedRevealPrivateLinkArgs, type DecodedSetAccountMetadataArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, type DispatchAsLinkedAccountArgs, type DispatchAsLinkedParams, type DispatchAsPrivateLinkArgs, type DispatchError, type DispatchInfo, type DynamicBuilder, ENCRYPTED_MEMO_SIZE, EncryptedMemo, type EncryptedNoteRecord, type EndowedEventData, type EthereumExecutedData, type EventData, type EventPhase, type EventRecord, type EvmAddressInfo, type EvmBlock, EvmClient, type EvmExecutedData, type EvmExitReason, EvmExplorer, type EvmLog, type EvmSigner, type EvmTransaction, type EvmTxRequest, type EvmTxSummary, type ExtrinsicDecoder, type ExtrinsicFailedData, type ExtrinsicSuccessData, type FeeClaimProofInputs, type FormatOptions, type IndexedBlock, type IndexedEvmTx, type IndexedExtrinsic, type IndexedSession, type IndexedValidator, type IndexerActivity, IndexerClient, type IndexerClientConfig, type IndexerStats, KNOWN_PRECOMPILES, type KnownPrecompileInfo, type ListingInfo, type MerkleRoot, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, type MetadataUpdatedEvent, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifierStatusResult, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, type PaginatedResult, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateChainLinkAddedEvent, type PrivateChainLinkRemovedEvent, type PrivateChainLinkRevealedEvent, type PrivateLink, type PrivateLinkDispatchExecutedEvent, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type PrivateTransferTimestamp, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type ProxyCallExecutedEvent, type PutAliasOnSaleArgs, type PutOnSaleParams, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAliasArgs, type RegisterAssetArgs, type RegisterPrivateLinkArgs, type RegisterVerificationKeyArgs, type RegisteredAsset, type RelayFeeEvent, type RelayFeeSummaryEntry, type Relayer, type RelayerInfo, RelayerStatusModule, type RemoveChainLinkArgs, type RemovePrivateLinkArgs, type RemoveSupportedChainArgs, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedAlias, type RevealPrivateLinkArgs, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SLIP0044_NAMESPACE, type ScanCommitment, type SetAccountMetadataArgs, type SetActiveVersionArgs, type SetMetadataParams, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedAddressEvent, type ShieldedCommitment, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SignatureScheme, type SpentNullifier, type StatusChangeEvent, type StatusListener, type StealthScanHint, SubstrateClient, type SupportedChain, type SupportedChainAddedEvent, type SupportedChainRemovedEvent, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferAliasArgs, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TxResult, type UnsafeTxOptions, type Unshield, type UnshieldArgs, type UnshieldParams, type UnshieldProofInputs, type UnshieldedEvent, type UnshieldedEventData, type UnverifyAssetArgs, VaultLockedError, type VerificationKeyRegisteredEvent, type VerificationKeyRemovedEvent, type VerifyAssetArgs, type VerifyProofArgs, type VkEntry, type ZkNote, type ZkVerifierCall, type ZkVerifierCircuitVersionInfo, type ZkVerifierEvent, type ZkVerifierHistoricalVersion, ZkVerifierModule, type ZkVerifierVersionStats, type ZkVerifierVkHash, accountIdHexToSs58, addressToAccountIdHex, applyNoteStatus, bigintTo32Be, bigintTo32Le, bigintTo32LeArr, buildDummyTransferInput, bytesToBigintLE, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessage, deriveStealthOwnerPk, deriveStealthSk, deriveVaultKey, deriveViewingPublicKey, deriveViewingSecretKey, encryptJson, encryptNote, ensureHexPrefix, evmAddressToAccountId, evmToImplicitSubstrate, evmToMappedAccountHex, evmToSubstrate, formatBalance, formatORB, fromBase64, fromHex, generateFeeClaimProof, generateTransferProof, generateUnshieldProof, getPrecompileLabel, hexToBigint, hexToNumber, implicitSubstrateToEvm, isEvmAddress, isImplicitEvmAccount, isSs58, isSubstrateAddress, isUnifiedAddress, leHexToBigint, mapExtrinsicArgs, mapZkEventData, normalizeEvmAddress, randomBlinding, recoverOwnerPkPoint, selectNotes, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
|
|
4529
|
+
export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, type ActivityBucket, type AddChainLinkArgs, type AddChainLinkParams, type AddSupportedChainArgs, type AliasFullIdentity, type AliasInfo, type AliasListedForSaleEvent, type AliasOnSaleData, type AliasRegisteredData, type AliasRegisteredEvent, type AliasReleasedEvent, type AliasSaleCancelledEvent, type AliasSoldData, type AliasSoldEvent, type AliasTransferredData, type AliasTransferredEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type BuyAliasArgs, type Bytes32, type ChainInfo, type ChainLink, type ChainLinkAddedEvent, type ChainLinkRemovedEvent, CircuitId, CircuitId as CircuitIdType, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedAddChainLinkArgs, type DecodedBatchArgs, type DecodedDispatchAsPrivateLinkArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedPutAliasForSaleArgs, type DecodedRegisterAliasArgs, type DecodedRemarkArgs, type DecodedRevealPrivateLinkArgs, type DecodedSetAccountMetadataArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, type DispatchAsLinkedAccountArgs, type DispatchAsLinkedParams, type DispatchAsPrivateLinkArgs, type DispatchError, type DispatchInfo, type DynamicBuilder, ENCRYPTED_MEMO_SIZE, EncryptedMemo, type EncryptedNoteRecord, type EndowedEventData, type EthereumExecutedData, type EventData, type EventPhase, type EventRecord, type EvmAddressInfo, type EvmBlock, EvmClient, type EvmExecutedData, type EvmExitReason, EvmExplorer, type EvmLog, type EvmSigner, type EvmTransaction, type EvmTxRequest, type EvmTxSummary, type ExtrinsicDecoder, type ExtrinsicFailedData, type ExtrinsicSuccessData, type FeeClaimProofInputs, type FormatOptions, type IndexedBlock, type IndexedEvmTx, type IndexedExtrinsic, type IndexedSession, type IndexedValidator, type IndexerActivity, IndexerClient, type IndexerClientConfig, type IndexerStats, KNOWN_PRECOMPILES, type KnownPrecompileInfo, type ListingInfo, type MerkleRoot, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, type MetadataUpdatedEvent, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifierStatusResult, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, type PaginatedResult, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateChainLinkAddedEvent, type PrivateChainLinkRemovedEvent, type PrivateChainLinkRevealedEvent, type PrivateLink, type PrivateLinkDispatchExecutedEvent, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type PrivateTransferTimestamp, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type ProxyCallExecutedEvent, type PutAliasOnSaleArgs, type PutOnSaleParams, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAliasArgs, type RegisterAssetArgs, type RegisterPrivateLinkArgs, type RegisterVerificationKeyArgs, type RegisteredAsset, type RelayFeeEvent, type RelayFeeSummaryEntry, type Relayer, type RelayerInfo, RelayerStatusModule, type RemoveChainLinkArgs, type RemovePrivateLinkArgs, type RemoveSupportedChainArgs, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedAlias, type RevealPrivateLinkArgs, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SLIP0044_NAMESPACE, type ScanCommitment, type SetAccountMetadataArgs, type SetActiveVersionArgs, type SetMetadataParams, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedAddressEvent, type ShieldedCommitment, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SignatureScheme, type SpentNullifier, type StatusChangeEvent, type StatusListener, type StealthScanHint, SubstrateClient, type SupportedChain, type SupportedChainAddedEvent, type SupportedChainRemovedEvent, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferAliasArgs, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TxResult, type UnsafeTxOptions, type Unshield, type UnshieldArgs, type UnshieldParams, type UnshieldProofInputs, type UnshieldedEvent, type UnshieldedEventData, type UnverifyAssetArgs, VaultLockedError, type VerificationKeyRegisteredEvent, type VerificationKeyRemovedEvent, type VerifyAssetArgs, type VerifyProofArgs, type VkEntry, type ZkNote, type ZkVerifierCall, type ZkVerifierCircuitVersionInfo, type ZkVerifierEvent, type ZkVerifierHistoricalVersion, ZkVerifierModule, type ZkVerifierVersionStats, type ZkVerifierVkHash, accountIdHexToSs58, addressToAccountIdHex, applyNoteStatus, bigintTo32Be, bigintTo32Le, bigintTo32LeArr, blindTag, buildDummyTransferInput, bytesToBigintLE, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessage, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, deriveVaultKey, deriveViewingPublicKey, deriveViewingSecretKey, encryptJson, encryptNote, ensureHexPrefix, evmAddressToAccountId, evmToImplicitSubstrate, evmToMappedAccountHex, evmToSubstrate, formatBalance, formatORB, fromBase64, fromHex, generateFeeClaimProof, generateTransferProof, generateUnshieldProof, getPrecompileLabel, hexToBigint, hexToNumber, implicitSubstrateToEvm, isEvmAddress, isImplicitEvmAccount, isSs58, isSubstrateAddress, isUnifiedAddress, leHexToBigint, mapExtrinsicArgs, mapZkEventData, normalizeEvmAddress, noteBlindTag, randomBlinding, recoverOwnerPkPoint, selectNotes, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
|
package/dist/index.d.ts
CHANGED
|
@@ -2820,6 +2820,25 @@ declare function vaultReviver(_key: string, value: unknown): unknown;
|
|
|
2820
2820
|
* @param masterBytes 32-byte pre-modulus key material from deriveMasterKeyBytes().
|
|
2821
2821
|
*/
|
|
2822
2822
|
declare function deriveVaultKey(masterBytes: Uint8Array): Promise<CryptoKey>;
|
|
2823
|
+
/**
|
|
2824
|
+
* Derives an HMAC-SHA-256 key ("blind key") from the same master key bytes,
|
|
2825
|
+
* for deterministically tagging note identifiers (commitment/nullifier) in the
|
|
2826
|
+
* vault WITHOUT storing them in plaintext.
|
|
2827
|
+
*
|
|
2828
|
+
* The tag `HMAC(blindKey, hex)` is stable, so equality lookups still work
|
|
2829
|
+
* (find a note by commitment/nullifier), but a raw storage dump reveals no
|
|
2830
|
+
* on-chain identifiers — an attacker with disk access can't link the vault to
|
|
2831
|
+
* chain activity. Derived from masterBytes, so it's device-independent and
|
|
2832
|
+
* survives reload (unlike a random per-session salt).
|
|
2833
|
+
*
|
|
2834
|
+
* @param masterBytes 32-byte pre-modulus key material from deriveMasterKeyBytes().
|
|
2835
|
+
*/
|
|
2836
|
+
declare function deriveVaultBlindKey(masterBytes: Uint8Array): Promise<CryptoKey>;
|
|
2837
|
+
/**
|
|
2838
|
+
* Deterministic tag for a note identifier hex, as `0x`-prefixed HMAC-SHA-256.
|
|
2839
|
+
* Used as the blinded storage key for commitment / nullifier / assetId.
|
|
2840
|
+
*/
|
|
2841
|
+
declare function blindTag(blindKey: CryptoKey, value: string): Promise<string>;
|
|
2823
2842
|
/**
|
|
2824
2843
|
* Serialises `payload` to JSON (bigint-safe) and encrypts it with AES-GCM.
|
|
2825
2844
|
* Returns base64-encoded `iv` and `ciphertext`.
|
|
@@ -2841,18 +2860,26 @@ declare function decryptJson(key: CryptoKey, iv: string, ciphertext: string): Pr
|
|
|
2841
2860
|
* Any backend (IndexedDB, SQLite, remote…) must produce/consume this shape
|
|
2842
2861
|
* so that encryptNote / decryptNoteRecord work without modification.
|
|
2843
2862
|
*/
|
|
2844
|
-
/**
|
|
2863
|
+
/**
|
|
2864
|
+
* A single encrypted note record as stored in the vault backend.
|
|
2865
|
+
*
|
|
2866
|
+
* Note identifiers are BLINDED — stored as HMAC tags derived from the vault
|
|
2867
|
+
* blind key, not the raw on-chain hex. A storage dump reveals no
|
|
2868
|
+
* commitment/nullifier/asset that could be linked to chain activity, yet
|
|
2869
|
+
* equality lookups (find-my-note) still work by comparing tags. `spent` /
|
|
2870
|
+
* `spentAt` stay plaintext: they're local flags with no on-chain linkage.
|
|
2871
|
+
*/
|
|
2845
2872
|
interface EncryptedNoteRecord {
|
|
2846
|
-
/** Primary key —
|
|
2847
|
-
|
|
2873
|
+
/** Primary key — blinded commitment tag: HMAC(blindKey, commitmentHex). */
|
|
2874
|
+
commitmentTag: string;
|
|
2848
2875
|
/** AES-GCM IV for this record — base64 */
|
|
2849
2876
|
iv: string;
|
|
2850
2877
|
/** AES-GCM ciphertext of the full ZkNote JSON — base64 */
|
|
2851
2878
|
ciphertext: string;
|
|
2852
|
-
/**
|
|
2853
|
-
|
|
2854
|
-
/**
|
|
2855
|
-
|
|
2879
|
+
/** Blinded nullifier tag: HMAC(blindKey, nullifierHex). Quick spent-check. */
|
|
2880
|
+
nullifierTag: string;
|
|
2881
|
+
/** Blinded asset tag: HMAC(blindKey, assetId). Filter by asset without unlock. */
|
|
2882
|
+
assetTag: string;
|
|
2856
2883
|
/** Whether the note has already been spent/nullified on-chain. */
|
|
2857
2884
|
spent?: boolean;
|
|
2858
2885
|
/** When the app marked the note as spent locally, if known. */
|
|
@@ -2886,17 +2913,25 @@ declare class VaultLockedError extends Error {
|
|
|
2886
2913
|
*/
|
|
2887
2914
|
declare function applyNoteStatus(note: ZkNote, status?: NoteStatusUpdate): ZkNote;
|
|
2888
2915
|
/**
|
|
2889
|
-
* Encrypts a ZkNote into
|
|
2890
|
-
*
|
|
2891
|
-
*
|
|
2916
|
+
* Encrypts a ZkNote into a v2 EncryptedNoteRecord.
|
|
2917
|
+
*
|
|
2918
|
+
* The full note (values, secrets) is AES-GCM encrypted under `key`; the note
|
|
2919
|
+
* identifiers (commitment, nullifier, asset) are stored as BLIND TAGS under
|
|
2920
|
+
* `blindKey` instead of plaintext — a storage dump reveals nothing linkable to
|
|
2921
|
+
* chain activity, while equality lookups still work (compare tags).
|
|
2892
2922
|
*/
|
|
2893
|
-
declare function encryptNote(key: CryptoKey, note: ZkNote): Promise<EncryptedNoteRecord>;
|
|
2923
|
+
declare function encryptNote(key: CryptoKey, blindKey: CryptoKey, note: ZkNote): Promise<EncryptedNoteRecord>;
|
|
2894
2924
|
/**
|
|
2895
|
-
* Decrypts
|
|
2925
|
+
* Decrypts a note record back into a ZkNote.
|
|
2896
2926
|
* Applies the record's spent/spentAt metadata onto the decrypted note.
|
|
2897
2927
|
* Throws DOMException on authentication failure (wrong key or corrupted data).
|
|
2898
2928
|
*/
|
|
2899
2929
|
declare function decryptNoteRecord(key: CryptoKey, rec: EncryptedNoteRecord): Promise<ZkNote>;
|
|
2930
|
+
/**
|
|
2931
|
+
* Blind tag for a note identifier hex — use to build the storage key or to
|
|
2932
|
+
* look a record up by commitment/nullifier without exposing the raw hex.
|
|
2933
|
+
*/
|
|
2934
|
+
declare function noteBlindTag(blindKey: CryptoKey, hex: string): Promise<string>;
|
|
2900
2935
|
|
|
2901
2936
|
/**
|
|
2902
2937
|
* Inputs required to generate an Unshield proof.
|
|
@@ -4491,4 +4526,4 @@ interface ExtrinsicFailedData {
|
|
|
4491
4526
|
dispatch_info: DispatchInfo;
|
|
4492
4527
|
}
|
|
4493
4528
|
|
|
4494
|
-
export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, type ActivityBucket, type AddChainLinkArgs, type AddChainLinkParams, type AddSupportedChainArgs, type AliasFullIdentity, type AliasInfo, type AliasListedForSaleEvent, type AliasOnSaleData, type AliasRegisteredData, type AliasRegisteredEvent, type AliasReleasedEvent, type AliasSaleCancelledEvent, type AliasSoldData, type AliasSoldEvent, type AliasTransferredData, type AliasTransferredEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type BuyAliasArgs, type Bytes32, type ChainInfo, type ChainLink, type ChainLinkAddedEvent, type ChainLinkRemovedEvent, CircuitId, CircuitId as CircuitIdType, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedAddChainLinkArgs, type DecodedBatchArgs, type DecodedDispatchAsPrivateLinkArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedPutAliasForSaleArgs, type DecodedRegisterAliasArgs, type DecodedRemarkArgs, type DecodedRevealPrivateLinkArgs, type DecodedSetAccountMetadataArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, type DispatchAsLinkedAccountArgs, type DispatchAsLinkedParams, type DispatchAsPrivateLinkArgs, type DispatchError, type DispatchInfo, type DynamicBuilder, ENCRYPTED_MEMO_SIZE, EncryptedMemo, type EncryptedNoteRecord, type EndowedEventData, type EthereumExecutedData, type EventData, type EventPhase, type EventRecord, type EvmAddressInfo, type EvmBlock, EvmClient, type EvmExecutedData, type EvmExitReason, EvmExplorer, type EvmLog, type EvmSigner, type EvmTransaction, type EvmTxRequest, type EvmTxSummary, type ExtrinsicDecoder, type ExtrinsicFailedData, type ExtrinsicSuccessData, type FeeClaimProofInputs, type FormatOptions, type IndexedBlock, type IndexedEvmTx, type IndexedExtrinsic, type IndexedSession, type IndexedValidator, type IndexerActivity, IndexerClient, type IndexerClientConfig, type IndexerStats, KNOWN_PRECOMPILES, type KnownPrecompileInfo, type ListingInfo, type MerkleRoot, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, type MetadataUpdatedEvent, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifierStatusResult, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, type PaginatedResult, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateChainLinkAddedEvent, type PrivateChainLinkRemovedEvent, type PrivateChainLinkRevealedEvent, type PrivateLink, type PrivateLinkDispatchExecutedEvent, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type PrivateTransferTimestamp, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type ProxyCallExecutedEvent, type PutAliasOnSaleArgs, type PutOnSaleParams, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAliasArgs, type RegisterAssetArgs, type RegisterPrivateLinkArgs, type RegisterVerificationKeyArgs, type RegisteredAsset, type RelayFeeEvent, type RelayFeeSummaryEntry, type Relayer, type RelayerInfo, RelayerStatusModule, type RemoveChainLinkArgs, type RemovePrivateLinkArgs, type RemoveSupportedChainArgs, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedAlias, type RevealPrivateLinkArgs, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SLIP0044_NAMESPACE, type ScanCommitment, type SetAccountMetadataArgs, type SetActiveVersionArgs, type SetMetadataParams, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedAddressEvent, type ShieldedCommitment, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SignatureScheme, type SpentNullifier, type StatusChangeEvent, type StatusListener, type StealthScanHint, SubstrateClient, type SupportedChain, type SupportedChainAddedEvent, type SupportedChainRemovedEvent, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferAliasArgs, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TxResult, type UnsafeTxOptions, type Unshield, type UnshieldArgs, type UnshieldParams, type UnshieldProofInputs, type UnshieldedEvent, type UnshieldedEventData, type UnverifyAssetArgs, VaultLockedError, type VerificationKeyRegisteredEvent, type VerificationKeyRemovedEvent, type VerifyAssetArgs, type VerifyProofArgs, type VkEntry, type ZkNote, type ZkVerifierCall, type ZkVerifierCircuitVersionInfo, type ZkVerifierEvent, type ZkVerifierHistoricalVersion, ZkVerifierModule, type ZkVerifierVersionStats, type ZkVerifierVkHash, accountIdHexToSs58, addressToAccountIdHex, applyNoteStatus, bigintTo32Be, bigintTo32Le, bigintTo32LeArr, buildDummyTransferInput, bytesToBigintLE, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessage, deriveStealthOwnerPk, deriveStealthSk, deriveVaultKey, deriveViewingPublicKey, deriveViewingSecretKey, encryptJson, encryptNote, ensureHexPrefix, evmAddressToAccountId, evmToImplicitSubstrate, evmToMappedAccountHex, evmToSubstrate, formatBalance, formatORB, fromBase64, fromHex, generateFeeClaimProof, generateTransferProof, generateUnshieldProof, getPrecompileLabel, hexToBigint, hexToNumber, implicitSubstrateToEvm, isEvmAddress, isImplicitEvmAccount, isSs58, isSubstrateAddress, isUnifiedAddress, leHexToBigint, mapExtrinsicArgs, mapZkEventData, normalizeEvmAddress, randomBlinding, recoverOwnerPkPoint, selectNotes, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
|
|
4529
|
+
export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, type ActivityBucket, type AddChainLinkArgs, type AddChainLinkParams, type AddSupportedChainArgs, type AliasFullIdentity, type AliasInfo, type AliasListedForSaleEvent, type AliasOnSaleData, type AliasRegisteredData, type AliasRegisteredEvent, type AliasReleasedEvent, type AliasSaleCancelledEvent, type AliasSoldData, type AliasSoldEvent, type AliasTransferredData, type AliasTransferredEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type BuyAliasArgs, type Bytes32, type ChainInfo, type ChainLink, type ChainLinkAddedEvent, type ChainLinkRemovedEvent, CircuitId, CircuitId as CircuitIdType, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedAddChainLinkArgs, type DecodedBatchArgs, type DecodedDispatchAsPrivateLinkArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedPutAliasForSaleArgs, type DecodedRegisterAliasArgs, type DecodedRemarkArgs, type DecodedRevealPrivateLinkArgs, type DecodedSetAccountMetadataArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, type DispatchAsLinkedAccountArgs, type DispatchAsLinkedParams, type DispatchAsPrivateLinkArgs, type DispatchError, type DispatchInfo, type DynamicBuilder, ENCRYPTED_MEMO_SIZE, EncryptedMemo, type EncryptedNoteRecord, type EndowedEventData, type EthereumExecutedData, type EventData, type EventPhase, type EventRecord, type EvmAddressInfo, type EvmBlock, EvmClient, type EvmExecutedData, type EvmExitReason, EvmExplorer, type EvmLog, type EvmSigner, type EvmTransaction, type EvmTxRequest, type EvmTxSummary, type ExtrinsicDecoder, type ExtrinsicFailedData, type ExtrinsicSuccessData, type FeeClaimProofInputs, type FormatOptions, type IndexedBlock, type IndexedEvmTx, type IndexedExtrinsic, type IndexedSession, type IndexedValidator, type IndexerActivity, IndexerClient, type IndexerClientConfig, type IndexerStats, KNOWN_PRECOMPILES, type KnownPrecompileInfo, type ListingInfo, type MerkleRoot, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, type MetadataUpdatedEvent, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifierStatusResult, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, type PaginatedResult, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateChainLinkAddedEvent, type PrivateChainLinkRemovedEvent, type PrivateChainLinkRevealedEvent, type PrivateLink, type PrivateLinkDispatchExecutedEvent, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type PrivateTransferTimestamp, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type ProxyCallExecutedEvent, type PutAliasOnSaleArgs, type PutOnSaleParams, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAliasArgs, type RegisterAssetArgs, type RegisterPrivateLinkArgs, type RegisterVerificationKeyArgs, type RegisteredAsset, type RelayFeeEvent, type RelayFeeSummaryEntry, type Relayer, type RelayerInfo, RelayerStatusModule, type RemoveChainLinkArgs, type RemovePrivateLinkArgs, type RemoveSupportedChainArgs, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedAlias, type RevealPrivateLinkArgs, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SLIP0044_NAMESPACE, type ScanCommitment, type SetAccountMetadataArgs, type SetActiveVersionArgs, type SetMetadataParams, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedAddressEvent, type ShieldedCommitment, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SignatureScheme, type SpentNullifier, type StatusChangeEvent, type StatusListener, type StealthScanHint, SubstrateClient, type SupportedChain, type SupportedChainAddedEvent, type SupportedChainRemovedEvent, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferAliasArgs, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TxResult, type UnsafeTxOptions, type Unshield, type UnshieldArgs, type UnshieldParams, type UnshieldProofInputs, type UnshieldedEvent, type UnshieldedEventData, type UnverifyAssetArgs, VaultLockedError, type VerificationKeyRegisteredEvent, type VerificationKeyRemovedEvent, type VerifyAssetArgs, type VerifyProofArgs, type VkEntry, type ZkNote, type ZkVerifierCall, type ZkVerifierCircuitVersionInfo, type ZkVerifierEvent, type ZkVerifierHistoricalVersion, ZkVerifierModule, type ZkVerifierVersionStats, type ZkVerifierVkHash, accountIdHexToSs58, addressToAccountIdHex, applyNoteStatus, bigintTo32Be, bigintTo32Le, bigintTo32LeArr, blindTag, buildDummyTransferInput, bytesToBigintLE, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessage, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, deriveVaultKey, deriveViewingPublicKey, deriveViewingSecretKey, encryptJson, encryptNote, ensureHexPrefix, evmAddressToAccountId, evmToImplicitSubstrate, evmToMappedAccountHex, evmToSubstrate, formatBalance, formatORB, fromBase64, fromHex, generateFeeClaimProof, generateTransferProof, generateUnshieldProof, getPrecompileLabel, hexToBigint, hexToNumber, implicitSubstrateToEvm, isEvmAddress, isImplicitEvmAccount, isSs58, isSubstrateAddress, isUnifiedAddress, leHexToBigint, mapExtrinsicArgs, mapZkEventData, normalizeEvmAddress, noteBlindTag, randomBlinding, recoverOwnerPkPoint, selectNotes, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
|
package/dist/index.js
CHANGED
|
@@ -59,6 +59,7 @@ __export(index_exports, {
|
|
|
59
59
|
bigintTo32Be: () => bigintTo32Be,
|
|
60
60
|
bigintTo32Le: () => bigintTo32Le,
|
|
61
61
|
bigintTo32LeArr: () => bigintTo32LeArr,
|
|
62
|
+
blindTag: () => blindTag,
|
|
62
63
|
buildDummyTransferInput: () => buildDummyTransferInput,
|
|
63
64
|
bytesToBigintLE: () => bytesToBigintLE,
|
|
64
65
|
computeNullifier: () => computeNullifier,
|
|
@@ -75,6 +76,7 @@ __export(index_exports, {
|
|
|
75
76
|
deriveSpendingKeyMessage: () => deriveSpendingKeyMessage,
|
|
76
77
|
deriveStealthOwnerPk: () => deriveStealthOwnerPk,
|
|
77
78
|
deriveStealthSk: () => deriveStealthSk,
|
|
79
|
+
deriveVaultBlindKey: () => deriveVaultBlindKey,
|
|
78
80
|
deriveVaultKey: () => deriveVaultKey,
|
|
79
81
|
deriveViewingPublicKey: () => deriveViewingPublicKey,
|
|
80
82
|
deriveViewingSecretKey: () => deriveViewingSecretKey,
|
|
@@ -109,6 +111,7 @@ __export(index_exports, {
|
|
|
109
111
|
mapExtrinsicArgs: () => mapExtrinsicArgs,
|
|
110
112
|
mapZkEventData: () => mapZkEventData,
|
|
111
113
|
normalizeEvmAddress: () => normalizeEvmAddress,
|
|
114
|
+
noteBlindTag: () => noteBlindTag,
|
|
112
115
|
randomBlinding: () => randomBlinding,
|
|
113
116
|
recoverOwnerPkPoint: () => recoverOwnerPkPoint,
|
|
114
117
|
selectNotes: () => selectNotes,
|
|
@@ -4484,6 +4487,7 @@ function fromBase64(b64) {
|
|
|
4484
4487
|
|
|
4485
4488
|
// src/vault/VaultCrypto.ts
|
|
4486
4489
|
var VAULT_KEY_INFO = new TextEncoder().encode("orbinum-vault-key-v1");
|
|
4490
|
+
var VAULT_BLIND_INFO = new TextEncoder().encode("orbinum-vault-blind-v1");
|
|
4487
4491
|
var IV_BYTES = 12;
|
|
4488
4492
|
async function deriveVaultKey(masterBytes) {
|
|
4489
4493
|
const keyMaterial = await crypto.subtle.importKey("raw", masterBytes.slice(0), "HKDF", false, [
|
|
@@ -4502,6 +4506,28 @@ async function deriveVaultKey(masterBytes) {
|
|
|
4502
4506
|
["encrypt", "decrypt"]
|
|
4503
4507
|
);
|
|
4504
4508
|
}
|
|
4509
|
+
async function deriveVaultBlindKey(masterBytes) {
|
|
4510
|
+
const keyMaterial = await crypto.subtle.importKey("raw", masterBytes.slice(0), "HKDF", false, [
|
|
4511
|
+
"deriveKey"
|
|
4512
|
+
]);
|
|
4513
|
+
return crypto.subtle.deriveKey(
|
|
4514
|
+
{
|
|
4515
|
+
name: "HKDF",
|
|
4516
|
+
hash: "SHA-256",
|
|
4517
|
+
salt: new Uint8Array(0),
|
|
4518
|
+
info: VAULT_BLIND_INFO
|
|
4519
|
+
},
|
|
4520
|
+
keyMaterial,
|
|
4521
|
+
{ name: "HMAC", hash: "SHA-256", length: 256 },
|
|
4522
|
+
false,
|
|
4523
|
+
["sign"]
|
|
4524
|
+
);
|
|
4525
|
+
}
|
|
4526
|
+
async function blindTag(blindKey, value) {
|
|
4527
|
+
const data = new TextEncoder().encode(value.toLowerCase());
|
|
4528
|
+
const sig = await crypto.subtle.sign("HMAC", blindKey, data);
|
|
4529
|
+
return "0x" + toBase64(sig).replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
|
|
4530
|
+
}
|
|
4505
4531
|
async function encryptJson(key, payload) {
|
|
4506
4532
|
const iv = crypto.getRandomValues(new Uint8Array(IV_BYTES));
|
|
4507
4533
|
const plaintext = new TextEncoder().encode(JSON.stringify(payload, vaultReplacer));
|
|
@@ -4533,14 +4559,19 @@ function applyNoteStatus(note, status) {
|
|
|
4533
4559
|
spentAt: status?.spentAt ?? note.spentAt ?? null
|
|
4534
4560
|
};
|
|
4535
4561
|
}
|
|
4536
|
-
async function encryptNote(key, note) {
|
|
4562
|
+
async function encryptNote(key, blindKey, note) {
|
|
4537
4563
|
const { iv, ciphertext } = await encryptJson(key, note);
|
|
4564
|
+
const [commitmentTag, nullifierTag, assetTag] = await Promise.all([
|
|
4565
|
+
blindTag(blindKey, note.commitmentHex),
|
|
4566
|
+
blindTag(blindKey, note.nullifierHex),
|
|
4567
|
+
blindTag(blindKey, note.assetId.toString())
|
|
4568
|
+
]);
|
|
4538
4569
|
return {
|
|
4539
|
-
|
|
4570
|
+
commitmentTag,
|
|
4540
4571
|
iv,
|
|
4541
4572
|
ciphertext,
|
|
4542
|
-
|
|
4543
|
-
|
|
4573
|
+
nullifierTag,
|
|
4574
|
+
assetTag,
|
|
4544
4575
|
spent: note.spent,
|
|
4545
4576
|
spentAt: note.spentAt,
|
|
4546
4577
|
updatedAt: Date.now()
|
|
@@ -4553,6 +4584,9 @@ async function decryptNoteRecord(key, rec) {
|
|
|
4553
4584
|
spentAt: rec.spentAt ?? null
|
|
4554
4585
|
});
|
|
4555
4586
|
}
|
|
4587
|
+
async function noteBlindTag(blindKey, hex) {
|
|
4588
|
+
return blindTag(blindKey, hex);
|
|
4589
|
+
}
|
|
4556
4590
|
|
|
4557
4591
|
// src/proof-generator/unshield.ts
|
|
4558
4592
|
var import_proof_generator = require("@orbinum/proof-generator");
|
|
@@ -5459,6 +5493,7 @@ var import_polkadot_api4 = require("polkadot-api");
|
|
|
5459
5493
|
bigintTo32Be,
|
|
5460
5494
|
bigintTo32Le,
|
|
5461
5495
|
bigintTo32LeArr,
|
|
5496
|
+
blindTag,
|
|
5462
5497
|
buildDummyTransferInput,
|
|
5463
5498
|
bytesToBigintLE,
|
|
5464
5499
|
computeNullifier,
|
|
@@ -5475,6 +5510,7 @@ var import_polkadot_api4 = require("polkadot-api");
|
|
|
5475
5510
|
deriveSpendingKeyMessage,
|
|
5476
5511
|
deriveStealthOwnerPk,
|
|
5477
5512
|
deriveStealthSk,
|
|
5513
|
+
deriveVaultBlindKey,
|
|
5478
5514
|
deriveVaultKey,
|
|
5479
5515
|
deriveViewingPublicKey,
|
|
5480
5516
|
deriveViewingSecretKey,
|
|
@@ -5509,6 +5545,7 @@ var import_polkadot_api4 = require("polkadot-api");
|
|
|
5509
5545
|
mapExtrinsicArgs,
|
|
5510
5546
|
mapZkEventData,
|
|
5511
5547
|
normalizeEvmAddress,
|
|
5548
|
+
noteBlindTag,
|
|
5512
5549
|
randomBlinding,
|
|
5513
5550
|
recoverOwnerPkPoint,
|
|
5514
5551
|
selectNotes,
|
package/dist/index.mjs
CHANGED
|
@@ -4357,6 +4357,7 @@ function fromBase64(b64) {
|
|
|
4357
4357
|
|
|
4358
4358
|
// src/vault/VaultCrypto.ts
|
|
4359
4359
|
var VAULT_KEY_INFO = new TextEncoder().encode("orbinum-vault-key-v1");
|
|
4360
|
+
var VAULT_BLIND_INFO = new TextEncoder().encode("orbinum-vault-blind-v1");
|
|
4360
4361
|
var IV_BYTES = 12;
|
|
4361
4362
|
async function deriveVaultKey(masterBytes) {
|
|
4362
4363
|
const keyMaterial = await crypto.subtle.importKey("raw", masterBytes.slice(0), "HKDF", false, [
|
|
@@ -4375,6 +4376,28 @@ async function deriveVaultKey(masterBytes) {
|
|
|
4375
4376
|
["encrypt", "decrypt"]
|
|
4376
4377
|
);
|
|
4377
4378
|
}
|
|
4379
|
+
async function deriveVaultBlindKey(masterBytes) {
|
|
4380
|
+
const keyMaterial = await crypto.subtle.importKey("raw", masterBytes.slice(0), "HKDF", false, [
|
|
4381
|
+
"deriveKey"
|
|
4382
|
+
]);
|
|
4383
|
+
return crypto.subtle.deriveKey(
|
|
4384
|
+
{
|
|
4385
|
+
name: "HKDF",
|
|
4386
|
+
hash: "SHA-256",
|
|
4387
|
+
salt: new Uint8Array(0),
|
|
4388
|
+
info: VAULT_BLIND_INFO
|
|
4389
|
+
},
|
|
4390
|
+
keyMaterial,
|
|
4391
|
+
{ name: "HMAC", hash: "SHA-256", length: 256 },
|
|
4392
|
+
false,
|
|
4393
|
+
["sign"]
|
|
4394
|
+
);
|
|
4395
|
+
}
|
|
4396
|
+
async function blindTag(blindKey, value) {
|
|
4397
|
+
const data = new TextEncoder().encode(value.toLowerCase());
|
|
4398
|
+
const sig = await crypto.subtle.sign("HMAC", blindKey, data);
|
|
4399
|
+
return "0x" + toBase64(sig).replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
|
|
4400
|
+
}
|
|
4378
4401
|
async function encryptJson(key, payload) {
|
|
4379
4402
|
const iv = crypto.getRandomValues(new Uint8Array(IV_BYTES));
|
|
4380
4403
|
const plaintext = new TextEncoder().encode(JSON.stringify(payload, vaultReplacer));
|
|
@@ -4406,14 +4429,19 @@ function applyNoteStatus(note, status) {
|
|
|
4406
4429
|
spentAt: status?.spentAt ?? note.spentAt ?? null
|
|
4407
4430
|
};
|
|
4408
4431
|
}
|
|
4409
|
-
async function encryptNote(key, note) {
|
|
4432
|
+
async function encryptNote(key, blindKey, note) {
|
|
4410
4433
|
const { iv, ciphertext } = await encryptJson(key, note);
|
|
4434
|
+
const [commitmentTag, nullifierTag, assetTag] = await Promise.all([
|
|
4435
|
+
blindTag(blindKey, note.commitmentHex),
|
|
4436
|
+
blindTag(blindKey, note.nullifierHex),
|
|
4437
|
+
blindTag(blindKey, note.assetId.toString())
|
|
4438
|
+
]);
|
|
4411
4439
|
return {
|
|
4412
|
-
|
|
4440
|
+
commitmentTag,
|
|
4413
4441
|
iv,
|
|
4414
4442
|
ciphertext,
|
|
4415
|
-
|
|
4416
|
-
|
|
4443
|
+
nullifierTag,
|
|
4444
|
+
assetTag,
|
|
4417
4445
|
spent: note.spent,
|
|
4418
4446
|
spentAt: note.spentAt,
|
|
4419
4447
|
updatedAt: Date.now()
|
|
@@ -4426,6 +4454,9 @@ async function decryptNoteRecord(key, rec) {
|
|
|
4426
4454
|
spentAt: rec.spentAt ?? null
|
|
4427
4455
|
});
|
|
4428
4456
|
}
|
|
4457
|
+
async function noteBlindTag(blindKey, hex) {
|
|
4458
|
+
return blindTag(blindKey, hex);
|
|
4459
|
+
}
|
|
4429
4460
|
|
|
4430
4461
|
// src/proof-generator/unshield.ts
|
|
4431
4462
|
import {
|
|
@@ -5354,6 +5385,7 @@ export {
|
|
|
5354
5385
|
bigintTo32Be,
|
|
5355
5386
|
bigintTo32Le,
|
|
5356
5387
|
bigintTo32LeArr,
|
|
5388
|
+
blindTag,
|
|
5357
5389
|
buildDummyTransferInput,
|
|
5358
5390
|
bytesToBigintLE,
|
|
5359
5391
|
computeNullifier,
|
|
@@ -5370,6 +5402,7 @@ export {
|
|
|
5370
5402
|
deriveSpendingKeyMessage,
|
|
5371
5403
|
deriveStealthOwnerPk,
|
|
5372
5404
|
deriveStealthSk,
|
|
5405
|
+
deriveVaultBlindKey,
|
|
5373
5406
|
deriveVaultKey,
|
|
5374
5407
|
deriveViewingPublicKey,
|
|
5375
5408
|
deriveViewingSecretKey,
|
|
@@ -5404,6 +5437,7 @@ export {
|
|
|
5404
5437
|
mapExtrinsicArgs,
|
|
5405
5438
|
mapZkEventData,
|
|
5406
5439
|
normalizeEvmAddress,
|
|
5440
|
+
noteBlindTag,
|
|
5407
5441
|
randomBlinding,
|
|
5408
5442
|
recoverOwnerPkPoint,
|
|
5409
5443
|
selectNotes,
|