Add check to new privkey generation.

This commit is contained in:
bip32jp
2015-01-01 03:06:24 +09:00
parent e8cc72ed85
commit 135dc3b368
2 changed files with 8 additions and 2 deletions
+6
View File
@@ -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;
}