Atomic cross-chain transaction using a third blockchain

Up until recently, if two parties wanted to exchange between two digital currency, like Bitcoin and Litecoin, there was no way to do this without the use of a third party. The problem inherent in blockchain technology is that there is no way to undo a transaction. This places the person initiating the transaction at a serious disadvantage. The solution to this problem has been the use of a third party exchange. The exchange acts as a mediator between parties and guarantees the two parties complete the transaction without anyone losing their coins. The problem with using an exchange requires people to deposit their coins onto the exchange first.



We are searching data for your request:

Atomic cross-chain transaction using a third blockchain

Databases of online projects:
Data from exhibitions and seminars:
Data from registers:
Wait the end of the search in all databases.
Upon completion, a link will appear to access the found materials.

Content:
WATCH RELATED VIDEO: What is Atomic or Cross Chain Transaction?

Atomic Crosschain Transactions for Ethereum Private Sidechains


A cross-chain atomic swap is method of exchanging different cryptocurrencies directly between two peers. Like trading dollars for pesos, it's a process in which two people can exchange one cryptocurrency for another, but without trust or third-party moderation. We say the swaps are "atomic" because they must be all-or-nothing. To protect both users, there must be no scenario in which one person can control both coins at the same time. Atomic swaps can be executed between many blockchains, but not all.

In this guide we'll be focusing on just Bitcoin and Bitcoin Cash, using the bcoin and bcash libraries respectively. It's a bit of a game: the rules can't be broken, but you still have to pay attention. Blockchains are like a stack of locked mailboxes with deposit slots. When you want to receive Bitcoin from someone, you tell them which mailbox to put the coin into.

Bob decides to pay Alice. He puts 0. HTLCs are more complicated. They also use much fancier locks than usual. Time locks still require the right key but they ALSO require a certain amount of time to pass. Even if you have the key for this lock, you also need to enter the right code to open it. When you enter the secret code, it is visible for the entire world to see, like the screen on a calculator.

In an ideal situation, only the hash locks are used anyway. As we'll see later on, the time locks are only used as refunds in order to cancel the swap. They agree to swap the coins they have for the coins they want. Alice knows the secret code but keeps it a secret for now. With the key and the code entered, the mailbox is opened and she can acquire the Bitcoin.

Now Bob knows the code too! Alice and Bob have just successfully swapped coins on two separate blockchains without ever trusting each other or any third-party. This is where the time locks come in. The time locks allow both parties to refund themselves in case the swap does not succeed as planned. The reason we use time locks for this is to eliminate the possibility that one person ends up with both coins, leaving the other person with nothing.

When the locks are put on the HTLC mailboxes, the time locks are set to give each counterparty a chance to redeem the swap without interference.

If the swap never happens, everyone can take back the coins they started with after the time expires. The length of time on each lock is important to ensure that the game can only be played fairly. Broadly speaking this is because Alice knows the hash lock secret and therefore has a major advantage. To illustrate why this is important, consider if the times were reversed. Alice would have all the money and Bob would be broke! Now it's time to turn these "two-lock mailboxes" into actual Bitcoin transactions.

For this guide we will describe a very simple method of constructing and executing smart contracts that sacrifice some privacy and potentially some security. It is not recommended these be used as is in production. For details on how the implementation can be improved, see next steps below. It hashes the secret and checks that it matches a given hash, then it checks the signature against the given public key.

To redeem the HTLC this way, we will use the following script in the input of a transaction:. The time lock will only be checked when if false. First it executes a Check Sequence Verify routine, which fails if the given relative locktime has not yet passed. Then it simply checks a signature against a given public key like usual. To redeem the transaction with this path, we will use this input script:.

The bcoin and bcash libraries are so similar that we can use the exact same commands to create HTLCs on both chains, and build a working application with wallets. With almost no conditionals, we can make this library completely chain-agnostic.

For example, observe how creating a new object with new Swap 'bcoin', 'testnet' would give us the specific Address module for making Bitcoin addresses.

We could create a second object for bcash that would, with the exact same line of code, give us the module for Bitcoin Cash addresses. The next three functions we'll need will compile our Bitcoin scripts from the last section into the actual byte code used in serialized transactions on the network.

To learn more about working with scripts, check out the bcoin. This is required by the mechanics of Pay-To-Script-Hash transactions. The transaction output we are spending from contains only a hash of the redeem script. The actual redeem script itself is provided by the input scripts at the time the coin is being spent, so they are included here.

The laws of the finite universe prevent us from signing a message that already contains its own signature, and the Bitcoin Protocol therefore expects the signatures to be removed from a transaction script during verification.

