Skip to content

go-faast/bip32-nano

Repository files navigation

bip32-nano

A BIP32 compatible library for the Nano currency written in TypeScript with transpiled JavaScript committed to git. Based on the implementation by superdarkbit which is based on this BIP32-ED25519 spec.

This library attempts to conform the the BIP32Interface defined by the bitcoinjs 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 until SHA512(i, seed) meets the requirements.

TODO

  • Update tests
  • Change bip32 public/private version number

Example

TypeScript

import * as bip32 from 'bip32-nano';
import { BIP32Interface } from 'bip32-nano';
let node: BIP32Interface = bip32.fromBase58('xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi');

let child: BIP32Interface = node.derivePath('m/0/0');
// ...

NodeJS

let bip32 = require('bip32-nano')
let node = bip32.fromBase58('xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi')

let child = node.derivePath('m/0/0')
// ...

LICENSE MIT

About

bip32 implementation for Nano currency

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published