Skip to content
This repository has been archived by the owner on Oct 11, 2020. It is now read-only.

Wallet Tech Notes

Aviv Eyal edited this page Oct 8, 2018 · 1 revision
  • Wallet should follow the following specs:

    • BIP23 HD Wallet
    • BIP39 (Paper wallet)
    • BIP39 (Mnemonic backups)
    • BIP44 (Multi-purpose passphrase protected HD wallet)
  • See account file format spec in Accounts

  • We need to register coin ID for Spacemesh Coin (SMC) and for each testnet Spacemesh Coin (SMCT1, SMCT2, etc...) See BIP44 and BIP44 LIST

Wallet App -> Wallet -> {NetworkId, Accounts} -> Default Account (key pair at index 0)

Passphrases and Paper Backups

  • We use BIP39 for 12 words mnemonic from a random seed generation for purposes of paper backups

  • We use a user-provided passphrase to create a derived key that is harder to brute-force regardless of user's passphrase strength. See 'From Mnemonic to Seed' in BIP39

  • An HD Wallet data file stores the seed encrypted with the derived key. To access the private seed (and the wallet addresses and 12 words mnemonic code) user must provide his passphrase and have access to the wallet's data file

  • User can recreate the data file in case he or she lost the passphrase using the 12 words mnemonic from a paper backup

Random Seed (512 bits) -> 12 words Mnemonic -> BIP32 Root Key -> BIP44 HD Wallet
User passphrase -> KDF -> Decrypt Random Seed (512 bits) from wallet file -> Access BIP44 HD Wallet or 12 words mnemonic

BIP32 Considerations

A Spacemesh wallet is a BIP44 HD Wallet with the following path rules:

m / 44 / NetId / account / change / address[i]

  • m and 44 - BIP32 constants
  • NetId - one of the Spacemesh networks, e.g. MainNet, TestNet1, TestNet2, etc...
  • change - 0 constant (not applicable to Spacemesh Coins)
  • account - 0 constant - for now. May change in the future.
  • `address[i] - addresses key pairs array.

Note that Spacemesh accounts are technically BIP32 address pairs and the default wallet account is address[0] and the we don't use the BIP32 accounts feature. Accounts is always constant 0 in a Spacemesh wallet. This may change in the future to support more advanced use cases (mainly multiple sub-wallets, each with its own accounts, in one wallet).

So, we use BIP44 with only account 0 and what we communicate to users as accounts are actually BIP44 addresses.

Examples: m/44/665/0/0/address[0] - the default account for Spacemesh mainnet (netId 665). m/44/666/0/0/address[0] - the default account for Spacemesh testnet1 (netId 666). m/44/666/0/0/address[1] - Second account for Spacemesh testnet1 (netId 666).

Additional Info

  • BIP39 Mnemonic code for generating deterministic keys and BIP38 paper wallets. Read more at the official BIP38 BIP39 specs
  • BIP32 Hierarchical Deterministic (HD) Wallets. Read more at the official BIP32 spec
  • See the demo at bip32.org
  • BIP44 Multi-Account Hierarchy for Deterministic Wallets. Read more at the official BIP44 spec
  • Keys are never stored in the cloud - only locally on the device, and store is encrypted with a key derived from user provided passphrase (or bio auth measure)

QR Codes Support

  • TODO: Research libs to generate QR code for a Spacemesh public key.