couple of small changes

This commit is contained in:
OutCast3k 2015-05-17 17:26:48 +00:00
parent e2f4756261
commit 024c5e5342
3 changed files with 11 additions and 7 deletions

View file

@ -384,7 +384,7 @@
</div> </div>
<h3>Address Options</h3> <h3>Address Options</h3>
<p>You can use the advanced options below to generate different kind of master address.</p> <p>You can use the advanced options below to generate different kinds of master addresses.</p>
<div class="checkbox"> <div class="checkbox">
<label><input type="checkbox" id="newHDBrainwallet" class="checkbox-inline"> Custom Seed or Brain Wallet</label> <label><input type="checkbox" id="newHDBrainwallet" class="checkbox-inline"> Custom Seed or Brain Wallet</label>

View file

@ -439,6 +439,7 @@
} }
} }
// extend prv/pub key
r.extend = function(){ r.extend = function(){
var hd = coinjs.hd(); var hd = coinjs.hd();
return hd.make({'depth':(this.depth*1)+1, return hd.make({'depth':(this.depth*1)+1,
@ -449,8 +450,9 @@
'pubkey':this.keys.pubkey}); 'pubkey':this.keys.pubkey});
} }
// derive key from index
r.derive = function(i){ r.derive = function(i){
i = (i)?i:0; i = (i)?:0;
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');
@ -469,6 +471,7 @@
o.child_index = i; o.child_index = i;
if(this.type=='private'){ if(this.type=='private'){
// derive xpub/xprv from a xprv key
k = il.add(new BigInteger([0].concat(Crypto.util.hexToBytes(this.keys.privkey)))).mod(ecparams.getN()); k = il.add(new BigInteger([0].concat(Crypto.util.hexToBytes(this.keys.privkey)))).mod(ecparams.getN());
key = Crypto.util.bytesToHex(k.toByteArrayUnsigned()); key = Crypto.util.bytesToHex(k.toByteArrayUnsigned());
@ -480,6 +483,7 @@
'address':coinjs.pubkey2address(pubkey)}; 'address':coinjs.pubkey2address(pubkey)};
} else if (this.type=='public'){ } else if (this.type=='public'){
// derive xpub key from an xpub key
q = ecparams.curve.decodePointHex(this.keys.pubkey); q = ecparams.curve.decodePointHex(this.keys.pubkey);
var curvePt = ecparams.getG().multiply(il).add(q); var curvePt = ecparams.getG().multiply(il).add(q);
@ -535,12 +539,12 @@
//child index //child index
k = k.concat((coinjs.numToBytes(data.child_index, 4)).reverse()); k = k.concat((coinjs.numToBytes(data.child_index, 4)).reverse());
// Chain code //Chain code
k = k.concat(data.chain_code); k = k.concat(data.chain_code);
var o = {}; // results var o = {}; // results
// Extended HD Private Key //encode xprv key
if(data.privkey){ if(data.privkey){
var prv = (coinjs.numToBytes(coinjs.hdkey.prv, 4)).reverse(); var prv = (coinjs.numToBytes(coinjs.hdkey.prv, 4)).reverse();
prv = prv.concat(k); prv = prv.concat(k);
@ -552,7 +556,7 @@
o.privkey = coinjs.base58encode(ret); o.privkey = coinjs.base58encode(ret);
} }
// Extended HD Public Key //encode xpub key
if(data.pubkey){ if(data.pubkey){
var pub = (coinjs.numToBytes(coinjs.hdkey.pub, 4)).reverse(); var pub = (coinjs.numToBytes(coinjs.hdkey.pub, 4)).reverse();
pub = pub.concat(k); pub = pub.concat(k);

View file

@ -10,7 +10,7 @@ f7c09f2f5a721371e7d478050119f7e2d58e3ef9 ./js/crypto-sha256-hmac.js
ad038e1f39646b68ae666324ed4c2882a8c42474 ./js/qrcode.js ad038e1f39646b68ae666324ed4c2882a8c42474 ./js/qrcode.js
64eb4ea5c882f8bce3e1885bf00728455f1c2f4c ./js/ripemd160.js 64eb4ea5c882f8bce3e1885bf00728455f1c2f4c ./js/ripemd160.js
114089ef2a3feb6d4db4f9cabcb186d7750d5884 ./js/sha512.js 114089ef2a3feb6d4db4f9cabcb186d7750d5884 ./js/sha512.js
b7d72e6064cf8a1a0b5a602bc2a976ce3d61aadf ./js/coin.js 6db735d6bc9fbacd7a874ad3c4dee92b6f8d95ce ./js/coin.js
8e921b2156d232871540e168e1677368b5611dc9 ./js/coinbin.js 8e921b2156d232871540e168e1677368b5611dc9 ./js/coinbin.js
ae49e56999d82802727455f0ba83b63acd90a22b ./js/jquery-1.9.1.min.js ae49e56999d82802727455f0ba83b63acd90a22b ./js/jquery-1.9.1.min.js
5f570018ed044eafd464f7e0ab1783b966224055 ./LICENCE 5f570018ed044eafd464f7e0ab1783b966224055 ./LICENCE
@ -25,4 +25,4 @@ de51a8494180a6db074af2dee2383f0a363c5b08 ./fonts/glyphicons-halflings-regular.s
278e49a86e634da6f2a02f3b47dd9d2a8f26210f ./fonts/glyphicons-halflings-regular.woff 278e49a86e634da6f2a02f3b47dd9d2a8f26210f ./fonts/glyphicons-halflings-regular.woff
44bc1850f570972267b169ae18f1cb06b611ffa2 ./fonts/glyphicons-halflings-regular.ttf 44bc1850f570972267b169ae18f1cb06b611ffa2 ./fonts/glyphicons-halflings-regular.ttf
fe8d57914bb036ab94e86ec35b2671eeb6d20d0d ./README.md fe8d57914bb036ab94e86ec35b2671eeb6d20d0d ./README.md
44ab99a496aab01d8181e0f2ac9b02ad8b854d9d ./index.html 954c6edeac5881c4e12b3db46875a6eab18239b8 ./index.html