Merge af91e78b98
into ca08d645a4
This commit is contained in:
commit
63bc9f7902
9 changed files with 270 additions and 63 deletions
|
@ -28,8 +28,17 @@ END USER NOTES:
|
|||
|
||||
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
|
||||
bitaddress.org-v3.2.2-SHA256-f4d047c264a2b71946de319482a9365e56d8d7289dd85a352da3b1448b7647df.html
|
||||
- version bump for unix line endings
|
||||
|
||||
2016-07-31: status ACTIVE
|
||||
bitaddress.org-v3.2.1-SHA256-.html
|
||||
bitaddress.org-v3.2.1-SHA256-42c3bcb643c451689e5bd1499ed4b516be2da06d2fe3886b0dd15b8fc2525ecd.html
|
||||
- BigInteger modInverse should be positive
|
||||
- throw if modInverse 0
|
||||
- improve BigInteger constructor so that it works if caller forgets 'new'
|
||||
|
|
|
@ -31,6 +31,23 @@ END USER NOTES:
|
|||
|
||||
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
|
||||
bitaddress.org-v3.2.2-SHA256-f4d047c264a2b71946de319482a9365e56d8d7289dd85a352da3b1448b7647df.html
|
||||
- version bump for unix line endings
|
||||
|
||||
2016-07-31: status ACTIVE
|
||||
bitaddress.org-v3.2.1-SHA256-42c3bcb643c451689e5bd1499ed4b516be2da06d2fe3886b0dd15b8fc2525ecd.html
|
||||
- BigInteger modInverse should be positive
|
||||
- throw if modInverse 0
|
||||
- improve BigInteger constructor so that it works if caller forgets 'new'
|
||||
- add unit tests for BigInteger
|
||||
- thanks to dooglus, jprichardson, dcousens
|
||||
|
||||
2016-02-19: status ACTIVE
|
||||
bitaddress.org-v3.2.0-SHA256-ad4fd171c647772aa76d0ce828731b01ca586596275d43a94008766b758e8736.html
|
||||
- switch languages without full page load
|
||||
|
@ -321,11 +338,11 @@ bitaddress.org-v0.1-SHA1-f40e706490f3eb2be56c31ddbf4c8646cd51ef40.html
|
|||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQEcBAEBAgAGBQJWx8DZAAoJEIdJe5Fjl09aFeEH/2wrQWW3YrDP1LuMfOEhydJ6
|
||||
4DsGN1hBRqR1qVzGWxFjwcHLrY95C0u+P0HI82riQF7+q+IKwU9KJWU2+ryfBTAG
|
||||
Px8CTMw2kL6lgk854UqbpdLvLiZUEgjpyiF2mtptlH4ruVFLzHmVe9CbjLU7GPOK
|
||||
Nni8oeYH5LWf5VUpSAZh6sGe39vfMQuEtREnpBcP+aJM8Mp5jwKHz2payWTNaTSa
|
||||
UXoYqY/ehQho3ILm0a5lEkGFyJC3ObJXRSiErGucFBDKM0SITlREfFEQDcRMvmrZ
|
||||
JaWrLi+dVmbMXXEVJZSoed5i1cOLA+byeay3UcDXcmz53PIAhSrZWFfMv22Re6M=
|
||||
=FiVM
|
||||
iQEcBAEBAgAGBQJYOz4QAAoJEIdJe5Fjl09ar74IAMiOx4/c/q7UaTEjlAQDmseh
|
||||
CxSRHHQUwGaZG6z9pwt9ecdKht4t3Y2+CufcPmoV7A1Vq2EtoXFxEibwDwLuTzYL
|
||||
pqcUZCV+fwd0PGGz69mL0iGrMJHy0lhBZb4lb+2P6fXz4D35n1Dnq1jHGAOzcFEF
|
||||
B2++ja2s8QJwd1S1xtOhBshVZDTHc8YYgv1JJSKDpJNeGSFHx9IapOv4ydETbhfT
|
||||
L7kp9z6TKZ5khkRUCGR2qL4BzlTA/lSDj/cgVb6tRQmIgusRMjvJP076nEqiJ4TX
|
||||
8YZrObi2yXM7bD8iBXIabc3W2r/R9olw+pCxI+ZuFEOU+UVndCRpP7XEMsTp4aw=
|
||||
=/wYY
|
||||
-----END PGP SIGNATURE-----
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
bitaddress.org
|
||||
# bitaddress.org
|
||||
JavaScript Client-Side Bitcoin Wallet Generator
|
||||
|
||||
Now Bitcoin addresses and their corresponding private key can be conveniently
|
||||
|
@ -18,15 +18,21 @@ Please send DONATIONS for this project to Bitcoin Address:
|
|||
1NiNja1bUmhSoTXozBRBEtR8LeF9TGbZBN
|
||||
|
||||
|
||||
END USER NOTES:
|
||||
END USER NOTES:
|
||||
|
||||
1) To print QRCode in IE8 you must enable the "Print Background Colors and
|
||||
Images" checkbox on the "Page Setup" screen.
|
||||
|
||||
2) For Bulk Wallet I recommended using Google Chrome, it's the fastest.
|
||||
|
||||
3) Requires IE8+, Firefox, Chrome or sufficient JavaScript support.
|
||||
|
||||
4) Mobile Safari only works with iPhone4 or newer devices.
|
||||
Older devices timeout while executing JavaScript.
|
||||
|
||||
5) DO NOT use Opera Mini it renders JavaScript output server side, therefore
|
||||
they might record the private key you generated.
|
||||
|
||||
6) Art Wallet does not work properly in IE8 due to CSS limitations.
|
||||
|
||||
|
||||
|
@ -44,15 +50,16 @@ throughout the document along with their licenses. Included JavaScript
|
|||
libraries are separated with HTML script tags.
|
||||
|
||||
Summary of JavaScript functions with a redistributable license:
|
||||
JavaScript function License
|
||||
------------------- --------------
|
||||
Array.prototype.map Public Domain
|
||||
window.Crypto BSD License
|
||||
window.SecureRandom BSD License
|
||||
window.EllipticCurve BSD License
|
||||
window.BigInteger BSD License
|
||||
window.QRCode MIT License
|
||||
window.Bitcoin MIT License
|
||||
|
||||
JavaScript function | License
|
||||
------------------- | --------------
|
||||
Array.prototype.map | Public Domain
|
||||
window.Crypto | BSD License
|
||||
window.SecureRandom | BSD License
|
||||
window.EllipticCurve | BSD License
|
||||
window.BigInteger | BSD License
|
||||
window.QRCode | MIT License
|
||||
window.Bitcoin | MIT License
|
||||
|
||||
The bitaddress.org software is available under The MIT License (MIT)
|
||||
Copyright (c) 2011-2013 bitaddress.org
|
|
@ -5720,19 +5720,23 @@ Bitcoin.ECKey = (function () {
|
|||
this.priv = BigInteger.fromByteArrayUnsigned(input);
|
||||
} else if ("string" == typeof input) {
|
||||
var bytes = null;
|
||||
if (ECKey.isWalletImportFormat(input)) {
|
||||
bytes = ECKey.decodeWalletImportFormat(input);
|
||||
} else if (ECKey.isCompressedWalletImportFormat(input)) {
|
||||
bytes = ECKey.decodeCompressedWalletImportFormat(input);
|
||||
this.compressed = true;
|
||||
} else if (ECKey.isMiniFormat(input)) {
|
||||
bytes = Crypto.SHA256(input, { asBytes: true });
|
||||
} else if (ECKey.isHexFormat(input)) {
|
||||
bytes = Crypto.util.hexToBytes(input);
|
||||
} else if (ECKey.isBase64Format(input)) {
|
||||
bytes = Crypto.util.base64ToBytes(input);
|
||||
try{
|
||||
if (ECKey.isWalletImportFormat(input)) {
|
||||
bytes = ECKey.decodeWalletImportFormat(input);
|
||||
} else if (ECKey.isCompressedWalletImportFormat(input)) {
|
||||
bytes = ECKey.decodeCompressedWalletImportFormat(input);
|
||||
this.compressed = true;
|
||||
} else if (ECKey.isMiniFormat(input)) {
|
||||
bytes = Crypto.SHA256(input, { asBytes: true });
|
||||
} else if (ECKey.isHexFormat(input)) {
|
||||
bytes = Crypto.util.hexToBytes(input);
|
||||
} else if (ECKey.isBase64Format(input)) {
|
||||
bytes = Crypto.util.base64ToBytes(input);
|
||||
}
|
||||
} catch (exc1) {
|
||||
this.setError(exc1);
|
||||
}
|
||||
|
||||
|
||||
if (ECKey.isBase6Format(input)) {
|
||||
this.priv = new BigInteger(input, 6);
|
||||
} else if (bytes == null || bytes.length != 32) {
|
||||
|
@ -5744,7 +5748,21 @@ Bitcoin.ECKey = (function () {
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -5754,6 +5772,15 @@ Bitcoin.ECKey = (function () {
|
|||
*/
|
||||
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.
|
||||
*/
|
||||
|
@ -7033,7 +7060,7 @@ input[type=checkbox] { position: relative; z-index: 20; }
|
|||
<div class="tooltip" id="statusprotocolbad">
|
||||
<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>
|
||||
<a id="statuslabelprotocolbad2" href="https://github.com/pointbiz/bitaddress.org/archive/v3.2.1.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>
|
||||
<br /><br /><input type="button" value="OK" class="button" id="statusokprotocolbad" onclick="document.getElementById('statusprotocolbad').style.display = 'none';" />
|
||||
</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" id="footerlabeltranslatedby"></span>
|
||||
<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.1.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 class="authorpgp">
|
||||
<span class="item">
|
||||
<a href="CHANGELOG.txt.asc" target="_blank"><span id="footerlabelversion">Version History</span> (3.2.1)</a>
|
||||
<a href="CHANGELOG.txt.asc" target="_blank"><span id="footerlabelversion">Version History</span> (3.2.3)</a>
|
||||
|
||||
</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) {
|
||||
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
|
||||
if (key.length >= wallets.brainwallet.minPassphraseLength) {
|
||||
// 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 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: {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQEcBAABAgAGBQJWx8DzAAoJEIdJe5Fjl09awNYIAIsrdkZJylt01F15y1jy5SUB
|
||||
elatgdvoWuvBtj1toTBknvWs3SrLbAi4OkzIZbZnu/QSf+6BejeGlus1AKJwbQFr
|
||||
srVVdw3x3I9T+mY3GLdrbrAhivulBQhGk+LSyJhp9/tVj6r924kbceK+QtV6GVLs
|
||||
6UXzjejbwoTF51av0n5isuF7tUIUC2cfpgvznSGVFGlUbseByBLIut+X0VgVwa7V
|
||||
zIjnkgI12tiAAWquZtaZ5H5SKcVOQ1+7MqcZ3m9fH7E3+st+xe6JczHIytqu0hVI
|
||||
IXs5TpzzdeXaxEuJPGa7w43M5e6CHKviDT8EjTnc/JBJjBLHymrTAa/jUkQXYaU=
|
||||
=y/7l
|
||||
iQEcBAABAgAGBQJYOz47AAoJEIdJe5Fjl09ateQIANi2qaAdLvTsslWSUtLH7fn5
|
||||
1Ywej5Dm+qX/TuzIoQ/eAIAKtrJe3KiLioRONDbMqDMovuseQUDB6FBYOlhOSHUd
|
||||
636Lwjs/aZW+weEgLnCi54JUj4/T/aaYZrQfzAvSFbj6G3mrc38xtB1anKJ6JmX0
|
||||
W482dWJR0+Ew0qB3419DKUtHUf8DjTlPT093H8HCb+DvCeWTxansnGXzAswxEJus
|
||||
yio7wUnGNaB9/rcVncU1dUHYsnb0hkstIwmlIIKcgPV/siDWCPXcigTI0IFSRoOW
|
||||
SrA+W9E5hWWxSYzzrzbW3iVJksT97ULXQOhzr3hy0ulUzTfqLZJmgNslfdfM3IU=
|
||||
=sgFZ
|
||||
-----END PGP SIGNATURE-----
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"name": "bitaddress.org",
|
||||
"version": "3.2.1",
|
||||
"sha1sum": "",
|
||||
"sha256sum": "",
|
||||
"version": "3.2.3",
|
||||
"sha1sum": "b8f7d12ddfef6561603f24a20478fad56abaca49",
|
||||
"sha256sum": "c9a0bb3ed50aa75a5ae9c606d81e3fd41a4ff686ad38ad5379e2402f481e79a4",
|
||||
"description": "Open Source JavaScript Client-Side Bitcoin Wallet Generator",
|
||||
"main": "Gruntfile.js",
|
||||
"dependencies": {
|
||||
|
@ -27,7 +27,7 @@
|
|||
],
|
||||
"author": "pointbiz",
|
||||
"license": "MIT",
|
||||
"readmeFilename": "README",
|
||||
"readmeFilename": "README.md",
|
||||
"gitHead": "d77aaf687fca1f0e28388b0a8de5eb3d89d4fad3",
|
||||
"bugs": {
|
||||
"url": "https://github.com/pointbiz/bitaddress.org/issues"
|
||||
|
|
|
@ -90,19 +90,23 @@ Bitcoin.ECKey = (function () {
|
|||
this.priv = BigInteger.fromByteArrayUnsigned(input);
|
||||
} else if ("string" == typeof input) {
|
||||
var bytes = null;
|
||||
if (ECKey.isWalletImportFormat(input)) {
|
||||
bytes = ECKey.decodeWalletImportFormat(input);
|
||||
} else if (ECKey.isCompressedWalletImportFormat(input)) {
|
||||
bytes = ECKey.decodeCompressedWalletImportFormat(input);
|
||||
this.compressed = true;
|
||||
} else if (ECKey.isMiniFormat(input)) {
|
||||
bytes = Crypto.SHA256(input, { asBytes: true });
|
||||
} else if (ECKey.isHexFormat(input)) {
|
||||
bytes = Crypto.util.hexToBytes(input);
|
||||
} else if (ECKey.isBase64Format(input)) {
|
||||
bytes = Crypto.util.base64ToBytes(input);
|
||||
try{
|
||||
if (ECKey.isWalletImportFormat(input)) {
|
||||
bytes = ECKey.decodeWalletImportFormat(input);
|
||||
} else if (ECKey.isCompressedWalletImportFormat(input)) {
|
||||
bytes = ECKey.decodeCompressedWalletImportFormat(input);
|
||||
this.compressed = true;
|
||||
} else if (ECKey.isMiniFormat(input)) {
|
||||
bytes = Crypto.SHA256(input, { asBytes: true });
|
||||
} else if (ECKey.isHexFormat(input)) {
|
||||
bytes = Crypto.util.hexToBytes(input);
|
||||
} else if (ECKey.isBase64Format(input)) {
|
||||
bytes = Crypto.util.base64ToBytes(input);
|
||||
}
|
||||
} catch (exc1) {
|
||||
this.setError(exc1);
|
||||
}
|
||||
|
||||
|
||||
if (ECKey.isBase6Format(input)) {
|
||||
this.priv = new BigInteger(input, 6);
|
||||
} else if (bytes == null || bytes.length != 32) {
|
||||
|
@ -114,7 +118,21 @@ Bitcoin.ECKey = (function () {
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -124,6 +142,15 @@ Bitcoin.ECKey = (function () {
|
|||
*/
|
||||
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.
|
||||
*/
|
||||
|
|
|
@ -50,7 +50,10 @@
|
|||
|
||||
keyToECKeyWithBrain: function (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
|
||||
if (key.length >= wallets.brainwallet.minPassphraseLength) {
|
||||
// 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 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: {
|
||||
|
|
Loading…
Add table
Reference in a new issue