Core Concepts
The derivation path is our recommendation to the client wallets so that user could easily migrate between different wallet apps. But the scheme is just a recommendation. You could implement a different scheme but then it will lose the ability to migrate to/from other apps.
Scheme
- m/8797555’/accountNumber’/0’ - Identity Key
- m/8797555’/accountNumber’/1’ - Base signing key - As leaf key
- m/8797555’/accountNumber’/2’ - Temporary signing key - As deposit key
- m/8797555’/accountNumber’/3’ - Static deposit key
Account
TheaccountNumber
should start from 0 and use hardened derivation.
Leaf key derivation
To accept a transfer, there will always be a leaf ID provided by the spark entity. The derivation path for a given leaf id is hash = sha256(leaf_id) From base signing key, the leaf key should be m/8797555’/accountNumber’/1’/hash(leaf_id)%0x80000000 + 0x80000000 (hash(leaf_id)%0x80000000’)Deposit address key derivation
For user deposit, there’s no leaf id because the leaf is generated after the tree is created. So user deposit should always use m/8797555’/accountNumber’/2’ And once a deposit tree is created, the user should perform a self transfer to the leaf key.Usage in the Spark SDK
initialize
Initializes your spark wallet
If no account number is provided, our JS-SDK defaults
accountNumber
to 1
to support backwards compatability for mainnet wallets created with earlier
versions of the SDK.Parameters
mnemonicOrSeed
: optional mnemonic or seedaccountNumber
: optional account numberoptions
: wallet configuration parameters