The library is called nanocurrency-web and can be found in Github and at the npm repository. It features mnemonic phrase generation and key derivation based on BIP39/44 standard defined in the Nano documentation and works alongside the Nano Ledger implementation. You can derive as many accounts as the BIP standard allows with the same mnemonic phrase and seed.
You can also sign send, receive and change representative blocks with the user’s private key. The library creates valid input data ready to be published to the blockchain using the Nano Node’s process RPC command.
The library has automated tests validating the implementation written with Chai.
How does one create a Nano wallet?
The BIP39/44 (Bitcoin Improvement Proposal) standard is defined in the Bitcoin repository. It defines the creation of wallets based on mnemonic phrases, seeds and key derivation.
A mnemonic phrase is a set of 12-24 words. These words come from a standardized list of 2048 words. The mnemonic phrase represents the initial entropy generated for it. Every word has an index in the word list. This index number is converted to a binary representation of 11 bits. The last word is deduced from a SHA256 hash of the initial entropy.
The seed is derived from the mnemonic phrase and an optional password. If the password is given, the words cannot be used without the password to gain access to assets. The mnemonic phrase is hashed with a password based key derivation function PBKDF2 using SHA512 as the hasher and encoded into a hexadecimal string.
The seed is used to derive private keys. The BIP44 standard defines hardened paths for different crypto-currencies. Nano’s path is 44’/165’/i, where i = the index of the private-key. The keys are recursively derived based on the hardened path and a sum of the chain and a constant offset using the function CKDpriv((kpar, cpar), i) → (ki, ci). The derived key in every iteration is hashed with HMACSHA512 and split in half. The left half is the private-key and the right half is the chain which can be continued to derive another key.
The private-key is used to generate a key pair with it being the private key and generating a public key with EdDSA’s ed25519 public-key signature scheme modified to use blake2b hashing algorithm instead of SHA512.
The public key is then encoded to a Nano address and there we have it.