Search content
Sort by

Showing 8 of 8 results by noobWithAComputer
Post
Topic
Board Development & Technical Discussion
Re: Trying to get a deeper understanding of atomic swaps
by
noobWithAComputer
on 09/10/2018, 20:07:07 UTC
I'm very sorry, that I was not able to translate it within a few days as I planned... And as it seems atm, it will take a few more weeks, as I have a lot on my table right now...

I hope to get it done this year, but I won't make any promises. Sorry Sad
Post
Topic
Board Development & Technical Discussion
Re: Trying to get a deeper understanding of atomic swaps
by
noobWithAComputer
on 21/09/2018, 11:55:41 UTC
I will start translating it today. Maybe I get it done this weekend. My thesis starts at the very beginning, so I hope even people who are not familiar with atomic swaps can under stand it.

As this is a thesis to a unimportant module in my course of studies, it was not peer reviewed and also not published (besides my personal git repo).

I will take a look at the homomorphic hashing stuff, this seems interesting, thanks.
Post
Topic
Board Development & Technical Discussion
Merits 4 from 3 users
Re: Trying to get a deeper understanding of atomic swaps
by
noobWithAComputer
on 21/09/2018, 10:31:49 UTC
⭐ Merited by ETFbitcoin (2) ,HeRetiK (1) ,Cyrus (1)
Hi together,

I finished my thesis now and have some results.

I put everything I accomplished in a git repo, so everybody can view my results. At the moment there is only the german thesis, but I will try to translate it within the next days.

I hope my work is usefull to somebody.

Git: https://github.com/noobWithAComputer/detect-atomic-swaps

Greetings.
Post
Topic
Board Development & Technical Discussion
Re: Trying to get a deeper understanding of atomic swaps
by
noobWithAComputer
on 23/07/2018, 19:54:24 UTC
Thank you all for your thoughts. Especially to Kallisteiros for your long post.

You are right about the swapped parameters in Type 4a/b and 6.

@mr_sparkles
I will look into it. This might be interesting.
Post
Topic
Board Development & Technical Discussion
Re: Trying to get a deeper understanding of atomic swaps
by
noobWithAComputer
on 20/07/2018, 09:41:43 UTC
Interesting, thank you for these information.

I just checked the HTLCs I found and there was none in Dec 2017. So it seems the LN HTLCs have another structure. I will take a deeper look into this in the next days.
Post
Topic
Board Development & Technical Discussion
Re: Trying to get a deeper understanding of atomic swaps
by
noobWithAComputer
on 19/07/2018, 09:53:06 UTC
When I find the time to translate my work (I'm writing the thesis in german), I will post them here.

As I will start my Diplom thesis in a few months, I won't have the time to implement such a tool. But I hope my findings may help other people to do so.
Post
Topic
Board Development & Technical Discussion
Merits 1 from 1 user
Re: Understanding Atomic Swaps
by
noobWithAComputer
on 16/07/2018, 14:21:37 UTC
⭐ Merited by ETFbitcoin (1)
The concept of an atomic swap is not a part of the lightning network.

It's just a structure of transactions utilizing hashed timelock contracts (HTLCs) in order to achieve a trustless exchange of different currencies on different chains. Until now multiple atomic swaps were made on bitcoin.
ATM I'm writing a thesis about atomic swaps and how to recognize them. There are a few different scripts for HTLCs, but they all do the same thing: they lock value for a specific time, except the counterparty can provide the preimage of the given hash.

One implementation of an HTLC looks like this:
Code:
63 if
82 size
01 data1
20
88 equalverify
a8 sha256
20 data32

88 equalverify
76 dup
a9 hash160
14 data20

67 else
04 data4

b1 checklocktimeverify
75 drop
76 dup
a9 hash160
14 data20

68 endif
88 equalverify
ac checksig

In order to have an atomic swap you just need an implementation which achieves the same thing. In ethereum you could also write a smart contract which does the same. As far as both parties can watch the blockchain and what is happening there, it is possible to make an atomic swap.
Post
Topic
Board Development & Technical Discussion
Merits 19 from 9 users
Trying to get a deeper understanding of atomic swaps
by
noobWithAComputer
on 16/07/2018, 12:43:59 UTC
⭐ Merited by Welsh (5) ,suchmoon (4) ,danda (3) ,dbshck (2) ,HeRetiK (1) ,qwk (1) ,ETFbitcoin (1) ,vapourminer (1) ,F2b (1)
Hi together,

I'm an IT-student and writing a thesis about atomic swaps on BTC and BTC-like blockchains. For the thesis I decided to use BTC, LTC, BCH and DCR. These chains have a somehow similar codebase and the same scripting language (I'm not a professional, so there might be differences, but they are not that serious). And they all have a high enough marketcap to be relevant for atomic swaps.
So the goal of the thesis is to find hashed timelock contracts (HTLCs) and connect matching HTLCs from different chains to get the atomic swap. Therefore I first searched the web for anything on atomic swaps [1] and analyzed the input script of this transaction [2] to get a basic understanding how atomic swaps work and what they look like.
Then I wrote a go program to search for any script longer than simple P2PKH scripts. This gave me a list of many different scripts which I analyzed by hand to only take the HTLC ones. (Besides many multisig scripts, there is not much to find on BTC^^)
At this point I found multiple different types of HTLCs as listed below. Afterwards I crawled* BTC again saving all transactions with HTLC scripts, storing the interesting data like tx-id, input value, pubKeyHashes, the secrets and their hashes. I found about one hundret HTLCs on BTC so far.
I did the same for LTC and found about 400 HTLCs.
As far as I understood, the secrets of HTLCs have to be the same on both chains. So I wrote another go program to match the found HTLCs from BTC and LTC and got around 30 matches. The next steps would then be to crawl BCH and DCR and also match the HTLCs found there.

