Feb 102014
 

So I’ve heard about this strange Bitcoin stuff for ages, but never found the time to look into it, until now. It cropped up at work, s I thought I should get acquainted. And this blog posting is an expression of my level of understanding, so it could well be wrong in places.

Certainly don’t take any of this as financial advice!

Bitcoin is a digital cash currency, but what does that mean?

Well the “cash” bit is understandable; it is normally expressed as a ‘peer-to-peer’ currency but essentially I hand over to you a certain number of bitcoins in exchange some agreed goods or services. Just the same as if I paid you in an ordinary currency in the form of cash.

It is a bit more complex than that as transactions have to be computationally confirmed. Or to put it another way, once you transfer the bitcoins, the transfer has to be independently verified which takes some time. The average seems to be about 8 minutes. So not quite the same as cash then; on the other hand it should be as anonymous as cash – perhaps even more so.

The “currency” bit is a tad more controversial. There’s more than a few governments that declare that bitcoins aren’t a currency but behaves more like a commodity (like gold). Of course they may be speaking with a forked tongue, or simply warning of the dangers of using bitcoins. Fundamentally a currency is a medium of exchange – so if you can find something to buy with your bitcoins, or you are prepared to sell goods or services for bitcoins, it is a currency for you.

Lastly the “digital” bit is where it can get a bit complex, so I won’t be trying. To put it very briefly, a bitcoin is a long string of digits that has been “discovered” (or more accurately mined) according to some complex calculation and then independently verified. It also includes details of all previous transactions that have occurred. The obvious question here is how is it that bitcoins cannot be forged?

There is no answer to that question without getting involved in the details of how bitcoins work computationally, but it is commonly held to be impossible without access to enough computational power to overwhelm the combined computational power of the bitcoin miners.

The Bitcoin “Bubble”?

In conventional economics a bubble is essentially some activity that becomes massively over valued and eventually loses it’s value. Examples include the South Sea Bubble, and the dot-com bubble. There are those who claim that bitcoin shares characteristics with famous historical bubbles, which is a very easy thing to say.

After all, no bubble is a bubble until it has been popped; at least in economics.

The trouble is that bitcoins are essentially worth what people agree they are worth. If everyone turned around tomorrow and agreed that they were worthless, you wouldn’t be able to spend them.

Which makes them the same as practically all modern currencies – the pound, the dollar, the euro. They are all backed not by silver or gold, but people’s confidence. Bitcoins are subject to much larger fluctuations than ordinary currencies which is at least partially a result of the small size of the bitcoins marketplace and the effect of external events such as China banning bitcoins.

The Wallet

To make use of bitcoins, you need a wallet to put them into. This is essentially an application that processes bitcoin transactions and keeps a record of how many bitcoins there are in the wallet. Full-blown wallets (such as one of the earliest – Bitcoin-QT) keep a full record of the bitcoin transactions to fully verify bitcoins; mobile wallets are less capable. Whilst there are still protections in mobile wallets, you may wish to be less trusting with mobile wallets until you know more about this than I do!

Once you have a wallet fully set up – which can take several days due to the large number of transactions it needs to download – you can start using it. Of course initially it will be empty, so you will be unable to buy anything, but you will be able to set up addresses for people to send you bitcoins which will look like 16hQid2ddoCwHDWN9NdSnARAfdXc2Shnoa.

Yes that’s a real address – it’s my “donation” address – and you are more than welcome to send me a coin or two. Or more realistically a tiny fraction of a coin.

Once you have something in your wallet, you can send bitcoins to addresses like the one above … or perhaps another address in return for something useful!

Mining Bitcoins

Previous sections have indicated that there is something called “mining” and that a great deal of computational power is behind the workings of the bitcoin network. Numerous volunteers contrib computer power – almost always using special hardware to do so – in the hope of making money.

Can you make money? Yes, but probably not enough to pay for the increased electricity bill and almost certainly not enough to pay back the initial hardware investment. People who got into mining earlier may have made a bit of money – when you could effectively mine with ordinary computer power, but unless you are prepared to invest many thousands of pounds on a regular basis it is unlikely that you will see anything like a reasonable return.

And this is probably bitcoin’s biggest weakness. The bitcoin network needs miners to validate all of the transactions that go on, and in the future, there may be a lack of volunteers if the return is not reasonable.

But of course I might be discouraging you as I’m mining a bit myself – and the more miners there are, the fewer bitcoins there are for me 🙂

Feb 042014
 

So I found myself in the position of wanting to poke around the file system of a virtual Windows machine – the kind of poking around you would prefer I didn’t if it were your Windows machine – and needed to make a VDI disk image available as a block device under Linux so it could be mounted in the normal fashion.

Googling around found some instructions; which didn’t work properly. Solutions were also available, but I’m writing up the ‘fixed’ instructions here to save myself time in case I need it again.

First step is to become root; if you need help doing that, this is probably the wrong page for you!

Next step is to install the Debian package qemu-utils which contains the tool qemu-nbd which we’ll need later. We also need to load the network block device module with a parameter :-

apt-get install qemu-utils
modprobe nbd max_part=16

This parameter is the key here – for some reason the default on at least some of my Linux machines is not to create additional block devices for any additional partitions that show up.

The next step is to ‘attach’ the VDI image (or presumably anything supported by qemu-img which covers pretty much everything popular) and tell the Linux kernel that there may be some new partitions to create device files for :-

qemu-nbd -n -c /dev/nbd0 disk.vdi
partx -a /dev/nbd0
partx: /dev/nbd0: error adding partitions 1-2

(Added the “-n” flag after reading about some more problems and a work-around; as I haven’t tested it, be careful!)

