Nxt Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest Nxt Client 1.11.5 - NEW RELEASE: Ardor 2.0.3e TestNet IS LAUNCHED!

Pages: [1] 2 3  All

Author Topic: Quack - NXT atomic asset swap  (Read 7308 times)

blackyblack1

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1654
    • View Profile
  • Karma: +163/-82
Quack - NXT atomic asset swap
September 16, 2015, 06:53:36 am


Quack enables easy, safe and secure atomic swaps of Nxt-based Assets and Currencies. With Quack, Nxt users can now directly exchange Assets, Currencies or NXT with no counterparty risk. Quack swaps/exchanges are implemented on the Nxt blockchain using Phased Transactions. Use Quack to directly exchange Asset<>Asset, Asset<>Currency, or Currency<>Currency, swapping them directly without the need to convert to NXT.

Features:

- Blockchain based. No off-chain communication required.
- Multiple assets and NXT payments supported in a single swap session.
- NRS 1.7 ready.
- Recipient has full information on swapped assets without off-chain communication.
- Full information of swap session is stored in blockchain. You can turn off your PC and come back later.

Fees:

- 2 NXT for each asset or NXT for swap.
- 3,5 NXT to send a tip to my account (also finalizes swap session). You are free to turn off tipping in the source code and have only 1 NXT fee here.

Last plugin release is here: https://bitbucket.org/blackyblack/quackplugin/downloads/quack-1.2.zip

Screens:





Discussion subforum: https://nxtforum.org/quack/
« Last Edit: January 07, 2016, 06:15:23 pm by blackyblack1 »

blackyblack1

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1654
    • View Profile
  • Karma: +163/-82
Re: Quack - NXT atomic asset swap
September 16, 2015, 06:54:51 am

I intend to start working on JS based GUI for a Quack. It will facilitate usage now and will help to port Quack to NXT plugin later. Some JS/CSS help is very welcome!

blackyblack1

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1654
    • View Profile
  • Karma: +163/-82
Re: Quack - NXT atomic asset swap
September 16, 2015, 06:55:24 am

- How it works.

Alice initiates asset swap by preparing a trigger tx. She does not broadcast it but uses it's fullhash as linked hash for phased transactions.
Now she broadcasts phased transactions linked to trigger tx and sets finish height to some reasonable number (eg 100 blocks ahead).
Bob can see incoming transactions. He waits until they are confirmed and sends his own phased transactions linked to the same trigger tx. Ideally he uses the same finish height as Alice's transactions.
Alice checks if Bob's transactions are confirmed and she is OK with his offer. Now she broadcasts her trigger tx and all transfers will be executed at finish height.

- How Bob could know of asset swap offer without off-chain communication?

Trigger tx contains information from Alice about her offer to Bob eg her assets and expected Bob assets. Unsigned bytes of trigger tx are added to each transaction in swap. This string of trigger tx bytes is known as swapid. Bob can check Alice offer and accept it with a single click (when UI is ready).

- How swap session is restored if PC is off.

We use linked hash field of transfers, quack identifier in messages and full hash of trigger tx to restore full history of swap session.
« Last Edit: September 16, 2015, 09:12:57 am by blackyblack1 »

blackyblack1

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1654
    • View Profile
  • Karma: +163/-82
Re: Quack - NXT atomic asset swap
September 16, 2015, 06:56:41 am

What I expect to see in future releases:

- UI (html/JS/CSS) *done
- MS currencies support (easy task) *done
- NXT plugin (requires JS porting) *done
- Auto confirmation of swap offer (optionally) *done
- Auto validation of swap offer *done
- Enforce tipping to my account *done
- Allow external service to finalize swap session (not safe, requires trust to external service, off-chain communication)
- Enforce safety of finish height and deadline settings *done
- Use prunnable messages *done
« Last Edit: December 11, 2015, 09:08:36 pm by blackyblack1 »

coinomat

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1520
    • View Profile
  • Karma: +214/-18
Re: Quack - NXT atomic asset swap
September 16, 2015, 08:58:16 am

pretty cool
OTC market for AE :)
Time to go further

Riker

  • Core Dev
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1578
    • View Profile
  • Karma: +412/-42
Re: Quack - NXT atomic asset swap
September 16, 2015, 09:46:59 am

You need to enforce that Bob's transaction finishes at the same height or before Alice's transaction, otherwise Alice can wait with the submission of the trigger transaction until her transaction finishes but not executed, then submit the trigger and cause only Bob's transaction to execute.

