-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Hi!
I found a small bug in the message signing library:
Background:
As defined by BIP 137 (and originally in the Satoshi client, now known as Bitcoin Core) the signature for a Bitcoin signed message always must be exactly 65 bytes long:
1 byte header, containing the recId32 byte r-value32 byte s-value
Bug:
The signMessage() method sometimes returns a signature shorter then 65 bytes (which renders the signature invalid).
Reason:
- The signature (consisting of
rands) is calculated correctly - But when encoding the signature here in signature.dart the two values
randsare encoded as hexadecimal Strings, using the methodbigIntToHex(..)which might return Strings shorter than 32 bytes, whenever the hexadecimal representation ofrorshas 2 or more leading zeros (i.e. whenever one of the numbers is shorter then 249 bits).
--> The resulting signature is then invalid, as by definition r and s MUST BE encoded as 32 byte values (as there is no field delimiter between the 2 values, there is no other way to tell where r ends and s begins.
Solution:
- In signature.dart, when ecoding the signature here take care that the values are always encoded in 32 bytes (even if that means that leading zeros must be added).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels