View on GitHub

Whiteflag API

Reference implementation of the Whiteflag protocol as a web API in Node.js to connect applications with the underlying blockchains

Whiteflag API Connector for Bitcoin

The Whiteflag API natively supports the Bitcoin blockchain.

NOTE - The Bitcoin module needs updating.

Blockchain specifications

   
Whiteflag message embedding: OP_RETURN
Script for address derivation P2PKH
Maximum message length: 80 bytes
Signature algorithm: ECDSA secp256k1
Transaction hash: 256 bits (64 hexadecimals)
Secret for account creation: Wallet Import Format (WIF)

Note that curve secp256k1 for the ECDSA signature algorthm is officially not specified to be used with JWS for Whiteflag authentication method 1. Instead, the JWS specification in RFC 7518 requires curve secp256r1 a.k.a. prime256v1. However, Whiteflag is using JSON Web Tokens just as a structure. For Whiteflag authentication method 1 to work, it is essential that the key pair and curve of the blockchain is used for the signature to prove possession of the associated secret key. See also Issue 28.

Accounts

Note that Bitcoin lacks the concept of an account, whereas Whiteflag assumes an identifiable originator that has an account on a blockchain. Such a blockchain account is nothing else than a key pair for signing blockchain transactions, with some related information, e.g. an address, balance etc. Therefore, what the API calls an account is nothing else than what sometimes is referred to as a “wallet”.

For the purposes of (testing) Whiteflag, the same account, i.e. Bitcoin address, is reused. This is not a good practice for several reasons, such as anonimity. However, for Whiteflag it is necessary that different transactions can be linked to the same originator. Therefore, it is strongly recommended NOT to use the Whiteflag account for anything else, such as payments or transfers.

Bitcoin configuration

The blockchains configuration file config/blockchains.toml should contain the Bitcoin specific parameters in one of its [[blockchains]] sections.

These parameters manage Bitcoin blockchain accounts (i.e. wallets):

For retrieving transactions containing Whiteflag messages from the blockchain, these parameters may be provided, otherwise default values are used:

To send and receive Whiteflag messages, the API must be connected to a Bitcoin node exposing the standard Bitcoin RPC interface. These parameters are used to configure the connection: