Closed pyramation closed 4 years ago
I made a test repo for anyone to try and verify or reproduce: https://github.com/pyramation/bitcoinjs-message-issue-24
looking at fixtures, and trying to guess a little, is there some mixup w compressed or uncompressed happening?
If I set compressed
manually to false
, it works. Is this an issue with bitcoinjs or message?
describe(
'straight from the docs', () => {
it('example from doc fails', () => {
const keyPair = bitcoin.ECPair.fromWIF('L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1')
var privateKey = keyPair.privateKey
var message = 'This is an example of a signed message.'
var signature = bitcoinMessage.sign(message, privateKey, keyPair.compressed)
console.log(signature.toString('base64'))
// => 'G9L5yLFjti0QTHhPyFrZCT1V/MMnBtXKmoiKDZ78NDBjERki6ZTQZdSMCtkgoNmp17By9ItJr8o7ChX0XxY91nk='
expect(signature.toString('base64')).toEqual(
'G9L5yLFjti0QTHhPyFrZCT1V/MMnBtXKmoiKDZ78NDBjERki6ZTQZdSMCtkgoNmp17By9ItJr8o7ChX0XxY91nk=')
})
it('compressed set to false works', () => {
const keyPair = bitcoin.ECPair.fromWIF('L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1')
var privateKey = keyPair.privateKey
var message = 'This is an example of a signed message.'
var signature = bitcoinMessage.sign(message, privateKey, false)
console.log(signature.toString('base64'))
// => 'G9L5yLFjti0QTHhPyFrZCT1V/MMnBtXKmoiKDZ78NDBjERki6ZTQZdSMCtkgoNmp17By9ItJr8o7ChX0XxY91nk='
expect(signature.toString('base64')).toEqual(
'G9L5yLFjti0QTHhPyFrZCT1V/MMnBtXKmoiKDZ78NDBjERki6ZTQZdSMCtkgoNmp17By9ItJr8o7ChX0XxY91nk=')
})
}
)
Thanks for the catch. Someone asked us to change the README examples to compressed but I forgot to change the signatures themselves.
If you could make a PR I'll merge it.
Fixed in a5107632abe1477b337adffd1f4cd69652a2cbbf
Directly from the docs, I've created a test case. Instead of the expected value, I'm getting
H9L5yLFjti0QTHhPyFrZCT1V/MMnBtXKmoiKDZ78NDBjERki6ZTQZdSMCtkgoNmp17By9ItJr8o7ChX0XxY91nk=
, so theG
and theH
are the only difference.Did I do anything wrong?