2020 – The year of the Blockchain
The last 36 months has seen a exponential growth in the interest in Blockchain. Businesses are moving quickly to embrace it – Many, without really understanding it!
Really Important concept right here:
1 + 1 = 2
And, if you change anything!!
Anything at all…
It’s obviously wrong!!
It’s that simple…
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.
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,
This short background will follow the The evolution of “Block Chain” technology.
Elliptic Curves and Blockchain encryption
: Such as (a Third Degree Polynomial) has a specific known solution.
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“)
Password > SHA256 > 256 bit number
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.
In the case of Bitcoin:
Elliptic curve equation: y2 = x3 +7
Prime modulo = 2256 – 232 – 29 – 28 – 27 – 26 – 24 – 1 = FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE FFFFFC2F
Base point = 04 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798 483ADA77 26A3C465 5DA4FBFC 0E1108A8 FD17B448 A6855419 9C47D08F FB10D4B8
Order = FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE BAAEDCE6 AF48A03B BFD25E8C D0364141
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.
- Calculate the point (x,y) = k * G, using scalar multiplication.
- Find r = mod n (if r = 0 return to step 1). Modulo Arithmetic Calculator Here
- Find s = (z + r * d) / k mod n. (If s = 0, return to step 1)
- The signature pair is (r, s).
To verify the signature with the Public Key, a third party would perform the following steps:
- Verify r and s are between 1 and n-1
- Calculate w = s-1 mod n
- Calculate u = z * w mod n
- Calculate v = r * w mod n
- Calculate the point (x, y) = uG + vQ
- Verify that r = x mod n. The signature is invalid if not.
You may verify that these steps work by here
“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.
Then add a number until the first digit of the hash is zero.
My inputs looked like this:
And the resultant Hash was:
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.
What is the Genesis Block?
A Genesis Block is:
- The first block to be created in the beginning of a blockchain.
- For Bitcoin it is numbered Block 0.
- The Genesis Block is hard coded into the software of applications that use the Blockchain.
View Bitcoin’s Genesis Block
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!!