AdamISZ / pathcoin-poc

PathCoin (transfer bitcoin without network interaction) - proof of concept demonstration
11 stars 2 forks source link

pathcoin-poc

PathCoin (transfer bitcoin off-chain without network interaction) - proof of concept demonstration

This code implements the idea laid out here.

It requires Bitcoin Core running in signet or regtest mode. For local testing you should use Bitcoin-Inquisition, because that supports BIP 119 (for signet, it's preferable but not necessary).

How would you use this? (i.e. test it)

The series of steps is:

Practically one could work with a number between 3 and 20 participants. File sizes (talking 100s of bytes to kilobytes) and computation are still perfectly fine up to 100 or more participants, but in that case, broadcasting penalty transactions would start to get problematic (e.g. 100 unconfirmed transactions chained together).

Just-in-time Fidelity Bonds

It's already obviously very limited to have one path of payment, i.e. one recipient per hop. And one coin denomination. Notice, though, that if you have not yet received the coin, you owe nothing and don't need to create a fidelity bond yet. You can wait to fund a fidelity bond until only when you want to send it to the next participant. If you just spend it out to an external Bitcoin address, you never need to fund a fidelity bond at all. And as explained in detail in the gist, the size of the fidelity bond utxo you fund will always be only the amount of the coin (plus a small delta, here 10%).

This can really matter if, as one might imagine, 1000 pathcoins were created amongst a small group of 20 people. They wouldn't have to lock up 1000 fidelity bonds, but only create them on the fly, if they need to send a pathcoin to the next person.

Advantages

The only reason this approach is interesting is that it creates an extreme case of non-interaction in off-chain payment. Two examples, neither of which are very practical, but at least have some sense:

  1. 20 people living together in a remote village with constrained access, could, as long as they could get together occasionally to share network access via the "village wifi", and at the same time check the blockchain, could theoretically effect real economic payments over a long period, using such coins and transferring them as small files. It would be pretty limited due to denominations, and the collateral requirements (penalty bonds) would probably all have to be committed in advance here (effectively, locking up 100% of the value that could be transferred) to avoid needing any network/blockchain checks during usage.

  2. Secret agents and similar needing super-high opsec, not wanting any ability to network trace their payments at the time they are made. A small group of people could do the initial negotiation of the pathcoinstate files in a Faraday cage, exchanging messages between their computing devices (the funding utxo could be prepared in advance of this meeting, without yet broadcasting the funding). Later one participant can fund the coin, and all the others fund penalty bonds, in separate, disconnected Bitcoin payments. Then individual transfers can be done "sitting on a park bench" with no blockchain access, no network access, only a cheap computing device capable of comparing the transfer file with the state file and ensuring cryptographic consistency. A fanciful scenario perhaps, but it has some logic.

A note on cost:

Payments on the path are free, i.e. literally zero sats cost, and immediate. But the collateral cost is very non-trivial, i.e. at the point of spending, you must have funded the penalty bond, which will be locked for some negotiated time. So the main cost comes in the form of sacrificed time value.

Caveat

This implementation of the idea is very insecure (python ECC, no testing, nowhere near enough logical checks in code, unreviewed, etc. etc.), and very unperformant.

(All this is just in case in some distant future, someone thinks they can use this code for mainnet - no, you can't.)

Still, it does function correctly - you can fund, spend the pathcoin, transfer the coin with (base64 encoded) files, reclaim bonds after timelock and penalties for illegal spends work.

Installation:

See INSTALL.md. These instructions have only been tested as working on Ubuntu 20.04.

Details on workflow

Note: in a properly developed implementation, the two first steps would be folded into one negotation between all the parties.

First and second steps require all parties to connect to each other (hence onions over tor or localhost with --no-tor option).

Workflow now splits. From here there is no longer a need for participants to connect to each other over a network. If they are not physically colocated, then one-way sending of files is sufficient (or dropping them off in some server, in a 'store and forward' way, encrypted).

See ./runme.py help [method] for the syntax of any of these methods.