Edited 03_how_ln_works.asciidoc with Atlas code editor

pull/910/head
kristen@oreilly.com 3 years ago
parent e70b51677d
commit 046d1140de

@ -415,18 +415,18 @@ Did you notice how this contrasts with Bitcoin and how different terms are used?
The most important part of the invoice is the _payment hash_. When constructing the invoice, Bob will make a payment hash as follows:
1. Bob chooses a random number +r+. This random number is called the _preimage_ or _payment secret_.
2. Bob uses +SHA256+ to calculate the hash +H+ of +r+ called the _payment hash_
2. Bob uses SHA-256 to calculate the hash _H_ of _r_ called the _payment hash_
+
latexmath:[$H = SHA256(r)$].
latexmath:[$H = SHA-256(r)$].
[NOTE]
====
The term _preimage_ comes from mathematics. In any function _y = f_(_x_), the set of inputs that produce a certain value _y_ are called the preimage of _y_. In this case, the function is the SHA256 hash algorithm and any value _r_ that produces the hash _H_ is called a preimage.
The term _preimage_ comes from mathematics. In any function _y = f_(_x_), the set of inputs that produce a certain value _y_ are called the preimage of _y_. In this case, the function is the SHA-256 hash algorithm and any value _r_ that produces the hash _H_ is called a preimage.
====
There is no known way to find the inverse of SHA256 (i.e., compute a preimage from a hash). Only Bob knows the value +r+, so it is Bob's secret. But once Bob reveals +r+, anyone who has the hash +H+ can check that +r+ is the correct secret, by calculating +SHA256(r)+ and seeing that it matches +H+.
There is no known way to find the inverse of SHA-256 (i.e., compute a preimage from a hash). Only Bob knows the value _r_, so it is Bob's secret. But once Bob reveals _r_, anyone who has the hash _H_ can check that _r_ is the correct secret, by calculating _SHA-256(r)_ and seeing that it matches _H_.
The payment process of the Lightning Network is only secure if +r+ is chosen completely randomly and is not predictable. This security relies on the fact that hash functions cannot be inverted or feasibly brute-forced and, therefore, no one can find +r+ from +H+.
The payment process of the Lightning Network is only secure if +r+ is chosen completely randomly and is not predictable. This security relies on the fact that hash functions cannot be inverted or feasibly brute-forced and, therefore, no one can find _r_ from _H_.
==== Additional Metadata

Loading…
Cancel
Save