Passwordless authentication using Bitcoin cryptography
BitAuth is a way to do secure, passwordless authentication using the cryptography in Bitcoin. Instead of using a shared secret, the client signs each request using a private key and the server checks to make sure the signature is valid and matches the public key.
Install with Node.js:
npm install bitauth
To generate a browser bundle, you can then run:
BitAuth uses the same technology in Bitcoin. A public private key pair is created using elliptic curve secp256k1. The public SIN (System identification number), like a bitcoin address, is the RIPEMD 160, SHA256 hash of the public key. See https://en.bitcoin.it/wiki/Identity_protocol_v1 for complete details.
In each request, the client includes a nonce to prevent replay attacks. The client
signs the full url with the request body concatenated if there is one. The signature
is included in the
x-signature header and the public key is included in the
The server verifies that the signature is valid and that it matches the identity (the public key). It then computes the SIN from the public key, and sees whether that SIN has access to the requested resource. The nonce is checked to make sure it is higher than the previously used nonce.
With the growing popularity of Bitcoin, there are already libraries written in many languages. Because BitAuth uses the same technology as Bitcoin, it is easy to start using BitAuth.
With BitAuth, users can use the same, strong password to encrypt their keys and not worry about one service gaining access to another.
In the future, an identity system could be built around BitAuth keys where a user could create one key to represent an identity which could authenticate against multiple services.
There also needs to be a public place to store SIN's, preferably in a decentralized blockchain or datastore like namecoin. Key revocations could be stored here as well as reviews/feedback to build a reputation around an identity.
var express = ;var bodyParser = ;var rawBody = ;var bitauth = ;var users ='Tf7UNQnxB8SccfoyZScQmb34V2GdEtQkzDz': name: 'Alice''Tf22EUFxHWh4wmA3sDuw151W5C5g32jgph2': name: 'Bob';var pizzas = ;var app = ;app;app;app;app;app;app;
var request = ;var bitauth = ;// These can be generated with bitauth.generateSin()var keys =alice: '38f93bdda21a5c4a7bae4eb75bb7811cbc3eb627176805c1009ff2099263c6ad'bob: '09880c962437080d72f72c8c63a69efd65d086c9e7851a87b76373eb6ce9aab5';// GETfork in keysvar url = '';var dataToSign = url;var options =url: urlheaders:'x-identity': bitauth'x-signature': bitauth;request;var pizzas = 'pepperoni' 'sausage' 'veggie' 'hawaiian';// POSTfork in keysvar url = '';var data = type: pizzasMath;var dataToSign = url + JSON;var options =url: urlheaders:'x-identity': bitauth'x-signature': bitauthjson: data;request;
BitAuth exposes a connect middleware for use in connect or ExpressJS applications. Use:
var bitauth = ;app;
To build a browser compatible version of BitAuth, run the following command from the project's root directory:
This will output
bitauth.min.js to project directory. The script can be loaded using
To then run tests for a web browser:
To run tests for Node.js: