Browse Source

Corrected encoded form with correct padding. See #1.

hk-custom-address
Stefan Thomas 14 years ago
parent
commit
d7ce1e5db8
  1. 11
      src/ecdsa.js

11
src/ecdsa.js

@ -18,13 +18,7 @@ ECPointFp.prototype.getEncoded = function (compressed) {
var x = this.getX().toBigInteger(); var x = this.getX().toBigInteger();
var y = this.getY().toBigInteger(); var y = this.getY().toBigInteger();
if (compressed) { var enc = integerToBytes(x, 32);
var PC;
}
var len = this.getX().getByteLength();
var enc = integerToBytes(x, len);
if (compressed) { if (compressed) {
if (y.testBit(0)) { if (y.testBit(0)) {
@ -32,9 +26,10 @@ ECPointFp.prototype.getEncoded = function (compressed) {
} else { } else {
enc.unshift(0x03); enc.unshift(0x03);
} }
// TODO: Implement
} else { } else {
enc.unshift(0x04); enc.unshift(0x04);
enc = enc.concat(integerToBytes(y, len)); enc = enc.concat(integerToBytes(y, 32));
} }
return enc; return enc;
}; };

Loading…
Cancel
Save