custom hd key derivation addded

This commit is contained in:
OutCast3k 2019-12-25 22:10:55 +00:00
parent 56cb104ea4
commit 5583675390
4 changed files with 64 additions and 16 deletions

View file

@ -1193,18 +1193,26 @@
<div class="row">
<div class="col-md-8">
<b>Path</b><br>
<select class="form-control">
<option>Simple: m/i</option>
<select class="form-control" id="hdpathtype"">
<option value="simple">Simple: m/i</option>
<option value="custom">Custom</option>
</select>
<div id="hdpath" class="hidden" style="margin-top:4px">
<span class="input-group">
<input type="text" class="form-control" value="m/0/1"> <br>
<span class="input-group-addon"> / </span>
</span>
</div>
</div>
<div class="col-md-2">
<b>Index (Start)</b><br>
<b><u>I</u>ndex (Start)</b><br>
<input type="text" class="form-control derivation_index_start" value="0">
</div>
<div class="col-md-2">
<b>Index (End)</b><br>
<b><u>I</u>ndex (End)</b><br>
<input type="text" class="form-control derivation_index_end" value="1">
</div>
@ -1325,7 +1333,7 @@
<div class="tab-pane tab-content" id="about">
<h2>About <small>open source bitcoin wallet</small></h2>
<p>Version 1.4</p>
<p>Version 1.5</p>
<p>Compatible with bitcoin core</p>
<p>Github <a href="https://github.com/OutCast3k/coinbin/">https://github.com/OutCast3k/coinbin/</a></p>
<p>TOR <a href="http://4zpinp6gdkjfplhk.onion">4zpinp6gdkjfplhk.onion</a></p>
@ -1466,7 +1474,7 @@
<div id="footer">
<div class="container text-right">
<p class="text-muted">Version 1.4</p>
<p class="text-muted">Version 1.5</p>
</div>
</div>

View file

@ -638,6 +638,8 @@
coinjs.compressed = c; // reset to default
}
return r;
}
// extend prv/pub key
@ -651,8 +653,37 @@
'pubkey':this.keys.pubkey});
}
// derive from path
r.derive_path = function(path) {
if( path == 'm' || path == 'M' || path == 'm\'' || path == 'M\'' ) return this;
var p = path.split('/');
var hdp = coinjs.clone(this); // clone hd path
for( var i in p ) {
if((( i == 0 ) && c != 'm') || i == 'remove'){
continue;
}
var c = p[i];
var use_private = (c.length > 1) && (c[c.length-1] == '\'');
var child_index = parseInt(use_private ? c.slice(0, c.length - 1) : c) & 0x7fffffff;
if(use_private)
child_index += 0x80000000;
hdp = hdp.derive(child_index);
var key = ((hdp.keys_extended.privkey) && hdp.keys_extended.privkey!='') ? hdp.keys_extended.privkey : hdp.keys_extended.pubkey;
hdp = coinjs.hd(key);
}
return hdp;
}
// derive key from index
r.derive = function(i){
i = (i)?i:0;
var blob = (Crypto.util.hexToBytes(this.keys.pubkey)).concat(coinjs.numToBytes(i,4).reverse());
@ -707,7 +738,6 @@
o.parent_fingerprint = (ripemd160(Crypto.SHA256(Crypto.util.hexToBytes(r.keys.pubkey),{asBytes:true}),{asBytes:true})).slice(0,4);
o.keys_extended = o.extend();
return o;
}
@ -772,8 +802,7 @@
return o;
}
r.parse();
return r;
return r.parse();
}

View file

@ -1660,7 +1660,11 @@ $(document).ready(function() {
var html = '';
$("#verifyHDaddress .derived_data table tbody").html("");
for(var i=index_start;i<=index_end;i++){
var derived = hd.derive(i);
if($("#hdpathtype option:selected").val()=='simple'){
var derived = hd.derive(i);
} else {
var derived = hd.derive_path(($("#hdpath input").val().replace(/\/+$/, ""))+'/'+i);
}
html += '<tr>';
html += '<td>'+i+'</td>';
html += '<td><input type="text" class="form-control" value="'+derived.keys.address+'" readonly></td>';
@ -1673,6 +1677,15 @@ $(document).ready(function() {
}
$("#hdpathtype").change(function(){
if($(this).val()=='simple'){
$("#hdpath").removeClass().addClass("hidden");
} else {
$("#hdpath").removeClass();
}
});
/* sign code */
$("#signBtn").click(function(){

10
sha1sum
View file

@ -1,9 +1,9 @@
---- Version 1.4 2019.12.24 ----
---- Version 1.4 2019.12.25 ----
77e4519962e2f6a9fc93342137dbb31c33b76b04 ./js/aes.js
3a09a8fc0cfe828b57fc798d668234d0490ee1a6 ./js/bootstrap-datetimepicker.min.js
253711c6d825de55a8360552573be950da180614 ./js/bootstrap.min.js
2bfcffc174dea70a64dd7c7b78d41b4c3a2ebee5 ./js/coinbin.js
af862d062e338c24c12a64405bd081c6a39c0f22 ./js/coin.js
17cc6a56ee601fbe3858563f26232f64ce12abcb ./js/coinbin.js
dc83017470f3ced2b0d522781b3ccded0d3a8d28 ./js/coin.js
988565bc2cb402d63ed5c5fd7ff47c4278efc2c5 ./js/collapse.js
9ba5ede3d7f9d4c8fd623395f196adfdcf7e970f ./js/crypto-min.js
f7c09f2f5a721371e7d478050119f7e2d58e3ef9 ./js/crypto-sha256-hmac.js
@ -31,6 +31,4 @@ de51a8494180a6db074af2dee2383f0a363c5b08 ./fonts/glyphicons-halflings-regular.s
278e49a86e634da6f2a02f3b47dd9d2a8f26210f ./fonts/glyphicons-halflings-regular.woff
44bc1850f570972267b169ae18f1cb06b611ffa2 ./fonts/glyphicons-halflings-regular.ttf
c024021c71cba503979a859d23cbf7a88b570d82 ./README.md
b3d3e947ebacce5aabfc3af57cbd0e094d06a8c9 ./index.html
9cf7084c331b7c536f5f6e34533300c3d9d3e038 ./index.html