I didn't understand the swap id and transaction bytes ... as far as I can tell Bob can see Alice's transfer transaction and the full hash of the trigger transaction from the blockchain.
Alice can specify what she expects in return as an encrypted message.


NXT Core Dev
Account: NXT-HBFW-X8TE-WXPW-DZFAG
Public Key: D8311651 Key fingerprint: 0560 443B 035C EE08 0EC0  D2DD 275E 94A7 D831 1651

blackyblack1

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1654
    • View Profile
  • Karma: +163/-82
Re: Quack - NXT atomic asset swap
September 16, 2015, 10:20:47 am

You need to enforce that Bob's transaction finishes at the same height or before Alice's transaction, otherwise Alice can wait with the submission of the trigger transaction until her transaction finishes but not executed, then submit the trigger and cause only Bob's transaction to execute.
Yes. It can be enforced by UI. Now it is up to Alice whether accept Bob's offer or not.

I didn't understand the swap id and transaction bytes ... as far as I can tell Bob can see Alice's transfer transaction and the full hash of the trigger transaction from the blockchain.
Alice can specify what she expects in return as an encrypted message.
Additional encrypted message costs additional NXT. I am using in-band information about swap so full swap session can be restored by either party without off-chain storage.

Riker

  • Core Dev
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1578
    • View Profile
  • Karma: +412/-42
Re: Quack - NXT atomic asset swap
September 16, 2015, 10:52:45 am

You need to enforce that Bob's transaction finishes at the same height or before Alice's transaction, otherwise Alice can wait with the submission of the trigger transaction until her transaction finishes but not executed, then submit the trigger and cause only Bob's transaction to execute.
Yes. It can be enforced by UI. Now it is up to Alice whether accept Bob's offer or not.

I didn't understand the swap id and transaction bytes ... as far as I can tell Bob can see Alice's transfer transaction and the full hash of the trigger transaction from the blockchain.
Alice can specify what she expects in return as an encrypted message.
Additional encrypted message costs additional NXT. I am using in-band information about swap so full swap session can be restored by either party without off-chain storage.

I meant prunable encryption message explaining Alice expectation in plain text as part of the phased asset transfer transaction published by Alice. This shouldn't cost any fees.
What do you mean by "in-band information about swap" ? Why do you need to restore a swap session ? (it is already recorded on the blockchain)
NXT Core Dev
Account: NXT-HBFW-X8TE-WXPW-DZFAG
Public Key: D8311651 Key fingerprint: 0560 443B 035C EE08 0EC0  D2DD 275E 94A7 D831 1651

blackyblack1

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1654
    • View Profile
  • Karma: +163/-82
Re: Quack - NXT atomic asset swap
September 16, 2015, 11:15:06 am

You need to enforce that Bob's transaction finishes at the same height or before Alice's transaction, otherwise Alice can wait with the submission of the trigger transaction until her transaction finishes but not executed, then submit the trigger and cause only Bob's transaction to execute.
Yes. It can be enforced by UI. Now it is up to Alice whether accept Bob's offer or not.

I didn't understand the swap id and transaction bytes ... as far as I can tell Bob can see Alice's transfer transaction and the full hash of the trigger transaction from the blockchain.
Alice can specify what she expects in return as an encrypted message.
Additional encrypted message costs additional NXT. I am using in-band information about swap so full swap session can be restored by either party without off-chain storage.

I meant prunable encryption message explaining Alice expectation in plain text as part of the phased asset transfer transaction published by Alice. This shouldn't cost any fees.
What do you mean by "in-band information about swap" ? Why do you need to restore a swap session ? (it is already recorded on the blockchain)
Let's suppose that Alice initiated swap exchange. Now she turns off PC and goes away. After she comes back she want to know what is the current status of the swap and she needs trigger full hash and trigger tx bytes. So we scan blockchain and restore swap session from the information embedded in our phased transfers.
I could send this information only once (not embed in each tx) but I want to find information about the session as early as possible so it can be restored from any transaction in swap.

Riker

  • Core Dev
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1578
    • View Profile
  • Karma: +412/-42
Re: Quack - NXT atomic asset swap
September 16, 2015, 11:44:26 am

You need to enforce that Bob's transaction finishes at the same height or before Alice's transaction, otherwise Alice can wait with the submission of the trigger transaction until her transaction finishes but not executed, then submit the trigger and cause only Bob's transaction to execute.
Yes. It can be enforced by UI. Now it is up to Alice whether accept Bob's offer or not.

I didn't understand the swap id and transaction bytes ... as far as I can tell Bob can see Alice's transfer transaction and the full hash of the trigger transaction from the blockchain.
Alice can specify what she expects in return as an encrypted message.
Additional encrypted message costs additional NXT. I am using in-band information about swap so full swap session can be restored by either party without off-chain storage.

I meant prunable encryption message explaining Alice expectation in plain text as part of the phased asset transfer transaction published by Alice. This shouldn't cost any fees.
What do you mean by "in-band information about swap" ? Why do you need to restore a swap session ? (it is already recorded on the blockchain)
Let's suppose that Alice initiated swap exchange. Now she turns off PC and goes away. After she comes back she want to know what is the current status of the swap and she needs trigger full hash and trigger tx bytes. So we scan blockchain and restore swap session from the information embedded in our phased transfers.
I could send this information only once (not embed in each tx) but I want to find information about the session as early as possible so it can be restored from any transaction in swap.

But if Alice stores the signed trigger transaction bytes in its phased transfer transaction, Bob itself (or anyone else) can broadcast the trigger transaction bytes without transferring anything back. Once the signed transaction bytes are published, any account can broadcast the transaction to the network (I tried this and it works)
Alice would have to store the signed trigger transaction offline until it is ready to broadcast it.
NXT Core Dev
Account: NXT-HBFW-X8TE-WXPW-DZFAG
Public Key: D8311651 Key fingerprint: 0560 443B 035C EE08 0EC0  D2DD 275E 94A7 D831 1651

blackyblack1

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1654
    • View Profile
  • Karma: +163/-82
Re: Quack - NXT atomic asset swap
September 16, 2015, 11:52:51 am

But if Alice stores the signed trigger transaction bytes in its phased transfer transaction, Bob itself (or anyone else) can broadcast the trigger transaction bytes without transferring anything back. Once the signed transaction bytes are published, any account can broadcast the transaction to the network (I tried this and it works)
Alice would have to store the signed trigger transaction offline until it is ready to broadcast it.
No it is stored unsigned on chain. Alice can sign it later when she is ready to finalize swap.

Riker

  • Core Dev
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1578
    • View Profile
  • Karma: +412/-42
Re: Quack - NXT atomic asset swap
September 16, 2015, 11:58:50 am

But if Alice stores the signed trigger transaction bytes in its phased transfer transaction, Bob itself (or anyone else) can broadcast the trigger transaction bytes without transferring anything back. Once the signed transaction bytes are published, any account can broadcast the transaction to the network (I tried this and it works)
Alice would have to store the signed trigger transaction offline until it is ready to broadcast it.
No it is stored unsigned on chain. Alice can sign it later when she is ready to finalize swap.

As far as I recall only signed transactions has full hash, so Alice cannot publish the phasing trigger full hash without first signing the trigger transaction.
NXT Core Dev
Account: NXT-HBFW-X8TE-WXPW-DZFAG
Public Key: D8311651 Key fingerprint: 0560 443B 035C EE08 0EC0  D2DD 275E 94A7 D831 1651

blackyblack1

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1654
    • View Profile
  • Karma: +163/-82
Re: Quack - NXT atomic asset swap
September 16, 2015, 11:59:38 am

But if Alice stores the signed trigger transaction bytes in its phased transfer transaction, Bob itself (or anyone else) can broadcast the trigger transaction bytes without transferring anything back. Once the signed transaction bytes are published, any account can broadcast the transaction to the network (I tried this and it works)
Alice would have to store the signed trigger transaction offline until it is ready to broadcast it.
No it is stored unsigned on chain. Alice can sign it later when she is ready to finalize swap.
As far as I recall only signed transactions has full hash, so Alice cannot publish the phasing trigger full hash without first signing the trigger transaction.
She signs but do not broadcast. She stores unsigned bytes on blockchain and signs again later to get trigger tx with matching hash.

Riker

  • Core Dev
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1578
    • View Profile
  • Karma: +412/-42
Re: Quack - NXT atomic asset swap
September 16, 2015, 12:23:41 pm

