|
|
@ -2,6 +2,7 @@ var ECKey = require('../../browser/vendor-bundle.js').ECKey; |
|
|
|
var SecureRandom = require('../SecureRandom'); |
|
|
|
var Curve = require('../Curve'); |
|
|
|
var bignum = require('bignum'); |
|
|
|
var elliptic = require('elliptic'); |
|
|
|
|
|
|
|
var Key = function() { |
|
|
|
this._pub = null; |
|
|
@ -85,9 +86,17 @@ Key.prototype.regenerateSync = function() { |
|
|
|
throw new Error('Key does not have a private key set'); |
|
|
|
} |
|
|
|
|
|
|
|
var eck = new ECKey(this.private.toString('hex')); |
|
|
|
eck.setCompressed(this._compressed); |
|
|
|
this._pub = new Buffer(eck.getPub()); |
|
|
|
var ec = elliptic.curves.secp256k1; |
|
|
|
var g = ec.g; |
|
|
|
var ecp = ec.g.mul(this.private); |
|
|
|
var x = new bignum(ecp.x.toArray()); |
|
|
|
var y = new bignum(ecp.y.toArray()); |
|
|
|
var p = new Point(x, y); |
|
|
|
if (this.compressed) |
|
|
|
this._pub = p.toCompressedPubKey(); |
|
|
|
else |
|
|
|
this._pub = p.toUncompressedPubKey(); |
|
|
|
|
|
|
|
return this; |
|
|
|
}; |
|
|
|
|
|
|
|