|
|
@ -6,7 +6,6 @@ var Point = require('./crypto/point'); |
|
|
|
var JSUtil = require('./util/js'); |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* Instantiate a PublicKey from a 'PrivateKey', 'Point', 'string', 'Buffer'. |
|
|
|
* |
|
|
|
* @example |
|
|
@ -137,7 +136,6 @@ PublicKey._transformDER = function(buf){ |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* Internal function to transform X into a public key point |
|
|
|
* |
|
|
|
* @param {Boolean} odd - If the point is above or below the x axis |
|
|
@ -155,7 +153,6 @@ PublicKey._transformX = function(odd, x){ |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* Instantiate a PublicKey from JSON |
|
|
|
* |
|
|
|
* @param {String} json - A JSON string |
|
|
@ -172,7 +169,6 @@ PublicKey.fromJSON = function(json) { |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* Instantiate a PublicKey from a PrivateKey |
|
|
|
* |
|
|
|
* @param {PrivateKey} privkey - An instance of PrivateKey |
|
|
@ -184,7 +180,6 @@ PublicKey.fromPrivateKey = function(privkey) { |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* Instantiate a PublicKey from a Buffer |
|
|
|
* |
|
|
|
* @param {Buffer} buf - A DER hex buffer |
|
|
@ -196,7 +191,6 @@ PublicKey.fromBuffer = function(buf) { |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* Instantiate a PublicKey from a Point |
|
|
|
* |
|
|
|
* @param {Point} point - A Point instance |
|
|
@ -210,7 +204,6 @@ PublicKey.fromPoint = function(point, compressed){ |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* Instantiate a PublicKey from a DER Buffer |
|
|
|
* |
|
|
|
* @param {Buffer} buf - A DER Buffer |
|
|
@ -222,7 +215,6 @@ PublicKey.fromDER = function(buf) { |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* Instantiate a PublicKey from a DER hex encoded string |
|
|
|
* |
|
|
|
* @param {String} str - A DER hex string |
|
|
@ -236,7 +228,6 @@ PublicKey.fromString = function(str, encoding) { |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* Instantiate a PublicKey from an X Point |
|
|
|
* |
|
|
|
* @param {Boolean} odd - If the point is above or below the x axis |
|
|
@ -250,7 +241,6 @@ PublicKey.fromX = function(odd, x) { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* Check if there would be any errors when initializing a PublicKey |
|
|
|
* |
|
|
|
* @param {String} data - The encoded data in various formats |
|
|
@ -268,7 +258,6 @@ PublicKey.getValidationError = function(data) { |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* Check if the parameters are valid |
|
|
|
* |
|
|
|
* @param {String} data - The encoded data in various formats |
|
|
@ -280,12 +269,9 @@ PublicKey.isValid = function(data) { |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* Will output the PublicKey to JSON |
|
|
|
* |
|
|
|
* @returns {Object} A JSON object |
|
|
|
* @returns {Object} A plain object of the PublicKey |
|
|
|
*/ |
|
|
|
PublicKey.prototype.toJSON = function() { |
|
|
|
PublicKey.prototype.toObject = function toObject() { |
|
|
|
return { |
|
|
|
x: this.point.getX().toString('hex'), |
|
|
|
y: this.point.getY().toString('hex'), |
|
|
@ -293,8 +279,11 @@ PublicKey.prototype.toJSON = function() { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
PublicKey.prototype.toJSON = function toJSON(){ |
|
|
|
return JSON.stringify(this.toObject()); |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* Will output the PublicKey to a Buffer |
|
|
|
* |
|
|
|
* @returns {Buffer} A DER hex encoded buffer |
|
|
@ -305,7 +294,6 @@ PublicKey.prototype.toBuffer = function() { |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* Will output the PublicKey to a DER Buffer |
|
|
|
* |
|
|
|
* @returns {Buffer} A DER hex encoded buffer |
|
|
@ -338,7 +326,6 @@ PublicKey.prototype.toDER = function(compressed) { |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* Will return an address for the public key |
|
|
|
* |
|
|
|
* @returns {Address} An address generated from the public key |
|
|
@ -348,7 +335,6 @@ PublicKey.prototype.toAddress = function(network) { |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* Will output the PublicKey to a DER encoded hex string |
|
|
|
* |
|
|
|
* @returns {String} A DER hex encoded string |
|
|
@ -359,7 +345,6 @@ PublicKey.prototype.toString = function() { |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* Will return a string formatted for the console |
|
|
|
* |
|
|
|
* @returns {String} Public key |
|
|
|