3

I see that a block contains 80 bytes. SHA256 expects integral multiples of 64 bytes as input. How are the remaining 48 bytes calculated?

0

1 Answer 1

2

According to section 5.1.1 of FIPS-180-4, SHA-256 messages are padded with a binary 1, followed by a number of 0s, and finally a 64-bit binary representation of the length of the message:

Suppose that the length of the message, M, is 𝓁 bits. Append the bit "1" to the
end of the message, followed by k zero bits, where k is the smallest, non-
negative solution to the equation 𝓁 + 1 + k ≡ 448 mod 512. Then append the 64-bit
block that is equal to the number 𝓁 expressed using a binary representation.

This is not specific to Bitcoin, and any correct SHA-256 implementation will do this. For Bitcoin, a remaining 48 bytes of padding would be a single binary 1, a bunch of 0s, and the binary representation of the number 640 (80 bytes in bits). In binary, the remaining 48 bytes would be:

1 00...00 0110 0100 0000

Note that the SHA family of functions represent binary in big-endian format.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .