From 29ad6b692e5bac9a1282f3dcf05222c79f086fc2 Mon Sep 17 00:00:00 2001 From: Andreas Brekken Date: Tue, 11 Mar 2014 18:25:36 +0100 Subject: [PATCH] Message signing does not work with compressed keys. ref #61 --- test/message.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/message.js b/test/message.js index 553cd13..fd00fa9 100644 --- a/test/message.js +++ b/test/message.js @@ -30,5 +30,21 @@ describe('Message', function() { var sig = Message.signMessage(key, msg); assert.ok(!Message.verifyMessage(addr, sig, msg)); }) + + it('handles compressed keys', function() { + var key = new ECKey(hexToBytes(priv)); + key.compressed = true + + var addr = key.getBitcoinAddress().toString() + + var sig = Message.signMessage(key, msg); + assert.ok(Message.verifyMessage(addr, sig, msg)); + + // wrong message + assert.ok(!Message.verifyMessage(addr, sig, 'not foobar')); + + // wrong address + assert.ok(!Message.verifyMessage('1MsHWS1BnwMc3tLE8G35UXsS58fKipzB7a', sig, msg)); + }) }) })