In the previous installments of this series, we touched on the progressive evolution of atomic swap technology, bringing us all the way to a comprehensive atomic swap-based DEX framework that is able to support coins with no scripting language support, such as Part(Anon) and XMR. This, of course, plays towards our eventual goal to integrate the BasicSwap protocol into other access gateways, most notably a web-based DEX and a seamlessly integrated Particl Marketplace integration, in an ongoing effort to bring truly decentralized, private e-commerce to the widest audience possible.
Although the BasicSwap protocol already boasts a wide array of different coins, each with their own advantages and communities, two big pieces are still being considered for integration into BSX: stablecoins, and the extremely popular Ethereum ecosystem. Of course, being able to integrate the latter would immediately make the integration of a number of stablecoins trivial, as many stablecoins already exist as ETH tokens.
These are some thoughts on what a PART(Anon)-ETH and XMR-ETH swap integration into a comprehensive DEX framework like BasicSwap could look like.
The Existing XMR-ETH Swap
People who had the pleasure to witness Elizabeth Bink’s Monerotopia presentation on XMR-ETH swaps may have developed a curiosity towards hyper-private Ethereum swaps and what they entail, perhaps most importantly in the hopes of facilitating untraceable, decentralized swaps between privacy coins and stablecoins (or simply ETH itself).
Elizabeth and the open source project AthanorLabs achieved the first XMR-ETH atomic swap earlier this year, and presented it to the world at the Monerotopia conference in Mexico City, on May 6th. Using their own breakthrough protocol, Athanor was able to deal with the unique limitations that both XMR and ETH bring to the table, to achieve for the first time a bona fide atomic swap between the two currencies. And while there are some code-related hurdles and considerations to integrate her swap into the BasicSwap environment, *how* her ETH-XMR swap works and what it reveals about the peculiarities of Ethereum is significantly more interesting for our purposes.
Under The Hood
XMR, of course, and as we’ve discussed at length, has no scripting language. For that reason, the classic HTLC swap, where both coins need some basic smart contract capabilities, is out of contention.
ETH considerations are of an entirely different order. It could seem to people familiar with the semi-scriptless adaptor signature protocol that the highly scriptable Ethereum would satisfy all possible requirements that the “script side” of the ECDSA adaptor signature scheme entails; however, as always, the devil is in the details.
As it happens, the adaptor signature swap, or at least the semi-scriptless adaptor signature scheme that was designed to work with ECDSA curves, is as of today fundamentally incompatible with Ethereum. The reason, as it turns out, is that Ethereum is account-based, and not UTXO-based.
The Challenges of an Account-based Architecture
In short, when a transaction is initiated in this model, it prompts nodes to decrease the sender's account balance and increase the receiver's account balance accordingly. To safeguard against replay attacks in account-based transaction models, each transaction is associated with a unique nonce. To that end, the nonce is publicly visible and intrinsically linked to a transaction. This ensures that the same transaction cannot be submitted more than once.
This breaks the adaptor signature scheme. The adaptor signature model requires refund transactions to be pre-signed; but for ethereum, you cannot pre-sign a transaction without knowing the nonce. Due to this, one of the parties could then send a transaction in between the moment when the pre-signing was done and when the transaction was executed - which would invalidate the pre-signed transaction (as the nonce was already used, and cannot be used twice).
AthanorLab's solution is to make use of Ethereum smart contracts themselves, in order to support the entirety of the swap without adaptor signature logic. It is, in that sense, also semi-scriptless - but whereas the elegant and impenetrable adaptor signature carries the necessary logic to achieve the XMR swap, the ETH swap counterpart is carried by the powerful capabilities of Ethereum smart contracts.
Privacy-wise, this means the anonymity set of the ETH swap is stronger than HTLC (where contracts can be found on both sides of the swap), but less so than adaptor signatures, due to the need for a public contract on one side. On the side without a contract, a swap transaction looks the same as any other transaction. But on the side with the contract, while it is evident that the transaction is for a swap, it is impossible to trace it to the other chain, even with sophisticated chain analysis tools.
So, while BasicSwap has under its belt the GUI, order book and all the internal logic needed to propagate and make available atomic swap trades of all kinds — including Ethereum — the two types of swaps it currently supports are both inadequate for Ethereum swaps. Such a feat, while conceivable, will require a full integration of Elizabeth’s protocol, or a similar protocol, into BasicSwap.
Current Protocol Limitations
An important setback of ETH-RingCT swaps, as the protocol stands right now, is that ETH providers are not able to publish offers they're willing to engage in. That means that, like the adaptor signature swap that had a similar issue, only one side can publish trades - in this case, the RingCT side.
The RingCT side, in this case XMR, has no scripting, and thus no way to refund in case the counterparty backs out – whereas for ETH, if the ETH-holder locks first, they can refund if the XMR-holder backs out. However, if the XMR-holder locks first and the ETH-holder only then backs out, then their funds are locked forever. This means that the swap itself always has to be structured in one way, with XMR as the initial offerer, similar to how adaptor signature swaps work at the protocol level.
Another underlying issue here, and the reason why ETH holders cannot even advertise offers for entering into a swap, is because of the gas fees of the Ethereum contract itself. Gas fees, of course, should be expected to be provided for by the ETH side of the transaction, and not the XMR side. This is another reason why the XMR-holder must initiate the swap, as the cost for the ETH-holder to lock is significantly higher than for the XMR-holder – the former could easily be griefed if someone repeatedly were to take an advertised offer, or multiple offers, and back out.
This unidirectional restriction is problematic: the offerer dictates the swap's parameters, including the offered and requested coins, their respective quantities, and the exchange rate. That means ETH holders, in this context, have little say on the parameters of any given swap, and are subject to the preferences of XMR holders to achieve a swap.
Much like was done with the XMR-BTC swap, BasicSwap's intention is to leverage the SMSG network in order to assess the current limitations of the proposed XMR-ETH swap protocol.
Remember, our solution to achieve bidirectionality for XMR-BTC atomic swaps didn't hinge on modifying the Monero codebase or its adaptor signature atomic swap protocol. Instead, we leveraged the SMSG network to simulate offers featuring Monero. In reality, BasicSwap still employs the same semi-scriptless protocol — hence, at the protocol level, the swap remains unidirectional. However, by integrating an additional automated step into the swap process — powered by the SMSG network — we've made it appear as if Monero can now be offered.
Even though it is fundamentally a clever workaround, essentially providing the illusion of a truly bidirectional swap, it is entirely seamless for the end user and doesn't necessitate any additional manual input or requirements.
This is all very exciting — the presence of ETH tokens would certainly prove a powerful addition to the BasicSwap ecosystem, and eventually to the Particl Marketplace, as it would open decentralized commerce to the entire Ethereum ecosystem. Furthermore, although a lot of work and testing are still ahead before this becomes a reality, the unique interaction of atomic swaps and BasicSwap's decentralized orderbook could once again prove to be key in achieving bidirectional swaps for a semi-scriptless protocol with substantial limitations.
The protocol is still in its early phases, having been out to the public for slightly more than 3 months, and they would certainly welcome knowledgeable beta testers and people willing to contribute end relays to this ongoing experiment! The project is open source and at the forefront of atomic swap technology, and every little bit helps.
If you would like to deepen your understanding of atomic swaps and their history, make sure to give these articles a read!
- Atomic Swap Style Showdown
- The DEX Revolution Pt. 1
- The DEX Revolution Pt. 2
- Bidirectional Monero and PART (Anon) Atomic Swaps
The Open-Source Revolution
We're on a mission to create a private, independent, and pro-liberty digital economy that is fair and open to all. Learn more about what we do at any of the following links.
Be a part of the movement and join us in the fight for our freedoms by meeting the community and spreading the word far and wide!
Learn more about Particl with these in-depth resources.
Follow the link below to get a list of all other useful Particl-related links you may find helpful.