0

in bip143 thet define a witness signature. In the first example there is a witness broken down

witness    00
               02 47304402203609e17b84f6a7d30c80bfa610b5b4542f32a8a0d5447a12fb1366d7f01cc44a0220573a954c4518331561406f90300e8f3358f51928d43c212a8caed02de67eebee01 21025476c2e83188368da1ff3e292e7acafcdb3566bb0ad253f62fc70f07aeee6357

this formatting doesn't appear to be defined anywhere in this document? my question is specifically

  1. what is the entire second piece "21025476c2e83188368da1ff3e292e7acafcdb3566bb0ad253f62fc70f07aeee6357"
  2. the first part is the signature but what are the extra bytes on the front and end specifically 0x47 and 0x01
  3. Most importantly the signature is too long?! it is 70 bytes instead of 64. "304402203609e17b84f6a7d30c80bfa610b5b4542f32a8a0d5447a12fb1366d7f01cc44a0220573a954c4518331561406f90300e8f3358f51928d43c212a8caed02de67eebee" I was able to take the example private key, public key, and sighash and sign and verify so I know they are good, unless they aren't using SECP256k1 but that doesn't appear to be specified anywhere?

Thank you a lot in advance!!

1 Answer 1

1

this formatting doesn't appear to be defined anywhere in this document?

The formatting follows the standard Bitcoin script. The main difference between the witness stack and traditional Bitcoin script is that instead of pushing things to the stack via a script, the stack is just provided. So all of the encodings are just as if it were a Bitcoin script.

what is the entire second piece "21025476c2e83188368da1ff3e292e7acafcdb3566bb0ad253f62fc70f07aeee6357"

That is the public key, prepended with it's length.

the first part is the signature but what are the extra bytes on the front and end specifically 0x47 and 0x01

0x47 is the length of the signature, including the extra byte on the end

0x01 is a Bitcoin specific byte called the sighash type. This as an enum that indicates what data needs to be included in the message that is hashed for the signature, aka the sighash.

Most importantly the signature is too long?! it is 70 bytes instead of 64.

No, this signature is DER encoded, so there ends up being extra bytes to indicate type and length.

1
  • 1
    You a scholar and saint sir! Thank you again!
    – noone392
    Commented Jun 17, 2021 at 2:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.