In the previous article we have seen what it is about and theoretically how this network works.
To have a clear picture and to be able to proceed in the comprehension in more precise way, I suggest you go to read (or to refresh your memory) the previous article.
In order to protect security, multi-signature addresses have been created.
In the multi-signature address several private keys are registered that can operate within this environment and validate the operation.
At the time of creation you must report the validation scheme: let's assume you have 5 private keys authorized to operate and to validate an operation you need only 3.
In this case we will have a "3-of-5" scheme.
A very important thing is that it makes no difference which of the 3 signatures have given authorization, the ‘conditio sine qua non’ is that there are at least 3 signatures.
Let's transpose this to the Lightning Network.
When we initialize a channel, the funds are blocked with a 2-of-2 scheme: in this way we have only two signatures that can validate the operation and both must be present.
At the security level we are protected, but at the "human" level not so much.
I explain why
Suppose Mike and Mary open a channel on LN where they block 3 BTC each.
After a certain period and a series of transactions, the balances of our 2 friends amount to 6 BTC for Mary and 0 BTC for Mike.
As mentioned just above, to perform any operation, including exiting the LN and recording the balances on the Blockchain, both signatures are needed.
Mike disagrees and does not affix his signature; at this point Mike loses nothing because he does not release his funds!
As is evident collaboration is key in order to keep things fair.
In this regard, a solution must be found that "forces" both parties to abide by the agreements.
This procedure is called the Hash TimeLock Contract (HTLC).
Through this procedure Mary has the ability to unlock their funds and remove them from the channel.
The word is a "fusion" of two technologies: HashLock and TimeLock.
Let's delve a little deeper to clarify the situation.
We all know the word Hash: it is an alphanumeric string that refers to a validated block of any blockchain.
True, that's correct, but a bit limiting; more precisely, a Hash is the result of a Hash function, which has transformed any amount of data into a single alphanumeric string of fixed length.
Let's apply the concept to an active transaction on the LN.
Along with the transaction, a Hash is created that allows the counterparty to be able to spend the tokens only if it is aware of the source of this hash.
Normally the reverse procedure, i.e., recovering the source from a hash, is very complicated if not impossible.
So the recipient of the transaction can only spend the tokens if the sender has sent him the hash source.
At this point collaboration is necessary, in fact once the HashLock function has finished, the TimeLock function comes into play.
With the TimeLock function, the receiver is given a period of time (sometimes corresponding to the height of the lock) within which he must confirm the transaction by resending the Hash source.
Obviously if he signs it, everything is easier and the tokens can be spent immediately.
If in the defined period of time, the sender does not receive the source of the hash, the funds are unlocked and the transaction cancelled.
Although the Lightning Network is not a blockchain, again, getting things to work quickly and functionally requires fairness and collaboration between the parties.
Yet another lesson in communal living being enjoyed by a new technology!