Armed only with a bucket full of enthusiasm, a wiki full of miss-information and a 2 digit IQ, the good Captain seeks not only to understand the modern world, but also fix one or two bits of kit along the way.

Category

Sunday, 15 November 2015

Hanging on the BlockChain

There has been much discussion (and some excitement) in our house recently about the BlockChain.

Interest is also growing in large financial institutions, and companies are beginning to invest in research & development to ensure that they don't get left behind.

So will the BlockChain change our lives, or is it a techno dead-end?
I'm not sure, but its time I took a closer look.

BlockChain, is that like Bitcoin?

The BlockChain is a decentralised, distributed, virtual ledger. This means that it is not held on a single server, or controlled by an organisation (like a bank or government) and it maintains all transactions in a sequential database.

In principle the BlockChain could be widely used for securely storing information for a range of applications, but its main application at the present time is for storing transactions for cryptocurrencies such as Bitcoin.

Find an API and get hacking

Back in 2013 I wrote a Bitcoin post where I tried to use an API to extract Bitcoin information and data. The api was badly documented, so it took a lot of experimentation to work out roughly how it was supposed to work.

But things have moved on in two & a half years and there are now many well documented APIs such as the one I chose to explore: https://blockchain.info/api

So I used my Raspberry Pi web server to conduct a few tests. This server already has PHP and Lighttpd installed, so it should have just been a case of cloning the api code from Git and trying a few of the examples in this project.

...and hit F4 (this opens a terminal at this location). Then I used the command:-

composer install

On a remote computer it should now be possible to access one of the example files using the appropriate url, e.g.

http://192.168.0.22:9080/BC_api/example/rates.php

I seemed to have a problem initially with Curl. However, after a bit of fiddling around and a couple of re-boots it all came good.

Just about the most simple PHP software I could come up with is this, which only has 4 lines of code and illustrates how straightforward it is using this api:-

Hopefully this simple commented PHP code is self explanatory

...which calculates the current conversion rate and produces this one line output in a web browser:-

However, this API will allow you do much more, including receiving and sending money using you Bitcoin wallet. It also has APIs for other languages including Java, Python, C# and Ruby.

You will find many other APIs on the net of varying complexity including this one, which I understand is quite popular:-https://github.com/blockcypher/php-client

BlockChain Security

Fans of bitcoin will emphasise that the strength of BlockChain encryption makes a brute-force attack impossible. Just like the WW2 Enigma machine, trying to crack the encryption head-on is a waste of time.

Attack is futile! ...but there are often other ways

However there are other points in the whole business of dealing with crypto-currency that are worth consideration.

Your Bitcoins need to be held in a wallet either by you, or on your behalf. If you store them, then lose them due to a drive failure or you lose the hardware, they are gone for ever. Any kind of storage media may suffer a random failure, possibly due to manufacturing issues. All digital media will probably fail eventually.

If your wallet is held online, maybe by a trader, it may be vulnerable to hackers or a rouge trader (think Mt.Gox). Passwords were originally stored in plain text, and even if you have changed your password and encrypted the new one, your old wallet may still be hackable.

And if you are selling goods for Bitcoin, there are potential "double-spend" scams to beware of. The blockChain has an update time of 10 minutes. This is a target, but updates may occur quicker or take longer than the target. So there may be an opportunity to spend the same Bitcoin twice!

However, its a dangerous world, however you choose to spend or handle your money (cash, credit card or crypto-currency).

The View From Above

Even the "clever" people like Economists and Bankers are divided on whether techonology like Bitcoin should be taken seriously or just ignored.