@orbinum/sdk 0.19.0 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +38 -19
- package/dist/index.d.ts +38 -19
- package/dist/index.js +17 -14
- package/dist/index.mjs +16 -13
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2449,16 +2449,42 @@ declare function deriveSpendingKeyTypedData(chainId: number, address: string): S
|
|
|
2449
2449
|
* only the HKDF domain separation in `PrivacyKeys` still applies.
|
|
2450
2450
|
*/
|
|
2451
2451
|
declare function deriveSpendingKeyMessageV2(chainId: number, address: string): string;
|
|
2452
|
+
|
|
2453
|
+
/**
|
|
2454
|
+
* Canonical account identifier for spending-key derivation.
|
|
2455
|
+
*
|
|
2456
|
+
* The address string is load-bearing twice: it goes into the signed payload AND
|
|
2457
|
+
* into the HKDF `info`. So whatever identifies the account must be stable for
|
|
2458
|
+
* the lifetime of that account — anything else silently rotates the spending key
|
|
2459
|
+
* and orphans every note already shielded.
|
|
2460
|
+
*
|
|
2461
|
+
* SS58 IS NOT STABLE. The same public key encodes to a different string per
|
|
2462
|
+
* network prefix:
|
|
2463
|
+
*
|
|
2464
|
+
* prefix 42 → 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
|
|
2465
|
+
* prefix 2700 → kcuMUgT1VAJR8MtE22C5cmoAR96qsTMLYzmEuyCKUj48jYHqR
|
|
2466
|
+
*
|
|
2467
|
+
* A wallet that lists an account under the generic prefix today and under the
|
|
2468
|
+
* chain's own prefix tomorrow (a wallet setting, a chain-metadata update) would
|
|
2469
|
+
* hand us a different string for the same key. Deriving from it directly means
|
|
2470
|
+
* the user opens the app to an empty vault with no error and no explanation.
|
|
2471
|
+
*
|
|
2472
|
+
* So Substrate accounts are identified by their decoded 32-byte public key,
|
|
2473
|
+
* which no prefix can change. EVM addresses are already canonical and pass
|
|
2474
|
+
* through unchanged.
|
|
2475
|
+
*/
|
|
2452
2476
|
/**
|
|
2453
|
-
*
|
|
2454
|
-
* `personal_sign`, so any dapp can request it and, because the signature is
|
|
2455
|
-
* deterministic, reconstruct the user's spending key, viewing key and vault key.
|
|
2477
|
+
* Reduces an address to the form used for derivation.
|
|
2456
2478
|
*
|
|
2457
|
-
*
|
|
2458
|
-
*
|
|
2459
|
-
*
|
|
2479
|
+
* SS58 → `0x`-prefixed hex of the underlying public key, so every prefix of the
|
|
2480
|
+
* same account maps to one identifier. Anything else (EVM `0x…`) is returned
|
|
2481
|
+
* lowercased and unchanged.
|
|
2482
|
+
*
|
|
2483
|
+
* Not a validator: an unrecognised string passes through, because rejecting it
|
|
2484
|
+
* here would break EVM callers. The signature guard in `PrivacyKeys` is what
|
|
2485
|
+
* fails closed on unusable input.
|
|
2460
2486
|
*/
|
|
2461
|
-
declare function
|
|
2487
|
+
declare function canonicalAccountId(address: string): string;
|
|
2462
2488
|
|
|
2463
2489
|
/**
|
|
2464
2490
|
* PrivacyKeys
|
|
@@ -2491,8 +2517,6 @@ declare function deriveSpendingKeyMessage(chainId: number, address: string): str
|
|
|
2491
2517
|
* Num2Bits(253), asserting spending_key < 2^253. BABYJUB_SUBORDER < 2^252
|
|
2492
2518
|
* satisfies it; BN254_R ≈ 2^254.8 does not — ~34% of values would fail at runtime.
|
|
2493
2519
|
*/
|
|
2494
|
-
/** Identity version. `v1` is the legacy personal_sign scheme, kept for sweeping only. */
|
|
2495
|
-
type KeyVersion = 'v1' | 'v2';
|
|
2496
2520
|
/**
|
|
2497
2521
|
* Shortest signature any supported signer produces: sr25519 VRF output is 32
|
|
2498
2522
|
* bytes, ed25519 is 64, ECDSA `personal_sign` is 65. Anything shorter is not a
|
|
@@ -2502,7 +2526,7 @@ declare const MIN_SIGNATURE_BYTES = 32;
|
|
|
2502
2526
|
/**
|
|
2503
2527
|
* Derives the 32-byte master key bytes from a wallet signature.
|
|
2504
2528
|
*
|
|
2505
|
-
* masterBytes = HKDF-SHA256(ikm=sigBytes, salt=empty, info="orbinum-sk-
|
|
2529
|
+
* masterBytes = HKDF-SHA256(ikm=sigBytes, salt=empty, info="orbinum-sk-v2:{chainId}:{address}")
|
|
2506
2530
|
*
|
|
2507
2531
|
* These bytes are the stable root for ALL derived keys:
|
|
2508
2532
|
* - spendingKey (circuit scalar) = BigInt(masterBytes) % BABYJUB_SUBORDER
|
|
@@ -2513,18 +2537,14 @@ declare const MIN_SIGNATURE_BYTES = 32;
|
|
|
2513
2537
|
* vault key are STABLE across any future change to the modulus — they never
|
|
2514
2538
|
* depend on which prime field the circuit uses.
|
|
2515
2539
|
*
|
|
2516
|
-
* The version is folded into the HKDF `info`, so v1 and v2 stay disjoint even if
|
|
2517
|
-
* the underlying signature bytes were somehow identical.
|
|
2518
|
-
*
|
|
2519
|
-
* @param version Defaults to 'v2'. Pass 'v1' only from the legacy sweep flow.
|
|
2520
2540
|
* @throws If the signature is not valid hex, or carries less entropy than the
|
|
2521
2541
|
* shortest real signing scheme (see {@link MIN_SIGNATURE_BYTES}).
|
|
2522
2542
|
*/
|
|
2523
|
-
declare function deriveMasterKeyBytes(signatureHex: string, chainId: number, address: string
|
|
2543
|
+
declare function deriveMasterKeyBytes(signatureHex: string, chainId: number, address: string): Promise<Uint8Array>;
|
|
2524
2544
|
/**
|
|
2525
2545
|
* Derives an Orbinum spending key from a wallet signature.
|
|
2526
2546
|
*
|
|
2527
|
-
* Uses HKDF-SHA256(ikm=sigBytes, salt=empty, info="orbinum-sk-
|
|
2547
|
+
* Uses HKDF-SHA256(ikm=sigBytes, salt=empty, info="orbinum-sk-v2:{chainId}:{address}")
|
|
2528
2548
|
* and reduces the resulting 32-byte value modulo BABYJUB_SUBORDER.
|
|
2529
2549
|
*
|
|
2530
2550
|
* IMPORTANT: viewingSecretKey and vaultKey must be derived from masterBytes (via
|
|
@@ -2534,12 +2554,11 @@ declare function deriveMasterKeyBytes(signatureHex: string, chainId: number, add
|
|
|
2534
2554
|
* @param signatureHex 0x-prefixed or bare hex of the wallet signature.
|
|
2535
2555
|
* @param chainId Chain ID used when building the signing message.
|
|
2536
2556
|
* @param address Signer address (EVM or SS58) used in the signing message.
|
|
2537
|
-
* @param version Defaults to 'v2'. Pass 'v1' only from the legacy sweep flow.
|
|
2538
2557
|
* @returns bigint in [1, BABYJUB_SUBORDER)
|
|
2539
2558
|
* @throws If the signature is not valid hex or is shorter than
|
|
2540
2559
|
* {@link MIN_SIGNATURE_BYTES} — see `deriveMasterKeyBytes`.
|
|
2541
2560
|
*/
|
|
2542
|
-
declare function deriveSpendingKeyFromSignature(signatureHex: string, chainId: number, address: string
|
|
2561
|
+
declare function deriveSpendingKeyFromSignature(signatureHex: string, chainId: number, address: string): Promise<bigint>;
|
|
2543
2562
|
/**
|
|
2544
2563
|
* Derive a 32-byte viewing secret key (ivsk) from the spending key.
|
|
2545
2564
|
* ivsk = HKDF-SHA256(ikm=bigintTo32Le(spendingKey), info="orbinum-ivk-v1")
|
|
@@ -4434,4 +4453,4 @@ interface ExtrinsicFailedData {
|
|
|
4434
4453
|
dispatch_info: DispatchInfo;
|
|
4435
4454
|
}
|
|
4436
4455
|
|
|
4437
|
-
export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, 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, CURRENT_CIRCUIT_VERSION, type ChainInfo, type ChainLink, type ChainLinkAddedEvent, type ChainLinkRemovedEvent, CircuitId, CircuitId as CircuitIdType, CircuitVersionResolver, 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, KNOWN_PRECOMPILES, type
|
|
4456
|
+
export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, 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, CURRENT_CIRCUIT_VERSION, type ChainInfo, type ChainLink, type ChainLinkAddedEvent, type ChainLinkRemovedEvent, CircuitId, CircuitId as CircuitIdType, CircuitVersionResolver, 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, KNOWN_PRECOMPILES, type KnownPrecompileInfo, type ListingInfo, MIN_SIGNATURE_BYTES, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, type MetadataUpdatedEvent, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, 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 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 RelayerInfo, RelayerStatusModule, type RemoveChainLinkArgs, type RemovePrivateLinkArgs, type RemoveSupportedChainArgs, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedAlias, type ResolvedSpendVersion, type RevealPrivateLinkArgs, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SLIP0044_NAMESPACE, SPENDING_KEY_VERIFYING_CONTRACT, SPENDING_KEY_WARNING, type ScanCommitment, type SelfEphWindowEntry, type SetAccountMetadataArgs, type SetActiveVersionArgs, type SetMetadataParams, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SignatureScheme, type SpendingKeyTypedData, type StatusChangeEvent, type StatusListener, SubstrateClient, type SupportedChain, type SupportedChainAddedEvent, type SupportedChainRemovedEvent, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferAliasArgs, 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, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
|
package/dist/index.d.ts
CHANGED
|
@@ -2449,16 +2449,42 @@ declare function deriveSpendingKeyTypedData(chainId: number, address: string): S
|
|
|
2449
2449
|
* only the HKDF domain separation in `PrivacyKeys` still applies.
|
|
2450
2450
|
*/
|
|
2451
2451
|
declare function deriveSpendingKeyMessageV2(chainId: number, address: string): string;
|
|
2452
|
+
|
|
2453
|
+
/**
|
|
2454
|
+
* Canonical account identifier for spending-key derivation.
|
|
2455
|
+
*
|
|
2456
|
+
* The address string is load-bearing twice: it goes into the signed payload AND
|
|
2457
|
+
* into the HKDF `info`. So whatever identifies the account must be stable for
|
|
2458
|
+
* the lifetime of that account — anything else silently rotates the spending key
|
|
2459
|
+
* and orphans every note already shielded.
|
|
2460
|
+
*
|
|
2461
|
+
* SS58 IS NOT STABLE. The same public key encodes to a different string per
|
|
2462
|
+
* network prefix:
|
|
2463
|
+
*
|
|
2464
|
+
* prefix 42 → 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
|
|
2465
|
+
* prefix 2700 → kcuMUgT1VAJR8MtE22C5cmoAR96qsTMLYzmEuyCKUj48jYHqR
|
|
2466
|
+
*
|
|
2467
|
+
* A wallet that lists an account under the generic prefix today and under the
|
|
2468
|
+
* chain's own prefix tomorrow (a wallet setting, a chain-metadata update) would
|
|
2469
|
+
* hand us a different string for the same key. Deriving from it directly means
|
|
2470
|
+
* the user opens the app to an empty vault with no error and no explanation.
|
|
2471
|
+
*
|
|
2472
|
+
* So Substrate accounts are identified by their decoded 32-byte public key,
|
|
2473
|
+
* which no prefix can change. EVM addresses are already canonical and pass
|
|
2474
|
+
* through unchanged.
|
|
2475
|
+
*/
|
|
2452
2476
|
/**
|
|
2453
|
-
*
|
|
2454
|
-
* `personal_sign`, so any dapp can request it and, because the signature is
|
|
2455
|
-
* deterministic, reconstruct the user's spending key, viewing key and vault key.
|
|
2477
|
+
* Reduces an address to the form used for derivation.
|
|
2456
2478
|
*
|
|
2457
|
-
*
|
|
2458
|
-
*
|
|
2459
|
-
*
|
|
2479
|
+
* SS58 → `0x`-prefixed hex of the underlying public key, so every prefix of the
|
|
2480
|
+
* same account maps to one identifier. Anything else (EVM `0x…`) is returned
|
|
2481
|
+
* lowercased and unchanged.
|
|
2482
|
+
*
|
|
2483
|
+
* Not a validator: an unrecognised string passes through, because rejecting it
|
|
2484
|
+
* here would break EVM callers. The signature guard in `PrivacyKeys` is what
|
|
2485
|
+
* fails closed on unusable input.
|
|
2460
2486
|
*/
|
|
2461
|
-
declare function
|
|
2487
|
+
declare function canonicalAccountId(address: string): string;
|
|
2462
2488
|
|
|
2463
2489
|
/**
|
|
2464
2490
|
* PrivacyKeys
|
|
@@ -2491,8 +2517,6 @@ declare function deriveSpendingKeyMessage(chainId: number, address: string): str
|
|
|
2491
2517
|
* Num2Bits(253), asserting spending_key < 2^253. BABYJUB_SUBORDER < 2^252
|
|
2492
2518
|
* satisfies it; BN254_R ≈ 2^254.8 does not — ~34% of values would fail at runtime.
|
|
2493
2519
|
*/
|
|
2494
|
-
/** Identity version. `v1` is the legacy personal_sign scheme, kept for sweeping only. */
|
|
2495
|
-
type KeyVersion = 'v1' | 'v2';
|
|
2496
2520
|
/**
|
|
2497
2521
|
* Shortest signature any supported signer produces: sr25519 VRF output is 32
|
|
2498
2522
|
* bytes, ed25519 is 64, ECDSA `personal_sign` is 65. Anything shorter is not a
|
|
@@ -2502,7 +2526,7 @@ declare const MIN_SIGNATURE_BYTES = 32;
|
|
|
2502
2526
|
/**
|
|
2503
2527
|
* Derives the 32-byte master key bytes from a wallet signature.
|
|
2504
2528
|
*
|
|
2505
|
-
* masterBytes = HKDF-SHA256(ikm=sigBytes, salt=empty, info="orbinum-sk-
|
|
2529
|
+
* masterBytes = HKDF-SHA256(ikm=sigBytes, salt=empty, info="orbinum-sk-v2:{chainId}:{address}")
|
|
2506
2530
|
*
|
|
2507
2531
|
* These bytes are the stable root for ALL derived keys:
|
|
2508
2532
|
* - spendingKey (circuit scalar) = BigInt(masterBytes) % BABYJUB_SUBORDER
|
|
@@ -2513,18 +2537,14 @@ declare const MIN_SIGNATURE_BYTES = 32;
|
|
|
2513
2537
|
* vault key are STABLE across any future change to the modulus — they never
|
|
2514
2538
|
* depend on which prime field the circuit uses.
|
|
2515
2539
|
*
|
|
2516
|
-
* The version is folded into the HKDF `info`, so v1 and v2 stay disjoint even if
|
|
2517
|
-
* the underlying signature bytes were somehow identical.
|
|
2518
|
-
*
|
|
2519
|
-
* @param version Defaults to 'v2'. Pass 'v1' only from the legacy sweep flow.
|
|
2520
2540
|
* @throws If the signature is not valid hex, or carries less entropy than the
|
|
2521
2541
|
* shortest real signing scheme (see {@link MIN_SIGNATURE_BYTES}).
|
|
2522
2542
|
*/
|
|
2523
|
-
declare function deriveMasterKeyBytes(signatureHex: string, chainId: number, address: string
|
|
2543
|
+
declare function deriveMasterKeyBytes(signatureHex: string, chainId: number, address: string): Promise<Uint8Array>;
|
|
2524
2544
|
/**
|
|
2525
2545
|
* Derives an Orbinum spending key from a wallet signature.
|
|
2526
2546
|
*
|
|
2527
|
-
* Uses HKDF-SHA256(ikm=sigBytes, salt=empty, info="orbinum-sk-
|
|
2547
|
+
* Uses HKDF-SHA256(ikm=sigBytes, salt=empty, info="orbinum-sk-v2:{chainId}:{address}")
|
|
2528
2548
|
* and reduces the resulting 32-byte value modulo BABYJUB_SUBORDER.
|
|
2529
2549
|
*
|
|
2530
2550
|
* IMPORTANT: viewingSecretKey and vaultKey must be derived from masterBytes (via
|
|
@@ -2534,12 +2554,11 @@ declare function deriveMasterKeyBytes(signatureHex: string, chainId: number, add
|
|
|
2534
2554
|
* @param signatureHex 0x-prefixed or bare hex of the wallet signature.
|
|
2535
2555
|
* @param chainId Chain ID used when building the signing message.
|
|
2536
2556
|
* @param address Signer address (EVM or SS58) used in the signing message.
|
|
2537
|
-
* @param version Defaults to 'v2'. Pass 'v1' only from the legacy sweep flow.
|
|
2538
2557
|
* @returns bigint in [1, BABYJUB_SUBORDER)
|
|
2539
2558
|
* @throws If the signature is not valid hex or is shorter than
|
|
2540
2559
|
* {@link MIN_SIGNATURE_BYTES} — see `deriveMasterKeyBytes`.
|
|
2541
2560
|
*/
|
|
2542
|
-
declare function deriveSpendingKeyFromSignature(signatureHex: string, chainId: number, address: string
|
|
2561
|
+
declare function deriveSpendingKeyFromSignature(signatureHex: string, chainId: number, address: string): Promise<bigint>;
|
|
2543
2562
|
/**
|
|
2544
2563
|
* Derive a 32-byte viewing secret key (ivsk) from the spending key.
|
|
2545
2564
|
* ivsk = HKDF-SHA256(ikm=bigintTo32Le(spendingKey), info="orbinum-ivk-v1")
|
|
@@ -4434,4 +4453,4 @@ interface ExtrinsicFailedData {
|
|
|
4434
4453
|
dispatch_info: DispatchInfo;
|
|
4435
4454
|
}
|
|
4436
4455
|
|
|
4437
|
-
export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, 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, CURRENT_CIRCUIT_VERSION, type ChainInfo, type ChainLink, type ChainLinkAddedEvent, type ChainLinkRemovedEvent, CircuitId, CircuitId as CircuitIdType, CircuitVersionResolver, 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, KNOWN_PRECOMPILES, type
|
|
4456
|
+
export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, 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, CURRENT_CIRCUIT_VERSION, type ChainInfo, type ChainLink, type ChainLinkAddedEvent, type ChainLinkRemovedEvent, CircuitId, CircuitId as CircuitIdType, CircuitVersionResolver, 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, KNOWN_PRECOMPILES, type KnownPrecompileInfo, type ListingInfo, MIN_SIGNATURE_BYTES, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, type MetadataUpdatedEvent, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, 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 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 RelayerInfo, RelayerStatusModule, type RemoveChainLinkArgs, type RemovePrivateLinkArgs, type RemoveSupportedChainArgs, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedAlias, type ResolvedSpendVersion, type RevealPrivateLinkArgs, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SLIP0044_NAMESPACE, SPENDING_KEY_VERIFYING_CONTRACT, SPENDING_KEY_WARNING, type ScanCommitment, type SelfEphWindowEntry, type SetAccountMetadataArgs, type SetActiveVersionArgs, type SetMetadataParams, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SignatureScheme, type SpendingKeyTypedData, type StatusChangeEvent, type StatusListener, SubstrateClient, type SupportedChain, type SupportedChainAddedEvent, type SupportedChainRemovedEvent, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferAliasArgs, 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, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
|
package/dist/index.js
CHANGED
|
@@ -66,6 +66,7 @@ __export(index_exports, {
|
|
|
66
66
|
blindTag: () => blindTag,
|
|
67
67
|
buildDummyTransferInput: () => buildDummyTransferInput,
|
|
68
68
|
bytesToBigintLE: () => bytesToBigintLE,
|
|
69
|
+
canonicalAccountId: () => canonicalAccountId,
|
|
69
70
|
computeNoteCommitment: () => computeNoteCommitment,
|
|
70
71
|
computeNullifier: () => computeNullifier,
|
|
71
72
|
computePathIndices: () => computePathIndices,
|
|
@@ -79,7 +80,6 @@ __export(index_exports, {
|
|
|
79
80
|
deriveOwnerPk: () => deriveOwnerPk,
|
|
80
81
|
deriveSelfEphSk: () => deriveSelfEphSk,
|
|
81
82
|
deriveSpendingKeyFromSignature: () => deriveSpendingKeyFromSignature,
|
|
82
|
-
deriveSpendingKeyMessage: () => deriveSpendingKeyMessage,
|
|
83
83
|
deriveSpendingKeyMessageV2: () => deriveSpendingKeyMessageV2,
|
|
84
84
|
deriveSpendingKeyTypedData: () => deriveSpendingKeyTypedData,
|
|
85
85
|
deriveStealthOwnerPk: () => deriveStealthOwnerPk,
|
|
@@ -107,7 +107,7 @@ __export(index_exports, {
|
|
|
107
107
|
getPolkadotSigner: () => import_signer.getPolkadotSigner,
|
|
108
108
|
getPolkadotSignerFromPjs: () => import_pjs_signer.getPolkadotSignerFromPjs,
|
|
109
109
|
getPrecompileLabel: () => getPrecompileLabel,
|
|
110
|
-
getSs58AddressInfo: () =>
|
|
110
|
+
getSs58AddressInfo: () => import_polkadot_api5.getSs58AddressInfo,
|
|
111
111
|
hexToBigint: () => hexToBigint,
|
|
112
112
|
hexToNumber: () => hexToNumber,
|
|
113
113
|
implicitSubstrateToEvm: () => implicitSubstrateToEvm,
|
|
@@ -4206,6 +4206,13 @@ function randomBlinding() {
|
|
|
4206
4206
|
return n === 0n ? 1n : n % BN254_R;
|
|
4207
4207
|
}
|
|
4208
4208
|
|
|
4209
|
+
// src/privacy-keys/accountIdentity.ts
|
|
4210
|
+
var import_polkadot_api4 = require("polkadot-api");
|
|
4211
|
+
function canonicalAccountId(address) {
|
|
4212
|
+
const info = (0, import_polkadot_api4.getSs58AddressInfo)(address);
|
|
4213
|
+
return info.isValid ? toHex(info.publicKey) : address.toLowerCase();
|
|
4214
|
+
}
|
|
4215
|
+
|
|
4209
4216
|
// src/privacy-keys/SpendingKeyRequest.ts
|
|
4210
4217
|
var SPENDING_KEY_VERIFYING_CONTRACT = PRECOMPILE_ADDR.SHIELDED_POOL;
|
|
4211
4218
|
var SPENDING_KEY_WARNING = "Signing this grants full control of your Orbinum private funds. Only sign on the official Orbinum app.";
|
|
@@ -4235,12 +4242,7 @@ function deriveSpendingKeyMessageV2(chainId, address) {
|
|
|
4235
4242
|
|
|
4236
4243
|
orbinum-spending-key-v2
|
|
4237
4244
|
${chainId}
|
|
4238
|
-
${address
|
|
4239
|
-
}
|
|
4240
|
-
function deriveSpendingKeyMessage(chainId, address) {
|
|
4241
|
-
return `orbinum-spending-key-v1
|
|
4242
|
-
${chainId}
|
|
4243
|
-
${address.toLowerCase()}`;
|
|
4245
|
+
${canonicalAccountId(address)}`;
|
|
4244
4246
|
}
|
|
4245
4247
|
|
|
4246
4248
|
// src/privacy-keys/PrivacyKeys.ts
|
|
@@ -4248,6 +4250,7 @@ var import_hkdf2 = require("@noble/hashes/hkdf.js");
|
|
|
4248
4250
|
var import_sha24 = require("@noble/hashes/sha2.js");
|
|
4249
4251
|
var import_baby_jubjub6 = require("@zk-kit/baby-jubjub");
|
|
4250
4252
|
var IVK_DOMAIN = new TextEncoder().encode("orbinum-ivk-v1");
|
|
4253
|
+
var KEY_VERSION = "v2";
|
|
4251
4254
|
var MIN_SIGNATURE_BYTES = 32;
|
|
4252
4255
|
function assertUsableSignature(sigBytes) {
|
|
4253
4256
|
if (sigBytes.length < MIN_SIGNATURE_BYTES) {
|
|
@@ -4256,16 +4259,16 @@ function assertUsableSignature(sigBytes) {
|
|
|
4256
4259
|
);
|
|
4257
4260
|
}
|
|
4258
4261
|
}
|
|
4259
|
-
async function deriveMasterKeyBytes(signatureHex, chainId, address
|
|
4262
|
+
async function deriveMasterKeyBytes(signatureHex, chainId, address) {
|
|
4260
4263
|
const sigBytes = fromHex(signatureHex);
|
|
4261
4264
|
assertUsableSignature(sigBytes);
|
|
4262
4265
|
const info = new TextEncoder().encode(
|
|
4263
|
-
`orbinum-sk-${
|
|
4266
|
+
`orbinum-sk-${KEY_VERSION}:${chainId}:${canonicalAccountId(address)}`
|
|
4264
4267
|
);
|
|
4265
4268
|
return (0, import_hkdf2.hkdf)(import_sha24.sha256, sigBytes, new Uint8Array(0), info, 32);
|
|
4266
4269
|
}
|
|
4267
|
-
async function deriveSpendingKeyFromSignature(signatureHex, chainId, address
|
|
4268
|
-
const masterBytes = await deriveMasterKeyBytes(signatureHex, chainId, address
|
|
4270
|
+
async function deriveSpendingKeyFromSignature(signatureHex, chainId, address) {
|
|
4271
|
+
const masterBytes = await deriveMasterKeyBytes(signatureHex, chainId, address);
|
|
4269
4272
|
const skBigint = BigInt(toHex(masterBytes)) % BABYJUB_SUBORDER;
|
|
4270
4273
|
return skBigint === 0n ? 1n : skBigint;
|
|
4271
4274
|
}
|
|
@@ -5462,7 +5465,7 @@ var import_substrate_bindings3 = require("@polkadot-api/substrate-bindings");
|
|
|
5462
5465
|
var import_base = require("@scure/base");
|
|
5463
5466
|
var import_signer = require("polkadot-api/signer");
|
|
5464
5467
|
var import_pjs_signer = require("polkadot-api/pjs-signer");
|
|
5465
|
-
var
|
|
5468
|
+
var import_polkadot_api5 = require("polkadot-api");
|
|
5466
5469
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5467
5470
|
0 && (module.exports = {
|
|
5468
5471
|
AccountId,
|
|
@@ -5511,6 +5514,7 @@ var import_polkadot_api4 = require("polkadot-api");
|
|
|
5511
5514
|
blindTag,
|
|
5512
5515
|
buildDummyTransferInput,
|
|
5513
5516
|
bytesToBigintLE,
|
|
5517
|
+
canonicalAccountId,
|
|
5514
5518
|
computeNoteCommitment,
|
|
5515
5519
|
computeNullifier,
|
|
5516
5520
|
computePathIndices,
|
|
@@ -5524,7 +5528,6 @@ var import_polkadot_api4 = require("polkadot-api");
|
|
|
5524
5528
|
deriveOwnerPk,
|
|
5525
5529
|
deriveSelfEphSk,
|
|
5526
5530
|
deriveSpendingKeyFromSignature,
|
|
5527
|
-
deriveSpendingKeyMessage,
|
|
5528
5531
|
deriveSpendingKeyMessageV2,
|
|
5529
5532
|
deriveSpendingKeyTypedData,
|
|
5530
5533
|
deriveStealthOwnerPk,
|
package/dist/index.mjs
CHANGED
|
@@ -4069,6 +4069,13 @@ function randomBlinding() {
|
|
|
4069
4069
|
return n === 0n ? 1n : n % BN254_R;
|
|
4070
4070
|
}
|
|
4071
4071
|
|
|
4072
|
+
// src/privacy-keys/accountIdentity.ts
|
|
4073
|
+
import { getSs58AddressInfo } from "polkadot-api";
|
|
4074
|
+
function canonicalAccountId(address) {
|
|
4075
|
+
const info = getSs58AddressInfo(address);
|
|
4076
|
+
return info.isValid ? toHex(info.publicKey) : address.toLowerCase();
|
|
4077
|
+
}
|
|
4078
|
+
|
|
4072
4079
|
// src/privacy-keys/SpendingKeyRequest.ts
|
|
4073
4080
|
var SPENDING_KEY_VERIFYING_CONTRACT = PRECOMPILE_ADDR.SHIELDED_POOL;
|
|
4074
4081
|
var SPENDING_KEY_WARNING = "Signing this grants full control of your Orbinum private funds. Only sign on the official Orbinum app.";
|
|
@@ -4098,12 +4105,7 @@ function deriveSpendingKeyMessageV2(chainId, address) {
|
|
|
4098
4105
|
|
|
4099
4106
|
orbinum-spending-key-v2
|
|
4100
4107
|
${chainId}
|
|
4101
|
-
${address
|
|
4102
|
-
}
|
|
4103
|
-
function deriveSpendingKeyMessage(chainId, address) {
|
|
4104
|
-
return `orbinum-spending-key-v1
|
|
4105
|
-
${chainId}
|
|
4106
|
-
${address.toLowerCase()}`;
|
|
4108
|
+
${canonicalAccountId(address)}`;
|
|
4107
4109
|
}
|
|
4108
4110
|
|
|
4109
4111
|
// src/privacy-keys/PrivacyKeys.ts
|
|
@@ -4111,6 +4113,7 @@ import { hkdf as hkdf2 } from "@noble/hashes/hkdf.js";
|
|
|
4111
4113
|
import { sha256 as sha2564 } from "@noble/hashes/sha2.js";
|
|
4112
4114
|
import { mulPointEscalar as mulPointEscalar4, Base8 as Base82, packPoint as packPoint3 } from "@zk-kit/baby-jubjub";
|
|
4113
4115
|
var IVK_DOMAIN = new TextEncoder().encode("orbinum-ivk-v1");
|
|
4116
|
+
var KEY_VERSION = "v2";
|
|
4114
4117
|
var MIN_SIGNATURE_BYTES = 32;
|
|
4115
4118
|
function assertUsableSignature(sigBytes) {
|
|
4116
4119
|
if (sigBytes.length < MIN_SIGNATURE_BYTES) {
|
|
@@ -4119,16 +4122,16 @@ function assertUsableSignature(sigBytes) {
|
|
|
4119
4122
|
);
|
|
4120
4123
|
}
|
|
4121
4124
|
}
|
|
4122
|
-
async function deriveMasterKeyBytes(signatureHex, chainId, address
|
|
4125
|
+
async function deriveMasterKeyBytes(signatureHex, chainId, address) {
|
|
4123
4126
|
const sigBytes = fromHex(signatureHex);
|
|
4124
4127
|
assertUsableSignature(sigBytes);
|
|
4125
4128
|
const info = new TextEncoder().encode(
|
|
4126
|
-
`orbinum-sk-${
|
|
4129
|
+
`orbinum-sk-${KEY_VERSION}:${chainId}:${canonicalAccountId(address)}`
|
|
4127
4130
|
);
|
|
4128
4131
|
return hkdf2(sha2564, sigBytes, new Uint8Array(0), info, 32);
|
|
4129
4132
|
}
|
|
4130
|
-
async function deriveSpendingKeyFromSignature(signatureHex, chainId, address
|
|
4131
|
-
const masterBytes = await deriveMasterKeyBytes(signatureHex, chainId, address
|
|
4133
|
+
async function deriveSpendingKeyFromSignature(signatureHex, chainId, address) {
|
|
4134
|
+
const masterBytes = await deriveMasterKeyBytes(signatureHex, chainId, address);
|
|
4132
4135
|
const skBigint = BigInt(toHex(masterBytes)) % BABYJUB_SUBORDER;
|
|
4133
4136
|
return skBigint === 0n ? 1n : skBigint;
|
|
4134
4137
|
}
|
|
@@ -5348,7 +5351,7 @@ import {
|
|
|
5348
5351
|
connectInjectedExtension,
|
|
5349
5352
|
getInjectedExtensions
|
|
5350
5353
|
} from "polkadot-api/pjs-signer";
|
|
5351
|
-
import { getSs58AddressInfo } from "polkadot-api";
|
|
5354
|
+
import { getSs58AddressInfo as getSs58AddressInfo2 } from "polkadot-api";
|
|
5352
5355
|
export {
|
|
5353
5356
|
AccountId2 as AccountId,
|
|
5354
5357
|
AccountMappingModule,
|
|
@@ -5396,6 +5399,7 @@ export {
|
|
|
5396
5399
|
blindTag,
|
|
5397
5400
|
buildDummyTransferInput,
|
|
5398
5401
|
bytesToBigintLE,
|
|
5402
|
+
canonicalAccountId,
|
|
5399
5403
|
computeNoteCommitment,
|
|
5400
5404
|
computeNullifier,
|
|
5401
5405
|
computePathIndices,
|
|
@@ -5409,7 +5413,6 @@ export {
|
|
|
5409
5413
|
deriveOwnerPk,
|
|
5410
5414
|
deriveSelfEphSk,
|
|
5411
5415
|
deriveSpendingKeyFromSignature,
|
|
5412
|
-
deriveSpendingKeyMessage,
|
|
5413
5416
|
deriveSpendingKeyMessageV2,
|
|
5414
5417
|
deriveSpendingKeyTypedData,
|
|
5415
5418
|
deriveStealthOwnerPk,
|
|
@@ -5437,7 +5440,7 @@ export {
|
|
|
5437
5440
|
getPolkadotSigner,
|
|
5438
5441
|
getPolkadotSignerFromPjs,
|
|
5439
5442
|
getPrecompileLabel,
|
|
5440
|
-
getSs58AddressInfo,
|
|
5443
|
+
getSs58AddressInfo2 as getSs58AddressInfo,
|
|
5441
5444
|
hexToBigint,
|
|
5442
5445
|
hexToNumber,
|
|
5443
5446
|
implicitSubstrateToEvm,
|