]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/commitdiff
fix Ethereum xpub derivation
authorMatthew Leon <ml@matthewleon.com>
Thu, 19 Dec 2019 20:36:44 +0000 (15:36 -0500)
committerMatthew Leon Grinshpun <matt@nydig.com>
Thu, 19 Dec 2019 20:37:08 +0000 (15:37 -0500)
src/js/index.js

index d843ee1cd828c387ad0bbbad1b51ea23621e8bf0..92772f6840013a41e1f08ef6ae34b6c5de4163c8 100644 (file)
                 }
                 // Ethereum values are different
                 if (networkIsEthereum()) {
                 }
                 // Ethereum values are different
                 if (networkIsEthereum()) {
-                    var privKeyBuffer = keyPair.d.toBuffer(32);
-                    privkey = privKeyBuffer.toString('hex');
-                    var addressBuffer = libs.ethUtil.privateToAddress(privKeyBuffer);
+                    var pubkeyBuffer = keyPair.getPublicKeyBuffer();
+                    var ethPubkey = libs.ethUtil.importPublic(pubkeyBuffer);
+                    var addressBuffer = libs.ethUtil.publicToAddress(ethPubkey);
                     var hexAddress = addressBuffer.toString('hex');
                     var checksumAddress = libs.ethUtil.toChecksumAddress(hexAddress);
                     address = libs.ethUtil.addHexPrefix(checksumAddress);
                     var hexAddress = addressBuffer.toString('hex');
                     var checksumAddress = libs.ethUtil.toChecksumAddress(hexAddress);
                     address = libs.ethUtil.addHexPrefix(checksumAddress);