From 135dc3b368ce95d6869cd2ca2b638ce5760f2429 Mon Sep 17 00:00:00 2001 From: bip32jp Date: Thu, 1 Jan 2015 03:06:24 +0900 Subject: [PATCH] Add check to new privkey generation. --- js/coin.js | 6 ++++++ js/coinbin.js | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/js/coin.js b/js/coin.js index a19ecef..2b2f883 100644 --- a/js/coin.js +++ b/js/coin.js @@ -60,6 +60,12 @@ for(i=0;i<(x).length/25;i++){ r = Crypto.SHA256(r.concat(x)); } + var checkrBigInt = new BigInteger(r); + var orderBigInt = new BigInteger("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"); + while (checkrBigInt.compareTo(orderBigInt) >= 0 || checkrBigInt.equals(BigInteger.ZERO) || checkrBigInt.equals(BigInteger.ONE)) { + r = Crypto.SHA256(r.concat(x)); + checkrBigInt = new BigInteger(r); + } return r; } diff --git a/js/coinbin.js b/js/coinbin.js index f39389e..84514d8 100644 --- a/js/coinbin.js +++ b/js/coinbin.js @@ -830,8 +830,8 @@ $(document).ready(function() { }; if (tempX < 0){tempX = 0}; if (tempY < 0){tempY = 0}; - var xEnt = Crypto.util.bytesToHex([tempX]); - var yEnt = Crypto.util.bytesToHex([tempY]); + var xEnt = Crypto.util.bytesToHex([tempX]).slice(-2); + var yEnt = Crypto.util.bytesToHex([tempY]).slice(-2); var addEnt = xEnt.concat(yEnt); if ($("#entropybucket").html().indexOf(xEnt) == -1 && $("#entropybucket").html().indexOf(yEnt) == -1) { $("#entropybucket").html(addEnt + $("#entropybucket").html());