Technology - Blockchain


The blockchain is a recent technology that we hear a lot about.
After 3 months of project on the subject, I decided to share with you the knowledge that I acquired.

Index

General Introduction

blockchain
Source: https://besticoforyou.com/


It was in 2008 that the first blockchain appeared, along with the Bitcoin digital currency. The creator(s) of this technology are known under the pseudonym of Satoshi Nakamoto.
The goal of Satoshi Nakamoto, was to create an electronic payment tool using a decentralized network, to dispense with the trusted third party that is the bank.

Behind the term "blockchain" hides a technology of storage, and transmission of information, allowing a constitution of replicated and distributed registers, without a central control organ. The "blocks", thanks to cryptographic means, are linked to each other at regular intervals of time, which makes the blockchain safe. Of course, I will go back in more detail on these notions and explain their functioning throughout this article.

In many cases, the blockchain is likened to "a big book of untransifiable accountant", a big book in which everyone can read and write freely, but is impossible to destroy.

During the first years of its appearance, the blockchain was only a "public" technology, reserved for cryptocurrency. Then, companies began to take an interest in this technology and use it in other areas, mainly for its disintermediation benefits. That's when blockchain "private" appeared, this term is generalist, because there are several types of blockchain, which I will also present.

These private blockchains rely on the data that the blockchain will contain, the protocols used, the different access restrictions set up, etc. Companies are also interested in "smart contracts": a computer program that can be integrated into the blockchain to perform actions according to certain defined conditions.

However, despite these many benefits, blockchains have limited transactional capacity over traditional solutions. In addition, their energy consumption is a major defect to date.

This technology therefore raises questions in the fields of economics, finance, law (particularly with regard to the protection of personal data), but also in politics



What is a blockchain ?

As its name implies, the blockchain designates a "chain of blocks": this term is used because the transactions made by the users of the network are grouped in blocks, which are linked together by cryptographic means.

The blockchain is a database, which is tamper-proof and distributed: the management of this database is handled by a network of "nodes" (computers) which are interconnected, and which contain the same information.

In the case of the Bitcoin blockchain (and most other public blockchains) as well as in most private blockchains, the protocol used to connect the nodes between them is the peer-to-peer protocol .
Peer-to-Peer is an exchange model where each entity in the network is both a client and a server, unlike the client-server model.

Nodes have a set of public / private key, the private key is used to sign the transaction, while the public key (that other members of the network have) to verify the authenticity of the signer.
There can be multiple sets of keys (which represent blockchain access accounts) per node, but a node may also contain no key sets but just a copy of the registry.

There is thus a system of "pseudonym" which brings a certain anonymity: we are identified on the network thanks to our public key, of the form "xq5z45Q $ SZD5qs95 + as4 .." and not thanks to personal data like the names / first names.

blockchain

What is a Block ?

Since the beginning of this article, we use the term "block". In this part, we will see in more detail this notion, which is the most important element of the blockchain.