* Crawling in this case means that I start to search the blockchain backwards (to get the newest first, the beginning years are not that interesting in this case^^) until the beginning of 2017. So about 18 months. As stated in [1] the first known atomic swap between BTC and LTC was made on 19th April 2017 (or April 19th 2017 or 19.4.2017 or whatever you like). So there is not much sense in crawling any further.

My questions now are the following:

  • Why are there so many different types? Is it compatibility with other chains? Or what?
  • What are the differences between these types (besides length and hashing algorithm)?
  • What are the advantages and disadvantages of these types?
  • Why are there so many HTLCs on LTC and so few on BTC?
  • Do you know other such HTLC scripts?
  • Can you provide interesting resources on this topic?

I'm open to any constructive input and hope you have a few answers for me. Thank you in advance.

Type 1: sha256 secret, length=97byte
Code:
63 if
82 size
01 data1
20
88 equalverify
a8 sha256
20 data32

88 equalverify
76 dup
a9 hash160
14 data20

67 else
04 data4

b1 checklocktimeverify
75 drop
76 dup
a9 hash160
14 data20

68 endif
88 equalverify
ac checksig

Type 2a: sha256 secret, length=94byte
Code:
63 if
a8 sha256
20 data32

76 dup
a9 hash160
14 data20

88 equalverify
ac checksig
67 else
04 data4

b1 checklocktimeverify
75 drop
76 dup
a9 hash160
14 data20

88 equalverify
ac checksig
68 endif

Type 2b: sha256 secret, length=93byte
Code:
63 if
a8 sha256
20 data32

88 equalverify
76 dup
a9 hash160
14 data20

67 else
04 data4

b1 checklocktimeverify
75 drop
76 dup
a9 hash160
14 data20

68 endif
88 equalverify
ac checksig

Type 3: ripemd160 secret, length=81byte
Code:
63 if
a6 ripemd160
14 data20

88 equalverify
76 dup
a9 hash160
14 data20

67 else
04 data4

b1 checklocktimeverify
75 drop
76 dup
a9 hash160
14 data20

68 endif
88 equalverify
ac checksig

Type 4a: hash160 secret, length=86byte
Code:
63 if
03 data3

b1 checklocktimeverify
75 drop
76 dup
a9 hash160
14 data20

88 equalverify
ac checksig
67 else
76 dup
a9 hash160
14 data20

88 equalverify
ad checksigverify
82 size
01 data1
21 -> 33
88 equalverify
a9 hash160
14 data20

87 equal
68 endif

Type 4b: hash160 secret, length=82byte
Code:
63 if
03 data3

b1 checklocktimeverify
75 drop
76 dup
a9 hash160
14 data20

88 equalverify
ac checksig
67 else
76 dup
a9 hash160
14 data20

88 equalverify
ad checksigverify
a9 hash160
14 data20

87 equal
68 endif

Type 5a: hash160 secret, length=81byte
Code:
63 if
a9 hash160
14 data20

88 equalverify
76 dup
a9 hash160
14 data20

67 else
04 data4

b2 checksequenceverify
75 drop
76 dup
a9 hash160
14 data20

68 endif
88 equalverify
ac checksig

Type 5b: hash160 secret, length=78byte
Code:
63 if
a9 hash160
14 data20

88 equalverify
76 dup
a9 hash160
14 data20

67 else
01 data1

b2 checksequenceverify
75 drop
76 dup
a9 hash160
14 data20

68 endif
88 equalverify
ac checksig

Type 6: hash160 secret, length=79byte
Code:
63 if
54
b1 checklocktimeverify
75 drop
76 dup
a9 hash160
14 data20

88 equalverify
ac checksig
67 else
76 dup
a9 hash160
14 data20

88 equalverify
ad checksigverify
a9 hash160
14 data20

87 equal
68 endif

Type 7: multiple ripemd160 secrets, length=80 + n*23byte
Code:
63 if
a6 ripemd160
14 data20

88 equalverify
a6 ripemd160
14 data20

...
88 equalverify
a6 ripemd160
14 data20

88 equalverify
21 data33

ac checksig
67 else
04 data4

b1 checklocktimeverify
75 drop
21 data33

ac checksig
68 endif

Type 8: multiple ripemd160 secrets, length=81 + n*23byte
Code:
74 depth
60 16
87 equal
63 if
a6 ripemd160
14 data20

88 equalverify
a6 ripemd160
14 data20

...
88 equalverify
a6 ripemd160
14 data20

88 equalverify
21 data33

67 else
03 data3

b1 checklocktimeverify
75 drop
21 data33

68 endif
ac checksig

[1] http://www.cryptovibes.com/crypto-news/charlie-lees-atomic-swap-between-litecoin-and-bitcoin-was-a-success/
[2] https://insight.bitpay.com/tx/0bb5a53a9c7e84e2c45d6a46a7b72afc2feffb8826b9aeb3848699c6fd856480