|
|
@ -1,5 +1,6 @@ |
|
|
|
var ECKey = require('../../browser/vendor-bundle.js').ECKey; |
|
|
|
var buffertools = require('buffertools'); |
|
|
|
var SecureRandom = require('../SecureRandom'); |
|
|
|
|
|
|
|
var Key = function() { |
|
|
|
this._pub = null; |
|
|
@ -33,13 +34,17 @@ Object.defineProperty(Key.prototype, 'public', { |
|
|
|
}); |
|
|
|
|
|
|
|
Key.generateSync = function() { |
|
|
|
var eck = new ECKey(); |
|
|
|
var privbuf = SecureRandom.getRandomBuffer(32); |
|
|
|
var privhex = privbuf.toString('hex'); |
|
|
|
var eck = new ECKey(privhex); |
|
|
|
eck.setCompressed(true); |
|
|
|
var pub = eck.getPub(); |
|
|
|
|
|
|
|
var ret = new Key(); |
|
|
|
ret.private = new Buffer(eck.priv.toByteArrayUnsigned()); |
|
|
|
ret.public = new Buffer(pub); |
|
|
|
ret = new Key(); |
|
|
|
ret.private = privbuf; |
|
|
|
ret.compressed = true; |
|
|
|
ret.public = new Buffer(eck.getPub()); |
|
|
|
|
|
|
|
return ret; |
|
|
|
}; |
|
|
|
|
|
|
|