mirror of
https://github.com/ok2/coinbin.git
synced 2026-04-24 11:44:02 +02:00
Fix the derivation of the hd wallet hardened path to be BIP32 compliant.
This commit is contained in:
parent
29baeff8c8
commit
704f2c96a3
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
coinjs.compressed = false;
|
coinjs.compressed = false;
|
||||||
|
|
||||||
|
coinjs.hd_derivation = "bip32_derivation";
|
||||||
|
|
||||||
/* other vars */
|
/* other vars */
|
||||||
coinjs.developer = '33tht1bKDgZVxb39MnZsWa8oxHXHvUYE4G'; //bitcoin
|
coinjs.developer = '33tht1bKDgZVxb39MnZsWa8oxHXHvUYE4G'; //bitcoin
|
||||||
|
|
||||||
@ -685,7 +687,11 @@
|
|||||||
r.derive = function(i){
|
r.derive = function(i){
|
||||||
|
|
||||||
i = (i)?i:0;
|
i = (i)?i:0;
|
||||||
|
if ((i >= 0x80000000) && (coinjs.hd_derivation == "bip32_derivation")) {
|
||||||
|
var blob = (Crypto.util.hexToBytes("00").concat(Crypto.util.hexToBytes(this.keys.privkey)).concat(coinjs.numToBytes(i,4).reverse()));
|
||||||
|
} else {
|
||||||
var blob = (Crypto.util.hexToBytes(this.keys.pubkey)).concat(coinjs.numToBytes(i,4).reverse());
|
var blob = (Crypto.util.hexToBytes(this.keys.pubkey)).concat(coinjs.numToBytes(i,4).reverse());
|
||||||
|
}
|
||||||
|
|
||||||
var j = new jsSHA(Crypto.util.bytesToHex(blob), 'HEX');
|
var j = new jsSHA(Crypto.util.bytesToHex(blob), 'HEX');
|
||||||
var hash = j.getHMAC(Crypto.util.bytesToHex(r.chain_code), "HEX", "SHA-512", "HEX");
|
var hash = j.getHMAC(Crypto.util.bytesToHex(r.chain_code), "HEX", "SHA-512", "HEX");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user