=== How does the padding work if my message is X bits in length? ===
Lets say we have a message that is exactly 448 bits.
We always need to include the `1` separator and the 64 bit message size in the padding, which takes the message+padding up to 513 bits. This exceeds the 512 bit message block size we're after, so we pad with 511 zeros to take us up to 1024 bits (the next multiple of 512).
The zeros go between the separator and the size, like so:
[message] [separator] {zeros} [size]
So in other words, if your message and the initial padding takes you beyond the size of a message block, you pad all the way up to the next multiple of 512.
How Does SHA-256 Work?learnmeabitcoin2020-05-12 | An explanation of how SHA-256 works, with animations of the operations used inside the hash function.
I'm not a cryptographer though, so I can't explain the reasons behind the design (at the moment).
=== How does the padding work if my message is X bits in length? ===
Lets say we have a message that is exactly 448 bits.
We always need to include the `1` separator and the 64 bit message size in the padding, which takes the message+padding up to 513 bits. This exceeds the 512 bit message block size we're after, so we pad with 511 zeros to take us up to 1024 bits (the next multiple of 512).
The zeros go between the separator and the size, like so:
[message] [separator] {zeros} [size]
So in other words, if your message and the initial padding takes you beyond the size of a message block, you pad all the way up to the next multiple of 512.Bitcoin Lesson | Scriptlearnmeabitcoin2018-05-09 | A simple yet full explanation of how the Script language in Bitcoin works.
Includes examples of the most commonly used locking scripts (and unlocking scripts), with animations showing how they are run to unlock bitcoins for spending.
Buy me a beer: 3Beer3irc1vgs76ENA4coqsEQpGZeM5CTdBitcoin Lesson | Keys & Addresseslearnmeabitcoin2018-03-09 | A developer's explanation of how Keys & Addresses work in Bitcoin, including a tutorial on how you can create your own. http://learnmeabitcoin.com
00:18 - Outline 02:03 - Introduction (Catch-up) 07:10 - Where do keys come from? 08:28 - Basic Key Generation
If you found this video helpful, please buy me a beer: 3Beer3irc1vgs76ENA4coqsEQpGZeM5CTdBitcoin Lesson | Transactionslearnmeabitcoin2018-01-15 | An explanation of how bitcoin transactions work.
If you found this video helpful, please buy me a beer: 3Beer3irc1vgs76ENA4coqsEQpGZeM5CTdBitcoin Lesson | Mininglearnmeabitcoin2017-11-14 | A simple technical explanation of how Mining works in Bitcoin.
00:49 - What is Mining? 08:39 - Hash Function 13:55 - Mining Basics ↳ 23:03 - Target ↳ 28:08 - Mining Simulator 33:20 - Mining Technical 54:46 - Live Coding Example