bitkey

1. What

bitkey is a global bitcoin user database, stored on bitcoin.

bitkey lets you register paymail public keys on the blockchain, which then can be used by any bitcoin apps, simply by running their own Bitkey Planaria.

2. Background

Every paymail account can have many public keys.

And because of this, whenever we post a signed message to the blockchain, we need to attach both the Paymail address AND its public key (watch the video below to learn more).

There are some problems with this naive approach, which will be discussed in the next section.

3. Problem

Let's think about a simple signed message posting app.



Here's an example:



This is equivalent to a database INSERT command into a table that looks like this:

Paymail Public Key Message Signature
644@moneybutton.com 03836714653ab7b17569be03eaf6593d59116700a226a3c812cc1f3b3c8f1cbd6c First Message ...
644@moneybutton.com 03836714653ab7b17569be03eaf6593d59116700a226a3c812cc1f3b3c8f1cbd6c Second Message ...
644@moneybutton.com 03836714653ab7b17569be03eaf6593d59116700a226a3c812cc1f3b3c8f1cbd6c Third Message ...
644@moneybutton.com 03836714653ab7b17569be03eaf6593d59116700a226a3c812cc1f3b3c8f1cbd6c Fourth Message ...
644@moneybutton.com 03836714653ab7b17569be03eaf6593d59116700a226a3c812cc1f3b3c8f1cbd6c Fifth Message ...


WHAT IS THE PROBLEM?

Every message contains the SAME "Paymail" AND "Public Key" fields EVERTYTIME.

This is redundant.


4. Solution


What if we separate above monolithic table into TWO tables?

There are two ways to separate them out.


Solution 1. Save space


First we create a dedicated "User" table:

Paymail Public Key
644@moneybutton.com 03836714653ab7b17569be03eaf6593d59116700a226a3c812cc1f3b3c8f1cbd6c

Then we only need to include the paymail address to the message table:

Paymail Message Signature
644@moneybutton.com First Message ...
644@moneybutton.com Second Message ...
644@moneybutton.com Third Message ...
644@moneybutton.com Fourth Message ...
644@moneybutton.com Fifth Message ...

This makes the application protocol much leaner because it doesn't have to use the redundant public key every time.


Solution 2. Separate paymail from messages


In some cases you may NOT want to include paymail addresses in your messages. In this case you can split out the table in the following manner:

First, the "User" table is the same:

Paymail Public Key
644@moneybutton.com 03836714653ab7b17569be03eaf6593d59116700a226a3c812cc1f3b3c8f1cbd6c

But this time, for the message app, we include the Public Key instead of the Paymail addresses:

Pubkey Message Signature
03836714653ab7b17569be03eaf6593d59116700a226a3c812cc1f3b3c8f1cbd6c First Message ...
03836714653ab7b17569be03eaf6593d59116700a226a3c812cc1f3b3c8f1cbd6c Second Message ...
03836714653ab7b17569be03eaf6593d59116700a226a3c812cc1f3b3c8f1cbd6c Third Message ...
03836714653ab7b17569be03eaf6593d59116700a226a3c812cc1f3b3c8f1cbd6c Fourth Message ...
03836714653ab7b17569be03eaf6593d59116700a226a3c812cc1f3b3c8f1cbd6c Fifth Message ...


Note that the "User" table is the same in both cases, and can be used for both cases.

bitkey is this "User" table, stored on the blockchain.

NOTE: the "message app" is not part of the bitkey protocol, it's just an example to demonstrate how bitkey may be used.

5. Protocol

bitkey uses the following protocol to register an on-chain link between a paymail address and its public key


  1. OP_0: Starts with OP_0 for safety
  2. OP_RETURN: Bitkey is an OP_RETURN protocol
  3. 13SrNDkVzY5bHBRKNu5iXTQ7K7VqTh5tJC: Bitcom address for Bitkey
  4. Bitkey Signature: Signature generated by the Bitkey server to prove authenticity
  5. User Signature: Signature generated by user wallet to prove user registration
  6. Paymail: The paymail address to register
  7. Pubkey: The public key tied to the paymail address

To verify authenticity of a bitkey transaction, BOTH of the following must succeed:

  1. Verify Bitkey Signature against Bitkey's Bitcom address 13SrNDkVzY5bHBRKNu5iXTQ7K7VqTh5tJC
  2. Verify User signature against the user pubkey

Here's the signing algorithm:

a. User Signature

Uses the Bitcoin Signed Message algorithm


b. Bitkey Signature

// 1. paymail hex encoding
const paymailHex = Buffer.from(paymail).toString("hex")

// 2. pubkey hex encoding
const pubkeyHex = Buffer.from(pubkey).toString("hex")

// 3. concatenate paymail hex and pubkey hex
const concatenated = paymailHex + pubkeyHex;

// 4. sha256 hash the concatenated hex
const hashed = bsv.crypto.Hash.sha256(Buffer.from(concatenated, "hex")).toString('hex')

// 5. sign using bitcoin signed message protocol https://docs.moneybutton.com/docs/bsv-message.html
const sig = bsv.Message.sign(hashed, key)

6. Benefits

Bitkey is global decentralized identity registry, stored on Bitcoin.

Why is this cool?
  1. Open: Anyone can make use of this global user database because it's on the blockchain.
  2. Reverse lookup: Given a pubkey, you can find its paymail address
  3. Bulk query: Instead of having to query one paymail or one public key at a time, you can query multiple at once, even for paymails that span multiple service providers.
  4. Cross platform: Because it's a globally shared database made up of any paymail provider, stored on the blockchain, nobody can restrict access to this global user database.
  5. History: You can record the entire history of a paymail address and its associated public keys.
  6. Efficient: You don't have to include both paymail and pubkey in every signed data transaction because the "bitkey user table" takes care of the paymail-pubkey association.