Culture

The New Stack Makers: Kyle Drake, Inventor of Coinpunk, an Open Source Bitcoin Wallet

29 Jul 2014 8:31am, by

Apple has allowed Blockchain back into the app store. It took Apple six months but now anyone using an iPhone can get the app for the Bitcoin wallet. It’s a change that had to come as currency and its definition continues to go through a transformation. Marcus Estes, an old friend here in Portland, did an interview recently with Kyle Drake, who has developed an open source Bitcoin walllet. His take on Bitcoin is a refreshing reminder that server-only technology is not always the answer, especially with the handling of commodities such as Bitcoin.

Marcus Estes: When was Coinpunk born?

Kyle Drake: Coinpunk was born about two years ago. I had been looking at Bitcoin, you know, I had some background in economics so I was actually fascinated by commodity monies and how they work because they’re interesting. They don’t follow our rules, they’re a sort of organic way that people represent purchasing power. For example, when there’s no paper money or some sort of other commodity like in prisoner of war camps, cigarettes become a form of currency. I’ve always been interested in that. About two years ago I started getting into Bitcoin and I read a paper on how it worked and I was like, I get it. It’s just a commodity. So I just took all that existing economic theory I knew and Bitcoin wasn’t that much of a leap once you understand how commodity monies work. Anything can be a commodity money, it just needs to be relatively durable and transferrable and not have a small, generally fixed amount of supply. In that context, Bitcoin is pretty awesome actually. You know how many Bitcoins were going to come into existence, and that’s a brilliant thing.

So I started playing around with this stuff and I realized there weren’t really any open source wallets. I kinda flirted with a project that was just a server wallet but I didn’t like the idea of keeping your keys on a server, it looked kind of dangerous to me. And actually philosophically it didn’t make a lot of sense, because the whole point of Bitcoin is that you don’t have to trust someone with your keys, right? I didn’t like that model so I went back to the drawing board and designed a system where basically the private key stuff happens on my end. So it’s encrypted in the browser and the server holds a copy but it’s encrypted. So I made a version like that, which became the first version of Coinpunk. It was the only one that was totally HTML5 and had a bar code scanner. So when Apple banned Bitcoin apps it was the only one that could work on iPhones and I was like – that’s interesting. So I launched coinpunk.com so that people would have something to use on their iPhone. And that’s been going for a little while. But the code that I based it on, this thing called bitcoinjs-lib was a total disaster. It didn’t have any tests and had been out of maintenance for 2 or 3 years. And I was like, you know, before I do anything with Coinpunk again I really need to fix this library. So me and a few other developers went to work and we just released version 1.0.

I ended up getting grant from the Bitcoin Foundation, which I framed as a living expenses grant. I said, “pay me my living expenses for 3 months and I will work on this thing.” So I got the grant, as well as some donations from the community. It ended up being like $25,000 dollars, and of course it was in Bitcoin. And that’s when a single Bitcoin was trading at $100. And since then it went up to like $1,000. I sold half of that and kept the other half in Bitcoin. And that amount paid out as my salary for a year. So I could say, ok, I don’t have to get a job, I can do anything I want. And obviously because it was due to donations for the Coinpunk stuff, I want to be able to do something cool and give people their money’s worth. So the refactor of bitcoinjs-lib was really good because it helped get us to a stable point where now we have this stable third party library written in JavaScript and we’re running Node in the browser and we have thousands of tests. And now anybody can build any Bitcoin wallet thing that they want based on this library.

So for someone that is just beyond Bitcoin-noob status, explain a little about Bitcoin wallets.

Kyle: A Bitcoin wallet helps you send and receive Bitcoin. The blockchain doesn’t really give you mechanisms for doing that really well, it’s really just a ledger that reports transactions. It’s surprising how little a wallet actually does. It doesn’t require a lot to make one. Basically you need a private key which represents the thing you expect money from. A private key is used to derive a public key and that’s used to derive a Bitcoin address. All you really need is a list of addresses and have a look at when incoming transactions come in. Also you need to get the “unspent outputs” from the previous transactions and put that into a new transaction. You sign it with your private key to prove you own it and then capture where to send them to. And then usually there’s actually two outputs in the transaction, because there’s no concept of change in Bitcoin. Let me try to describe it this way: When you spend the previous output, you have to spend the entirety of the number. Because if you don’t, what’s left over gets sent to the miners for the miner fee. So let’s say that you give me $100 and I need to pay someone $20 dollars. I can’t just send that $100 and pre-break it up, I have to use that whole $100 in the next transaction. So what you typically do is spend that whole output, even if it’s a billion dollars. You split that up so that whatever amount you want to send is the amount that’s in there, and there’s a second output called the change address that I can send back to your address. And that’s how you deal with change in Bitcoin. And you know, this is all actually really easy to do.

It’s actually not that difficult to make wallets if you have a good library. Now that we’ve cleaned up the code, it’s a lot easier to make stuff like this.

You mentioned the first version ran server side. Can you explain what’s happening now that you have a version that’s more client-side focused?

Kyle: So the client has the private keys but the server doesn’t get that information, the server just gets an encrypted box that only the client can unlock. The next version of Coinpunk will move away from that model a little bit because even with that model there’s a little security problem, because if you’re serving the website from the server a hacker can change that code. So it’s not perfect model. What’s better is if you have a Chrome plugin that will sign the code. That’s a better approach because servers don’t work very well.

