Post
Topic
Board Development & Technical Discussion
Re: Question about Wt in the SHA-256 algorithm
by
w0lverine
on 16/03/2018, 17:26:04 UTC
You left out a line of pseudo-code:

It should be:

For i = 1 to N
Wt = {
    Mti  (when 0 ≤ t ≤ 15)
    ROTL1 (Wt−3 ⊕ Wt−8 ⊕ Wt−14 ⊕ Wt−16) (when 16 ≤ t ≤ 79)
}


N is the number of blocks in the padded message, so the first line says to loop through all the blocks in the message (this explains where the i in the Mti comes from).

Wt is the tth word of the message schedule, so when processing word #1, that would be W1, when processing word #2, it would be W2, and so on.

For each word of the message schedule, you perform one of two processes...

If you are processing any of the first 16 words in a message block (word #0 through word #15), then you simply set Wt to the value of that word:
Mti is just the tth word of the ith message block

If you are processing any of the remaining words in a message block (word #16 through word #79) then you set Wt to the result of the following function:
ROTL1 (Wt−3 ⊕ Wt−8 ⊕ Wt−14 ⊕ Wt−16)

ROTL1 means to perform a one bit circular left shift.

The thing that is being shifted is the result of:
Wt−3 ⊕ Wt−8 ⊕ Wt−14 ⊕ Wt−16

Remember that you are processing the tth word and that this only happens when you are processing words 16 through 79, so for example:
If t is 17 then you perform:
W17−3 ⊕ W17−8 ⊕ W17−14 ⊕ W17−16
complete those subtractions and you find that you are performing:
W14 ⊕ W9 ⊕ W3 ⊕ W1
Since  is the symbol for the EXCLUSIVE OR (XOR) operation, you need to perform an XOR on those 4 words of the message schedule.

This set of instructions is performed for all 80 words in the message block (word #0 through word #79)



Thank you very much for your answer Danny, I am still digesting it.
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?