Eventually we will sign our transactions with these Int 0 's in the scripts, then replace them with the final signatures for broadcasting to the network.

This is an easy process. This is where the similarity between libraries is crucial. For both networks, we can generate valid P2SH addresses using the same function:. On testnet, using two different instances of our Swap class, this function will give us the following example addresses:. Once funds are sent to the P2SH addresses, we can spend them using either the swap or refund input scripts. We have already generated the scripts so we just need to create a transaction and sign it!

Generating the signatures is handled entirely by the TX module in each library:. Ok, here we finally have some divergence between bcoin and bcash. In the tx. Since Bitcoin Cash does not have any SegWit features at all, this parameter is instead used to pass additional SigHash flags used for replay protection at the time of the hard fork. Due to a similar inconsistency, we will need to pass different values for sigHashType depending on which chain we are constructing transactions for.

With those disclaimers behind us, let's build the transaction! The following function puts together all the pieces to complete the swap.

For more detail on how these MTX methods work, see the bcoin. Once we've completed and signed the transaction, we can test that it verifies against the network rules:. Now that we have all the tools, you might be asking yourself "What is the minimum amount of information two parties need to send each other to engage in a swap? It turns out that besides the exchange rate and volume, the only thing the two trading partners need to exchange is:.

Using these data and the scripting functions from the last section, both parties can deterministically derive the P2SH addresses for the contracts on both chains. By watching for transactions in and out of those addresses on both chains, everyone will have everything they need to play the atomic swap game.

We can add two simple functions to generate these data, using the bcrypto module as a utility:. They key exchange method is up to the users on the application layer. They could save a little space by agreeing on a protocol in advance. We can imagine preset, hard-coded locktimes and perhaps a common exchange rate API. Remember, part of the swap protocol involves Alice revealing her secret value to Bob. That is done on the blockchain, so Bob needs to watch the chain for Alice's redemption transaction and pull the secret value out of it somehow.

Since we know the exact structure of Alice's input script we can expect her secret to be the second value in the script. Once we catch Alice's transaction we need to figure out which input is redeeming the swap, then grab the secret. We discover the input by looking for the P2SH address we derived earlier. The last mechanism we need to make a functional atomic swap application is a wallet, or several wallets. Refer to the bcoin. For brevity, we'll just review the last step in our swap story: Bob extracting the HTLC secret from Alice's Bitcoin Cash sweep-transaction and using it to sweep his own Bitcoin transaction.

Keep in mind that by the time the following code is run, Bob has already deposited BTC into the swap address for Alice to sweep. The code is presented linearly here but in the actual application it is organized a bit differently. Alice will have similar code running on her end. We've built a very simple atomic swaps application! But what have we sacrificed for convenience? To improve privacy, we might want to use separate public keys for each blockchain, instead of using the same key on both networks although it is very cool and convenient that public keys can be re-used on these two networks.

We have been using raw public keys, but most of the time in Bitcoin we exchange hashed RIPE public keys. In our case, this hash would require a few extra OP codes in the redeem script. We should also check all the amounts being transacted and return an error if the counterparty didn't send the right amount.

How will Bob ever know? The app should be able to rescan recent blockchain history to make sure it hasn't missed anything on launch. CSV encoding. We built our app using timelocks based in seconds, not blocks. BIP 68 describes a specific bit-by-bit encoding scheme that must be used to create a valid timelock value. A better UI or bpanel plugin would make the application much easier to use.



Atomic Swaps

First come, first served: Critical choices between alternative actions are often made based on events external to an organization, and reacting promptly to their occurrence can be a major advantage over the competition. In Business Process Management BPM , such deferred choices can be expressed in process models, and they are an important aspect of process engines. Blockchain-based process execution approaches are no exception to this, but are severely limited by the inherent properties of the platform: The isolated environment prevents direct access to external entities and data, and the non-continual runtime based entirely on atomic transactions impedes the monitoring and detection of events. In this paper we provide an in-depth examination of the semantics of deferred choice, and transfer them to environments such as the blockchain.

Step 3: As soon as Mr. A receives Mr. B's litecoin transaction, Mr. A now signs it by using the same original key he has in the form of pre-.

Cross-chain deals and adversarial commerce