The error from partx indicates that qemu-nbd managed to create the partitions itself, but there are hints that this sometimes doesn’t happen so I’ve included the command here “just in case”. Once the partition block devices are present, they can be used as any ordinary devices.

Once finished, unmount anything mounted and release the block device with :-

qemu-nbd -d /dev/nbd0
rmmod nbd
Jan 272014
 

I’m old enough enough to remember the tail end of the real cold war between the West and the old Soviet Union when we were waving nuclear missiles at each other. And threatening each other with nuclear annihilation.

So it is a bit of an exaggeration to speak of a new cold war when the threat is nowhere near as apocalyptic. But if you take a look at how the old cold war was fought – with espionage, and signals intelligence – you begin to realise we do have a new cold war. Intelligence agencies around the world are cooperating in fighting against a new enemy.

Us.

Oh, they’ll defend themselves by saying that it’s not the normal man or woman in the street they are worried about, but but the terrorists in our midst they are targeting. But to do that they have to spy on us.

They’ll say that they are not spying on the people in their own country; just on those sneaky foreigners. But when GCHQ spies on US citizens, they pass the information they obtain to the NSA; and the NSA passes information on their spying activities to GCHQ.

Which means that what little protection we have against our own intelligence agencies spying on us is effectively meaningless.

Jan 172014
 

There is no clear answer to the question of how old the Internet is. For different definitions of the “Internet”, there will be different starting dates.

For instance, it is commonly held that the pre-cursor to the Internet – ARPANET – could not be called the Internet. And it is true that ARPANET was not the same as today’s Internet even at the lowest possible level. But there is a commonality to ARPANET standards through Internet standards – the very first RFC (issued in 1969) to one of the very latest (RFC7115) are all part of the same body of work.

And whilst the overwhelming majority of ARPANET era standards have been superceeded, there are a few that are still valid today. For example, an early standard for the names of hosts which restricts what characters can be used is still valid and (for example) restricts the names that can be used in email addresses – see RFC608 (it has been updated but the essential restrictions remain).

The next milestone in the history of the Internet came when the older NCP protocol was replaced with TCP/IP in 1982 (actually the “flag day” was 1st January 1983); this immediately raised the possibility of joining networks together and to route between them. Previous to this, different networks had gateway machines which were connected to two (or more) networks. Before the Internet took off, there were more than a few precursor networks – MERIT, JANET, BitNET, …; all of which used different network protocols.

Gateway machines would typically only gateway certain kinds of application traffic from one network to another; typically email was the bare minimum leading to services which would send information via email – at one point you could even “browse” the web using email!

Routing on the other hand allowed end to end communication so it was possible to use applications directly.

The next milestone was allowing commercial traffic on the Internet. The earliest networks were founded for research purposes by the American military or academic organisations, and prohibited commercial traffic Until the core networks allowed commercial traffic we wouldn’t have seen the Internet as we see it today.

There are plenty of other milestones – some would include the foundation of the world wide web (in 1991 and not 1993) as one of the most important. I don’t; simply because it was something that was bound to happen in one way or another.

Jan 162014
 

This is not original work, but merely a set of notes on how to do the set up. The core information (and the code) came from this blog posting.

Essentially I’ve re-ordered the steps in which to work and excluded anything other than the bare essentials to get it all working. With the intention I can get my missile launcher working at home and at work  😎

Step 1 is to prevent the HID driver from clamping on to the missile launcher. This was done by :-

  1. Editing /etc/default/grub and adding usbhid.quirks=0x2123:0x1010:0x04 to the existing variable GRUB_CMDLINE_LINUX_DEFAULT.
  2. Run update-grub (I always manage to forget this).
  3. Reboot the machine and check /var/log/messages for 2123 (the VendorID) to see if it has been claimed by usbhid (which will show up as a line beginning generic-usb 0003:2123:1010.0006: hiddev0 if it does claim it).

The next step is to download and compile the code given in the blog link above. If you need instructions on how to do this, then you probably need to look elsewhere – it builds easily.

Once built, an sudo insmod launcher_driver.ko will verify that the kernel module loads – you can double check by looking at /var/log/messages.

It’s also necessary to install both the kernel driver and the control program manually :-

  1. Copy the compiled kernel module to /lib/modulessudo cp  launcher_driver.ko /lib/modules
  2. Edit /etc/rc.local and add the command: /sbin/insmod /lib/modules/launcher_driver.ko
  3. Copy the control program to a sensible location: sudo install launcher_control /opt/bin

There’s probably better ways of doing this, and better places to stick things but as you’re following my instructions you’re stuck with my suggestions! It’s tempting to try a reboot at this stage to verify that this works, but as there’s just one small extra step we may as well get that done too. This is to create a udev rule to set up a device file in /dev.

Create a file (/etc/udev/rules.d/99-usb-launcher.rules) with the following contents :-

KERNEL=="launcher?*",MODE="0660",GROUP="cdrom"

The choice of group name is rather inappropriate except it will work well enough, and I have changed the permissions on this to something a little more restrictive. This can be tested with sudo udevadm trigger which will re-run udev. This should change the permissions on any existing /dev/launcher* file(s). If it doesn’t work, the blog pointer above is the place to head.

Lastly, there’s a couple of corrections to the launcher_control.c that is convenient to make :-

% diff launcher_control.c launcher_control.c.orig
63c63
<         while ((c = getopt(argc, argv, "m:lrudfsht:")) != -1) {
---
>         while ((c = getopt(argc, argv, "mlrudfsht:")) != -1) {
97,98c97
< 		fprintf(stderr, "Couldn't open file: %s\n", dev);
<                 /*perror("Couldn't open file: %m");*/
---
>                 perror("Couldn't open file: %m");