A block is a file, which contains several "categories" of data:

  • At first, we have the block header, which contains: the date / time the block was created, as well as its number

  • Then we have the hash of the previous block. That's what makes the blockchain so interesting and safe, because if someone is malicious and changes something in a block, his hash will vary, and so all the other blocks will not have the same hash.
    (A hash is a mathematical function that calculates the numerical fingerprint of an input data, which makes it possible to quickly identify this data.It works in the same way as a signature to identify one person)

  • Then we have a number of transactions taken in the waiting list.

  • Then there is a proof of work (or other) consensus mechanism that we will explain in the next part.

  • Finally, there is the hash (sha256) of the current block that is generated from its header, the hash of the previous block, transactions and (or not, according to some cases) the result of the proof of work.


  • blocks

    In the diagram above, we can notice in block 0 that the hash of the previous block is null, this block is called the genesis block because it is the first block of the blockchain, created manually.

    blockchain

    Here is a preview of the first block of the Bitcoin Blockchain, where we can see the hash of the previous block which is 0. The same goes for each first block of public and private blockchains

    Link : https://www.blockchain.com/en/btc/block/

    Mechanisms of consensus

    A consensus algorithm can be defined as the mechanism by which a Blockchain network reaches a consensus. Public (decentralized) blockchains are built as distributed systems and, since they do not depend on a central authority, the distributed nodes must agree on the validity of the transactions.

    This is where the consensus algorithms come into play. They make sure that the rules of the protocol are followed and that all the transactions take place reliably, so that the corners can only be spent once

    There are several types of consensus algorithms. The most common implementations are PoW (Proof Of Work) and PoS (Proof Of Stake).

    Proof Of Work

    Proof of work is the consensus mechanism most used by blockchains (this is notably the mechanism used by Bitcoin blockchain as well as many cryptocurrencies).

    Mining consists in solving a cryptographic problem, called proof of work, which will allow the validation of a block. Performed by some nodes of the network, it is what allows to carry out a decentralized work and which replaces the verification by a single office.

    The success of this problem is to get the hash of the block that the miner deals with, and this hash must begin with a certain number of zeros.

    As the SHA-256 function is random, the resolution of the problem can be more or less long, all depends on our computing power, as well as the difficulty: it can be adjusted for private blockchains, so that the average time of a resolution is close to a given duration.

    In the case of public blockchains, this difficulty depends on the number of minors present on the network, and minors are encouraged to "mine" (to put their computing power at the disposal of the blockchain) by a remuneration in cryptocurrency when they validate a block.

    blockchain
    Source: I translated and redone the diagram proposed by Wikipedia

    Proof Of Stake

    An alternative to the proof of work, called proof of stake (Proof Of Stake), was created in order to overcome the problems of energy consumption related to the proof of work. The principle of this mechanism is to assign the validation of a block randomly to a node.

    Behind this mechanism is actually two proofs, that of participation, which aims to allocate the blocks to the nodes, according to their amount of cryptocurrency, and that of stake, which will require that the node in question put in "Pledge" the cryptocurrency they own.

    PoW VS PoS


    blockchain

    What is a Smart Contract ?

    A Smart Contract freezes rules in a Blockchain while ensuring the transfer of an asset, and it is contained directly on the blockchain's registry.

    A Smart contract is a piece of code that allows you to define rules, conditions, depending on the actions that happen on the blockchain, so it automates actions, and therefore pass from trusted third parties, but also to restrict actions.

    One of the most used programming languages ​​for the development of Smart Contracts, is Solidty, similar to JavaScript.

    blockchain

    Example of smart contract


    You are about to take a plane, and your trip is delayed, or canceled.

    By using the Smart Contracts, you would not have to call, make a file to get a refund, the program would receive the information of the cancellation or the delay of your flight, and will trigger an automatic refund, in the condifitions specified in your travel insurance contract.

    Another example imaginable, in the same register, is that of so-called index insurance (linked to an index such as the temperature or the level of rain). Thus, a smart contract concluded between the farmer and the insurer can stipulate that a payment is made after 30 days without precipitation. The smart contract is again fed by reliable external data (for example the rainfall data from the national meteorological service), which automatically triggers the payment after 30 days of drought, without the intervention of an expert or the need for a declaration or claim of the insured.

    The advantage of setting up smart contracts in a blockchain lies in the guarantee that the terms of the contract can not be modified.

    Public blockchain and private blockchain

    Public Blockchains

    Public blockchains are all those whose record of transactions is readable by everyone on the planet, everyone can send them transactions and expect them to be included in the registry, at least as long as these transactions follow the rules of this Blockchain.This is the case of Bitcoin for example, and others cryptocurrencies , for which everyone has free access to the register.  

    Private Blockchains

    Private blockchains bring together all the solutions that companies can install in their internal context and that they will decide to use either partially decentralized governance (consortium) or with a completely centralized governance (permissioned).

    Private Blockchain has certain access restrictions and requests permission to access it.

    To become a member of this type of blockchain, you need an invitation. It is approved or rejected by the creator of a network or the user-moderator who sets rules. Existing network members can also confirm access or deny access. The control mechanism is variable and depends on the rules.

    Businesses who set up a private blockchain, will generally set up a permissioned network. This places restrictions on who is allowed to participate in the network, and only in certain transactions.

    Private Blokchain is a good solution for companies where the confidentiality of information is very important. As a result, businesses can also reduce transaction costs and time.

    Open source blockchain

    In this part, I will briefly introduce the most famous open source blockchains, for more information, you can visit their official websites which explain very well how they work.

    Ethereum blockchain


    Created by Vitalik Buterin in 2014, Ethereum allows, beyond the functions of Bitcoin, to create smart contracts (smart-contract), ie accounts that can carry code-driven ethers (cryptocurrency). computer. In 2017, smart-contracts are mainly used for the issue of tokens and fundraising directly on the Blockchain.

    Link : https://www.ethereum.org/

    Hyperledger Fabric blockchain


    Hyperledger is an open source development platform for Blockchain. This project, initiated in December 2015 by the Linux Foundation, was later joined by IBM. Development is essentially in Go language.
    It is the blockchain open source most used in the private domain, but also the most complex to set up.

    Link : https://www.hyperledger.org/projects/fabric

    Multichain blockchain


    As part of my project, it is on this technology that I worked, but I will not detail what I realized because it would take time, the objective of this article is to present the blockchain so General. Maybe another article on the operation and deployment of Multichain will be written later.

    MultiChain forked from the Bitcoin Blockchain allowing users to control whether the chain is private or public, permissions to connect to the network, target time for blocks, and maximum block size and metadata. MultiChain also has a simple API and command line interface that helps to set up the chain.

    MultiChain key features:
  • Native multi-currency support
  • Expected to be faster than Bitcoin
  • Permissioned management
  • Quick deployments
  • Supported languages - Python, C#, JavaScript, PHP, Ruby

  • Link : https://github.com/MultiChain

    Hydrachain blockchain


    HydraChain is an extension of the Ethereum Blockchain platform which provides support to create private/permission Blockchain networks. The supporting language for HydraChain is python.

    As an extension of Ethereum, HydraChain is fully compatible with all the API level and contract level protocols in Ethereum. There are several well-defined tools in Ethereum for creating smart contracts and Dapps (Decentralized Apps).

    Link : https://github.com/hydrachain

    How the blockchain communicates with an application ?


    blockchain

    Realised by me on draw.io

    Use cases of the Blockchain

    Origin

    Here we will present the Origin solution created by Bureau Vertias.

    Bureau Veritas is a world-renowned company, which carries out inspections, audits, in many areas. Its main activity is certification.

    After several years of work on the blockchain and its applications, Bureau Veritas launches Origin, an application that allows the traceability of food products, using blockchain technology to guarantee transparency and data security.

    The goal is to provide the customer, through the scan of a QRcode, all the information about the product (give proof of the product's origin and quality, increase trust by making visible all checks and audits done throughout the product lifecycle)

    So this will give us a complete history of the product's journey, from fork to fork.

    This solution aims to remove intermediaries and increase customer confidence.

    blockchain

    Link : http://origin.bureauveritas.com/

    BCDiploma

    In France, according to the Ministry of Education, recruitment offices receive up to 30% of CVs that mention diplomas abusively<, or inaccurate (mentions, etc. ..).

    So far the solution that allows to bring a certain "authenticity" of a diploma is to request a certified copy to the issuer. But this process is long and tedious, so applications like BCdiploma use blockchain technology to provide a reliable and durable solution.

    Here's how it works with the case of the ESILV engineering school in Paris:

    Verification process

    blockchain

    blockchain

    When you have choose the blockchain, you can search in if a student have a diploma :

    blockchain

    Link of the App : http://diploma.report/issuers/school_list

    Bank sector

    In the banking sector, blockchain is mainly used in the context of asset transfers. Nowadays, a bank transfer from one country to another may require a large number of intermediaries to ensure the smooth running of the transaction.
    Thanks to the blockchain, it is possible to limit the number of intermediaries and to streamline the flow of information.

    By limiting the number of intermediaries, this would speed up operations and reduce their costs.

    Take the example of the Spanish bank Santander, which has launched a new international payment service based on blockchain, named One Pay FX.

    One Pay FX is a mobile application for international payments, which uses blockchain technology. This application allows users to view the total cost of sending their payments, including bank charges, exchange rates ...

    Thus, customers of this bank can make international transfers the same day, or so at the latest D + 1, which remains acceptable, compared to the traditional system which is several days.

    There are many other examples of applications in the banking field, but I can not present them all here..

    End of this article

    I tried to present the points is more important about the blockchain, I hope this article has been useful, do not hesitate to share it, it will be very encouraging for the future.

    Follow me on Twitter to be informed of my new articles/infographics → twitter(@SecurityGuill)
    If you like my work, feel free to support me with Buy me a coffeeBuy me a coffee