v3.2.3 wallet details: show error when checksum validation fails or private key outside of curve range
This commit is contained in:
parent
67e167930c
commit
af91e78b98
8 changed files with 234 additions and 50 deletions
|
@ -28,6 +28,11 @@ END USER NOTES:
|
||||||
|
|
||||||
Here is a signed list of file names and version history.
|
Here is a signed list of file names and version history.
|
||||||
|
|
||||||
|
2016-11-27: status ACTIVE
|
||||||
|
bitaddress.org-v3.2.3-SHA256-c9a0bb3ed50aa75a5ae9c606d81e3fd41a4ff686ad38ad5379e2402f481e79a4.html
|
||||||
|
- wallet details: show error when checksum validation fails
|
||||||
|
- wallet details: show error when private key outside of curve range
|
||||||
|
|
||||||
2016-08-21: status ACTIVE
|
2016-08-21: status ACTIVE
|
||||||
bitaddress.org-v3.2.2-SHA256-f4d047c264a2b71946de319482a9365e56d8d7289dd85a352da3b1448b7647df.html
|
bitaddress.org-v3.2.2-SHA256-f4d047c264a2b71946de319482a9365e56d8d7289dd85a352da3b1448b7647df.html
|
||||||
- version bump for unix line endings
|
- version bump for unix line endings
|
||||||
|
|
|
@ -31,6 +31,11 @@ END USER NOTES:
|
||||||
|
|
||||||
Here is a signed list of file names and version history.
|
Here is a signed list of file names and version history.
|
||||||
|
|
||||||
|
2016-11-27: status ACTIVE
|
||||||
|
bitaddress.org-v3.2.3-SHA256-c9a0bb3ed50aa75a5ae9c606d81e3fd41a4ff686ad38ad5379e2402f481e79a4.html
|
||||||
|
- wallet details: show error when checksum validation fails
|
||||||
|
- wallet details: show error when private key outside of curve range
|
||||||
|
|
||||||
2016-08-21: status ACTIVE
|
2016-08-21: status ACTIVE
|
||||||
bitaddress.org-v3.2.2-SHA256-f4d047c264a2b71946de319482a9365e56d8d7289dd85a352da3b1448b7647df.html
|
bitaddress.org-v3.2.2-SHA256-f4d047c264a2b71946de319482a9365e56d8d7289dd85a352da3b1448b7647df.html
|
||||||
- version bump for unix line endings
|
- version bump for unix line endings
|
||||||
|
@ -333,11 +338,11 @@ bitaddress.org-v0.1-SHA1-f40e706490f3eb2be56c31ddbf4c8646cd51ef40.html
|
||||||
-----BEGIN PGP SIGNATURE-----
|
-----BEGIN PGP SIGNATURE-----
|
||||||
Version: GnuPG v1
|
Version: GnuPG v1
|
||||||
|
|
||||||
iQEcBAEBAgAGBQJXuj+4AAoJEIdJe5Fjl09a7wEIAJIfRmwqcr1oniY/arJpr+e6
|
iQEcBAEBAgAGBQJYOz4QAAoJEIdJe5Fjl09ar74IAMiOx4/c/q7UaTEjlAQDmseh
|
||||||
a97QMVgpzFrj2G3k8odW6MMowjnWOeYmzhdiNQ+9crmKUFjElrzzUEOg0Mh32Ix3
|
CxSRHHQUwGaZG6z9pwt9ecdKht4t3Y2+CufcPmoV7A1Vq2EtoXFxEibwDwLuTzYL
|
||||||
iNVspXlHwgYfc5Xj7qtkWRPCoZ9u4TmOY5HA0gL7nsPZOrEbXjbYlknTTJertbpN
|
pqcUZCV+fwd0PGGz69mL0iGrMJHy0lhBZb4lb+2P6fXz4D35n1Dnq1jHGAOzcFEF
|
||||||
gNZBaCxKQD2U4goUVXMyby9+3lnam6IOegpOqWQRxq8ZmPo+bbtjWpifp9roSaoG
|
B2++ja2s8QJwd1S1xtOhBshVZDTHc8YYgv1JJSKDpJNeGSFHx9IapOv4ydETbhfT
|
||||||
6fJb6T3fEx3aXcwamJktkh5Xh6WivUJnkR8vgLLbWEN4M1HXg1hCqipMnw9cw/U/
|
L7kp9z6TKZ5khkRUCGR2qL4BzlTA/lSDj/cgVb6tRQmIgusRMjvJP076nEqiJ4TX
|
||||||
FXSCSOv5Iw0thYTBhqR2NeRWdUEu81l95t9HXxjIKc75ej4J14QaPSDgt46PQvA=
|
8YZrObi2yXM7bD8iBXIabc3W2r/R9olw+pCxI+ZuFEOU+UVndCRpP7XEMsTp4aw=
|
||||||
=3IgE
|
=/wYY
|
||||||
-----END PGP SIGNATURE-----
|
-----END PGP SIGNATURE-----
|
||||||
|
|
|
@ -5720,19 +5720,23 @@ Bitcoin.ECKey = (function () {
|
||||||
this.priv = BigInteger.fromByteArrayUnsigned(input);
|
this.priv = BigInteger.fromByteArrayUnsigned(input);
|
||||||
} else if ("string" == typeof input) {
|
} else if ("string" == typeof input) {
|
||||||
var bytes = null;
|
var bytes = null;
|
||||||
if (ECKey.isWalletImportFormat(input)) {
|
try{
|
||||||
bytes = ECKey.decodeWalletImportFormat(input);
|
if (ECKey.isWalletImportFormat(input)) {
|
||||||
} else if (ECKey.isCompressedWalletImportFormat(input)) {
|
bytes = ECKey.decodeWalletImportFormat(input);
|
||||||
bytes = ECKey.decodeCompressedWalletImportFormat(input);
|
} else if (ECKey.isCompressedWalletImportFormat(input)) {
|
||||||
this.compressed = true;
|
bytes = ECKey.decodeCompressedWalletImportFormat(input);
|
||||||
} else if (ECKey.isMiniFormat(input)) {
|
this.compressed = true;
|
||||||
bytes = Crypto.SHA256(input, { asBytes: true });
|
} else if (ECKey.isMiniFormat(input)) {
|
||||||
} else if (ECKey.isHexFormat(input)) {
|
bytes = Crypto.SHA256(input, { asBytes: true });
|
||||||
bytes = Crypto.util.hexToBytes(input);
|
} else if (ECKey.isHexFormat(input)) {
|
||||||
} else if (ECKey.isBase64Format(input)) {
|
bytes = Crypto.util.hexToBytes(input);
|
||||||
bytes = Crypto.util.base64ToBytes(input);
|
} else if (ECKey.isBase64Format(input)) {
|
||||||
|
bytes = Crypto.util.base64ToBytes(input);
|
||||||
|
}
|
||||||
|
} catch (exc1) {
|
||||||
|
this.setError(exc1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ECKey.isBase6Format(input)) {
|
if (ECKey.isBase6Format(input)) {
|
||||||
this.priv = new BigInteger(input, 6);
|
this.priv = new BigInteger(input, 6);
|
||||||
} else if (bytes == null || bytes.length != 32) {
|
} else if (bytes == null || bytes.length != 32) {
|
||||||
|
@ -5744,7 +5748,21 @@ Bitcoin.ECKey = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.compressed = (this.compressed == undefined) ? !!ECKey.compressByDefault : this.compressed;
|
this.compressed = (this.compressed == undefined) ? !!ECKey.compressByDefault : this.compressed;
|
||||||
KeyPool.push(this);
|
try {
|
||||||
|
// check not zero
|
||||||
|
if (this.priv != null && BigInteger.ZERO.compareTo(this.priv) == 0) this.setError("Error: BigInteger equal to zero.");
|
||||||
|
// valid range [0x1, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140])
|
||||||
|
var hexKeyRangeLimit = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140";
|
||||||
|
var rangeLimitBytes = Crypto.util.hexToBytes(hexKeyRangeLimit);
|
||||||
|
var limitBigInt = BigInteger.fromByteArrayUnsigned(rangeLimitBytes);
|
||||||
|
if (this.priv != null && limitBigInt.compareTo(this.priv) < 0) this.setError("Error: BigInteger outside of curve range.")
|
||||||
|
|
||||||
|
if (this.priv != null) {
|
||||||
|
KeyPool.push(this);
|
||||||
|
}
|
||||||
|
} catch (exc2) {
|
||||||
|
this.setError(exc2);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ECKey.privateKeyPrefix = 0x80; // mainnet 0x80 testnet 0xEF
|
ECKey.privateKeyPrefix = 0x80; // mainnet 0x80 testnet 0xEF
|
||||||
|
@ -5754,6 +5772,15 @@ Bitcoin.ECKey = (function () {
|
||||||
*/
|
*/
|
||||||
ECKey.compressByDefault = false;
|
ECKey.compressByDefault = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether the public key should be returned compressed or not.
|
||||||
|
*/
|
||||||
|
ECKey.prototype.setError = function (err) {
|
||||||
|
this.error = err;
|
||||||
|
this.priv = null;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether the public key should be returned compressed or not.
|
* Set whether the public key should be returned compressed or not.
|
||||||
*/
|
*/
|
||||||
|
@ -7033,7 +7060,7 @@ input[type=checkbox] { position: relative; z-index: 20; }
|
||||||
<div class="tooltip" id="statusprotocolbad">
|
<div class="tooltip" id="statusprotocolbad">
|
||||||
<span class="statuswarn" id="statuslabelprotocolbad">⚠ Think twice!</span>
|
<span class="statuswarn" id="statuslabelprotocolbad">⚠ Think twice!</span>
|
||||||
<span id="statuslabelprotocolbad1">You appear to be running this generator online from a live website. For valuable wallets it is recommended to</span>
|
<span id="statuslabelprotocolbad1">You appear to be running this generator online from a live website. For valuable wallets it is recommended to</span>
|
||||||
<a id="statuslabelprotocolbad2" href="https://github.com/pointbiz/bitaddress.org/archive/v3.2.2.zip">download</a>
|
<a id="statuslabelprotocolbad2" href="https://github.com/pointbiz/bitaddress.org/archive/v3.2.3.zip">download</a>
|
||||||
<span id="statuslabelprotocolbad3">the zip file from GitHub and run this generator offline as a local html file.</span>
|
<span id="statuslabelprotocolbad3">the zip file from GitHub and run this generator offline as a local html file.</span>
|
||||||
<br /><br /><input type="button" value="OK" class="button" id="statusokprotocolbad" onclick="document.getElementById('statusprotocolbad').style.display = 'none';" />
|
<br /><br /><input type="button" value="OK" class="button" id="statusokprotocolbad" onclick="document.getElementById('statusprotocolbad').style.display = 'none';" />
|
||||||
</div>
|
</div>
|
||||||
|
@ -7058,12 +7085,12 @@ input[type=checkbox] { position: relative; z-index: 20; }
|
||||||
<span class="item"><span id="footerlabeldonations">Donations:</span> <b>1NiNja</b>1bUmhSoTXozBRBEtR8LeF9TGbZBN</span>
|
<span class="item"><span id="footerlabeldonations">Donations:</span> <b>1NiNja</b>1bUmhSoTXozBRBEtR8LeF9TGbZBN</span>
|
||||||
<span class="item" id="footerlabeltranslatedby"></span>
|
<span class="item" id="footerlabeltranslatedby"></span>
|
||||||
<span class="item"><a href="https://github.com/pointbiz/bitaddress.org" target="_blank" id="footerlabelgithub">GitHub Repository</a>
|
<span class="item"><a href="https://github.com/pointbiz/bitaddress.org" target="_blank" id="footerlabelgithub">GitHub Repository</a>
|
||||||
(<a href="https://github.com/pointbiz/bitaddress.org/archive/v3.2.2.zip" target="_blank" id="footerlabelgithubzip">zip</a>)</span>
|
(<a href="https://github.com/pointbiz/bitaddress.org/archive/v3.2.3.zip" target="_blank" id="footerlabelgithubzip">zip</a>)</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="authorpgp">
|
<div class="authorpgp">
|
||||||
<span class="item">
|
<span class="item">
|
||||||
<a href="CHANGELOG.txt.asc" target="_blank"><span id="footerlabelversion">Version History</span> (3.2.2)</a>
|
<a href="CHANGELOG.txt.asc" target="_blank"><span id="footerlabelversion">Version History</span> (3.2.3)</a>
|
||||||
|
|
||||||
</span>
|
</span>
|
||||||
<span class="item">527B 5C82 B1F6 B2DB 72A0<br />ECBF 8749 7B91 6397 4F5A</span>
|
<span class="item">527B 5C82 B1F6 B2DB 72A0<br />ECBF 8749 7B91 6397 4F5A</span>
|
||||||
|
@ -10448,7 +10475,10 @@ ninja.wallets.vanitywallet = {
|
||||||
|
|
||||||
keyToECKeyWithBrain: function (key) {
|
keyToECKeyWithBrain: function (key) {
|
||||||
var btcKey = new Bitcoin.ECKey(key);
|
var btcKey = new Bitcoin.ECKey(key);
|
||||||
if (btcKey.priv == null) {
|
if (btcKey.error != null) {
|
||||||
|
alert(translator.get("detailalertnotvalidprivatekey") + "\n" + btcKey.error);
|
||||||
|
}
|
||||||
|
else if (btcKey.priv == null) {
|
||||||
// enforce a minimum passphrase length
|
// enforce a minimum passphrase length
|
||||||
if (key.length >= wallets.brainwallet.minPassphraseLength) {
|
if (key.length >= wallets.brainwallet.minPassphraseLength) {
|
||||||
// Deterministic Wallet confirm box to ask if user wants to SHA256 the input to get a private key
|
// Deterministic Wallet confirm box to ask if user wants to SHA256 the input to get a private key
|
||||||
|
@ -11630,7 +11660,64 @@ ninja.wallets.splitwallet = {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
},
|
||||||
|
|
||||||
|
// test checksum exceptions
|
||||||
|
testUncompressedWifShouldFailChecksum: function () {
|
||||||
|
// original key: 5KjQAHniFiy18SU7eenyJ9EPYUkjrbiBPfDqw987QjT5vehVQZV K->k
|
||||||
|
var key = "5kjQAHniFiy18SU7eenyJ9EPYUkjrbiBPfDqw987QjT5vehVQZV";
|
||||||
|
var btcKey = new Bitcoin.ECKey(key);
|
||||||
|
if (btcKey.error.toString().indexOf("failed") == -1) { //Checksum validation failed!
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
},
|
||||||
|
testCompressedWifShouldFailChecksum: function () {
|
||||||
|
// original key: L5g9E16m5zEBZqQgMBouUfL6VwW49vCks1hgyxrPHkN8jNNdWTTk g->G
|
||||||
|
var key = "L5G9E16m5zEBZqQgMBouUfL6VwW49vCks1hgyxrPHkN8jNNdWTTk";
|
||||||
|
var btcKey = new Bitcoin.ECKey(key);
|
||||||
|
if (btcKey.error.toString().indexOf("failed") == -1) { //Checksum validation failed!
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
},
|
||||||
|
// test range of valid private key values for the secp256k1 curve, when specified in hex is
|
||||||
|
// [0x1, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140]
|
||||||
|
testBigIntegerZeroShouldSetError: function () {
|
||||||
|
var key = "0000000000000000000000000000000000000000000000000000000000000000";
|
||||||
|
var btcKey = new Bitcoin.ECKey(key);
|
||||||
|
if (btcKey.error == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
},
|
||||||
|
testBigIntegerOutOfCurveRangeShouldSetError1: function () {
|
||||||
|
var key = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141";
|
||||||
|
var btcKey = new Bitcoin.ECKey(key);
|
||||||
|
if (btcKey.error == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
testBigIntegerOutOfCurveRangeShouldSetError2: function () {
|
||||||
|
var key = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364142";
|
||||||
|
var btcKey = new Bitcoin.ECKey(key);
|
||||||
|
if (btcKey.error == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
testBigIntegerOutOfCurveRangeShouldSetError3: function () {
|
||||||
|
var key = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
|
||||||
|
var btcKey = new Bitcoin.ECKey(key);
|
||||||
|
if (btcKey.error == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
asynchronousTests: {
|
asynchronousTests: {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
-----BEGIN PGP SIGNATURE-----
|
-----BEGIN PGP SIGNATURE-----
|
||||||
Version: GnuPG v1
|
Version: GnuPG v1
|
||||||
|
|
||||||
iQEcBAABAgAGBQJXuj/DAAoJEIdJe5Fjl09axyIIAJSBaV3/yIX0oTVrvhbdLZrv
|
iQEcBAABAgAGBQJYOz47AAoJEIdJe5Fjl09ateQIANi2qaAdLvTsslWSUtLH7fn5
|
||||||
Odno0yBfsmQZNWKAKeQH1dp4FQ82w+9hDSQUczyj6kKfENhlnk+h6aiIXLcDXmth
|
1Ywej5Dm+qX/TuzIoQ/eAIAKtrJe3KiLioRONDbMqDMovuseQUDB6FBYOlhOSHUd
|
||||||
7KFbEN2UhsuWW6wfvw5/FqUMnSoqGBAVBBpNi/ZnUxyYlZPDR7eyMJy+vfSQ1leN
|
636Lwjs/aZW+weEgLnCi54JUj4/T/aaYZrQfzAvSFbj6G3mrc38xtB1anKJ6JmX0
|
||||||
27p2OIlusN30mCR8b32fQ8MOqovKsR4Jx+eGjRsk2aKcSOywE+08rRx9ATISXML8
|
W482dWJR0+Ew0qB3419DKUtHUf8DjTlPT093H8HCb+DvCeWTxansnGXzAswxEJus
|
||||||
aaLQBAPjKgmJGUdWVma+qACJO5qcff7IaxOpXACcylVz3W0oDiPD6tWqT+6tnSNa
|
yio7wUnGNaB9/rcVncU1dUHYsnb0hkstIwmlIIKcgPV/siDWCPXcigTI0IFSRoOW
|
||||||
ZpwoJDVkJFTuawcrbrBxTm6Qbh6Dfn/IaEMlRleFT4iqBVk55nKC85EL+JcRXBU=
|
SrA+W9E5hWWxSYzzrzbW3iVJksT97ULXQOhzr3hy0ulUzTfqLZJmgNslfdfM3IU=
|
||||||
=c3ih
|
=sgFZ
|
||||||
-----END PGP SIGNATURE-----
|
-----END PGP SIGNATURE-----
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"name": "bitaddress.org",
|
"name": "bitaddress.org",
|
||||||
"version": "3.2.2",
|
"version": "3.2.3",
|
||||||
"sha1sum": "324a332b3964f1631a4fb6e070b7f5748e5672f8",
|
"sha1sum": "b8f7d12ddfef6561603f24a20478fad56abaca49",
|
||||||
"sha256sum": "f4d047c264a2b71946de319482a9365e56d8d7289dd85a352da3b1448b7647df",
|
"sha256sum": "c9a0bb3ed50aa75a5ae9c606d81e3fd41a4ff686ad38ad5379e2402f481e79a4",
|
||||||
"description": "Open Source JavaScript Client-Side Bitcoin Wallet Generator",
|
"description": "Open Source JavaScript Client-Side Bitcoin Wallet Generator",
|
||||||
"main": "Gruntfile.js",
|
"main": "Gruntfile.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -90,19 +90,23 @@ Bitcoin.ECKey = (function () {
|
||||||
this.priv = BigInteger.fromByteArrayUnsigned(input);
|
this.priv = BigInteger.fromByteArrayUnsigned(input);
|
||||||
} else if ("string" == typeof input) {
|
} else if ("string" == typeof input) {
|
||||||
var bytes = null;
|
var bytes = null;
|
||||||
if (ECKey.isWalletImportFormat(input)) {
|
try{
|
||||||
bytes = ECKey.decodeWalletImportFormat(input);
|
if (ECKey.isWalletImportFormat(input)) {
|
||||||
} else if (ECKey.isCompressedWalletImportFormat(input)) {
|
bytes = ECKey.decodeWalletImportFormat(input);
|
||||||
bytes = ECKey.decodeCompressedWalletImportFormat(input);
|
} else if (ECKey.isCompressedWalletImportFormat(input)) {
|
||||||
this.compressed = true;
|
bytes = ECKey.decodeCompressedWalletImportFormat(input);
|
||||||
} else if (ECKey.isMiniFormat(input)) {
|
this.compressed = true;
|
||||||
bytes = Crypto.SHA256(input, { asBytes: true });
|
} else if (ECKey.isMiniFormat(input)) {
|
||||||
} else if (ECKey.isHexFormat(input)) {
|
bytes = Crypto.SHA256(input, { asBytes: true });
|
||||||
bytes = Crypto.util.hexToBytes(input);
|
} else if (ECKey.isHexFormat(input)) {
|
||||||
} else if (ECKey.isBase64Format(input)) {
|
bytes = Crypto.util.hexToBytes(input);
|
||||||
bytes = Crypto.util.base64ToBytes(input);
|
} else if (ECKey.isBase64Format(input)) {
|
||||||
|
bytes = Crypto.util.base64ToBytes(input);
|
||||||
|
}
|
||||||
|
} catch (exc1) {
|
||||||
|
this.setError(exc1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ECKey.isBase6Format(input)) {
|
if (ECKey.isBase6Format(input)) {
|
||||||
this.priv = new BigInteger(input, 6);
|
this.priv = new BigInteger(input, 6);
|
||||||
} else if (bytes == null || bytes.length != 32) {
|
} else if (bytes == null || bytes.length != 32) {
|
||||||
|
@ -114,7 +118,21 @@ Bitcoin.ECKey = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.compressed = (this.compressed == undefined) ? !!ECKey.compressByDefault : this.compressed;
|
this.compressed = (this.compressed == undefined) ? !!ECKey.compressByDefault : this.compressed;
|
||||||
KeyPool.push(this);
|
try {
|
||||||
|
// check not zero
|
||||||
|
if (this.priv != null && BigInteger.ZERO.compareTo(this.priv) == 0) this.setError("Error: BigInteger equal to zero.");
|
||||||
|
// valid range [0x1, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140])
|
||||||
|
var hexKeyRangeLimit = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140";
|
||||||
|
var rangeLimitBytes = Crypto.util.hexToBytes(hexKeyRangeLimit);
|
||||||
|
var limitBigInt = BigInteger.fromByteArrayUnsigned(rangeLimitBytes);
|
||||||
|
if (this.priv != null && limitBigInt.compareTo(this.priv) < 0) this.setError("Error: BigInteger outside of curve range.")
|
||||||
|
|
||||||
|
if (this.priv != null) {
|
||||||
|
KeyPool.push(this);
|
||||||
|
}
|
||||||
|
} catch (exc2) {
|
||||||
|
this.setError(exc2);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ECKey.privateKeyPrefix = 0x80; // mainnet 0x80 testnet 0xEF
|
ECKey.privateKeyPrefix = 0x80; // mainnet 0x80 testnet 0xEF
|
||||||
|
@ -124,6 +142,15 @@ Bitcoin.ECKey = (function () {
|
||||||
*/
|
*/
|
||||||
ECKey.compressByDefault = false;
|
ECKey.compressByDefault = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether the public key should be returned compressed or not.
|
||||||
|
*/
|
||||||
|
ECKey.prototype.setError = function (err) {
|
||||||
|
this.error = err;
|
||||||
|
this.priv = null;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether the public key should be returned compressed or not.
|
* Set whether the public key should be returned compressed or not.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -50,7 +50,10 @@
|
||||||
|
|
||||||
keyToECKeyWithBrain: function (key) {
|
keyToECKeyWithBrain: function (key) {
|
||||||
var btcKey = new Bitcoin.ECKey(key);
|
var btcKey = new Bitcoin.ECKey(key);
|
||||||
if (btcKey.priv == null) {
|
if (btcKey.error != null) {
|
||||||
|
alert(translator.get("detailalertnotvalidprivatekey") + "\n" + btcKey.error);
|
||||||
|
}
|
||||||
|
else if (btcKey.priv == null) {
|
||||||
// enforce a minimum passphrase length
|
// enforce a minimum passphrase length
|
||||||
if (key.length >= wallets.brainwallet.minPassphraseLength) {
|
if (key.length >= wallets.brainwallet.minPassphraseLength) {
|
||||||
// Deterministic Wallet confirm box to ask if user wants to SHA256 the input to get a private key
|
// Deterministic Wallet confirm box to ask if user wants to SHA256 the input to get a private key
|
||||||
|
|
|
@ -837,7 +837,64 @@
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
},
|
||||||
|
|
||||||
|
// test checksum exceptions
|
||||||
|
testUncompressedWifShouldFailChecksum: function () {
|
||||||
|
// original key: 5KjQAHniFiy18SU7eenyJ9EPYUkjrbiBPfDqw987QjT5vehVQZV K->k
|
||||||
|
var key = "5kjQAHniFiy18SU7eenyJ9EPYUkjrbiBPfDqw987QjT5vehVQZV";
|
||||||
|
var btcKey = new Bitcoin.ECKey(key);
|
||||||
|
if (btcKey.error.toString().indexOf("failed") == -1) { //Checksum validation failed!
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
},
|
||||||
|
testCompressedWifShouldFailChecksum: function () {
|
||||||
|
// original key: L5g9E16m5zEBZqQgMBouUfL6VwW49vCks1hgyxrPHkN8jNNdWTTk g->G
|
||||||
|
var key = "L5G9E16m5zEBZqQgMBouUfL6VwW49vCks1hgyxrPHkN8jNNdWTTk";
|
||||||
|
var btcKey = new Bitcoin.ECKey(key);
|
||||||
|
if (btcKey.error.toString().indexOf("failed") == -1) { //Checksum validation failed!
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
},
|
||||||
|
// test range of valid private key values for the secp256k1 curve, when specified in hex is
|
||||||
|
// [0x1, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140]
|
||||||
|
testBigIntegerZeroShouldSetError: function () {
|
||||||
|
var key = "0000000000000000000000000000000000000000000000000000000000000000";
|
||||||
|
var btcKey = new Bitcoin.ECKey(key);
|
||||||
|
if (btcKey.error == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
},
|
||||||
|
testBigIntegerOutOfCurveRangeShouldSetError1: function () {
|
||||||
|
var key = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141";
|
||||||
|
var btcKey = new Bitcoin.ECKey(key);
|
||||||
|
if (btcKey.error == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
testBigIntegerOutOfCurveRangeShouldSetError2: function () {
|
||||||
|
var key = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364142";
|
||||||
|
var btcKey = new Bitcoin.ECKey(key);
|
||||||
|
if (btcKey.error == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
testBigIntegerOutOfCurveRangeShouldSetError3: function () {
|
||||||
|
var key = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
|
||||||
|
var btcKey = new Bitcoin.ECKey(key);
|
||||||
|
if (btcKey.error == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
asynchronousTests: {
|
asynchronousTests: {
|
||||||
|
|
Loading…
Add table
Reference in a new issue