Adaptor Signature based swap for reduced tx fees
Adaptor signatures are used in the XMR/BTC atomic swap reference [client](https://github.com/comit-network/xmr-btc-swap) 
More In Depth Reading [HERE](https://comit.network/blog/2020/10/06/monero-bitcoin/)
### Adaptor signatures 
The setup for an adaptor signature involves a secret value, an adaptor signature, and a “normal" signature. Knowing any two of these data is enough to calculate the third
This allows us to verify the signatures across different curves in a way that secrets can be revealed upon the final redeem transaction. 
### Ethereum cost advantages
ed25519 inside of a smart contract is costly. An adaptor signature swap allows for native secp256k1 inside the contract through sha256() and ecrecover() calls. These also cut down on the needed storage for each instance of the swap which reduces cots. This approach also enables ETH to be pre-deposited to a market contract which enables on chain signaling for easier defi integration. 
### Adaptor Signature Process 
This is based earlier [draft](https://github.com/Crypt0-Bear/xmr-eth-swap-playground/blob/main/draftProcess.md)
**Classic Alice and Bob want to swap eth for xmr**

* 1- Alice:Create Deposit of eth into swap smart contract
* 2- Bob:Fund xmr address and key split priv Key (K) into 2 parts (aK & bK) 
* 3- Bob:Submit adaptor sig to Alice (OffChain) 
* 3- Bob:Submit hash(aK) to contract (OnChain contract interaction)
* 4- Alice:Lock withdraw address to B's + time lock with auto revert on expiry (OnChain contract interaction)
* 5- Bob: claim eth deposit in contract using aK and signing it as part of the tx (OnChain contract interaction)
* 6- Alice: calculates bK from signature and adaptor sig. Is able to spend xmr since they now have K 

*step 4 is needed to prevent front running attacks since only the withdraw address is able to withdraw. Time lock reverts funds to original funder after x amount of time. Financial incentive makes B claim deposit To further add privacy on the eth side, funds are pooled in the smart contract allowing for an anon set to increase the more atomic swaps that happen. (similar to tornado cash)

Key advantage in this means that no zero-knowledge proofs are needed inside the smart contract as it all happens offchain. This reduces costs significantly and reduces the need for trusted key setups and complexity. The smart contract is basically a simple escrow contract which is locked for a period of time and reverts if nothing happens after x amount of time. 
The contract in a locked state can release funds by the withdrew address interacting with it and providing the Ak key shard as a claim key. The transaction that does this also contains a signature so this enables Alice to then calculate the monero priv key K from the shard received earlier (Ak) and adaptor sig + signature in tx to calculate bK. 

The contract not only time locks to allow enough time for the swap to happen, but it also locks the address. This is done to prevent the potential of a party brute forcing hashes for AK. This lowers the privacy a bit since the address is on chain in the contract but I think it isn't a big deal since it would be public when they withdrew anyways. In the future it could incorporate some zero knowledge proofs in contract but that's a later conversation. 

### Comments 
While I understand the highlevel use of adaptor signatures I am having some trouble implementing them. I know that there are reference clients in rust that were used for the XMR/BTC swap, we can use the same functions for creating the adaptor sigs and for calculating secrets once Bob claims eth deposit. This should seriously cut down on associated costs for the swap as the computational expensive cryptography is done off chain and the on chain contract acts as a simple escrow contract. 

Also if there is anything wrong in my foundational understanding of adaptor signatures please call me out on it. I wasn't able to get as much feedback and those specific crypto concepts are not super common. 

### references

Golang adaptor sig [libary ](https://github.com/HyperspaceApp/ed25519)
XMR/BTC atomic swap reference [client](https://github.com/comit-network/xmr-btc-swap)
XMR/BTC atomic swap POC [client](https://github.com/comit-network/xmr-btc-swap-poc)
Encrypted Signature [whitepaper](https://github.com/LLFourn/one-time-VES/blob/master/main.pdf) 
