From 1f0fb902137c77b607e26ec1de97269f88049a19 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Wed, 9 Apr 2014 18:06:50 +1000 Subject: [PATCH] Pads zeros in toBytes output, fixes #121 --- src/eckey.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/eckey.js b/src/eckey.js index c5a35bd..6c73877 100644 --- a/src/eckey.js +++ b/src/eckey.js @@ -85,6 +85,10 @@ ECKey.prototype.toHex = function() { ECKey.prototype.toBytes = function() { var bytes = this.priv.toByteArrayUnsigned() + + // ensure 32 bytes + while (bytes.length < 32) bytes.unshift(0) + if (this.compressed) bytes.push(1) return bytes }