Bi-directional payment channels over the Bitcoin cryptocurrency


Initial report


David Lozano Jarque

Computer Science Engineering degree

2016 - 2017 course

ETSE UAB

Introduction

Cryptocurrencies

In a few words, a cryptocurrency is a currency that uses digital assets in combination with cryptography to secure and verify its transactions, and regulate the generation of units of currency independently from a central bank.

Unlike physical currencies, cryptocurrencies do not rely on official authorities or institutions to get its value worth, instead, the users of the cryptocurrency give value to the currency itself by being a part of it.

How a cryptocurrency works

Functionalities

To create a currency, we need to be able to handle accounts, create and manage the creation of units of currency, know the accounts' balances and let users create transactions between their accounts. This is done with a software that will run every user of the cryptocurrency and will communicate with other users to create a decentralized network where the cryptocurrency operates.

Currency units generation

To generate units of currency, the software is coded with an algorithm that allows users to create units of currency under certain conditions that require consensus between all users to validate the currency unit value. Commonly the conditions for the currency unit generation are some work required for the cryptocurrency to be safe. Therefore there's an incentive for the nodes to work for the network safety. This action of currency units generation by nodes is often called mining.

Identities

In most current cryptocurrencies, users are identified with their public key-pair (or their hash in Bitcoin) so everyone can create an account without being part of the network simply by generating a public / private key pair.

Transactions

Once the account is created, transactions are created locally with the software and afterwards broadcasted to the network so other users know about the transaction. When the transaction is added to the blockchain, the transaction is valid and therefore accepted as valid by the nodes on the network. To select which user can add transactions to the blockchain, consensus algorithms are used.

Consensus

As said, some actions require consensus like adding transactions to the blockchain. Consensus algorithms are needed to take decisions like this one and also to ensure the generation of currency and transactions is valid and all nodes agree on the status of the cryptocurrency.

Components of a cryptocurrency

Technically, a cryptocurrency as is known nowadays involves the following components:

The Bitcoin cryptocurrency

Bitcoin is the most known cryptocurrency and the first decentralized cryptocurrency since its appearance in 2009, when an anonymous programmer whose nickname was Satoshi Nakamoto published a white paper in a cryptography mailing list and later on, the implementation of the cryptocurrency.

Bitcoin components

In the case of the Bitcoin cryptocurrency, the implementation of their components are:

Problems of the cryptocurrency

Speed

The problem as stated is that blocks of transactions are emitted every 10 minutes approximately, therefore, knowing the maximum size of the block and normal size of transactions, we obtain that the throughput of the cryptocurrency is one transaction per second. Traditional credit card companies process more than 10.000 per second.

Size

Also, all transactions are saved in the blockchain to be valid so even if we could process more transactions, nodes would have to buy more storage to store the blockchain as its size would increase 10TB per year, rather than the current rate of 20GB per year.

Payment channels

A solution for the stated problems is to create payment channels between nodes that don't operate on the blockchain, although their transactions could end up in the blockchain and appear as valid. This way, we can achieve higher throughputs as the transactions are sent between payment channel peers immediately. To implement payment channels, game theory is applied so new transactions that reflect the status of the payment channel make older transactions unprofitable so they are dropped and just the last transaction is kept, solving the size problem too.

To implement payment channels, Bitcoin scripting used in transactions to send and receive funds are used to create smart contracts.

Goals

The goal of the project is to implement a real a bi-directional payment channel using the idea stated article A Fast and Scalable Payment Network with Bitcoin Duplex Micropayment Channels that can be found in references section. The payment channel must work and be able to ensure the good behavior of all the parties in the channel with the use of smart contracts

Methodology

To perform the project, a research about the Bitcoin cryptocurrency low-level implementation to see what smart contracts has to be made to know the limits of the scripting language and therefore check if the implementation of the payment channel can be performed.

Later, we'll create the transactions to operate the channel. To do so, we'll create a software that generates real transactions that a payment channel would use.

As an optional step, automate the software so a final user without any knowledge about payment channels rather than the basic concept and definition can use it to create a payment channel with another peer running the software.

Software development methodology

To develop the software we'll use Git control versioning using a private repository in GitHub:

https://github.com/ccebrecos/btc-payment-channels

The software development methodology will be an agile methodology with cycles of design, implementation and test of one or two weeks.

Planning

To plan the project, we have used Microsoft Project to list all the tasks we'll perform to achieve the project goal and finally create a Gantt diagram to see the project estimated schedule.

gantt_diagram

Visit http://bit.ly/2mqxb2V for a high-resolution version

Agile development

The group of tasks number 30 that consists of the software development defines the first cycle of development, that will be repeated until the project deadline while adding new features in each cycle until the goal is completed.

If the goal is completed before the deadline, next development cycles will add features to the software such as the listed in the Goals previous section.

References