BlockChain Internals: Data Storage

A BlockChain is a public ledger that create a digital ledger of transactions and share it among a distributed network of computers. BlockChain uses cryptography to allow each participant on the network to manipulate the ledger in a secure way without the need for a central authority.

BlockChain is just an data structure i.e. how logically data can be put together and stored. BlockChain in context of data structure is similar to Book. Lets take a look how BlockChain stores data :-

  • BlockChain uses Merkle Tree to Store the data in distributed manner.
  • You can think a Block as a page in the Book. just like a page contains header and content similarly Block also contains Header and Content.
  • Header contains the data about the block (we will read later).
  • Content contains the transaction data and data related to mining rewards.

Header of the Block :-    Header of the Block stores the following informations :-

  • Technical Data :- it contains Version , size of the block  and Magic ID.
  • Previous Block Hash :-  it contains hash of previous block header generated by 2 times applying SHA256 algorithm.
  • Merkle Root :-  it contains the single hash of the Block.
  • Time Stamp :-  it contains the time stamp when the block is created.
  • Difficulty Target :-  this data is related to mining how hard it is to mine the block.
  • Nonce :- A random number.

After the Header There is another part of the block that stores the Transaction count i.e. the total number of transaction this block stores.

Content of the Block :-  Content of the block contains the following informations:-

  • Coinbase Transactions:-    this contains the data related to mining reward, processing fees. its special type of transaction where there  is no input and from address.
  • BitCoin Transaction :-   this contains all to information related to all the transactions.

Transaction :-   Each transaction is the bitcoin payment. Each transaction contains the following informations :-

  • Technical Data :-  it contains Version number, Transaction lock time, Input count and Output Count.
  • Inputs :-   it contains the information about which coin are being spent. it includes Sequence number, script data, input script length, Previous transaction hash and index.
  • Output :-  it contains the information about who is getting the coin. in includes Output script length, Amount and output script.

These are information that are stored inside the Block of the BlockChain. Block contains lot of Hashes of different values thats makes it kind of immutable.

Each Block contains the reference of the previous block so, each block is connected with other block in chain like form which is more similar to pages link to each other in book.

Are we really eliminating central authorities with blockchain?

There is a lot of promise around blockchains. While we at DeepChains do subscribe to the philosophy and would be eager to provide business solutions to meet the industry needs but there has been a lot of double talk, it seems with blockchains.

The premise of blockchain is the following

  • No central registration – No big papa.
  • Decentralized – there is no single point of failure.
  • Safe – Encrypted and secure.
  • Private – My data as an individual is not held by a central authority. I choose what to share
  • Secure – end-to-end encrypted communication routed over Tor.
  • Open – Open source code

However, for all the so-called currency exchanges, this does not seem to be the case. Let us understand the premise of Bitcoins philosophy first. If you look at the image below, we are trying to get rid of any central agencies,

screenshot-from-2016-11-27-13-37-34

We are trying to get rid of any paperwork that needs to be submitted to these central agencies which make me share more information than what i need to.

Screenshot from 2016-11-27 13-38-03.png

and I need to be working without any central control in a true P2P manner.

screenshot-from-2016-11-27-13-41-19

However, let us cut to the current state of things with any blockchain enabled exchange that we are talking about. The current set of exchanges work on the concept of centralisation. They would become the man in the middle instead. So now we take out the banks but we have these men in the middle which would peddle less money than the traditional banks but peddle nevertheless. They would keep your information and subver the ideal blockchain model.

Screenshot from 2016-11-27 14-56-32.png

Let us take the example of a leading Bitcoin exchange called Unocoin in India. It provides a valuable service for converting Bitcoins into currency of choice but it does charge a fee. It asks me to store by Bitcoins in a wallet that it gives me and also asks me to submit a lot of information about me including some of my key identities (which is probably required by the law of the land). Let us see how it defeats the purpose on the parameters that we discussed.

  • No central registration – It is Central
  • Decentralized – Single point of failure. If Unocoin is down, i cannot transact
  • Safe – Encrypted and secure. Probably true.
  • Private – My data is held in central repo. I cannot decide what i need to share and what not to share.
  • Secure – Yes
  • Open – No

So as we see it fails to deliver some of the credible requirements from the original philosophy. Also, since there are so many central exchanges present, it almost ends up being like banks competing with each other on their exchange rates and you have to do the homework to get to the right one. I have seen so many videos and tips on how to buy on one exchange and transfer to another and then sell it on another exchange so that you can get the best leeway.

So essentially, YOU (A) as a person cannot decide how much you would want to transfer to another person (B) exactly the way you would want to. You would have to go through an intermediary (central system) to make the transfer happen. Ideally, we would like to see  NO CENTRAL system and the money should just be transferred form computer to computer on a P2P network. Something like this

Screenshot from 2016-11-27 15-11-36.png

In support of this paradigm, Bitsquare seems to be working on this model with a software which works. This seems to gel well with the idea of actual decentralisation.

In the next few blogs, we would be looking at these differences in detail but for now a lot of new exchanges are spinning up which seem to be creating pseudo central agencies rather than decentralised ones.

Keep tuned.


References and image courtesy:-

[1] https://bitsquare.io/

[2]https://blockchainedu.org

 

 

Introduction to MultiChain : BlockChains