Public blockchains such as Ethereum and Bitcoin do not give enterprises the privacy they need for their business processes. Consequently consortiums are exploring private blockchains to keep their membership and transactions private. Ethereum Private Sidechains is a private blockchain technology which allows many blockchains to be operated in parallel. Communication is needed between Ethereum Private Sidechains to allow a function in a contract on one sidechain to execute function calls which return values from, or update the state of, another sidechain. We propose a crosschain technique which allows transactions to be executed atomically across sidechains, introduce a new mechanism for proving values across sidechains, describe a transaction locking mechanism which works in the context of blockchain to enable atomic transactions, and a methodology for providing a global time-out across sidechains. We outline the programming model to be used with this technology and provide as an example, a variable amount atomic swap contract for exchanging value between sidechains. Although this paper presents Atomic Crosschain Transaction technology in the context of Ethereum Private Sidechains, we discuss how this technology can be readily applied to many blockchain systems to provide cross-blockchain transactions.


Atomic Swap

atomic cross-chain transaction using a third blockchain

It contains Solidity contracts, Java library code, test code, and example code. It contains Docker files to run multiple blockchains using Hyperledger Besu so that the entire system can be run on a laptop computer. GPACT forms part of an overall crosschain protocol stack as shown in the diagram below. The links in the table below will take you to implementations of those parts of the protocol stack. Applications use the Crosschain Function Call code to execute function calls across blockchains.

This is an Informational ZIP describing a proposed specification for a standardized protocol for performing cross-chain atomic transactions XCAT between Zcash and Bitcoin, or other Bitcoin-derived cryptocurrencies. This proposal only supports transparent cross-chain swaps and relies on the scripting system inherited from Bitcoin.

Atomic Cross-Chain Exchange

An Atomic Swap is a series of blockchain transactions that allows two parties to perform trustless cross-chain trading across blockchains. Alice and Bob would have to trust a third-party to conduct the trade on their behalf. With Atomic Swaps, a cross-chain trade can be completed without the need for a third-party and without any risk of loss due to the counterparty not honoring the deal. To make an Atomic Swap trade, the users would proceed as follows:. Alice chooses a secret password e.


What Are Atomic Swaps?

It is instructive to know the course taken by blockchain technology and its applications over the past few years, as this will allow us to understand where we are, where are headed, and thereby motivate the necessity of interoperability. The original vision of blockchain technology called for a global decentralized network of peers and clients that could conduct transactions at scale without requiring intermediation by trusted third parties. The Bitcoin network was the first example of this, and it was purposely left open for anyone to join precisely because its initiators hoped for a single global network somewhat akin to the internet. But the limitations of Bitcoin as a transaction processing system soon became apparent, and the Ethereum network emerged to fill this gap, retaining the openness and scalability of Bitcoin while supporting arbitrary smart contracts over a shared ledger. But Ethereum too was not destined to be the single canonical global blockchain network that everyone would use. Sub-groups within the Bitcoin and Ethereum communities dissented from the rest, thereby creating forks , or separate networks with separate chains of blocks.

Atomic swap is also known as cross-chain trading. you are no longer dependent on a third party like a miner to valid your transaction.

Blockchain exists with a vision to evolve and widen the scope of its use cases across the world. While we understand that blockchain could redefine various industries such as finance, trading, gaming, and capital market , the non-cumulative nature of its ecosystem continues to trouble the growing prevalence of blockchain technology. Currently, there are numerous blockchain platforms available, ranging from first-generation blockchain like Bitcoin to third-generation like Avalanche.


The inability to perform cross-chain swaps are one of the many problems that burden the blockchain industry. It constrains the application of the blockchain technology. Atomic cross-chain swaps [1] are one of the many cross-chain solutions. It has the following advantages:. Its disadvantages are:.

An atomic swap is an exchange of cryptocurrencies from separate blockchains. The swap is conducted between two entities without a third party's involvement.

Springer Professional. Back to the search result list. Table of Contents. Hint Swipe to navigate through the chapters of this book Close hint. Abstract In this paper, we consider the problem of cross-chain transactions where parties that do not trust each other safely exchange digital assets across blockchains. Open blockchains models are decentralized ledgers that keep records of transactions. They are comparable with distributed account books.

However, the throughput of blockchain-based application in VANETs is limited by the network bandwidth. The blockchain-based public-key encryption with keyword search is further introduced to protect user privacy. The simulation results show that our method can realize multiple blockchain-based applications in VANETs.


Comments: 5
Thanks! Your comment will appear after verification.
Add a comment

  1. Taukus

    Remove everything, that a theme does not concern.

  2. Moke

    the Excellent Communication))

  3. Vonos

    I agree, this great thought will come in just the right place.

  4. Stantun

    How interesting that sounds

  5. Guiderius

    I congratulate, your thinking simply excellent