"How can assets be transferred between blockchains?"
"How do they agree on the exchange contract, if nobody owns the implementation?" Great question, Gabriel.
Essentially, the way assets are transferred between blockchains is through a very basic smart contract.
[So basic] that you can also implement it in a very simplified script language like [what is in] Bitcoin.
These contracts are usually some form of multi-sig or merkle proof that allows you to lock value...
on one blockchain and release an equivalent amount on the other blockchain [through a series of conditions].
The two parties who engage in a transfer or atomic swap between two blockchains...
[must] agree [to those conditions] and choose which contract to use.
There can be multiple implementations that transfer value between two blockchains, between sidechains.
You [would] choose which implementation you [will] use; if somebody else is also using that implementation,
then you can execute a swap with them.
"[Are] multi-sig and time delays [features] of smart contracts?" In some cases.
[Although] I don't see why you would implement a smart contract system that didn't at least have the [option for]
multiple owners / signatures and time delays.
I have never seen a smart contract language [which] didn't have those.
Even Bitcoin, which most people don't call a 'smart contracts' platform, [has] basic script [for both].
You don't need [complex] smart contracts in order to do [multi-sig, time delays, or] Lightning payment channels,
The ability to do basic multi-sig and time delays is usually enough.
"Do the participants of the Lightning Network [need to] set up a smart contract?"
What I mean by "smart contract" is basically...
a Bitcoin address with [scripts] for multi-sig, time [delays], and a refund or penalty process.
[Those are] used to continuously update the channel.
You don't do any of that [manually]; effectively, that is automatically done by your Lightning wallet.
It looks very similar to a bitcoin payment.
You receive a QR code [within] a Lightning invoice, you tell your wallet to pay that invoice,
and [your node] finds a route within the network...
through which it can make a series of commitments to transmit [satoshis] to the party [who sent the invoice].
That will execute in less than a second, in most cases. [The Lightning Network] is very fast.
Your payment will be received at the other end [of the route]. All of the smart contracts, multi-sig [conditions],
and all of those details are managed by the wallets [and can be made] invisible to the user.
To the user, it just looks like a very fast bitcoin transaction that can have very small amounts.
You can [send] amounts that are even less than a satoshi, with very low fee or sometimes no fee at all.
"Is the Lightning Network a sidechain or a second-layer?" A very good question, Erik. Lightning is not a sidechain.
Lightning is a second-layer [network].
Lightning is a mechanism for transmitting payments off-chain, using an underlying blockchain for security.
It allows you to route through payment channels, which are smart contracts using multi-sig and time delays.
It allows you to transfer [small amounts of] bitcoin...
between two participants, without [needing] to record it on the blockchain [until settlement or there is a dispute].
Those two participants don't need to trust [anyone else] because the underlying Bitcoin blockchain is the basis...
of trust and security.
Because something like Lightning can also be a multi-currency routing network,
you can have nodes that are participating in Lightning with Bitcoin, or nodes that run Litecoin.
Theoretically you could have nodes that run Ethereum or [other compatible blockchains].
The requirements for a blockchain to be Lightning compatible, to interact with these payment channels,
are certain fundamental security functions, including multi-sig, time delay, [and a transaction malleability fix].
Together with those two functions, [multi-sig and time delays] you can implement what is called...
a hashed timelock contract, which is the building block..
for [uni-directional and bi-directional, or] routed, payment channels.
The Lightning Network is absolutely not a sidechain. It is a second layer. Theoretically, you could use it...
to connect side chains to each other.
Today, in fact, you can transmit a Lightning payment [with] bitcoin, and the recipient [will get] Litecoin,
which is another blockchain, because both of them are Lightning compatible.
Effectively, that has made Litecoin and Bitcoin into sidechains of each other, with the Lightning Network...
being the smart contract layer that connects them.
"If sidechains had to be created as a second layer from the original decentralized Bitcoin blockchain,
does this mean centralization?"
"Who runs, keeps, maintains, or is incentivized for [the security model] regarding side chains?"
Great question, Christian. Sidechains aren't a second layer.
The technology that connects two blockchains together is kind of a second layer, but not really.
[They involve] transactions within each of the blockchains, but sidechains are not really a layer.
They're more a parallel stack, if you like. You have two stacks that operate side by side.
[And you ask], "Who runs, keeps, maintains, and is incentivized for the security [model]?"
That is the most important question.
Unless you can answer that question, you can't say anything about the security of a sidechain.
Keep in mind, a sidechain is an attribute of a relationship.
To be a sidechain to another blockchain means that one blockchain has the ability to transfer or peg value...
in and out of another blockchain, with some form of atomic swap mechanism.
Neither of these is really subordinate to the other. The term 'sidechain' is often confusing.
Bitcoin can be a 'sidechain' to something else.
If something is a sidechain to Bitcoin, then [perhaps] Bitcoin is also sidechain to [that chain].
It [can] simply mean "a chain on the side."