Accord bip66, lenR check bug
guotie opened this issue · comments
if (5 + lenR >= buffer.length) return false
should be
if (5 + lenR > buffer.length) return false
because buffer is slice the last byte.
https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki:
// Make sure the length of the S element is still inside the signature.
if (5 + lenR >= sig.size()) return false;
@guotie can you provide a test fixture?
because buffer is slice the last byte.
What buffer.slice
?
I mean the input param buffer length = origin buffer length - 1, so the condition should be change accord the code :
// Make sure the length of the S element is still inside the signature.
if (5 + lenR >= sig.size()) return false;
@guotie buffer length = origin buffer length - 1
what?
Can you directly link to the code you are querying?
line 16
@guotie I have no idea what you are referring to.
There is no buffer.length - 1
.
There is no buffer.slice
.
If you could provide a test case that shows clearly what isn't working, I'll re-open this issue, but as is, the code appears to be OK.
I don't doubt you might be on to something, but, I can't see based on the hints you are providing 😕 .
Are you saying it should be 4 + lenR
?
yes, I think so
See #12 for working PR, tests needed though