Bitcom icon indicating copy to clipboard operation
Bitcom copied to clipboard

"su": authentication command

Open unwriter opened this issue 4 years ago • 0 comments

Spec website

Check out the website:

https://su.planaria.network

This is version 0.0.1. The spec is not 100% set in stone yet, so feel free to provide feedback and discuss.

Below is a copy/paste of the su specification.

what

su is a simple protocol for authenticating bitcoin applications.

su is a Bitcom command, inspired by the Unix "su" command.

However su is the first of its kind. If Bitcom commands have been all about admin purposes, su is the first Bitcom command designed for powering actual application transactions themselves by acting as an authentication extension to all apps.

The following command concatenates and signs the push data items at <sign_position> with <pubkey>'s private key pair and attaches the result <signature> to the transaction, which then can be verified later:

command


why

Because most bitcoin wallets generate a new address for every new transaction, it is impossible to identify a user by simply looking at a sender address for a transaction.

We need ways to separately attach user identity and its proof (signature) to transactions.

There are other existing authentication protocols such as AIP and HAIP which focus on flexibility, but sometimes you may just want a simple opinionated protocol that "just works".


design

here are the design principles of su:

  1. Umbrella protocol: su is a native Bitcom command, using the $ su prompt to indicate the authentication protocol. Thanks to its simplicity, it can easily plug into any bitcoin script protocol to attach signature.
  2. Focus on Simplicity: the protocol spec is as minimal as it can get. No redundant metadata. Less data, lower cost. The su syntax consists of only three attributes:
  • <PUBKEY>
  • <SIGN_POSITION>
  • <SIGNATURE>
  1. Convention over Configuration: To achieve simplicity, su makes certain assumptions about how the signing should be carried out. There is no "configuration". su assumes the following convention:
  • Hex: Uses hex encoding.
  • SHA256: The hex data is always SHA256-hashed before being signed.
  • ECDSA: Uses ECDSA to sign the data.
  • Base64 Signature: The final signature is represented as a Base64 string.
  1. Easy to Filter: su always shows up at the beginning of an output script sequence (Instead of showing up anywhere within a Bitcom pipeline). This deliberate constraint makes it easy to detect, index, and filter transactions that contain signed data, through systems like Planaria.

syntax

Just like the Metanet protocol, we can think of su as an "umbrella protocol" for authenticating ANYTHING. Because of this nature, the su protocol appears at the beginning of an output script sequence.

OP_FALSE OP_RETURN $ su <PUBKEY> <SIGN_POSITION> <SIGNATURE>

Where <SIGN_POSITION> is used to select one or more pushdata within a script, and takes the following form:

<SIGN_POSITION> ::= <digit>
                  | <digit>-<digit>
                  | <SIGN_POSITION>,<SIGN_POSITION>

Here are some <SIGN_POSITION> examples:

  • 0: Select the pushdata at index 0
  • 0,1,2: Select and concatenate pushdata at index 0,1,2
  • 0-4: Select and concatenate pushdata at index 0,1,2,3,4
  • 0-4,7: Select and concatenate pushdata at index 0,1,2,3,4,7
  • 0-4,7-9: Select and concatenate pushdata at index 0,1,2,3,4,7,8,9

example

Note that su always appears at the beginning of an output script sequence.

1. basic

A su command implementation which signs a B protocol upload (Bitcom: 19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut)

0    OP_FALSE
1    OP_RETURN
2    $
3      su
4      03836714653ab7b17569be03eaf6593d59116700a226a3c812cc1f3b3c8f1cbd6c
5      9
6      HyOG2TVUR/Hdru7G8ZMl/MNkIEcjWFNgNDNF76FbOrHletOkb8He0in6G+g4uuDq5ee/YOiBV9OOfmYZYXjdqX4=
7    |
8    19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut
9      <html><body>hello</body></html>
10     text/html
11     utf-8
12     index.html

Let's take a look at the relevant parts:

  • Line 2: Bitcom prompt $
  • Line 3: Bitcom command su
  • Line 4: Signer Pubkey 03836714653ab7b17569be03eaf6593d59116700a226a3c812cc1f3b3c8f1cbd6c
  • Line 5: Push data sign position 9
  • Line 6: Signature HyOG2TVUR/Hdru7G8ZMl/MNkIEcjWFNgNDNF76FbOrHletOkb8He0in6G+g4uuDq5ee/YOiBV9OOfmYZYXjdqX4=

How it works:

  1. Select the data at index 9: <html><body>hello</body></html>
  2. Get its hex format: 3c68746d6c3e3c626f64793e68656c6c6f3c2f626f64793e3c2f68746d6c3e
  3. Hash it with SHA256: f97a8935f1bb9b75c4ee5d9968e76aae46debaacde6a8126ce9298698693704d
  4. Sign it with PUBKEY 03836714653ab7b17569be03eaf6593d59116700a226a3c812cc1f3b3c8f1cbd6c's private key pair.
  5. The result should match the SIGNATURE: HyOG2TVUR/Hdru7G8ZMl/MNkIEcjWFNgNDNF76FbOrHletOkb8He0in6G+g4uuDq5ee/YOiBV9OOfmYZYXjdqX4=

We can easily filter the transactions on Neon Genesis using:

{
  "v": 3,
  "q": {
    "find": {
      "out.s4": "03836714653ab7b17569be03eaf6593d59116700a226a3c812cc1f3b3c8f1cbd6c"
    }
  }
}

Or on BOB using:

{
  "v": 3,
  "q": {
    "find": {
      "out.tape.cell.s": "03836714653ab7b17569be03eaf6593d59116700a226a3c812cc1f3b3c8f1cbd6c"
    }
  }
}

2. multi-field signature

The same data, but signing multiple pushdata.

0    OP_FALSE
1    OP_RETURN
2    $
3    su
4    03836714653ab7b17569be03eaf6593d59116700a226a3c812cc1f3b3c8f1cbd6c
5    8,9,10,11,12
6    1b3ffcb62a3bce00c9b4d2d66196d123803e31fa88d0a276c125f3d2524858f4d16bf05479fb1f988b852fe407f39e680a1d6d954afa0051cc34b9d444ee6cb0af
7    |
8    19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut
9    <html><body>hello</body></html>
10   text/html
11   utf-8
12   index.html
  1. Get the pushdata at index 8,9,10,11,12 (line 5)
  • 8: 19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut
  • 9: <html><body>hello</body></html>
  • 10: text/html
  • 11: utf-8
  • 12: index.html
  1. Get the hex value for each
  • hex(8): 31394878696756345179427633744870515663554551797131707a5a56646f417574
  • hex(9): 3c68746d6c3e3c626f64793e68656c6c6f3c2f626f64793e3c2f68746d6c3e
  • hex(10): 746578742f68746d6c
  • hex(11): 7574662d38
  • hex(12): 696e6465782e68746d6c
  1. Concatenate the hex values and create a sha256 hash
  • 3aae6932baf004abc7e0355eeed704bb486f74d95bcd49232992df5aa88cb121
  1. Sign it with PUBKEY 03836714653ab7b17569be03eaf6593d59116700a226a3c812cc1f3b3c8f1cbd6c's private key pair (line 4)
  2. The result should match the SIGNATURE 1b3ffcb62a3bce00c9b4d2d66196d123803e31fa88d0a276c125f3d2524858f4d16bf05479fb1f988b852fe407f39e680a1d6d954afa0051cc34b9d444ee6cb0af (line 4)

unwriter avatar Oct 28 '19 13:10 unwriter