Hot answers tagged

4 votes
Accepted

How do I generate the Bitcoin Cash hash preimage?

Bitcoin Cash uses BIP 143 for signature hash creation. From the BIP: Double SHA256 of the serialization of: 1. nVersion of the transaction (4-byte little endian) 2. hashPrevouts (32-byte ...
user avatar
  • 60.4k
3 votes
Accepted

Why hash witness script instead of pubkey script in signature?

I'm just guessing, but by having the transaction commit to the scriptCode, we ensure that the signer knows what script they're signing for. A hardware wallet, for example, can only be certain that ...
user avatar
3 votes
Accepted

The example signature in BIP143 doesn't validate?

Using this library: from cryptotools import Signature, PublicKey, hex_to_bytes pub = PublicKey.from_hex('025476c2e83188368da1ff3e292e7acafcdb3566bb0ad253f62fc70f07aeee6357') sig = Signature.from_hex('...
user avatar
  • 3,145
2 votes
Accepted

What goes in the tx hash preimage when signing with 0x83 (SINGLE|ANYONECANPAY)?

From BIP143: If the ANYONECANPAY flag is not set, hashPrevouts is the double SHA256 of the serialization of all input outpoints; Otherwise, hashPrevouts is a uint256 of 0x0000......0000. ...
user avatar
  • 4,646
2 votes
Accepted

Help signing a P2WSH Multisig

I found the problem, in the bip143 tx digest preimage, the scriptCode needs to be preceded by the length of the scriptCode. In this case 0x47
user avatar
  • 669
2 votes

The example signature in BIP143 doesn't validate?

ok So thanks to PieterWuille I (we) were able to figure out why my code wasn't working and how to use a standard python or openssl library. These were the following problems the DER decoding for the ...
user avatar
  • 412
1 vote
Accepted

Understanding BIP 143 [hash computation, lockTime, sequence number, witness format]

I believe you can use either at this stage. The marker and the flag show let the client decipher which scheme is being used and interpret appropriately. lockTime sets when the transaction is valid ...
user avatar
  • 106
1 vote
Accepted

bip143 witness formatting

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 ...
user avatar
  • 60.4k
1 vote
Accepted

When generating witness for bip143, how do you choose WHAT outpoint to use?

When you are creating signatures, you are signing for a specific input in the transaction. That specific input has a corresponding outpoint, so you use its outpoint in the sighash. In the examples ...
user avatar
  • 60.4k
1 vote

Hardware Wallet Vulnerability Fix - Verifying Input Value

The way I understand it, the important part is that for BIP-143 each signature is only calculated for the amount that it's own input spends. For the other inputs only their outpoints (txid+txidx) are ...
user avatar
1 vote
Accepted

P2WPKH - which private key is used to generate signature?

Only the private key for the second input is used in this signature as this signature is only for the second input. The first input is P2PK and is ignored in this example as it is non-segwit so the ...
user avatar
  • 60.4k
1 vote
Accepted

Failed CHECK(MULTI)SIG operation - BIP143 hash pre-image

After a while of debugging, I was able to find the issue. My previous assumption that I was committing the wrong data to the hash was correct. The transaction ID that is needed to construct ...
user avatar
  • 197

Only top scored, non community-wiki answers of a minimum length are eligible