Toms Blog

Where I talk about Bitcoin and Technology

Tom Zander

The earliest known usage of a lock and key, such as used to bar entry to buildings, is about 2500 years ago. The idea of locks has been based on a simple idea for all this time. The lock has a secret combination, technique or just positioning of tumblers and the only one allowed access is the one that knows the secret.

There is a fascinating story behind the arms race of the people building safes and the people cracking them leading to heavier and more complex safes. Lots of ingenuity for geeks to find there. But that is a story for someone else to tell. I'll focus just on the locks themselves.

The secret of how to unlock a normal door, in most modern locks, is plainly exposed in the key and as such we see that more secure buildings solve the problem by law. They patented the key and make sure that the key creation is itself a privilege. So you can see the keys design and thus its secret, but you can't open the door because the piece of metal that is the key can't legally be created without permission.

Its been some years since 3D printers became cheap enough to be considered mainstream. People can print any plastic object with zero government oversight and with zero accountability.

The direct consequence is that pretty much all locks can be cracked by just having a smart solution to take a couple of photos of any key and then using some smart software that turns it into a 3d model and prints it.

As such I conclude that most common locks (excluding the safes mentioned above) work on the idea that the owner has a secret, in the form of a specially crafted key, that is the only thing that can unlock the door. The flaw, as such, is that the shape of a key is rather easy to steal. A couple of pictures or a piece of gum can be enough.

Crypto locks

If we look at cryptography, the kind that Bitcoin Cash uses, we see some opportunities for improvement. The basic cryptographic concept of public/private key-pair is used.

The owner of a key can have a private key and the lock has the public key. I can simply sign a message with my private key and the lock can validate this using the public key as proof that I actually own the private key.

The basic advantage of using public/private key cryptography is that the "secret", in the form of the private key, will never be made visible to anyone and even by borrowing the physical key-card attackers can not copy this secret.

In 2009 Satoshi Nakamoto shared the idea of a chain of signatures in his Bitcoin whitepaper and we can reuse this idea to allow users to transfer ownership of a lock. A lock could have a factory set crypto-key installed which can hardly be called secure in a mass production environment. When I buy the lock I then provide my own key-pair of a public-private key.

The current owner (the salesman) creates a signed transfer of ownership record to my key-pair. Since I make my own key-pair, this is completely private and secure. If I were to sell the lock on, I'd be expected to create a signed transfer of ownership record as well that stops me having access and instead gives access to the new owner.

This results in a chain of ownership transactions. Each of them signed by the previous owner and in that transaction a new owner has his data encoded. Exactly like transactions in Bitcoin Cash.

The "key" can be an implementation on a phone, or a specially created card with a chip. The action of authenticating to the lock would then be using something like Bluetooth and NFC.

The "lock" is a very simple computer capable of creating cryptographic challenges and validating the result. It would also store and be able to process the entire chain of transactions from its birth to the current owner.

After the lock is sold to a new owner, the new owner should try to open the lock. The lock poses a challenge (current data/time for instance) to the key and the key detects that the pub-key-hash requested by the lock is old and the key will respond with a transfer of ownership transaction. The lock can validate that one to be proper and correct and then update its internal memory. Effectively changing ownership.

Immediately after the lock did this update it can challenge the key with a new time stamp and the new updated pkh it now thinks is its owner.

Blockchain

As most locks go, the above setup is more than enough security. The lock is very low complexity and does as much with crypto that most existing locks do. It will be significantly more secure than most locks and with some simple API extension you can have multiple keys open a door. All controlled by the owner.

However, for ownership that is not a door-lock, this may not be enough. We may want to actually store the transfer of ownership records on the public global block chain. Many have speculated that this implies that the 'lock' computer needs to be connected to the internet. Spawning an "internet of things" hype that seems to just turn into a consumer-data revealing nightmare. We don't want to make locks or simple household things connect to the internet if we value our privacy.

How do we solve this then?

In the previous part I described how the key is the one that takes the burden of proof to convince the lock of the new world state. The "key" is a smart-card or a phone of some sort.

As long as we are willing to physically go to the lock in question and update it whenever there is a change of ownership we can extend this concept quite simply and avoid the dreaded double-spend problem. Because if I sell the lock to two people at the same time, the one that actually gets it in the default scenario is the one that actually physically gets to the lock first.

Again, this is likely good enough for the vast majority of locks, but for things like cars or houses this may not be enough. A good solution for such special locks is to enforce the transfer of lock ownership to be mined on the Bitcoin Cash Blockchain. Bitcoin mining exists primarily to solve the double-spend problem, how about we just hitch a ride and get the same benefit?

To execute this sale the car owner creates a Bitcoin transaction paying a tiny fee from the private-key that is currently the owner of the lock and it also sends a large sum of money he wants as payment for his car to a bitcoin address he owns. He signs it as "anyone-can-pay". This transaction itself is not valid as it spends more than he pays.

The buyer of the car receives the transaction and adds his own money to it as a way to pay the seller and most importantly he transfers a small amount to an address that is to represent the new owner. This last address will be the one the lock on the car will accept to open it. After signing the transaction it can be mined on the Bitcoin Cash blockchain.

The new owner needs to download a couple of things on his smartphone or smartkey before he can open the car lock. He needs to download the missing block-headers (at 80 bytes each) and indeed the actual transaction that transferred the ownership. Last he needs to download the merkle-proof that proves the transaction was actually in the block. If that sounds too technical, just skip over it or google for details, it is a well known way to provide proofs.

In our futuristic story the car is self driving and after the sale succeeded the old owner tells it to drive to the new owner. As the car arrives it parks itself in the driveway of the new owner and at this point the car is not yet aware of the sale and it would only start for the old owner.

The new owner simply holds his smart card "key" to the car door and the car will not just receive the transaction of car ownership, it will also request from the key-card, and validate, the entire list of block-headers since the last header it knew about. Which is likely when it last got sold.

Validating the new ownership is then essentially the same as any Simplified Payment Verification (SPV) Bitcoin Cash wallet does. With the big difference that it only needs to do it once when there actually is a new owner and the burden of proof is on the new owner.

Additional access and associated features

The first thing that came up when I explained this to others is how you would allow 3rd parties to open the door. Or how you rent out a car and thus give access for a day or a week.

The ideas described in this article are only talking about ownership, specifically how one specific private key can be used to proof ownership.

It is rather easy to imagine a protocol of signed messages send by the owner to the lock to allow additional private keys to be allowed to open the door, without transferring ownership. None of this has to be mined on a blockchain, none of these messages even have to be properly formatted Bitcoin transactions. It is just a simple API where the instructions are signed by the owner using his private key.

Conclusion

The technology for doing this properly has been around for a long time. Unfortunately Cryptography is something that seems to scare people and the TV isn't doing us any favours where many popular programs make anything computer based sound less secure than our current situation. This is double unfortunate as the reality is exactly the opposite. Big government 3 letter agencies don't like cryptography because they can't break it.

The idea is likely to be much more friendly and secure when designed properly. For instance I can grant access to visitors of my house without fearing they will make a copy of the key and thus I have no risk of them getting access again after the timeout expired.

This idea is based on basic cryptographic concepts, public/private keys and hashes. No blockchain is needed for the vast majority (95%+) of the cases.

I personally have no resources to build this, but I've been talking about this approach for a long time, as anyone close to me knows, and at least on the software side this approach is sane. I would be very happy to support a kickstarter that makes this a reality.