Compressed pubkey output is confirmed working, remove TODO, add comments.

This commit is contained in:
justmoon 2012-04-07 02:02:21 +02:00
parent d03e489913
commit faa10f0f6a

View file

@ -24,12 +24,17 @@ ECPointFp.prototype.getEncoded = function (compressed) {
if (compressed) { if (compressed) {
if (y.isEven()) { if (y.isEven()) {
// Compressed even pubkey
// M = 02 || X
enc.unshift(0x02); enc.unshift(0x02);
} else { } else {
// Compressed uneven pubkey
// M = 03 || X
enc.unshift(0x03); enc.unshift(0x03);
} }
// TODO: Implement
} else { } else {
// Uncompressed pubkey
// M = 04 || X || Y
enc.unshift(0x04); enc.unshift(0x04);
enc = enc.concat(integerToBytes(y, 32)); enc = enc.concat(integerToBytes(y, 32));
} }