Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: JackH on January 31, 2017, 02:57:17 PM



Title: Pre-image in relation to payment channels
Post by: JackH on January 31, 2017, 02:57:17 PM
A cornerstone of payment channels seems to be the idea of pre-images and their secret being communicated through the network. But when it comes to the definition of the pre-image itself, and its properties in terms of how it works within a technical system, such as payment channels, there is little information anywhere. The closest I came to information about pre-image was the mathematical description of it here: https://en.wikipedia.org/wiki/Image_%28mathematics%29#Inverse_image

When talking in terms of cryptography, anything I have been able to find was how pre-image is put together as a pre-image attack on hash functions, but not a description of how the pre-image itself, and its construction for being used as a secret in for example payment channels actually works.

Anyone care to chip in some info on pre-image and how it relates to the crypto/hash of payment channels in more details?


Title: Re: Pre-image in relation to payment channels
Post by: belcher on January 31, 2017, 06:25:13 PM
The pre-images used in payment channels refer to those of cryptographic hash functions.

See https://en.wikipedia.org/wiki/Cryptographic_hash_function#Properties

Quote
A cryptographic hash function must be able to withstand all known types of cryptanalytic attack. In theoretical cryptography, the security level of a cryptographic hash function has been defined using the following properties:

* Pre-image resistance
Given a hash value h it should be difficult to find any message m such that h = hash(m). This concept is related to that of one-way function. Functions that lack this property are vulnerable to preimage attacks.

* Second pre-image resistance
Given an input m1 it should be difficult to find different input m2 such that hash(m1) = hash(m2). Functions that lack this property are vulnerable to second-preimage attacks.

* Collision resistance
It should be difficult to find two different messages m1 and m2 such that hash(m1) = hash(m2). Such a pair is called a cryptographic hash collision. This property is sometimes referred to as strong collision resistance. It requires a hash value at least twice as long as that required for preimage-resistance; otherwise collisions may be found by a birthday attack.[2]

For understanding how hash values and preimages are actually used to build payment channels, I think this series of articles from bitcoinmagazine are pretty good: https://bitcoinmagazine.com/articles/understanding-the-lightning-network-part-building-a-bidirectional-payment-channel-1464710791/ Hopefully it answers your question.