Blockchain: A technical primer
© Shutterstock / phoelixDE
Gather around and I’ll tell you the story of blockchain! In this article, Greg Brady, founder and CEO of Tranquility Halo explains what blockchain is and how to put it to good use. Kepp in mind though: even though Bitcoin and the Blockchain are intertwined, as long as the Bitcoin ecosystem continues to roar away, you can use the Blockchain to write anything down forever.
A blockchain consists of blocks that hold batches of valid transactions.
Each block includes the hash of the prior block in the blockchain, linking the two. The linked blocks form a chain.
In addition to a secure hash based history, any blockchain database has a specified algorithm for storing 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 implementation 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
: Such as (a Third Degree Polynomial) has a specific known solution.
And Elliptic curves have a unique property, in that there is a way to “add” solutions of an elliptic curve together to get another solution.
Put simply, if you draw a line through the curve (that is not totally horizontal or vertical), it will always meet the curve at a third point. This is defined as adding Point P to Point Q. As shown below:
The only exception to this 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).
File >
Password > SHA256 > 256 bit number
Data >
In the case of SHA256 there are 2^{256} 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 algorithm relies on these values being large, and therefore impractical to brute force or reverse engineer.
In the case of bitcoin:
Elliptic curve equation: y^{2} = x^{3} +7
Prime modulo = 2^{256} – 2^{32} – 2^{9} – 2^{8} – 2^{7} – 2^{6} – 2^{4} – 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 <= 2^{256})
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 Algorithm to sign 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 quietly 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 n1
 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 clicking here
“Bit Coin” Mining and the “Proof of Work” concept
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 header is run through a hash function, also known as a “oneway” or “trapdoor” function. In this case, the SHA256 hash function is used. If the output of the hash function is below a threshold value, then the block is valid, is accepted by other miners, and the miner who guessed correctly is rewarded with the block reward, in bitcoins.
The lower the hash function output threshold, the harder it is to provide a guess that will cause the output of the hash function to be low enough, and just how low the threshold is is determined by something called bitcoin “difficulty.” Difficulty adjusts every two weeks based upon how much time it took to find the last 6 * 24 * 14 worth of blocks: 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 you write in it, stays in it. Bitcoin is a currency that is the first asset tracked on the Blockchain, and because it is used to pay the miners, Bitcoin and the Blockchain are intertwined. But as long as the Bitcoin ecosystem continues to roar away, you can use the Blockchain to write anything down forever.
This article was originally published on Tranquility Halo.
asap
Leave a Reply
Be the First to Comment!