@orbinum/sdk 0.23.0 → 0.25.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 +43 -3
- package/dist/index.d.ts +43 -3
- package/dist/index.js +52 -10
- package/dist/index.mjs +49 -10
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -124,7 +124,7 @@ declare class SubstrateClient {
|
|
|
124
124
|
static connect(wsUrl: string, timeoutMs?: number): Promise<SubstrateClient>;
|
|
125
125
|
/**
|
|
126
126
|
* Performs a raw JSON-RPC request. Use this for custom Orbinum RPCs
|
|
127
|
-
* (
|
|
127
|
+
* (`privacy_*`, `zkVerifier_*`, `relayer_*`, etc.).
|
|
128
128
|
*/
|
|
129
129
|
request<T>(method: string, params?: unknown[]): Promise<T>;
|
|
130
130
|
/**
|
|
@@ -1718,6 +1718,46 @@ interface SelfEphWindowEntry {
|
|
|
1718
1718
|
*/
|
|
1719
1719
|
declare function selfEphWindow(spendingKey: bigint, ivkPacked: Uint8Array, from: number, count: number): SelfEphWindowEntry[];
|
|
1720
1720
|
|
|
1721
|
+
/**
|
|
1722
|
+
* The secret shared by a sender/receiver pair: ECDH between one side's viewing
|
|
1723
|
+
* SECRET key and the other side's viewing PUBLIC key. Symmetric — both parties
|
|
1724
|
+
* compute the same 32 bytes from opposite inputs, which is what lets the
|
|
1725
|
+
* sender choose an ephemeral the receiver can predict.
|
|
1726
|
+
*
|
|
1727
|
+
* @param myViewingSk 32-byte viewing secret key (from `deriveViewingSecretKey`).
|
|
1728
|
+
* @param theirIvkPacked 32-byte LE packed viewing public key of the other party.
|
|
1729
|
+
*/
|
|
1730
|
+
declare function derivePairwiseSharedSecret(myViewingSk: Uint8Array, theirIvkPacked: Uint8Array): Uint8Array;
|
|
1731
|
+
/**
|
|
1732
|
+
* The ephemeral secret for the `index`-th note between this pair. Feed it to
|
|
1733
|
+
* `EncryptedMemo.encrypt` / `NoteBuilder.build` as `ephSkOverride`.
|
|
1734
|
+
*/
|
|
1735
|
+
declare function derivePairwiseEphSk(pairSecret: Uint8Array, index: number): Uint8Array;
|
|
1736
|
+
/** One precomputed pairwise window entry — same shape as `SelfEphWindowEntry`. */
|
|
1737
|
+
interface PairwiseEphWindowEntry {
|
|
1738
|
+
index: number;
|
|
1739
|
+
/** 0x-prefixed LE-packed ephPk — byte-identical to the memo's last 32 bytes. */
|
|
1740
|
+
ephPkHex: string;
|
|
1741
|
+
/** ECDH shared secret vs the RECEIVER's ivk — feeds decryptWithSharedSecret. */
|
|
1742
|
+
sharedSecret: Uint8Array;
|
|
1743
|
+
}
|
|
1744
|
+
/**
|
|
1745
|
+
* Precomputes the discovery window [from, from+count) for one counterparty:
|
|
1746
|
+
* for each index, the ephPk that party would publish and the secret needed to
|
|
1747
|
+
* open the memo. One EC pass per sender up front; the scan then matches by hex
|
|
1748
|
+
* equality with no per-hint EC work.
|
|
1749
|
+
*
|
|
1750
|
+
* The cost is paid once per sender and reused across every page of the scan,
|
|
1751
|
+
* which is what makes it worth building — unlike a per-hint precompute, which
|
|
1752
|
+
* measured 26× SLOWER than just doing the multiplication.
|
|
1753
|
+
*
|
|
1754
|
+
* @param pairSecret From `derivePairwiseSharedSecret`.
|
|
1755
|
+
* @param receiverIvkPacked The RECEIVER's packed viewing public key — the memo
|
|
1756
|
+
* is encrypted to it, so the shared secret is against
|
|
1757
|
+
* that key regardless of which side is precomputing.
|
|
1758
|
+
*/
|
|
1759
|
+
declare function pairwiseEphWindow(pairSecret: Uint8Array, receiverIvkPacked: Uint8Array, from: number, count: number): PairwiseEphWindowEntry[];
|
|
1760
|
+
|
|
1721
1761
|
/**
|
|
1722
1762
|
* NoteDecryptor
|
|
1723
1763
|
*
|
|
@@ -2203,7 +2243,7 @@ declare function deriveViewingSecretKey(spendingKey: bigint): Uint8Array;
|
|
|
2203
2243
|
* Derive the packed BabyJubJub viewing public key (ivk) from ivsk bytes.
|
|
2204
2244
|
*
|
|
2205
2245
|
* ivsk_scalar = BigInt(ivsk_bytes_BE) % BABYJUB_SUBORDER (clamped to [1, ∞))
|
|
2206
|
-
* ivk_point =
|
|
2246
|
+
* ivk_point = fastMulBase(ivsk_scalar) → [Ax, Ay]
|
|
2207
2247
|
* result = bigintTo32Le(packPoint([Ax, Ay])) → 32-byte Uint8Array (LE)
|
|
2208
2248
|
*
|
|
2209
2249
|
* The packed bigint is stored in little-endian so it is consistent with the
|
|
@@ -3564,4 +3604,4 @@ interface ExtrinsicFailedData {
|
|
|
3564
3604
|
dispatch_info: DispatchInfo;
|
|
3565
3605
|
}
|
|
3566
3606
|
|
|
3567
|
-
export { type ActiveVersionSetEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type Bytes32, CURRENT_CIRCUIT_VERSION, type ChainInfo, CircuitId, CircuitId as CircuitIdType, CircuitVersionResolver, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedBatchArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedRemarkArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, 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, KNOWN_PRECOMPILES, type KnownPrecompileInfo, MIN_SIGNATURE_BYTES, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAssetArgs, type RegisterVerificationKeyArgs, type RelayerInfo, RelayerStatusModule, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedSpendVersion, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SPENDING_KEY_VERIFYING_CONTRACT, SPENDING_KEY_WARNING, type ScanCommitment, type SelfEphWindowEntry, type SetActiveVersionArgs, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, type SpendingKeyTypedData, type StatusChangeEvent, type StatusListener, SubstrateClient, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TryDecryptOptions, type TxResult, type UnsafeTxOptions, 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, canonicalAccountId, computeNoteCommitment, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, deriveSelfEphSk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessageV2, deriveSpendingKeyTypedData, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, deriveVaultKey, deriveViewTag, 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, selfEphWindow, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, treeIdOf, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
|
|
3607
|
+
export { type ActiveVersionSetEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type Bytes32, CURRENT_CIRCUIT_VERSION, type ChainInfo, CircuitId, CircuitId as CircuitIdType, CircuitVersionResolver, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedBatchArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedRemarkArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, 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, KNOWN_PRECOMPILES, type KnownPrecompileInfo, MIN_SIGNATURE_BYTES, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, type PairwiseEphWindowEntry, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAssetArgs, type RegisterVerificationKeyArgs, type RelayerInfo, RelayerStatusModule, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedSpendVersion, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SPENDING_KEY_VERIFYING_CONTRACT, SPENDING_KEY_WARNING, type ScanCommitment, type SelfEphWindowEntry, type SetActiveVersionArgs, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, type SpendingKeyTypedData, type StatusChangeEvent, type StatusListener, SubstrateClient, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TryDecryptOptions, type TxResult, type UnsafeTxOptions, 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, canonicalAccountId, computeNoteCommitment, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, derivePairwiseEphSk, derivePairwiseSharedSecret, deriveSelfEphSk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessageV2, deriveSpendingKeyTypedData, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, deriveVaultKey, deriveViewTag, 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, pairwiseEphWindow, randomBlinding, recoverOwnerPkPoint, selectNotes, selfEphWindow, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, treeIdOf, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
|
package/dist/index.d.ts
CHANGED
|
@@ -124,7 +124,7 @@ declare class SubstrateClient {
|
|
|
124
124
|
static connect(wsUrl: string, timeoutMs?: number): Promise<SubstrateClient>;
|
|
125
125
|
/**
|
|
126
126
|
* Performs a raw JSON-RPC request. Use this for custom Orbinum RPCs
|
|
127
|
-
* (
|
|
127
|
+
* (`privacy_*`, `zkVerifier_*`, `relayer_*`, etc.).
|
|
128
128
|
*/
|
|
129
129
|
request<T>(method: string, params?: unknown[]): Promise<T>;
|
|
130
130
|
/**
|
|
@@ -1718,6 +1718,46 @@ interface SelfEphWindowEntry {
|
|
|
1718
1718
|
*/
|
|
1719
1719
|
declare function selfEphWindow(spendingKey: bigint, ivkPacked: Uint8Array, from: number, count: number): SelfEphWindowEntry[];
|
|
1720
1720
|
|
|
1721
|
+
/**
|
|
1722
|
+
* The secret shared by a sender/receiver pair: ECDH between one side's viewing
|
|
1723
|
+
* SECRET key and the other side's viewing PUBLIC key. Symmetric — both parties
|
|
1724
|
+
* compute the same 32 bytes from opposite inputs, which is what lets the
|
|
1725
|
+
* sender choose an ephemeral the receiver can predict.
|
|
1726
|
+
*
|
|
1727
|
+
* @param myViewingSk 32-byte viewing secret key (from `deriveViewingSecretKey`).
|
|
1728
|
+
* @param theirIvkPacked 32-byte LE packed viewing public key of the other party.
|
|
1729
|
+
*/
|
|
1730
|
+
declare function derivePairwiseSharedSecret(myViewingSk: Uint8Array, theirIvkPacked: Uint8Array): Uint8Array;
|
|
1731
|
+
/**
|
|
1732
|
+
* The ephemeral secret for the `index`-th note between this pair. Feed it to
|
|
1733
|
+
* `EncryptedMemo.encrypt` / `NoteBuilder.build` as `ephSkOverride`.
|
|
1734
|
+
*/
|
|
1735
|
+
declare function derivePairwiseEphSk(pairSecret: Uint8Array, index: number): Uint8Array;
|
|
1736
|
+
/** One precomputed pairwise window entry — same shape as `SelfEphWindowEntry`. */
|
|
1737
|
+
interface PairwiseEphWindowEntry {
|
|
1738
|
+
index: number;
|
|
1739
|
+
/** 0x-prefixed LE-packed ephPk — byte-identical to the memo's last 32 bytes. */
|
|
1740
|
+
ephPkHex: string;
|
|
1741
|
+
/** ECDH shared secret vs the RECEIVER's ivk — feeds decryptWithSharedSecret. */
|
|
1742
|
+
sharedSecret: Uint8Array;
|
|
1743
|
+
}
|
|
1744
|
+
/**
|
|
1745
|
+
* Precomputes the discovery window [from, from+count) for one counterparty:
|
|
1746
|
+
* for each index, the ephPk that party would publish and the secret needed to
|
|
1747
|
+
* open the memo. One EC pass per sender up front; the scan then matches by hex
|
|
1748
|
+
* equality with no per-hint EC work.
|
|
1749
|
+
*
|
|
1750
|
+
* The cost is paid once per sender and reused across every page of the scan,
|
|
1751
|
+
* which is what makes it worth building — unlike a per-hint precompute, which
|
|
1752
|
+
* measured 26× SLOWER than just doing the multiplication.
|
|
1753
|
+
*
|
|
1754
|
+
* @param pairSecret From `derivePairwiseSharedSecret`.
|
|
1755
|
+
* @param receiverIvkPacked The RECEIVER's packed viewing public key — the memo
|
|
1756
|
+
* is encrypted to it, so the shared secret is against
|
|
1757
|
+
* that key regardless of which side is precomputing.
|
|
1758
|
+
*/
|
|
1759
|
+
declare function pairwiseEphWindow(pairSecret: Uint8Array, receiverIvkPacked: Uint8Array, from: number, count: number): PairwiseEphWindowEntry[];
|
|
1760
|
+
|
|
1721
1761
|
/**
|
|
1722
1762
|
* NoteDecryptor
|
|
1723
1763
|
*
|
|
@@ -2203,7 +2243,7 @@ declare function deriveViewingSecretKey(spendingKey: bigint): Uint8Array;
|
|
|
2203
2243
|
* Derive the packed BabyJubJub viewing public key (ivk) from ivsk bytes.
|
|
2204
2244
|
*
|
|
2205
2245
|
* ivsk_scalar = BigInt(ivsk_bytes_BE) % BABYJUB_SUBORDER (clamped to [1, ∞))
|
|
2206
|
-
* ivk_point =
|
|
2246
|
+
* ivk_point = fastMulBase(ivsk_scalar) → [Ax, Ay]
|
|
2207
2247
|
* result = bigintTo32Le(packPoint([Ax, Ay])) → 32-byte Uint8Array (LE)
|
|
2208
2248
|
*
|
|
2209
2249
|
* The packed bigint is stored in little-endian so it is consistent with the
|
|
@@ -3564,4 +3604,4 @@ interface ExtrinsicFailedData {
|
|
|
3564
3604
|
dispatch_info: DispatchInfo;
|
|
3565
3605
|
}
|
|
3566
3606
|
|
|
3567
|
-
export { type ActiveVersionSetEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type Bytes32, CURRENT_CIRCUIT_VERSION, type ChainInfo, CircuitId, CircuitId as CircuitIdType, CircuitVersionResolver, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedBatchArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedRemarkArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, 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, KNOWN_PRECOMPILES, type KnownPrecompileInfo, MIN_SIGNATURE_BYTES, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAssetArgs, type RegisterVerificationKeyArgs, type RelayerInfo, RelayerStatusModule, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedSpendVersion, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SPENDING_KEY_VERIFYING_CONTRACT, SPENDING_KEY_WARNING, type ScanCommitment, type SelfEphWindowEntry, type SetActiveVersionArgs, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, type SpendingKeyTypedData, type StatusChangeEvent, type StatusListener, SubstrateClient, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TryDecryptOptions, type TxResult, type UnsafeTxOptions, 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, canonicalAccountId, computeNoteCommitment, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, deriveSelfEphSk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessageV2, deriveSpendingKeyTypedData, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, deriveVaultKey, deriveViewTag, 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, selfEphWindow, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, treeIdOf, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
|
|
3607
|
+
export { type ActiveVersionSetEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type Bytes32, CURRENT_CIRCUIT_VERSION, type ChainInfo, CircuitId, CircuitId as CircuitIdType, CircuitVersionResolver, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedBatchArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedRemarkArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, 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, KNOWN_PRECOMPILES, type KnownPrecompileInfo, MIN_SIGNATURE_BYTES, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, type PairwiseEphWindowEntry, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAssetArgs, type RegisterVerificationKeyArgs, type RelayerInfo, RelayerStatusModule, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedSpendVersion, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SPENDING_KEY_VERIFYING_CONTRACT, SPENDING_KEY_WARNING, type ScanCommitment, type SelfEphWindowEntry, type SetActiveVersionArgs, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, type SpendingKeyTypedData, type StatusChangeEvent, type StatusListener, SubstrateClient, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TryDecryptOptions, type TxResult, type UnsafeTxOptions, 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, canonicalAccountId, computeNoteCommitment, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, derivePairwiseEphSk, derivePairwiseSharedSecret, deriveSelfEphSk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessageV2, deriveSpendingKeyTypedData, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, deriveVaultKey, deriveViewTag, 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, pairwiseEphWindow, randomBlinding, recoverOwnerPkPoint, selectNotes, selfEphWindow, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, treeIdOf, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
|
package/dist/index.js
CHANGED
|
@@ -74,6 +74,8 @@ __export(index_exports, {
|
|
|
74
74
|
decryptNoteRecord: () => decryptNoteRecord,
|
|
75
75
|
deriveMasterKeyBytes: () => deriveMasterKeyBytes,
|
|
76
76
|
deriveOwnerPk: () => deriveOwnerPk,
|
|
77
|
+
derivePairwiseEphSk: () => derivePairwiseEphSk,
|
|
78
|
+
derivePairwiseSharedSecret: () => derivePairwiseSharedSecret,
|
|
77
79
|
deriveSelfEphSk: () => deriveSelfEphSk,
|
|
78
80
|
deriveSpendingKeyFromSignature: () => deriveSpendingKeyFromSignature,
|
|
79
81
|
deriveSpendingKeyMessageV2: () => deriveSpendingKeyMessageV2,
|
|
@@ -117,6 +119,7 @@ __export(index_exports, {
|
|
|
117
119
|
mapZkEventData: () => mapZkEventData,
|
|
118
120
|
normalizeEvmAddress: () => normalizeEvmAddress,
|
|
119
121
|
noteBlindTag: () => noteBlindTag,
|
|
122
|
+
pairwiseEphWindow: () => pairwiseEphWindow,
|
|
120
123
|
randomBlinding: () => randomBlinding,
|
|
121
124
|
recoverOwnerPkPoint: () => recoverOwnerPkPoint,
|
|
122
125
|
selectNotes: () => selectNotes,
|
|
@@ -279,7 +282,7 @@ var SubstrateClient = class _SubstrateClient {
|
|
|
279
282
|
}
|
|
280
283
|
/**
|
|
281
284
|
* Performs a raw JSON-RPC request. Use this for custom Orbinum RPCs
|
|
282
|
-
* (
|
|
285
|
+
* (`privacy_*`, `zkVerifier_*`, `relayer_*`, etc.).
|
|
283
286
|
*/
|
|
284
287
|
async request(method, params = []) {
|
|
285
288
|
return this._papi._request(method, params);
|
|
@@ -3307,6 +3310,42 @@ function selfEphWindow(spendingKey, ivkPacked, from, count) {
|
|
|
3307
3310
|
return entries;
|
|
3308
3311
|
}
|
|
3309
3312
|
|
|
3313
|
+
// src/shielded-pool/protocol/pairwiseEph.ts
|
|
3314
|
+
var import_sha24 = require("@noble/hashes/sha2.js");
|
|
3315
|
+
var import_baby_jubjub6 = require("@zk-kit/baby-jubjub");
|
|
3316
|
+
var PAIRWISE_EPH_DOMAIN = new TextEncoder().encode("orbinum-pairwise-eph-v1");
|
|
3317
|
+
function derivePairwiseSharedSecret(myViewingSk, theirIvkPacked) {
|
|
3318
|
+
const theirPoint = (0, import_baby_jubjub6.unpackPoint)(bytesToBigintLE(theirIvkPacked));
|
|
3319
|
+
if (!theirPoint) throw new Error("derivePairwiseSharedSecret: invalid viewing public key");
|
|
3320
|
+
const shared = fastMulPoint(theirPoint, bytesToBjjScalar(myViewingSk));
|
|
3321
|
+
return bigintTo32Le(shared[0]);
|
|
3322
|
+
}
|
|
3323
|
+
function derivePairwiseEphSk(pairSecret, index) {
|
|
3324
|
+
const h = import_sha24.sha256.create();
|
|
3325
|
+
h.update(PAIRWISE_EPH_DOMAIN);
|
|
3326
|
+
h.update(pairSecret);
|
|
3327
|
+
const idx = new Uint8Array(4);
|
|
3328
|
+
new DataView(idx.buffer).setUint32(0, index >>> 0, true);
|
|
3329
|
+
h.update(idx);
|
|
3330
|
+
return h.digest();
|
|
3331
|
+
}
|
|
3332
|
+
function pairwiseEphWindow(pairSecret, receiverIvkPacked, from, count) {
|
|
3333
|
+
const ivkPoint = (0, import_baby_jubjub6.unpackPoint)(bytesToBigintLE(receiverIvkPacked));
|
|
3334
|
+
if (!ivkPoint) throw new Error("pairwiseEphWindow: invalid viewing public key");
|
|
3335
|
+
const entries = [];
|
|
3336
|
+
for (let i = from; i < from + count; i++) {
|
|
3337
|
+
const scalar = bytesToBjjScalar(derivePairwiseEphSk(pairSecret, i));
|
|
3338
|
+
const ephPk = fastMulBase(scalar);
|
|
3339
|
+
const sharedPoint = fastMulPoint(ivkPoint, scalar);
|
|
3340
|
+
entries.push({
|
|
3341
|
+
index: i,
|
|
3342
|
+
ephPkHex: toHex(bigintTo32Le((0, import_baby_jubjub6.packPoint)(ephPk))),
|
|
3343
|
+
sharedSecret: bigintTo32Le(sharedPoint[0])
|
|
3344
|
+
});
|
|
3345
|
+
}
|
|
3346
|
+
return entries;
|
|
3347
|
+
}
|
|
3348
|
+
|
|
3310
3349
|
// src/shielded-pool/protocol/NoteDecryptor.ts
|
|
3311
3350
|
var import_poseidon_lite2 = require("poseidon-lite");
|
|
3312
3351
|
function computeNullifier(commitment, spendingKey) {
|
|
@@ -3539,8 +3578,8 @@ ${canonicalAccountId(address)}`;
|
|
|
3539
3578
|
|
|
3540
3579
|
// src/privacy-keys/PrivacyKeys.ts
|
|
3541
3580
|
var import_hkdf2 = require("@noble/hashes/hkdf.js");
|
|
3542
|
-
var
|
|
3543
|
-
var
|
|
3581
|
+
var import_sha25 = require("@noble/hashes/sha2.js");
|
|
3582
|
+
var import_baby_jubjub7 = require("@zk-kit/baby-jubjub");
|
|
3544
3583
|
var IVK_DOMAIN = new TextEncoder().encode("orbinum-ivk-v1");
|
|
3545
3584
|
var KEY_VERSION = "v2";
|
|
3546
3585
|
var MIN_SIGNATURE_BYTES = 32;
|
|
@@ -3557,7 +3596,7 @@ async function deriveMasterKeyBytes(signatureHex, chainId, address) {
|
|
|
3557
3596
|
const info = new TextEncoder().encode(
|
|
3558
3597
|
`orbinum-sk-${KEY_VERSION}:${chainId}:${canonicalAccountId(address)}`
|
|
3559
3598
|
);
|
|
3560
|
-
return (0, import_hkdf2.hkdf)(
|
|
3599
|
+
return (0, import_hkdf2.hkdf)(import_sha25.sha256, sigBytes, new Uint8Array(0), info, 32);
|
|
3561
3600
|
}
|
|
3562
3601
|
async function deriveSpendingKeyFromSignature(signatureHex, chainId, address) {
|
|
3563
3602
|
const masterBytes = await deriveMasterKeyBytes(signatureHex, chainId, address);
|
|
@@ -3566,17 +3605,17 @@ async function deriveSpendingKeyFromSignature(signatureHex, chainId, address) {
|
|
|
3566
3605
|
}
|
|
3567
3606
|
function deriveViewingSecretKey(spendingKey) {
|
|
3568
3607
|
const ikm = bigintTo32Le(spendingKey);
|
|
3569
|
-
return (0, import_hkdf2.hkdf)(
|
|
3608
|
+
return (0, import_hkdf2.hkdf)(import_sha25.sha256, ikm, void 0, IVK_DOMAIN, 32);
|
|
3570
3609
|
}
|
|
3571
3610
|
function deriveViewingPublicKey(ivsk) {
|
|
3572
3611
|
const ivskScalar = BigInt(toHex(ivsk)) % BABYJUB_SUBORDER || 1n;
|
|
3573
|
-
const ivkPoint = (
|
|
3574
|
-
const packed = (0,
|
|
3612
|
+
const ivkPoint = fastMulBase(ivskScalar);
|
|
3613
|
+
const packed = (0, import_baby_jubjub7.packPoint)(ivkPoint);
|
|
3575
3614
|
return bigintTo32Le(packed);
|
|
3576
3615
|
}
|
|
3577
3616
|
function deriveOwnerPk(spendingKey) {
|
|
3578
3617
|
try {
|
|
3579
|
-
const pubPoint = (
|
|
3618
|
+
const pubPoint = fastMulBase(spendingKey);
|
|
3580
3619
|
return pubPoint[0];
|
|
3581
3620
|
} catch {
|
|
3582
3621
|
return 0n;
|
|
@@ -3885,7 +3924,7 @@ async function noteBlindTag(blindKey, hex) {
|
|
|
3885
3924
|
// src/proof-generator/unshield.ts
|
|
3886
3925
|
var import_proof_generator2 = require("@orbinum/proof-generator");
|
|
3887
3926
|
var import_utils3 = require("@noble/ciphers/utils.js");
|
|
3888
|
-
var
|
|
3927
|
+
var import_baby_jubjub8 = require("@zk-kit/baby-jubjub");
|
|
3889
3928
|
var import_poseidon_lite4 = require("poseidon-lite");
|
|
3890
3929
|
|
|
3891
3930
|
// src/proof-generator/merkle.ts
|
|
@@ -3908,7 +3947,7 @@ async function generateUnshieldProof(inputs, options = {}) {
|
|
|
3908
3947
|
if (changeValue < 0n) {
|
|
3909
3948
|
throw new Error("changeValue must be >= 0.");
|
|
3910
3949
|
}
|
|
3911
|
-
const changeOwnerPubkey = inputs.changeOwnerPubkey ?? (0,
|
|
3950
|
+
const changeOwnerPubkey = inputs.changeOwnerPubkey ?? (0, import_baby_jubjub8.mulPointEscalar)(import_baby_jubjub8.Base8, inputs.spendingKey)[0];
|
|
3912
3951
|
const changeBlinding = inputs.changeBlinding ?? (changeValue > 0n ? bytesToBigintLE((0, import_utils3.randomBytes)(32)) : 0n);
|
|
3913
3952
|
const changeCommitment = changeValue > 0n ? (0, import_poseidon_lite4.poseidon4)([changeValue, inputs.assetId, changeOwnerPubkey, changeBlinding]) : 0n;
|
|
3914
3953
|
const circuitInputs = {
|
|
@@ -4619,6 +4658,8 @@ var import_polkadot_api4 = require("polkadot-api");
|
|
|
4619
4658
|
decryptNoteRecord,
|
|
4620
4659
|
deriveMasterKeyBytes,
|
|
4621
4660
|
deriveOwnerPk,
|
|
4661
|
+
derivePairwiseEphSk,
|
|
4662
|
+
derivePairwiseSharedSecret,
|
|
4622
4663
|
deriveSelfEphSk,
|
|
4623
4664
|
deriveSpendingKeyFromSignature,
|
|
4624
4665
|
deriveSpendingKeyMessageV2,
|
|
@@ -4662,6 +4703,7 @@ var import_polkadot_api4 = require("polkadot-api");
|
|
|
4662
4703
|
mapZkEventData,
|
|
4663
4704
|
normalizeEvmAddress,
|
|
4664
4705
|
noteBlindTag,
|
|
4706
|
+
pairwiseEphWindow,
|
|
4665
4707
|
randomBlinding,
|
|
4666
4708
|
recoverOwnerPkPoint,
|
|
4667
4709
|
selectNotes,
|
package/dist/index.mjs
CHANGED
|
@@ -142,7 +142,7 @@ var SubstrateClient = class _SubstrateClient {
|
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
144
|
* Performs a raw JSON-RPC request. Use this for custom Orbinum RPCs
|
|
145
|
-
* (
|
|
145
|
+
* (`privacy_*`, `zkVerifier_*`, `relayer_*`, etc.).
|
|
146
146
|
*/
|
|
147
147
|
async request(method, params = []) {
|
|
148
148
|
return this._papi._request(method, params);
|
|
@@ -3173,6 +3173,42 @@ function selfEphWindow(spendingKey, ivkPacked, from, count) {
|
|
|
3173
3173
|
return entries;
|
|
3174
3174
|
}
|
|
3175
3175
|
|
|
3176
|
+
// src/shielded-pool/protocol/pairwiseEph.ts
|
|
3177
|
+
import { sha256 as sha2564 } from "@noble/hashes/sha2.js";
|
|
3178
|
+
import { packPoint as packPoint3, unpackPoint as unpackPoint4 } from "@zk-kit/baby-jubjub";
|
|
3179
|
+
var PAIRWISE_EPH_DOMAIN = new TextEncoder().encode("orbinum-pairwise-eph-v1");
|
|
3180
|
+
function derivePairwiseSharedSecret(myViewingSk, theirIvkPacked) {
|
|
3181
|
+
const theirPoint = unpackPoint4(bytesToBigintLE(theirIvkPacked));
|
|
3182
|
+
if (!theirPoint) throw new Error("derivePairwiseSharedSecret: invalid viewing public key");
|
|
3183
|
+
const shared = fastMulPoint(theirPoint, bytesToBjjScalar(myViewingSk));
|
|
3184
|
+
return bigintTo32Le(shared[0]);
|
|
3185
|
+
}
|
|
3186
|
+
function derivePairwiseEphSk(pairSecret, index) {
|
|
3187
|
+
const h = sha2564.create();
|
|
3188
|
+
h.update(PAIRWISE_EPH_DOMAIN);
|
|
3189
|
+
h.update(pairSecret);
|
|
3190
|
+
const idx = new Uint8Array(4);
|
|
3191
|
+
new DataView(idx.buffer).setUint32(0, index >>> 0, true);
|
|
3192
|
+
h.update(idx);
|
|
3193
|
+
return h.digest();
|
|
3194
|
+
}
|
|
3195
|
+
function pairwiseEphWindow(pairSecret, receiverIvkPacked, from, count) {
|
|
3196
|
+
const ivkPoint = unpackPoint4(bytesToBigintLE(receiverIvkPacked));
|
|
3197
|
+
if (!ivkPoint) throw new Error("pairwiseEphWindow: invalid viewing public key");
|
|
3198
|
+
const entries = [];
|
|
3199
|
+
for (let i = from; i < from + count; i++) {
|
|
3200
|
+
const scalar = bytesToBjjScalar(derivePairwiseEphSk(pairSecret, i));
|
|
3201
|
+
const ephPk = fastMulBase(scalar);
|
|
3202
|
+
const sharedPoint = fastMulPoint(ivkPoint, scalar);
|
|
3203
|
+
entries.push({
|
|
3204
|
+
index: i,
|
|
3205
|
+
ephPkHex: toHex(bigintTo32Le(packPoint3(ephPk))),
|
|
3206
|
+
sharedSecret: bigintTo32Le(sharedPoint[0])
|
|
3207
|
+
});
|
|
3208
|
+
}
|
|
3209
|
+
return entries;
|
|
3210
|
+
}
|
|
3211
|
+
|
|
3176
3212
|
// src/shielded-pool/protocol/NoteDecryptor.ts
|
|
3177
3213
|
import { poseidon2 as poseidon22, poseidon4 as poseidon42 } from "poseidon-lite";
|
|
3178
3214
|
function computeNullifier(commitment, spendingKey) {
|
|
@@ -3405,8 +3441,8 @@ ${canonicalAccountId(address)}`;
|
|
|
3405
3441
|
|
|
3406
3442
|
// src/privacy-keys/PrivacyKeys.ts
|
|
3407
3443
|
import { hkdf as hkdf2 } from "@noble/hashes/hkdf.js";
|
|
3408
|
-
import { sha256 as
|
|
3409
|
-
import {
|
|
3444
|
+
import { sha256 as sha2565 } from "@noble/hashes/sha2.js";
|
|
3445
|
+
import { packPoint as packPoint4 } from "@zk-kit/baby-jubjub";
|
|
3410
3446
|
var IVK_DOMAIN = new TextEncoder().encode("orbinum-ivk-v1");
|
|
3411
3447
|
var KEY_VERSION = "v2";
|
|
3412
3448
|
var MIN_SIGNATURE_BYTES = 32;
|
|
@@ -3423,7 +3459,7 @@ async function deriveMasterKeyBytes(signatureHex, chainId, address) {
|
|
|
3423
3459
|
const info = new TextEncoder().encode(
|
|
3424
3460
|
`orbinum-sk-${KEY_VERSION}:${chainId}:${canonicalAccountId(address)}`
|
|
3425
3461
|
);
|
|
3426
|
-
return hkdf2(
|
|
3462
|
+
return hkdf2(sha2565, sigBytes, new Uint8Array(0), info, 32);
|
|
3427
3463
|
}
|
|
3428
3464
|
async function deriveSpendingKeyFromSignature(signatureHex, chainId, address) {
|
|
3429
3465
|
const masterBytes = await deriveMasterKeyBytes(signatureHex, chainId, address);
|
|
@@ -3432,17 +3468,17 @@ async function deriveSpendingKeyFromSignature(signatureHex, chainId, address) {
|
|
|
3432
3468
|
}
|
|
3433
3469
|
function deriveViewingSecretKey(spendingKey) {
|
|
3434
3470
|
const ikm = bigintTo32Le(spendingKey);
|
|
3435
|
-
return hkdf2(
|
|
3471
|
+
return hkdf2(sha2565, ikm, void 0, IVK_DOMAIN, 32);
|
|
3436
3472
|
}
|
|
3437
3473
|
function deriveViewingPublicKey(ivsk) {
|
|
3438
3474
|
const ivskScalar = BigInt(toHex(ivsk)) % BABYJUB_SUBORDER || 1n;
|
|
3439
|
-
const ivkPoint =
|
|
3440
|
-
const packed =
|
|
3475
|
+
const ivkPoint = fastMulBase(ivskScalar);
|
|
3476
|
+
const packed = packPoint4(ivkPoint);
|
|
3441
3477
|
return bigintTo32Le(packed);
|
|
3442
3478
|
}
|
|
3443
3479
|
function deriveOwnerPk(spendingKey) {
|
|
3444
3480
|
try {
|
|
3445
|
-
const pubPoint =
|
|
3481
|
+
const pubPoint = fastMulBase(spendingKey);
|
|
3446
3482
|
return pubPoint[0];
|
|
3447
3483
|
} catch {
|
|
3448
3484
|
return 0n;
|
|
@@ -3755,7 +3791,7 @@ import {
|
|
|
3755
3791
|
WebArtifactProvider as WebArtifactProvider2
|
|
3756
3792
|
} from "@orbinum/proof-generator";
|
|
3757
3793
|
import { randomBytes as randomBytes3 } from "@noble/ciphers/utils.js";
|
|
3758
|
-
import { mulPointEscalar as
|
|
3794
|
+
import { mulPointEscalar as mulPointEscalar4, Base8 as Base82 } from "@zk-kit/baby-jubjub";
|
|
3759
3795
|
import { poseidon4 as poseidon44 } from "poseidon-lite";
|
|
3760
3796
|
|
|
3761
3797
|
// src/proof-generator/merkle.ts
|
|
@@ -3778,7 +3814,7 @@ async function generateUnshieldProof(inputs, options = {}) {
|
|
|
3778
3814
|
if (changeValue < 0n) {
|
|
3779
3815
|
throw new Error("changeValue must be >= 0.");
|
|
3780
3816
|
}
|
|
3781
|
-
const changeOwnerPubkey = inputs.changeOwnerPubkey ??
|
|
3817
|
+
const changeOwnerPubkey = inputs.changeOwnerPubkey ?? mulPointEscalar4(Base82, inputs.spendingKey)[0];
|
|
3782
3818
|
const changeBlinding = inputs.changeBlinding ?? (changeValue > 0n ? bytesToBigintLE(randomBytes3(32)) : 0n);
|
|
3783
3819
|
const changeCommitment = changeValue > 0n ? poseidon44([changeValue, inputs.assetId, changeOwnerPubkey, changeBlinding]) : 0n;
|
|
3784
3820
|
const circuitInputs = {
|
|
@@ -4507,6 +4543,8 @@ export {
|
|
|
4507
4543
|
decryptNoteRecord,
|
|
4508
4544
|
deriveMasterKeyBytes,
|
|
4509
4545
|
deriveOwnerPk,
|
|
4546
|
+
derivePairwiseEphSk,
|
|
4547
|
+
derivePairwiseSharedSecret,
|
|
4510
4548
|
deriveSelfEphSk,
|
|
4511
4549
|
deriveSpendingKeyFromSignature,
|
|
4512
4550
|
deriveSpendingKeyMessageV2,
|
|
@@ -4550,6 +4588,7 @@ export {
|
|
|
4550
4588
|
mapZkEventData,
|
|
4551
4589
|
normalizeEvmAddress,
|
|
4552
4590
|
noteBlindTag,
|
|
4591
|
+
pairwiseEphWindow,
|
|
4553
4592
|
randomBlinding,
|
|
4554
4593
|
recoverOwnerPkPoint,
|
|
4555
4594
|
selectNotes,
|