0075 - Final - Standards - Nov. 20, 2015 (10 years, 8 months ago)
20
2015
BIP: 75
Layer: Applications
Title: Out of Band Address Exchange using Payment Protocol Encryption
Author: Justin Newton <[email protected]>
Matt David <[email protected]>
Aaron Voisine <[email protected]>
James MacWhyte <[email protected]>
Comments-Summary: Recommended for implementation (one person)
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP 75
Status: Final
Type: Standards Track
Created: 2015-11-20
License: CC-BY-4.0
This BIP is an extension to BIP 70 that provides two enhancements to the existing Payment Protocol.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
This work is licensed under a Creative Commons Attribution 4.0 International License .
|
Sender |
Entity wishing to transfer value that they control |
|
Receiver |
Entity receiving a value transfer |
The motivation for defining this extension to the BIP 70 Payment Protocol is to allow two parties to exchange payment information in a permissioned and encrypted way, such that wallet address communication can become a more automated process. This extension also expands the types of PKI (public-key infrastructure) data that is supported, and allows it to be shared by both parties (with BIP 70 , only the receiver could provide PKI information). This allows for automated creation of off-blockchain transaction logs that are human readable, now including information about the sender and not just the recipient.
The motivation for this extension to BIP 70 is threefold:
#* Make Bitcoin logs (wallet transaction history) more human readable
#* Give the user the ability to decide whether or not they share their Bitcoin address and other payment details when requested
#* Allow for an open standards based way for businesses to keep verifiable records of their financial transactions, to better meet the needs of accounting practices or other reporting and statutory requirements
#* Automate the active exchange of payment addresses, so static addresses and BIP 32 X-Pubs can be avoided to maintain privacy and convenience
In short we wanted to make Bitcoin more human, while at the same time improving transaction privacy.
1. Address Book
A Bitcoin wallet developer would like to offer the ability to store an "address book" of payees, so users could send multiple payments to known entities without having to request an address every time. Static addresses compromise privacy, and address reuse is considered a security risk. BIP 32 X-Pubs allow the generation of unique addresses, but watching an X-Pub chain for each person you wish to receive funds from is too resource-intensive for mobile applications, and there is always a risk of unknowingly sending funds to an X-Pub address after the owner has lost access to the corresponding private key.
With this BIP, Bitcoin wallets could maintain an "address book" that only needs to store each payee's public key. Adding an entry to one's address book could be done by using a Wallet Name, scanning a QR code, sending a URI through a text message or e-mail, or searching a public repository. When the user wishes to make a payment, their wallet would do all the work in the background to communicate with the payee's wallet to receive a unique payment address. If the payee's wallet has been lost, replaced, or destroyed, no communication will be possible, and the sending of funds to a "dead" address is prevented.
2. Individual Permissioned Address Release
A Bitcoin wallet developer would like to allow users to view a potential sending party's identifying information before deciding whether or not to share payment information with them. Currently, BIP 70 shares the receiver’s payment address and identity information with anyone who requests it.
With this BIP, Bitcoin wallets could use the sender’s identifying information to make a determination of whether or not to share their own information. This gives the receiving party more control over who receives their payment and identity information. Additionally, this could be used to automatically provide new payment addresses to whitelisted senders, or to protect users’ privacy from unsolicited payment requests.
3. Using Store & Forward Servers
A Bitcoin wallet developer would like to use a public Store & Forward service for an asynchronous address exchange. This is a common case for mobile and offline wallets.
With this BIP, returned payment information is encrypted with an ECDH-computed shared key before sending to a Store & Forward service. In this case, a successful attack against a Store & Forward service would not be able to read or modify wallet address or payment information, only delete encrypted messages.
This BIP adds additional possible values for the pki_type variable in the PaymentRequest message. The complete list is now as follows:
| pki_type | Description |
|---|---|
|
x509+sha256 |
A x.509 certificate, as described in BIP 70 |
|
pgp+sha256 |
An OpenPGP certificate |
|
ecdsa+sha256 |
NOTE : Although SHA1 was supported in BIP 70, it has been deprecated and BIP 75 only supports SHA256. The hashing algorithm is still specified in the values listed above for forward and backwards compatibility.
Updated [/bip-0075/paymentrequest.proto paymentrequest.proto] contains the existing PaymentRequest Protocol Buffer messages as well as the messages newly defined in this BIP.
NOTE : Public keys from both parties must be known to each other in order to facilitate encrypted communication. Although including both public keys in every message may get redundant, it provides the most flexibility as each message is completely self-contained.
The InvoiceRequest message allows a Sender to send information to the Receiver such that the Receiver can create and return a PaymentRequest.
message InvoiceRequest {
required bytes sender_public_key = 1;
optional uint64 amount = 2 [default = 0];
optional string pki_type = 3 [default = "none"];
optional bytes pki_data = 4;
optional string memo = 5;
optional string notification_url = 6;
optional bytes signature = 7;
}
| Field Name | Description |
|---|---|
|
sender_public_key |
Sender's SEC-encoded EC public key |
|
amount |
amount is integer-number-of-satoshis (default: 0) |
|
pki_type |
none / x509+sha256 / pgp+sha256 / ecdsa+sha256 (default: "none") |
|
pki_data |
Depends on pki_type |
|
memo |
Human-readable description of invoice request for the receiver |
|
notification_url |
Secure (usually TLS-protected HTTP) location where an EncryptedProtocolMessage SHOULD be sent when ready |
|
signature |
PKI-dependent signature |
This enum is used in the newly defined ProtocolMessage and EncryptedProtocolMessage messages to define the serialized message type. The ProtocolMessageType enum is defined in an extensible way to allow for new message type additions to the Payment Protocol.
enum ProtocolMessageType {
UNKNOWN_MESSAGE_TYPE = 0;
INVOICE_REQUEST = 1;
PAYMENT_REQUEST = 2;
PAYMENT = 3;
PAYMENT_ACK = 4;
}
The ProtocolMessage message is an encapsulating wrapper for any Payment Protocol message. It allows two-way, non-encrypted communication of Payment Protocol messages. The message also includes a status code and a status message that is used for error communication such that the protocol does not rely on transport-layer error handling.
message ProtocolMessage {
required uint64 version = 1
required uint64 status_code = 2;
required ProtocolMessageType message_type = 3;
required bytes serialized_message = 4;
optional string status_message = 5;
required bytes identifier = 6;
}
| Field Name | Description |
|---|---|
|
version |
Protocol version number (Currently 1) |
|
status_code |
Payment Protocol Status Code |
|
message_type |
Message Type of serialized_message |
|
serialized_message |
Serialized Payment Protocol Message |
|
status_message |
Human-readable Payment Protocol status message |
|
identifier |
Unique key to identify this entire exchange on the server. Default value SHOULD be SHA256(Serialized Initial InvoiceRequest + Current Epoch Time in Seconds as a String) |
This BIP introduces version 1 of this protocol. All messages sent using these base requirements MUST use a value of 1 for the version number. Any future BIPs that modify this protocol (encryption schemes, etc) MUST each increment the version number by 1.
When initiating communication, the version field of the first message SHOULD be set to the highest version number the sender understands. All clients MUST be able to understand all version numbers less than the highest number they support. If a client receives a message with a version number higher than they understand, they MUST send the message back to the sender with a status code of 101 ("version too high") and the version field set to the highest version number the recipient understands. The sender must then resend the original message using the same version number returned by the recipient or abort.
The EncryptedProtocolMessage message is an encapsulating wrapper for any Payment Protocol message. It allows two-way, authenticated and encrypted communication of Payment Protocol messages in order to keep their contents secret. The message also includes a status code and status message that is used for error communication such that the protocol does not rely on transport-layer error handling.
message EncryptedProtocolMessage {
required uint64 version = 1 [default = 1];
required uint64 status_code = 2 [default = 1];
required ProtocolMessageType message_type = 3;
required bytes encrypted_message = 4;
required bytes receiver_public_key = 5;
required bytes sender_public_key = 6;
required uint64 nonce = 7;
required bytes identifier = 8;
optional string status_message = 9;
optional bytes signature = 10;
}
| Field Name | Description |
|---|---|
|
version |
Protocol version number |
|
status_code |
Payment Protocol Status Code |
|
message_type |
Message Type of Decrypted encrypted_message |
|
encrypted_message |
AES-256-GCM Encrypted (as defined in BIP 75) Payment Protocol Message |
|
receiver_public_key |
Receiver's SEC-encoded EC Public Key |
|
sender_public_key |
Sender's SEC-encoded EC Public Key |
|
nonce |
Microseconds since epoch |
|
identifier |
Unique key to identify this entire exchange on the server. Default value SHOULD be SHA256(Serialized Initial InvoiceRequest + Current Epoch Time in Seconds as a String) |
|
status_message |
Human-readable Payment Protocol status message |
|
signature |
DER-encoded Signature over the full EncryptedProtocolMessage with EC Key Belonging to Sender / Receiver, respectively |
The full process overview for using
InvoiceRequests
in the Payment Protocol is defined below.
All Payment Protocol messages MUST be encapsulated in either a
ProtocolMessage
or
EncryptedProtocolMessage
. Once the
process begins using
EncryptedProtocolMessage
messages,
all subsequent communications MUST use
EncryptedProtocolMessages
.
All Payment Protocol messages SHOULD be communicated using
EncryptedProtocolMessage
encapsulating messages with the exception that an
InvoiceRequest
MAY be communicated using the
ProtocolMessage
if the receiver's public key
is unknown.
The process of creating encrypted Payment Protocol messages is
enumerated in
Sending
Encrypted Payment Protocol Messages using EncryptedProtocolMessages
,
and the process of decrypting encrypted messages can be found under
Validating
and Decrypting Payment Protocol Messages using
EncryptedProtocolMessages
.
A standard exchange from start to finish would look like the following:
NOTE: See Initial Public Key Retrieval for InvoiceRequest Encryption for possible options to retrieve Receiver's public key.
When communicated via
HTTP
, the listed messages MUST
be transmitted via TLS-protected HTTP using the appropriate Content-Type
header as defined here per message:
{| class="wikitable" ! Message Type !! Content Type |- | ProtocolMessage
|| application/bitcoin-paymentprotocol-message |- |
EncryptedProtocolMessage ||
application/bitcoin-encrypted-paymentprotocol-message |}
Every
ProtocolMessage
or
EncryptedProtocolMessage
MUST
include a status code which conveys information about the last message
received, if any (for the first message sent, use a status of 1 "OK"
even though there was no previous message). In the case of an error that
causes the Payment Protocol process to be stopped or requires that
message be retried, a ProtocolMessage or EncryptedProtocolMessage SHOULD
be returned by the party generating the error. The content of the
message MUST contain the same
serialized_message
or
encrypted_message
and identifier (if present) and MUST
have the status_code set appropriately.
The status_message value SHOULD be set with a human readable explanation
of the status code.
| Status Code | Description |
|---|---|
|
1 |
OK |
|
2 |
Cancel |
|
100 |
General / Unknown Error |
|
101 |
Version Too High |
|
102 |
Authentication Failed |
|
103 |
Encrypted Message Required |
|
200 |
Amount Too High |
|
201 |
Amount Too Low |
|
202 |
Amount Invalid |
|
203 |
Payment Does Not Meet PaymentRequest Requirements |
|
300 |
Certificate Required |
|
301 |
Certificate Expired |
|
302 |
Certificate Invalid for Transaction |
|
303 |
Certificate Revoked |
|
304 |
Certificate Not Well Rooted |
+==Canceling A Message==+ If a participant to a transaction would like to inform the other party that a previous message should be canceled, they can send the same message with a status code of 2 ("Cancel") and, where applicable, an updated nonce. How recipients make use of the "Cancel" message is up to developers. For example, wallet developers may want to offer users the ability to cancel payment requests they have sent to other users, and have that change reflected in the recipient's UI. Developers using the non-encrypted ProtocolMessage may want to ignore "Cancel" messages, as it may be difficult to authenticate that the message originated from the same user.
Communication errors MUST be communicated to the party that initiated the communication via the communication layer's existing error messaging facilities. In the case of TLS-protected HTTP, this SHOULD be done through standard HTTP Status Code messaging ( RFC 7231 Section 6 ).
This BIP extends the Payment Protocol as defined in BIP 70 .
For the following we assume the Sender already knows the Receiver's public key, and the exchange is being facilitated by a Store & Forward server which requires valid signatures for authentication.
nonce MUST be set to a non-repeating number and MUST be chosen by the encryptor. The current epoch time in microseconds SHOULD be used, unless the creating device doesn't have access to a RTC (in the case of a smart card, for example). The service receiving the message containing the nonce MAY use whatever method to make sure that the nonce is never repeated.
SIGNATURE NOTE: EncryptedProtocolMessage messages are signed with the public keys of the party transmitting the message. This allows a Store & Forward server or other transmission system to prevent spam or other abuses. For those who are privacy conscious and don't want the server to track the interactions between two public keys, the Sender can generate a new public key for each interaction to keep their identity anonymous.
NOTE : AES-256-GCM is used because it provides authenticated encryption facilities, thus negating the need for a separate message hash for authentication.
The 16 byte authentication tag resulting from the AES-GCM encrypt operation MUST be prefixed to the returned ciphertext. The decrypt operation will use the first 16 bytes of the ciphertext as the GCM authentication tag and the remainder of the ciphertext as the ciphertext in the decrypt operation.
When either status_code OR status_message are present, the AES-256 GCM authenticated data used in both the encrypt and decrypt operations MUST be: STRING(status_code) || status_message. Otherwise, there is no additional authenticated data. This provides that, while not encrypted, the status_code and status_message are authenticated.
Initial public key retrieval for InvoiceRequest encryption via EncryptedProtocolMessage encapsulation can be done in a number of ways including, but not limited to, the following:
If a Store & Forward server wishes to protect themselves from spam or abuse, they MAY enact whatever rules they deem fit, such as the following:
Clients SHOULD keep in mind Receivers can broadcast a transaction
without returning an ACK. If a Payment message needs to be updated, it
SHOULD include at least one input referenced in the original transaction
to prevent the Receiver from broadcasting both transactions and getting
paid twice.
A reference implementation for a Store & Forward server supporting this proposal can be found here:
A reference client implementation can be found in the InvoiceRequest functional testing for Addressimo here:
BIP 75 Client Reference Implementation
The following flowchart is borrowed from BIP 70 and expanded upon in order to visually describe how this BIP is an extension to BIP 70 .
The following diagram shows a sample flow in which one mobile client is sending value to a second mobile client with the use of an InvoiceRequest, a Store & Forward server, PaymentRequest, Payment and PaymentACK. In this case, the PaymentRequest, Payment and PaymentACK messages are encrypted using EncryptedProtocolMessage and the Receiver submits the transaction to the Bitcoin network.
The following diagram shows a sample flow in which one mobile client is sending value to a second mobile client using an EncryptedProtocolMessage to transmit the InvoiceRequest using encryption, Store & Forward server, and PaymentRequest. In this case, all Payment Protocol messages are encrypting using EncryptedProtocolMessage and the Sender submits the transaction to the Bitcoin network.
Aaron Voisine is recognized in the cryptocurrency community for co-founding and developing …