Menu

Bitcoin

2018 – The year of the Blockchain

The last 18 months has seen a phenomenal growth in the interest in Blockchain. Businesses are moving quickly to embrace it. This article will examine the technical aspects associated with a Blockchain.

So what is a Blockchain?

A blockchain consists of blocks that hold batches of valid and immutable transactions.

A ‘Hash’ is like digital DNA

Each block includes the hash of the prior block in the blockchain, linking the two. A “hash’ might be described as the mathematical DNA of a transaction or piece of information. And just like DNA the hash of each block is passed down to the hash of the next block. The linked blocks form a chain, all the way back to the first block – called the Genesis Block.

Any minor change in any prior block will produce a vastly different hash and cause a major change in the hash of subsequent blocks. This difference is obvious to other computers in the distribute network and is therefore penalised as per the scoring system described below.

In addition to a secure hash based history, any blockchain database has a specified algorithm for scoring different versions of the history so that one with a higher value can be selected over others. Peers supporting the database don’t have exactly the same version of the history at all times, rather they keep the highest scoring version of the database that they currently know of. Whenever a peer receives a higher scoring version (usually the old version with a single new block added), they extend or overwrite their own database and retransmit the improvement to their peers.

There is never an absolute guarantee that any particular entry will remain in the best version of the history forever. Blockchains are typically built to add the score of new blocks onto old blocks. There are incentives to only work on extending with new blocks rather than overwriting old blocks. The probability of an entry becoming superseded goes down as more blocks are built on top of it – eventually becoming very low.

In the context of bitcoin, the blockchain is a digital ledger that records every bitcoin transaction that has ever occurred.

A blockchain system consists of two kinds of records:

transactions, and,

blocks.

This short background will follow the The evolution of “Block Chain” technology.

Elliptic Curves and Blockchain encryption

And Elliptic curves have a unique property, in that you can to “add” solutions of an elliptic curve together to get another solution.

If you draw a line through the curve (that is not horizontal or vertical), it will always intersect the curve at a third point. This is defined as adding Point P to Point Q. As shown below:-

The only exception is if a line is Tangential to the Elliptic curve. In this case, the line intersects the curve at one other point only. And this is defined as “Doubling” of point “P”. As shown below:-

In the above examples point R is found by reflecting R’ though the x axis

Blockchain, Finite Fields and Hash Functions

A finite field, in the context of Elliptical Curve Digital Signature Algorithm (ECDSA), can be thought of as a predefined range of positive numbers within which every calculation must fall. Any number outside this range “wraps around” so as to fall within the range.

The simplest way to think about this is calculating remainders, as represented by the modulus (mod) operator. For example, 9/7 gives 1 with a remainder of 2:

9 mod 7 = 2

Here our finite field is modulo 7, and all mod operations over this field yield a result falling within a range from 0 to 6.

A Hash function is simply a rule applied to data to give a result – in this case a number. For example, SHA256 is a Hash function that takes an input and has a 256 bit output. (SHA = Secure Hash Algorithm. “See Playing with the SHA256 Calculator“)

File >

Password > SHA256 > 256 bit number

Data >

In the case of SHA256 there are 2256 possible outcomes.

(Another important Hash algorithm is RIPMED160).

Block Chain technologies (such as Bitcoin), use very large numbers for their base point, prime modulo and order. The security of the blockchain relies on these values being large, and therefore totally impractical to reconstruct.

Private and Public Keys and Wallets

To produce a “Private Key”, the Block Chain protocol chooses a point on the elliptical curve, eg. Point “E” i.e. The Base Point.

A Private Key is just a number – “N” (such that, 0 <= N <= 2256)

The Public Key associated with a Private Key is simply the Point “E”, added to itself “N” times. I.E. P = NxE

For Bitcoin, the address associated with the key is the RIPMED160 Hash of the SHA256 Hash of the Public Key.

Wallets are simply files that contain the Private and Public Keys and the addresses. Wallets usually contain many keys and may also contain labelling information for transactions, such as “Loan Payment” etc.

Digital Signatures and the Blockchain

The Elliptical Curve is used to construct a Digital Signature , (or Signature Hash), to sign the data. The data can be of any length. The first step is to “Hash” the data to create a number containing the same number of bits as the order of the curve (256). The mathematics is quiet involved, so for simplicity I will just outline the steps. (If you require further information click here for a full worked example using small numbers.

Hash the Data to create a number containing the same number of bits as the order of the curve i.e. 256 bits.

“Bitcoin Mining” and “Proof of Work”

Miners are not so much solving a math problem as they are spending a lot of effort making guesses until they guess correctly.

Bitcoin works by having a linked set of “blocks” of transaction records that document who has what bitcoin. To make bitcoin work, they needed some way to ensure that the record of blocks is immutable, i.e. nobody can change it.

The way they accomplished this was to create the concept of mining. Miners take a current set of transactions, which includes a link to the last set accepted, and make many trillions of guesses, each time putting a number into the “nonce” field of the block header. The block, including the “header” and “Nonce” is then a “hashed”. For Bitcoin, the SHA-256 hash function is used. Then it is just a simple “IF” statement:

If the output of the hash is below a threshold value, then the block is valid…

And the block will be added to the chain and considered valid by other miners. The miner who guessed correctly is paid with a freshly minted Bitcoin. Hence, a new coin enters the system and other miners remain incentivised to process blocks.

Playing with the SHA256 Calculator

You may test the above procedure by playing with the SHA256 calculator. Just type in a line you want hashed – e.g.: Hello Dolly. Note the hash produced.

6F813C0EEBC8AC32C0A84A7D6FA19985394516D55E5862B1AB6C541F1355EE96

Then add a number until the first digit of the hash is zero.

My inputs looked like this:

Hello Dolly

12342453

And the resultant Hash was:

04540EE2809F31C0B0DD30B8D9CF640EE8CA4F4F47638652B37CE34CCAE062FD

Essentially, this is what miners do. However they are looking for a number that will produce many more leading zeros. I.E. A much smaller number – or threshold value. Try SHA256 for yourself.

The Bitcoin ‘Difficulty Parameter”

The “threshold value” above, is the “Difficulty Parameter”. The lower this value is set the more difficult it is to provide a guess “Nonce” that will produce a Hash low enough to be accepted and agreed as valid by other miners.

Difficulty is adjusted every two weeks to ensure that a new valid block is produced approximately every ten minutes or so. Difficulty is based upon how much time it took to find the last 2016 blocks (i.e. 60mins/10 * 24hrs * 14days). As an example:- If it took only one week, then the “difficulty” should double – so that no matter how much mining is happening worldwide, a new block continues to be created every 10 minutes on average.

Blockchain:- Writing things down forever

The blockchain is a permanent and agreed, self auditing ledger. Anything written to it is written in indelible ink.

Any attempt to change an entry will change the Blocks Hash (Digital Signature) and invalidate the block and every other subsequent block in the chain…

This would be immediately noticed by all the other computers in the distributed ledger. (All of whom keep a full and current copy of the last agreed upon blockchain (or ledger).

Bitcoin is merely a currency that is tracked on the Blockchain. There are possibilities for many more.

Please see my subsequent articles on Blockchain and Bitcoin.

As always,please like and share this article if you found it useful.

And you may download Satoshi Nakamoto original white paper here –

Download Satoshi Nakamoto

Read the original white paper now!

Get instant access to the most important Financial Technology paper ever written!!