I am not too sure where N comes from in BTC, is it from a previous block (blockchain block)?

What is a block in this equation? is it a 32bit chunk of the padded message?

SHA256 is an algorithm that can be applied to any arbitrary binary data. It isn't exclusive to Bitcoin.

The Wikipedia and NIST links that you provided are generic descriptions about the SHA256 algorithm. There is nothing about Bitcoin at all in either of those links. Therefore, references to "blocks" in either of those are references to some defined block of data, and not to a "Bitcoin Block".

Specifically, if you actually started reading the NIST document from the top, (

**instead of jumping straight to the calculation on page 27**), then you would have found that:

M is the message to be hashed. In other words, it is the data that is being hashed.

You would also have found that some pre-processing is required to pad the message separate it into blocks (see page 21).

**5. PREPROCESSING**

Preprocessing consists of three steps: padding the message, M (Sec. 5.1), parsing the message into message blocks (Sec. 5.2), and setting the initial hash value, H^{(0)} (Sec. 5.3).

Then you would have discovered that the message M needs to be padded to a multiple of 512 bits before it can be hashed:

**5.1 Padding the message**

The purpose of this padding is to ensure that the padded message is a multiple of 512 or 1024

bits, depending on the algorithm.

5.1.1 SHA-1, SHA-224 and SHA-256

Suppose that the length of the message, M, is *l* 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 (*l* + 1 + k)mod512 = 448. Then append the 64-bit block that is equal to the number *l* expressed using a binary representation.

And finally, you would find that the message M needs to be parsed into blocks of data that are each exactly 512 bits long:

**5.2 Parsing the message**

The message and its padding must be parsed into N *m*-bit blocks.

**5.2.1 SHA-1, SHA-224 and SHA-256 **

For SHA-1, SHA-224 and SHA-256, the message and its padding are parsed into N 512-bit blocks, M^{(1)}, M^{(2)},...,M^{(N)}. Since the 512 bits of the input block may be expressed as sixteen 32-bit words, the first 32 bits of message block *i* are denoted M_{0}^{(i)}, the next 32 bits are M_{1}^{(i)}, and so on up to M_{15}^{(i)}.

So:

Data that is less than 449 bits will be padded out to 512 bits and will be parsed into a single 512 bit block. In that case N is 1 (there is only 1 block of data to hash).

Data that is more than 448 bits and less than 961 bits will be padded out to 1024 bits and will be parsed into two 512 bit blocks. In that case N is 2 (there are 2 blocks of data to hash).

Data that is more than 960 bits and less than 1473 bits will be padded out to 1536 bits and will be parsed into three 512 bit blocks. In that case N is 3 (there are 3 blocks of data to hash).

This process can be continued for any arbitrary length of data.

Note that the Bitcoin Block header is 80 bytes (640 bits), and therefore must be padded to 1024 bits and parsed into two 512 bit blocks.