From 558367539050d14c4876e8a15c8d5dc4db601795 Mon Sep 17 00:00:00 2001 From: OutCast3k Date: Wed, 25 Dec 2019 22:10:55 +0000 Subject: [PATCH] custom hd key derivation addded --- index.html | 20 ++++++++++++++------ js/coin.js | 35 ++++++++++++++++++++++++++++++++--- js/coinbin.js | 15 ++++++++++++++- sha1sum | 10 ++++------ 4 files changed, 64 insertions(+), 16 deletions(-) diff --git a/index.html b/index.html index d0df43e..37cdc13 100644 --- a/index.html +++ b/index.html @@ -1193,18 +1193,26 @@
Path
- + + + +
- Index (Start)
+ Index (Start)
- Index (End)
+ Index (End)
@@ -1325,7 +1333,7 @@

About open source bitcoin wallet

-

Version 1.4

+

Version 1.5

Compatible with bitcoin core

Github https://github.com/OutCast3k/coinbin/

TOR 4zpinp6gdkjfplhk.onion

@@ -1466,7 +1474,7 @@ diff --git a/js/coin.js b/js/coin.js index 9f46bcb..2c03e14 100644 --- a/js/coin.js +++ b/js/coin.js @@ -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(); } diff --git a/js/coinbin.js b/js/coinbin.js index 7571ddb..ede2769 100644 --- a/js/coinbin.js +++ b/js/coinbin.js @@ -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 += ''; html += ''+i+''; html += ''; @@ -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(){ diff --git a/sha1sum b/sha1sum index 5ae5460..989a3e3 100644 --- a/sha1sum +++ b/sha1sum @@ -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