- Notifications
You must be signed in to change notification settings - Fork0
bip32 implementation for Nano currency
License
NotificationsYou must be signed in to change notification settings
go-faast/bip32-nano
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
ABIP32 compatible library for the Nano currency written in TypeScript with transpiled JavaScript committed to git. Based on the implementation bysuperdarkbit which is based on thisBIP32-ED25519 spec.
This library attempts to conform the theBIP32Interface
defined by thebitcoinjs bip32 library.
The following are intentional deviations or incompatabilities:
BIP32Interface.toWIF
is not supported because Nano does not use WIF for private keys- xprv's are 109 bytes instead of the standard 78 bytes in order to include the full 512 bit private key that is needed for BIP32-ED25519
- xpub's are 77 bytes instead of the standard 78 bytes because byte 45 is no longer needed to indicate whether the public key is compressed. ED25519 public keys are always compressed.
- BIP32-ED25519 requires a master secret such that it's SHA512 hash has the third highest bit of the first 32 bytes unset. In order to be compatible with all existing seeds, a conforming master secret is discovered by iterating over 32 bit integers
i
starting from 0 untilSHA512(i, seed)
meets the requirements.
- Update tests
- Change bip32 public/private version number
TypeScript
import*asbip32from'bip32-nano';import{BIP32Interface}from'bip32-nano';letnode:BIP32Interface=bip32.fromBase58('xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi');letchild:BIP32Interface=node.derivePath('m/0/0');// ...
NodeJS
letbip32=require('bip32-nano')letnode=bip32.fromBase58('xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi')letchild=node.derivePath('m/0/0')// ...