Closed ghost closed 6 years ago
the first byte is a flag, followed by 32byte R and 32byte S
The purpose of the flag is to allow reconstructing the address from the signature. The meaning is somewhat obscure; i'm recovering it from the code (and asking my colleagues :) ).
basically:
27
+ <key recovery bit>
+ <4 if compressed key>
+ <4 if P2SH-segwit>
+ <8 if native segwit>
where:
So:
and the resulting flag is 27 + <key recovery bit> + <address type>
. This is enough information to recover the btc address used to sign this message.
Thank you! This is very helpful. I was under the impression that R and S could be different than 32 bytes, but perhaps that only in the DER encoding? In any case, I will continue to play around and see if what I want to do works. Thank you again.
Hello,
I am playing around with the
sign_message
function and am trying to decipher the output. I am assuming that this is an ecdsa (secp256k1) signature, but is that even correct? The first byte seems like a length, perhaps of r? Followed by r, then by s? But this does not seem to be the case. Any help would be appreciated.Thank you!