MultiChain  is a platform that enable us to create and deploy private BlockChain that can be used either within a Organization or between Organizations.  MultiChain provides a simple API and command-line interface thats make it easy to maintain and deploy.

The main aim of MultiChain is :-

  • to ensure that visibility of BlockChain‘s activity must be kept within the chosen participants.
  • to control over which transaction are permitted.
  • to enable more secure mining with proof of work and its associated cost.
  • the BlockChain system only store transaction related to participants.

Hand-shaking process in MultiChain :-      Hand-shaking process in MultiChain take place when two BlockChain nodes Connect

  • Each node present its identity as a public address on the permitted list.
  • Each node verify that other’s address is on its own permitted list.
  • Each node sends a challenge message to other party.
  • Each node sends back a signature of the challenge message providing there ownership of the private key corresponding to the public address they presented.

If any of the node is not satisfying with the results then  it aborts the peer-to-peer connection.

Mining in MultiChain :-      MultiChain restricts miner to a set of identifiable entities. MultiChain introduce a parameter called “mining diversity” which is constrains by

0  <=  mining diversity <= 1. The Validity of block is verified by :

  • Apply the permissions changes defined by transactions n the block in order.
  • Count the total permitted miners who are defined after these changes in the block.
  • Multiply no of miners by mining diversity and round up to get left spacing.

this enforce the round-robin schedule in which miner create blocks in rotation in order to generate a valid BlockChain. The mining diversity parameter defines the strictness of the schema. The 1 value defines every permitted  miner is included in rotation and 0 defines no restrictions at all.

In MultiChain the transaction fees and the Block reward is Zero by default but you can set these value in params.dat file. the params.dat file contains the whole configuration like :-

  • The Chain’s Protocol
  • Target Time for Block
  • Active Permission Type
  • Mining Diversity
  • Mining Reward
  • Permitted Transaction Type
  • Maximum Block size
  • Maximum meta data per Transaction.

you can find and read about all these parameters Here.

References :-    MultiChain White Paper

What would kill Uber, Airbnb, TripAdvisor in one go?

What do Uber, Airbnb, TripAdvisor, PayPal etc have in common. Right, they are super successful and highly valued and …. ?

Uber and Airbnb fall in the category of Shared Economy. Paypal has changed the way financial transactions are carried out and TripAdvisor makes the rating and booking of hotels and trips easier. So, what is the common theme? The common theme is that all of these are centralised, they control (we can debate this) what gets published and who gets the maximum attention (we can debate this as well). So say Airbnb decides tomorrow that person X in San Francisco should get better hits than person Y then they have the potential to do that. Again, I am not way suggesting that they are doing this but they do have the right (well, err ..?) and the potential because there are like a central authority now. For that matter, we have made them almost like banks, governments and visa.

Ok, and who can disrupt this business model. It is Blockchain.

So what is Block chain, as a starter, it is completely decentralised. It is not stored on any central location. It is distributed across volunteer machines in a true P2P fashion across the world. It is encrypted with public key and private key and is impossible to tamper with (well, until you implement it incorrectly, see DAO hack)

Let us see how it would work for say Uber. So now, instead of centralised Uber, we have an Uber in which all the people who want to drive  a car for living attach that meta with their profile in the Blockchain. So say there are 10,000 people in Toronto who register on the distributed block chain (remember no centralisation here) their intention to drive when hired. Now when a passenger wants a ride, there is a filter which finds the city and the driver on the basis of reputation on the Blockchain and gives us the result. Further, if along with driving I also put my intent to rent out my extra room on the block chain then if someone wants to book a room then they specify the filter in the same way on the blockchain and get back the listing of all the rooms that they would be interested in.

So once I use the blockchained car service or the room then I can leave a ranking of the service. With this data being IMMUTABLE, without any CENTRAL control and co-exists on several thousand computers across the globe in an encrypted format, there is NO WAY in which I could go and change the ranking. Some of the central aggregators would always face challenges for this. Blockchain on the other hand makes it virtually impossible ( in the absence of central control to get into frauds like this). Since the block chain is immutable for someone to go back and change anything, it would have to be done across thousands of machines and when other machines find a change in information on a set of machines which does not match them then they would start blacklisting those machines.

Uber, Airbnb and TripAdvisors are great central aggregators which help with automating workers on the periphery. What does that mean? It means that if you want to drive a car, you connect with Uber and it would automate your job of finding customers. Likewise for Airbnd and TripAdvisor. Whereas, Blockchain automates the centre of the ecosystem. Hence instead of putting a Cab driver out of job, it would put Uber and aggregators out of job since it would be connecting the consumer directly to the service provider.

Blockchain replaces this central system with a decentralized ledger of chained records. Each record is connected to the one before and the one after it, yielding a traceable history of every transaction. No record can be deleted and no existing records can be altered.

There are other instances where there is a direct attack on the central guardians of information or man-in-middle. Lloyd Marino suggested,

For instance, Mycelia, started by English singer-songwriter Imogen Heap, is developing a way to encode a blockchain contract into songs, so fans would pay the artist directly, without going through a record company. A blockchain e-reader could download ebooks directly from the authors, bypassing both publisher and bookstore, or even Amazon.

Hence, there is an amazing amount of interest and possibilities of what we can do and what we can achieve with Blockchain. Stay tuned!