Merge pull request #1258 from braydonf/bug/double-error
Removed double errors in publickey. Fixes #1256
This commit is contained in:
commit
37d0e1f956
|
@ -39,7 +39,7 @@ var PublicKey = function PublicKey(data, extra) {
|
||||||
return new PublicKey(data, extra);
|
return new PublicKey(data, extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
$.checkArgument(data, new TypeError('First argument is required, please include public key data.'));
|
$.checkArgument(data, 'First argument is required, please include public key data.');
|
||||||
|
|
||||||
if (data instanceof PublicKey) {
|
if (data instanceof PublicKey) {
|
||||||
// Return copy, but as it's an immutable object, return same argument
|
// Return copy, but as it's an immutable object, return same argument
|
||||||
|
@ -134,8 +134,7 @@ PublicKey._isJSON = function(json) {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
PublicKey._transformPrivateKey = function(privkey) {
|
PublicKey._transformPrivateKey = function(privkey) {
|
||||||
$.checkArgument(PublicKey._isPrivateKey(privkey),
|
$.checkArgument(PublicKey._isPrivateKey(privkey), 'Must be an instance of PrivateKey');
|
||||||
new TypeError('Must be an instance of PrivateKey'));
|
|
||||||
var info = {};
|
var info = {};
|
||||||
info.point = Point.getG().mul(privkey.bn);
|
info.point = Point.getG().mul(privkey.bn);
|
||||||
info.compressed = privkey.compressed;
|
info.compressed = privkey.compressed;
|
||||||
|
@ -154,7 +153,7 @@ PublicKey._transformPrivateKey = function(privkey) {
|
||||||
PublicKey._transformDER = function(buf, strict) {
|
PublicKey._transformDER = function(buf, strict) {
|
||||||
/* jshint maxstatements: 30 */
|
/* jshint maxstatements: 30 */
|
||||||
/* jshint maxcomplexity: 12 */
|
/* jshint maxcomplexity: 12 */
|
||||||
$.checkArgument(PublicKey._isBuffer(buf), new TypeError('Must be a hex buffer of DER encoded public key'));
|
$.checkArgument(PublicKey._isBuffer(buf), 'Must be a hex buffer of DER encoded public key');
|
||||||
var info = {};
|
var info = {};
|
||||||
|
|
||||||
strict = _.isUndefined(strict) ? true : strict;
|
strict = _.isUndefined(strict) ? true : strict;
|
||||||
|
@ -199,8 +198,7 @@ PublicKey._transformDER = function(buf, strict) {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
PublicKey._transformX = function(odd, x) {
|
PublicKey._transformX = function(odd, x) {
|
||||||
$.checkArgument(typeof odd === 'boolean',
|
$.checkArgument(typeof odd === 'boolean', 'Must specify whether y is odd or not (true or false)');
|
||||||
new TypeError('Must specify whether y is odd or not (true or false)'));
|
|
||||||
var info = {};
|
var info = {};
|
||||||
info.point = Point.fromX(odd, x);
|
info.point = Point.fromX(odd, x);
|
||||||
return info;
|
return info;
|
||||||
|
@ -213,8 +211,7 @@ PublicKey._transformX = function(odd, x) {
|
||||||
* @returns {PublicKey} A new valid instance of PublicKey
|
* @returns {PublicKey} A new valid instance of PublicKey
|
||||||
*/
|
*/
|
||||||
PublicKey.fromJSON = function(json) {
|
PublicKey.fromJSON = function(json) {
|
||||||
$.checkArgument(PublicKey._isJSON(json),
|
$.checkArgument(PublicKey._isJSON(json), 'Must be a valid JSON string or plain object');
|
||||||
new TypeError('Must be a valid JSON string or plain object'));
|
|
||||||
return new PublicKey(json);
|
return new PublicKey(json);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -244,7 +241,7 @@ PublicKey._transformJSON = function(json) {
|
||||||
* @returns {PublicKey} A new valid instance of PublicKey
|
* @returns {PublicKey} A new valid instance of PublicKey
|
||||||
*/
|
*/
|
||||||
PublicKey.fromPrivateKey = function(privkey) {
|
PublicKey.fromPrivateKey = function(privkey) {
|
||||||
$.checkArgument(PublicKey._isPrivateKey(privkey), new TypeError('Must be an instance of PrivateKey'));
|
$.checkArgument(PublicKey._isPrivateKey(privkey), 'Must be an instance of PrivateKey');
|
||||||
var info = PublicKey._transformPrivateKey(privkey);
|
var info = PublicKey._transformPrivateKey(privkey);
|
||||||
return new PublicKey(info.point, {
|
return new PublicKey(info.point, {
|
||||||
compressed: info.compressed,
|
compressed: info.compressed,
|
||||||
|
@ -259,8 +256,7 @@ PublicKey.fromPrivateKey = function(privkey) {
|
||||||
* @returns {PublicKey} A new valid instance of PublicKey
|
* @returns {PublicKey} A new valid instance of PublicKey
|
||||||
*/
|
*/
|
||||||
PublicKey.fromDER = PublicKey.fromBuffer = function(buf, strict) {
|
PublicKey.fromDER = PublicKey.fromBuffer = function(buf, strict) {
|
||||||
$.checkArgument(PublicKey._isBuffer(buf),
|
$.checkArgument(PublicKey._isBuffer(buf), 'Must be a hex buffer of DER encoded public key');
|
||||||
new TypeError('Must be a hex buffer of DER encoded public key'));
|
|
||||||
var info = PublicKey._transformDER(buf, strict);
|
var info = PublicKey._transformDER(buf, strict);
|
||||||
return new PublicKey(info.point, {
|
return new PublicKey(info.point, {
|
||||||
compressed: info.compressed
|
compressed: info.compressed
|
||||||
|
@ -275,8 +271,7 @@ PublicKey.fromDER = PublicKey.fromBuffer = function(buf, strict) {
|
||||||
* @returns {PublicKey} A new valid instance of PublicKey
|
* @returns {PublicKey} A new valid instance of PublicKey
|
||||||
*/
|
*/
|
||||||
PublicKey.fromPoint = function(point, compressed) {
|
PublicKey.fromPoint = function(point, compressed) {
|
||||||
$.checkArgument(point instanceof Point,
|
$.checkArgument(point instanceof Point, 'First argument must be an instance of Point.');
|
||||||
new TypeError('First argument must be an instance of Point.'));
|
|
||||||
return new PublicKey(point, {
|
return new PublicKey(point, {
|
||||||
compressed: compressed
|
compressed: compressed
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue