elective-stereophonic
elective-stereophonic
Trustless Escrows are Coming! singapore
Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest Stable Nxt Client: Nxt 1.12.2

Author Topic: Trustless Escrows are Coming!  (Read 3025 times)

kushti

  • Sr. Member
  • ****
  • Karma: +184/-5
  • Offline Offline
  • Posts: 384
  • Nxt Core & Apps Dev
    • View Profile
Trustless Escrows are Coming!
« on: October 23, 2014, 10:16:03 pm »

With 0.9.9 release ( https://nxtforum.org/nrs-releases/nrs-v0-9-9/ ) we've got ability to have trustless escrows though not working in some rare cases(so the approach is suitable for small-value transactions only):

Quote from: Jean-Luc
Alice prepares and signs a transaction A, but doesn't broadcast it (setting the
broadcast=false parameter introduced in this release). She sends to Bob the
unsigned transaction bytes, the full transaction hash, and the signature hash.
All of those are included in the JSON returned by the API. (Warning: make sure
not to send the signed transaction bytes, or the signature itself, as then Bob
can just broadcast transaction A himself).

Bob prepares, signs and broadcasts transaction B, setting the
referencedTransactionFullHash parameter to the full hash of A provided by Alice.
He can verify that this hash indeed belongs to the transaction he expects from
Alice, by using the new calculateFullHash API, which takes unsigned transaction
bytes and signature hash (both of which Alice has also sent to Bob). He can also
use the parseTransaction API to decode the unsigned bytes and inspect all
transaction fields.

Transaction B is accepted in the unconfirmed transaction pool, but as long as A
is still missing, B will not be confirmed, i.e. will not be included in the
blockchain. If A is never submitted, B will eventually expire - so Bob should
make sure to set a long enough deadline, such as the maximum of 1440 minutes.

Once in the unconfirmed transactions pool, Bob has no way of recalling B back.
So now Alice can safely submit her transaction A, by just broadcasting the
signed transaction bytes she got in the first step. Transaction A will get
included in the blockchain first, and in the next block Bob's transaction B
will also be included.

Note that while the above scheme is good enough for a simple escrow, the
blockchain does not enforce that if A is included, B will also be included. It
may happen due to forks and blockchain reorganization, that B never gets a
chance to be included and expires unconfirmed, while A still remains in the
blockchain. However, it is not practically possible for Bob to intentionally
cause such chain of events and to prevent B from being confirmed.


Two months ago I published specification for 2-phased transactions ( https://nxtforum.org/general/2-phased-transactions-pre-implementation-specification/ ). Implementation is done according to the spec(though minHeight parameter is missed), so I'm going to investigate real-world use cases for 2-phased transactions & possible changes to spec&implementation before release(which is planned for 1.4.x):

1. Multivoting

By adding ability to vote for few pending transactions release at the same time trustless and 100% reliable escrow scheme possible with 4 transactions:

Tx 1. Alice publishes into blockchain a pending transaction to Bob which will be released only when both Alice and Bob vote for it
Tx 2. Bob publishes into blockchain a pending transaction to Alice which will be released only when both Alice and Bob vote for it
Tx 3. Alice generates  transaction bytes for a multivote transaction with votes for both transactions 1 & 2  & sends unsigned transaction bytes, the full transaction hash, and the signature hash to Bob
Tx 4. Bob sends to the unconfirmed transactions pool a transaction with votes for both transactions 1 & 2  & reference to hash of transaction #3

Then... read JLP's explanations above, but in (pretty unusual but possible) case of having transaction #4 lost both Alice & Bob loses nothing except of transactions fees(transactions #1 & #2 will be refused after deadline)

2. Vote-for-hash & votable appendix

In 1.2.x(I've forgotten 'x' unfortunately) transaction appendages were introduced. E,g, with message appendix every transaction could has message included, with pendable appendix it will be possible to create pending transaction to be released  when voting quorum met or refused on deadline etc
 I think we can introduce Votable appendix as well means transaction doing voting on another transaction in addition to its main purpose.

Another promising feature is voting for transaction hash(so transaction couldn't be presented into blockchain but a vote for it is already there).

With those additions trustless escrow could be done with just 2 transactions:

1. Alice generates  transaction bytes for a pending transaction to Bob which will be released only when Bob votes for it. Then she sends unsigned transaction bytes, the full transaction hash, and the signature hash to Bob
2. Bob sends to the unconfirmed transactions pool a transaction to Alice with tx #1 hash within voting appendix. 

Then again, JLP's turn to explain :)

Feedback & Contribution are needed

What features to implement? Multivoting is simple, vote-for-hash & votable appendix is a harder task. It also depends on community needs so let's think together about possible use cases of phased transactions!


(More contracts further)
Logged
for donations / messages: NXT-PKXM-WH25-UXXG-CJAVD (alias: kushti)

TwinWinNerD

  • Hero Member
  • *****
  • Karma: +222/-116
  • Offline Offline
  • Posts: 2012
  • CEO BitPanda.com
    • View Profile
Re: Trustless Escrows are Coming!
« Reply #1 on: October 23, 2014, 10:32:01 pm »

Is it possible with that stuff to make arbitrated transactions?

Alice wants to sell 100 NXT for 1 BTC to Bob
An arbitrator will release the NXT to Bob, without ever holding it.

Tx 1.  Alice sends a pending Tx to Bob that needs to be "confirmed" by Abritrator.
BTC Tx. Bob sends the BTC to Alice.
Tx 2. As soon as Arbitrator sees that the BTC Tx is confirmed, he will then confirm the NXT payment.

kushti

  • Sr. Member
  • ****
  • Karma: +184/-5
  • Offline Offline
  • Posts: 384
  • Nxt Core & Apps Dev
    • View Profile
Re: Trustless Escrows are Coming!
« Reply #2 on: October 23, 2014, 10:37:17 pm »

Is it possible with that stuff to make arbitrated transactions?

Alice wants to sell 100 NXT for 1 BTC to Bob
An arbitrator will release the NXT to Bob, without ever holding it.

Tx 1.  Alice sends a pending Tx to Bob that needs to be "confirmed" by Abritrator.
BTC Tx. Bob sends the BTC to Alice.
Tx 2. As soon as Arbitrator sees that the BTC Tx is confirmed, he will then confirm the NXT payment.

That simplest case with trusted party is already implemented!
Logged
for donations / messages: NXT-PKXM-WH25-UXXG-CJAVD (alias: kushti)

TwinWinNerD

  • Hero Member
  • *****
  • Karma: +222/-116
  • Offline Offline
  • Posts: 2012
  • CEO BitPanda.com
    • View Profile
Re: Trustless Escrows are Coming!
« Reply #3 on: October 23, 2014, 10:40:44 pm »

But that doesn't work with 2 different blockchains?

Also how can you do such a "trade", is there a GUI for us non-coders?

kushti

  • Sr. Member
  • ****
  • Karma: +184/-5
  • Offline Offline
  • Posts: 384
  • Nxt Core & Apps Dev
    • View Profile
Re: Trustless Escrows are Coming!
« Reply #4 on: October 23, 2014, 10:48:35 pm »

But that doesn't work with 2 different blockchains?

Also how can you do such a "trade", is there a GUI for us non-coders?

I'm Nxt core developer and crosschains stuff is out of scope of my duties. I'm willing to give a better support from Nxt to crosschains businesses though.
Logged
for donations / messages: NXT-PKXM-WH25-UXXG-CJAVD (alias: kushti)

TwinWinNerD

  • Hero Member
  • *****
  • Karma: +222/-116
  • Offline Offline
  • Posts: 2012
  • CEO BitPanda.com
    • View Profile
Re: Trustless Escrows are Coming!
« Reply #5 on: October 23, 2014, 11:10:09 pm »

Yes, but the NXT pending transaction that needs to be confirmed by the arbitrator is pretty much NXT chain only.

kushti

  • Sr. Member
  • ****
  • Karma: +184/-5
  • Offline Offline
  • Posts: 384
  • Nxt Core & Apps Dev
    • View Profile
Re: Trustless Escrows are Coming!
« Reply #6 on: October 23, 2014, 11:23:27 pm »

Yes, but the NXT pending transaction that needs to be confirmed by the arbitrator is pretty much NXT chain only.

Bitcoin has multisigs already. An arbitrator needs to build a logic on top of bitcoin's multisigs & Nxt's 2-phased transactions to provide escrow service by just providing signatures on both chains not holding money
Logged
for donations / messages: NXT-PKXM-WH25-UXXG-CJAVD (alias: kushti)

jl777

  • Hero Member
  • *****
  • Karma: +718/-123
  • Offline Offline
  • Posts: 6170
    • View Profile
Re: Trustless Escrows are Coming!
« Reply #7 on: October 23, 2014, 11:45:14 pm »

Yes, but the NXT pending transaction that needs to be confirmed by the arbitrator is pretty much NXT chain only.

Bitcoin has multisigs already. An arbitrator needs to build a logic on top of bitcoin's multisigs & Nxt's 2-phased transactions to provide escrow service by just providing signatures on both chains not holding money
havent had a chance to study this in detail yet, but if two coins both support some sort of multisig ability, it is usually possible to create a hybrid and then a matter of making a GUI for it
Logged
There are over 1000 people in SuperNET slack! http://slackinvite.supernet.org/ automatically sends you an invite

I am just a simple C programmer

jabo38

  • Sr. Member
  • ****
  • Karma: +40/-38
  • Offline Offline
  • Posts: 381
    • View Profile
Re: Trustless Escrows are Coming!
« Reply #8 on: October 24, 2014, 04:51:58 pm »

Yes, but the NXT pending transaction that needs to be confirmed by the arbitrator is pretty much NXT chain only.

Bitcoin has multisigs already. An arbitrator needs to build a logic on top of bitcoin's multisigs & Nxt's 2-phased transactions to provide escrow service by just providing signatures on both chains not holding money

that is really cool.  I would love to see that implemented.
Logged
Never Enough Money

kushti

  • Sr. Member
  • ****
  • Karma: +184/-5
  • Offline Offline
  • Posts: 384
  • Nxt Core & Apps Dev
    • View Profile
Re: Trustless Escrows are Coming!
« Reply #9 on: October 29, 2014, 01:13:03 am »

Multivoting is implemented, other features will be not implemented for first time at least.
Logged
for donations / messages: NXT-PKXM-WH25-UXXG-CJAVD (alias: kushti)
 

elective-stereophonic
elective-stereophonic
assembly
assembly