Adds BI.toPaddedBuffer and toBuffer

This commit is contained in:
Daniel Cousens 2014-04-24 07:22:10 +10:00
parent 596b31b1e1
commit d8883e8d32
8 changed files with 131 additions and 26 deletions

View file

@ -65,13 +65,7 @@ ECKey.prototype.sign = function(hash) {
// Export functions
ECKey.prototype.toBuffer = function() {
var buffer = new Buffer(this.D.toByteArrayUnsigned())
// pad out to atleast 32 bytes
var padded = new Buffer(32 - buffer.length)
padded.fill(0)
return Buffer.concat([padded, buffer])
return this.D.toPaddedBuffer(32)
}
ECKey.prototype.toHex = function() {
return this.toBuffer().toString('hex')