For example, if we use a command-line terminal to feed the text "Mastering the Lightning Network" into the SHA256 function, it will produce a fingerprint as follows:
For example, if we use a command-line terminal to feed the text "Mastering the Lightning Network" into the SHA-256 function, it will produce a fingerprint as follows:
----
----
$ echo -n "Mastering the Lightning Network" | shasum -a 256
$ echo -n "Mastering the Lightning Network" | shasum -a 256
While it takes longer than a single sentence, the SHA256 function processes the 9-page PDF, "digesting" it into a 256-bit fingerprint.
While it takes longer than a single sentence, the SHA-256 function processes the 9-page PDF, "digesting" it into a 256-bit fingerprint.
Now at this point you might be wondering how it is possible for a function that digests data of unlimited size to produce a unique fingerprint that is a fixed-size number?
Now at this point you might be wondering how it is possible for a function that digests data of unlimited size to produce a unique fingerprint that is a fixed-size number?
@ -332,7 +332,7 @@ To demonstrate this, let's have Bob generate a random number +R+ and keep it sec
R = 1833462189
R = 1833462189
----
----
Now, Bob calculates the SHA256 hash of this number:
Now, Bob calculates the SHA-256 hash of this number:
----
----
H = SHA256(R) =>
H = SHA256(R) =>
@ -352,7 +352,7 @@ where +H+ is the actual hash value (+0ffd8...036a+) that Bob gave to Alice.
Let's explain this script:
Let's explain this script:
The HASH256 operator pops a value from the stack and calculates the SHA256 hash of that value. Then it pushes the result onto the stack.
The HASH256 operator pops a value from the stack and calculates the SHA-256 hash of that value. Then it pushes the result onto the stack.
The +H+ value is pushed onto the stack, and then the +EQUAL+ operator checks if the two values are the same and pushes +TRUE+ or +FALSE+ onto the stack accordingly.
The +H+ value is pushed onto the stack, and then the +EQUAL+ operator checks if the two values are the same and pushes +TRUE+ or +FALSE+ onto the stack accordingly.