But it’s been interesting because there are two sides to the Bitcoin community now. You’ve got server wallets where the server has has your wallet and controls your private key. And those aren’t actually Bitcoin wallets. They call them wallets but I think of them more as bank accounts. What’s the difference between a bank and a server wallet when someone else controls your private key? There’s a split in the community where some think server wallets are fine. Others think, “we should make systems where people don’t have to trust us.” Because the whole point of Bitcoin is to reduce the reliance on trust. Putting an intermediary in that process is ruining that. It’s harder to build these systems, it requires more self-reliance. But again, that’s the whole point of Bitcoin. If it changes from that model, it comes just some cheaper way to store money than a bank.

There are a lot of VC-backed Bitcoin startups right now…

Kyle: They’re pretty much all server wallets.

That’s what I was going to ask. It seems that an easy way to generate value for a firm is to aggregate things on a server.

Kyle: Sure. Absolutely. From a business perspective it makes a lot of sense. And this is one reason why I haven’t really wanted to do a Bitcoin startup. I feel like I could have started 10 Bitcoin startups buy now. There’s so much crazy stuff you can do with Bitcoin. But again, it’s like, the whole point of Bitcoin is to make it free to do all of this stuff. It’s pretty tough to come into the business and make an argument against that. To say, “you should pay us money to do this thing with Bitcoin.” Pretty much the only startups that make any real sense to me are startups that aren’t running server wallets – they run connections to central banking systems. You know, like ACH wire transfers. That’s an area where it makes sense to have startups, because you can’t do that by yourself. But as a solo person you can’t get a bank account and buy and sell Bitcoins through it. For example, Coinbase does that. They buy on your behalf. But I worry that lenience is going to make a system that isn’t what Bitcoin is supposed to be about. The question is, what’s the difference? I don’t have an answer to that question. To me, there would be no difference. I wish there were a separations of concerns there. But yeah, if you centralize and control everything than you can make money off of it. But I think you can make money doing it a different way.

Your choice to use an HTML5 stack, can you speak a little about that?

Kyle: You know honestly, I’d like to say that I predicted that Apple would ban Bitcoin, but I would be wrong. The reason I made it in HTML5 was really simple. Because I don’t want to learn a proprietary programming language. To me the idea of having to use a proprietary programming language for your special platform is this really anachronistic thing that’s going away and I think the future of interface dev, wether we like it or not, and it wouldn’t be my first choice, is the HTML5 stack. Once you realize that it’s the only thing that makes sense, why just develop for the iPhone when I can develop for Android, the desktop, tablets – and it’s the same codebase. Most applications developed in 10 years will work like that. HTML5 is becoming a universal rendering layer. Everything else is water under the bridge. I’d argue that most of it is much worse than JavaScript. It’s sexy to hate on JS. But when you actually get into JS it’s not that bad. It’s actually pretty manageable. My beef with JS actually concerns concurrency issues. Because it can’t scale out very well across multiple processors. But that’s such a pedantic argument. I’ve never had an application that’s had a severe problem with that that I couldn’t take care of. It’s good enough.

But Apple came out with this programming language Swift, and everybody went nuts. They were frothing at the mouth. But the language is unstable. It fundamentally doesn’t allow you to do certain things. It’s not finished. It was designed in a lab. And it had little or no user feedback. But more to the point, it’s proprietary. I actually don’t have a Macbook anymore, I use a Linux stack. So I can’t use that. One of the reasons that Macbooks are so popular with developers is that they can do Android on anything, they can do JS on anything, but they can’t do Apple on anything. But making an application for every platform? I mean, it’s hard enough to make one good application. To me, it’s obvious that it should be done with HTML5, with JS.

A lot of early JS libraries were focused more on the view layer. But it sounds like with Bitcoin-JS, it’s doing more pure computation?

Kyle: Yeah, with Bitcoin JS it’s literally doing cryptography in the browser with pure JS. It’s actually pretty crazy that JS can do that stuff. But it’s not that crazy. In many respects it’s better than a lot of other languages. For example they have typed arrays. Which makes them smaller and more efficient. You’re basically telling the browser or V8, this is going to be this size and you can create a super efficient memory store for it. The libraries for JS are the best thing about it. They have fantastic library support. Especially with NodeJS. There’s this movement to take the browser and NodeJS and put them together. For instance, Bitcoin JS used a library called Browserify, and it was written by a guy called substack. James Halliday. He’s great guy. Browserify takes NodeJS code and converts it to run in the browser. So you can basically run anything in Node in the browser as a module. It’s just a way better system. JS has become a really nice environment to work in. I would take it any day over something like Swift. Which doesn’t even have libraries yet! You know, people will have to write those libraries first.

Let’s say somebody’s considering accepting Bitcoin for the first time. Any tips?

Kyle: There’s more than few routes you can take. The simplest is to download a Bitcoin wallet. Make a backup of the private key. And use that to accept Bitcoin. The hard part is cashing out – a lot of companies that don’t want to hold their money in Bitcoin are using services like BitPay. They’ll convert Bitcoin to cash and send it to your bank account, with a transaction fee. So that’s how you can get your money out. But for me? I just take Bitcoin. I don’t even need to cash it out, I don’t care. I think Bitcoin is very useful and I use it to buy a lot of things. In fact, I haven’t been paid in US dollars for my job in like 2 years. I’ve been basically getting paid in Bitcoin. I can go to gyft.com and cash out for a Whole Foods gift card. And there’s a Whole Foods 2 blocks from my house. So I literally buy groceries with Bitcoin. I’m just not living in the traditional financial world anymore. I’m internet cyberpunk money job man. [smiles, takes a sip of beer]

A newsletter digest of the week’s most important stories & analyses.