code from bitcore. original implementation derived from here: https://github.com/sarchar/brainwallet.github.com/blob/bip32/js/bip32.js