But if Alice stores the signed trigger transaction bytes in its phased transfer transaction, Bob itself (or anyone else) can broadcast the trigger transaction bytes without transferring anything back. Once the signed transaction bytes are published, any account can broadcast the transaction to the network (I tried this and it works)
Alice would have to store the signed trigger transaction offline until it is ready to broadcast it.
No it is stored unsigned on chain. Alice can sign it later when she is ready to finalize swap.
As far as I recall only signed transactions has full hash, so Alice cannot publish the phasing trigger full hash without first signing the trigger transaction.
She signs but do not broadcast. She stores unsigned bytes on blockchain and signs again later to get trigger tx with matching hash.

I see now, Alice would iterate through all her account phased, outgoing transactions, read the unsigned bytes from a message attachment, sign the bytes to determine the full hash (which should match the current transaction trigger full hash) then find all incoming and outgoing phased transactions using this full hash to restore the session.
Bob can rely on the full hash of the trigger transaction to restore the session.
NXT Core Dev
Account: NXT-HBFW-X8TE-WXPW-DZFAG
Public Key: D8311651 Key fingerprint: 0560 443B 035C EE08 0EC0  D2DD 275E 94A7 D831 1651

blackyblack1

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1654
    • View Profile
  • Karma: +163/-82
Re: Quack - NXT atomic asset swap
September 16, 2015, 12:26:05 pm

But if Alice stores the signed trigger transaction bytes in its phased transfer transaction, Bob itself (or anyone else) can broadcast the trigger transaction bytes without transferring anything back. Once the signed transaction bytes are published, any account can broadcast the transaction to the network (I tried this and it works)
Alice would have to store the signed trigger transaction offline until it is ready to broadcast it.
No it is stored unsigned on chain. Alice can sign it later when she is ready to finalize swap.
As far as I recall only signed transactions has full hash, so Alice cannot publish the phasing trigger full hash without first signing the trigger transaction.
She signs but do not broadcast. She stores unsigned bytes on blockchain and signs again later to get trigger tx with matching hash.

I see now, Alice would iterate through all her account phased, outgoing transactions, read the unsigned bytes from a message attachment, sign the bytes to determine the full hash (which should match the current transaction trigger full hash) then find all incoming and outgoing phased transactions using this full hash to restore the session.
Bob can rely on the full hash of the trigger transaction to restore the session.
Yes. Or more easy way - use linked hash of phased transactions to group them together.

abctc

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1264
    • View Profile
  • Karma: +141/-13
Re: Quack - NXT atomic asset swap
September 16, 2015, 06:08:56 pm

I hacked a proof-of-concept java app for NXT assets atomic swap. Source code and initial release is here: https://github.com/blackyblack/quack
It does not have a UI yet so please use curl for Linux of fiddler for Windows to execute API calls.

Features:

....
- Great!  Translated and shared here: https://bitcointalk.org/index.php?topic=345882.msg12440425#msg12440425
Welcome to the Nxt generation of crypto!   Magis quam Moneta (More than a Coin)
"Do not worry, it is an attack" (c) Jean-Luc

blackyblack1

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1654
    • View Profile
  • Karma: +163/-82
Re: Quack - NXT atomic asset swap
September 17, 2015, 09:00:16 pm

Updated to 1.1.0 version.

Added MS support. Added prunnable messages. Added optional encrypted message to recipient. Removed unnecessary bloat in blockchain and algorithm.

Also tested on live network with NRS 1.5.9.

blackyblack1

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1654
    • View Profile
  • Karma: +163/-82
Re: Quack - NXT atomic asset swap
November 10, 2015, 08:39:33 am

I have announced 15000 NXT bounty for Quack GUI. I am already working with one guy who intend to claim the bounty. I think the reward will speed up the project a bit.

abctc

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1264
    • View Profile
  • Karma: +141/-13
Re: Quack - NXT atomic asset swap
November 10, 2015, 09:11:59 am

I have announced 15000 NXT bounty for Quack GUI. I am already working with one guy who intend to claim the bounty. I think the reward will speed up the project a bit.
- thank you!
I will send another 15000 NXT bounty to those guy(s)/girl(s), who will help blackyblack1 to build Quack GUI.
Welcome to the Nxt generation of crypto!   Magis quam Moneta (More than a Coin)
"Do not worry, it is an attack" (c) Jean-Luc

yassin54

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 2508
  • I am Homer, Sorry my english is Bad!!
    • View Profile
  • Karma: +240/-14
Pages: [1] 2 3  All