Meetup-Notes

Bordeaux Engineers Share and Talk #7 - On Blockchain

đź•‘ Estimated reading time: 9mn

Table of Contents

Introduction to blockchain

By Chloé Moreau, Java engineer @ ekino

Introduction

It is at the end of 2008 that we started hearing about Bitcoin, a cryptocurrency created by an anonymous individual or group called Satoshi Nakamoto, with its first whitebook released the following year. It is what most people know about blockchain but blockchain is not just limited to cryptocurrencies; it is defined as a transparent and decentralized transaction ledger.

Each transaction is signed, added to a block and shared with the whole network. Asymmetric encryption is foundational to blockchain; each node, an actor like you and me, has a public key which is generally related to the address of a wallet and a private key. The whole system works with the concept of consensus; a method shared by everyone in the network to add information to the chain. Each actor is not trusted but the network as a whole is. After a block is accepted through either the Proof of Work or Proof of Stake consensus methods, it is added to the chain and copied locally to the chains of every actor.

There are multiple types of nodes in a blockchain: lightweight, full, mining / staking, etc. Each type has its own specialties. Lightweight nodes will not download the whole blockchain, full nodes make decisions regarding blocks to add and mining or staking participate to the blockchain by creating blocks or storing it. Created blocks will consolidate a set of transactions and get sent to the other nodes of the network.

There are also multiple types of blockchain but to simplify, we will concentrate on either public or private ones. Public blockchains like Bitcoin or Ethereum hold a native currency or native token and no central authority. Private blockchains or “hybrid” or “consortium” have restricted access in read or write with a central authority distributing permissions. Examples of private blockchains include Hyperledger and MultiChain.

MultiChain

MultiChain is a private blockchain that is simple to install and use. It does not have a native cryptocurrency and exposes an API and a CLI. It is composed of assets, which are elements that hold value exchangeable between users and streams of data stored on which each element possesses its own key, an author and generic metadata to ease access. Basically, streams are an abstraction that enables data storage and archival use cases.

On the authorization side, they relate to the ability to connect, send and receive transactions, issue assets, create streams, mine blocks, activate users and administer the chain. From the version 2 onwards, it is even possible to create and apply custom permissions. It is important to note however that due to the fact that the chain is private by default, mining is impossible without prior permission. The mining diversity can also be configured to distribute the origins of the blocks to more than one mining node.

MultiChain has integrations for Java, C#, Python, JavaScript, PHP, Go, etc. which makes this technology ideal for Proof of Concepts.

Questions and Answers session

What is an example of blockchain that is not linked to cryptocurrency?

SAP uses blockchain to trace prescriptions. You can also use it in conjunction with IoT to track the state of a large network of industrial equipments.

Decentralization and scalability

By Hugo Briand, Blockchain Lead and Digital architect @ ekino

On scalability

To enable scalability on decentralized systems, it is necessary to understand the different types of distribution of an application and their limits. When there is only one actor distributing an application, it is said to be centralized and scalability is as easy as increasing the resources for that actor. When there are multiple actors distributing the same application, the situation is different.

Scalability is the capacity of adaptation of a service to its demand. Demand may be predicted from technical metrics such as CPU or RAM consumption or business metrics such as a number of concurrent users. There are two strategies to scale a system: vertical, i.e. tuning the capacity of the infrastructure or the consumption of the solution and horizontal which is equivalent to increasing the number of entry points.

The capacity to scale a service depends on multiple criteria: its usability, performance, security and its volumetry. To each of these criteria it is possible to assign one or multiple metrics related to users, requests, responses, network usage, hardware or any other fine-grained technical or business metric.

Architectures

Application architectures can be classified in three different categories:

Blockchain problematics

Blockchains must be immutable: modifying a block must be more expensive than any reward acquired by doing so. This approach comes from cybersecurity, where an attack that earns the attacker less that what it actually costs them is considered secure enough. A public blockchain is distributable, usable, accessible by any new actor at least for control and validation and must not create a hierarchy or a central authority. As for metrics, they will depend on the consensus algorithm.

If the consensus uses Proof of Work, metrics like difficulty and global power are exposed. In any case, the time to update the chain, the number of transactions per second, time to access the balance, transaction cost, delay and number per block are all valid metrics for a blockchain.

From a pure storage size standpoint, the Ethereum blockchain is ten times bigger than Bitcoin’s. This is due to its block creation frequency of every 15 seconds for Ethereum against every 10 minutes for Bitcoin and the way it is used with more complex smart contracts.

Scaling

It is possible to play on the type of architecture when scaling: changing the protocol, tweaking the consensus algorithm, abstracting the protocol with a new layer adding services and reducing access to the underlying stack. By adding abstractions, the system will require the installation and adoption of new tools. An example of that is the Lightning Network built on top of Bitcoin.

If we look at Bitcoin, in 2017, multiple solutions have been proposed: increasing the block size led to Bitcoin Cash, reducing the size of the transactions to add more in a block is the approach chosen by SegWit and required a soft fork and months of deployment. It is also possible to reduce the delay between two consecutive blocks like Ethereum or adding a protocol that reduces writes to the absolute minimum on top as we have shown before with the Lightning Network.

Similarly to the OSI model, there is an actual stack related to blockchains, which is composed of the following:
Physical > Data link > Network > Transport > Blockchain > Scripts > Crypto

Lightning Network is a full-fledged protocol facilitating and accelerating transactions but it is not the only example nor the only way to scale the network; parallel chains or sidechains are also a valid solution.

Eventually, scaling a system requires asking a question: what do we want to scale and how? Combining strategies may lead to better outcomes.

EasyWallet: Crypto everywhere

By Maxime Nory, Frontend engineer @ ekino, Personal website
By CĂ©cile Lesgourgues, Frontend engineer @ ekino

The EasyWallet application has not been released yet but will soon allow users to pay with Bitcoin during checkout at local stores. It has been developed in React Native with TypeScript using multiple components: Navigation, Styles Components, intl and Jest for tests.

Essentially, it creates a local wallet which private key is displayed as mnemonic generated thanks to a combination of libraries to the user. Since it is to be installed on phones, it is impossible to store the complete chain and make the phone a full node so it acts as a lightweight one depending on a server running the necessary software to act as a chain-connected node. The transactions are signed multiple times: once by the terminal held by the user thanks to the app and again by the server that transfers the transaction to the network. This mechanism is called PSBT, which stands for “Partially Signed Bitcoin Transaction”.

Bitcoin exposes two chains: MainNet and TestNet, the second of which is identical in behavior but which Bitcoins hold no value at all. It comes in handy when there are delicate scenarios to test such as currency conversion and hardware-rounded values, which can happen with Bitcoin, even though the Satoshi, the smallest unit of Bitcoin, is only worth 0,000 000 01 or 10^-8 Bitcoin.