From 8bf7d90d204db64f3af4a28abacb55b961d02c2c Mon Sep 17 00:00:00 2001 From: Matt David Date: Tue, 29 Mar 2016 15:49:49 -0700 Subject: - Update HTTPS to be TLS-protected HTTP - Add Updated Messages section to describe the status_code and status_message - Separated Message and Communication Errors into Payment Protocol Errors and Communication Errors - Add first draft Payment Protocol error codes - Update InvoiceRequest Message Creation description amount example to return Payment Protocol error in the case of an issue with the amount. --- bip-0075.mediawiki | 60 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 6 deletions(-) (limited to 'bip-0075.mediawiki') diff --git a/bip-0075.mediawiki b/bip-0075.mediawiki index 753c6e5..6bac44a 100644 --- a/bip-0075.mediawiki +++ b/bip-0075.mediawiki @@ -101,7 +101,7 @@ message InvoiceRequest { |- | memo || Human-readable description of invoice request for the receiver |- -| notification_url || Secure (usually HTTPS) location where an [[#EncryptedPaymentRequest|EncryptedPaymentRequest]] (see below) SHOULD be sent when ready +| notification_url || Secure (usually TLS-protected HTTP) location where an [[#EncryptedPaymentRequest|EncryptedPaymentRequest]] (see below) SHOULD be sent when ready |- | signature || PKI-dependent signature |} @@ -242,6 +242,19 @@ message EncryptedPaymentACK { | identifier || Use the identifier specified with the EncryptedPayment, if any. |} +==Updated Messages== +The BIP70 PaymentRequest, Payment and PaymentACK messages have been updated by this BIP to contain Payment Protocol error communication. The following two extension fields have been added to each of the aforementioned messages: + +
+{
+...
+    optional uint32 status_code = 1000;     // Payment Protocol status code
+    optional string status_message = 1001;  // Human-readable status message
+}
+
+ +status_code and/or status_message MUST be set to communicate a Payment Protocol error to the message receiver. The message consumer MUST handle status_code and status_message if either field is present. + ==InvoiceRequest / PaymentRequest Process== The process overview for using InvoiceRequests and receiving encrypted PaymentRequests is defined below in two sections. Optionally, the Sender MAY choose to encrypt the InvoiceRequest message and therefore MUST follow the '''Encrypted InvoiceRequest Overview''' process below. @@ -282,8 +295,8 @@ The process overview for using InvoiceRequests and receiving encrypted PaymentRe ==Message Interaction Details== -===New Message Content Types=== -Messages MUST be transmitted via TLS-protected HTTP using the appropriate Content-Type header as defined per message type here: +===New Message HTTP Content Types=== +When communicated via HTTP, these messages MUST be transmitted via TLS-protected HTTP using the appropriate Content-Type header as defined per message type here: {| class="wikitable" ! Message Type !! Content Type |- @@ -298,8 +311,43 @@ Messages MUST be transmitted via TLS-protected HTTP using the appropriate Conten | EncryptedPaymentACK || application/bitcoin-encrypted-paymentack |} -===Message or Communication Errors=== -An invalid or unparsable message or communications error MUST be communicated to the party that initiated the communication. This SHOULD be done through standard HTTP Status Code messaging ([https://tools.ietf.org/html/rfc7231 RFC 7231 Section 6]). If the provided hash of each message does not match the contents of the message once decrypted, a general error should be returned to prevent oracle attacks. +===Payment Protocol Errors=== + +Payment Protocol errors MUST be communicated to the party that initiated the communication via the status_code and status_message extension fields present in the PaymentRequest, Payment and PaymentACK messages. For example, if the provided hash of each message does not match the contents of the message once decrypted, a general error MUST be returned to prevent oracle attacks. + +====Payment Protocol Status Codes==== +{| class="wikitable" +! Status Code !! Description +|- +| 1 || General / Unknown Error +|- +| 2 || Authentication Failed +|- +| 3 || Encrypted Message Required +|- +| 100 || Amount Too High +|- +| 101 || Amount Too Low +|- +| 102 || Amount Invalid +|- +| 103 || Payment Does Not Meet PaymentRequest Requirements +|- +| 200 || Certificate Required +|- +| 201 || Certificate Expired +|- +| 202 || Certificate Invalid for Transaction +|- +| 203 || Certificate Revoked +|- +| 204 || Certificate Not Well Rooted +|- +|} + +===Communication Errors=== + +Communications errors MUST be communicated to the party that initiated the communication via the communication layer's existing error messaging faciltiies. In the case of TLS-protected HTTP, this SHOULD be done through standard HTTP Status Code messaging ([https://tools.ietf.org/html/rfc7231 RFC 7231 Section 6]). ==Process Step Details== @@ -311,7 +359,7 @@ Where used, '''nonce''' MUST be set to a non-repeating number AND MUST be chosen * Create an InvoiceRequest message * sender_public_key MUST be set to the public key of an EC keypair * nonce MUST be set according to the requirement above. -* Amount is optional. If the amount is not specified by the InvoiceRequest, the Receiver MAY specify the amount in the returned PaymentRequest. If an amount is specified by the InvoiceRequest and a PaymentRequest cannot be generated for that amount, the InvoiceRequest SHOULD be rejected with HTTP status code 406. +* Amount is optional. If the amount is not specified by the InvoiceRequest, the Receiver MAY specify the amount in the returned PaymentRequest. If an amount is specified by the InvoiceRequest and a PaymentRequest cannot be generated for that amount, the InvoiceRequest SHOULD return a PaymentRequest with the status_code and status_message fields set appropriately. * Memo is optional. This MAY be set to a human readable description of the InvoiceRequest * Set notification_url to URL that the Receiver will submit completed EncryptedPaymentRequest to * If NOT including certificate, set pki_type to "none" -- cgit v1.2.3 From 8bb63058fd80b6b89b2e09de402ad5ba635e9eeb Mon Sep 17 00:00:00 2001 From: Matt David Date: Tue, 26 Apr 2016 15:23:12 -0700 Subject: - Reset bip-0070/extensions.mediawiki to the original BIP70 contents - Remove status_code and status_message from individual Payment Protocol messages - Remove EncryptedInvoiceRequest, EncryptedPaymentRequest, EncryptedPayment and EncryptedPaymentACK messages from protobuf definition file - Add ProtocolMessageType enum and ProtocolMessageType and EncryptedProtocolMesssage messages to bip-0075/paymentrequest.proto definition file - Update BIP75 text to remove old individual message encryption paths and include new encapsulating messages for self-contained PaymentProtocol communication (including errors) over various transport layers - Add initial list of status codes - Update BIP75 to use AES-256-GCM and remove message hash as GCM mode provides authenticated encryption - Update ECDH calculation to use SHA256 hash of ECDH's X point instead of the raw X point itself --- bip-0075.mediawiki | 345 ++++++++++++++++------------------------------------- 1 file changed, 104 insertions(+), 241 deletions(-) (limited to 'bip-0075.mediawiki') diff --git a/bip-0075.mediawiki b/bip-0075.mediawiki index 6bac44a..3b0ba1f 100644 --- a/bip-0075.mediawiki +++ b/bip-0075.mediawiki @@ -14,9 +14,9 @@ This BIP is an extension to BIP 70 that provides two enhancements to the existing Payment Protocol. -# It allows the requester (Sender) of a Payment Request to voluntarily sign the original request and provide a certificate to allow the payee to know the identity of who they are transacting with. +# It allows the requester (Sender) of a PaymentRequest to voluntarily sign the original request and provide a certificate to allow the payee to know the identity of who they are transacting with. -# It encrypts the Payment Request that is returned, before handing it off to the SSL/TLS layer to prevent man in the middle viewing of the Payment Request details. +# It encrypts the PaymentRequest that is returned, before handing it off to the SSL/TLS layer to prevent man in the middle viewing of the Payment Request details. 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. @@ -69,12 +69,12 @@ A Bitcoin wallet developer would like to use a public Store & Forward service fo 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. ==New Messages== -Updated [/bip-0075/paymentrequest.proto paymentrequest.proto] contains the existing PaymentRequest Protocol Buffer messages as well asthe messages newly defined in this BIP. +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. ===InvoiceRequest=== -The InvoiceRequest message allows a Sender to send information to the Receiver such that they can create and return a PaymentRequest. +The InvoiceRequest message allows a Sender to send information to the Receiver such that the Receiver can create and return a PaymentRequest.
 message InvoiceRequest {
@@ -106,190 +106,97 @@ message InvoiceRequest {
 | signature             || PKI-dependent signature
 |}
 
-
-===EncryptedInvoiceRequest===
-The EncryptedInvoiceRequest message allows a Sender to send an encrypted InvoiceRequest to the Receiver such that the details of the InvoiceRequest are kept secret.
+===ProtocolMessageType Enum===
+The ProtocolMessageType enum is defined in an extensible way to allow for new message type additions to the Payment Protocol. This enum is used in the newly defined ProtocolMessage and EncryptedProtocolMessage messages to define the serialized message type.
 
-message EncryptedInvoiceRequest {
-    required bytes  encrypted_invoice_request = 1;
-    required bytes  invoice_request_hash = 2;
-    required bytes  sender_public_key = 3;
-    required bytes  receiver_public_key = 4;
-    required uint64 nonce = 5;
-    optional bytes  signature = 6;
-    optional bytes  identifier = 7;
-    
+enum ProtocolMessageType {
+    INVOICE_REQUEST = 0;
+    PAYMENT_REQUEST = 1;
+    PAYMENT = 2;
+    PAYMENT_ACK =  3;
 }
 
-{| class="wikitable" -! Field Name !! Description -|- -| encrypted_invoice_request || AES-256-CBC encrypted, serialized InvoiceRequest -|- -| invoice_request_hash || SHA256 Hash of non-encrypted, serialized InvoiceRequest. MUST be used for verification to prevent oracle attacks. -|- -| sender_public_key || Sender's EC public key -|- -| receiver_public_key || Receiver's EC public key -|- -| nonce || The nonce in use for the CBC encryption -|- -| signature || A signature of this message using Sender's EC key, serialized with a value of "" for signature. REQUIRED if server requires authentication. -|- -| identifier || A unique key to identify this entire exchange on the server. invoice_request_hash SHOULD be used by default. -|} - -===EncryptedPaymentRequest=== - -The EncryptedPaymentRequest message is an encapsulating message that allows the transmission of an encrypted, serialized PaymentRequest. - +===ProtocolMessage=== +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 so the protocol does not rely on transport-layer error handling.
-message EncryptedPaymentRequest {
-        required bytes  encrypted_payment_request = 1;
-        required bytes  payment_request_hash = 2;
-        required bytes  receiver_public_key = 3;
-        required bytes  sender_public_key = 4;
-        required uint64 nonce = 5;
-        optional bool   requires_payment_message = 6;
-        optional bytes  signature = 7;
-        optional bytes  identifier = 8;
+message ProtocolMessage {
+    required ProtocolMessageType message_type = 1;
+    required bytes serialized_message = 2;
+    optional uint64 status_code = 3;
+    optional string status_message = 4;
+    optional bytes identifier = 5;
 }
 
-{| class="wikitable" -! Field Name !! Description -|- -| encrypted_payment_request || AES-256-CBC encrypted, serialized BIP70 PaymentRequest -|- -| payment_request_hash || SHA256 Hash of non-encrypted, serialized PaymentRequest. MUST be used for verification to prevent oracle attacks. -|- -| receiver_public_key || Receiver's EC public key -|- -| sender_public_key || Sender's EC public key -|- -| nonce || The nonce in use for the CBC encryption -|- -| requires_payment_message || Internal PaymentRequest requires follow-up Payment message -|- -| signature || A signature of this message using Receiver's EC key, serialized with a value of "" for signature. REQUIRED if server requires authentication. -|- -| identifier || MUST use the identifier specified with the InvoiceRequest if the PaymentRequest is in response to an InvoiceRequest. Otherwise, use payment_request_hash or other unique value. -|} -===EncryptedPayment=== - -The EncryptedPayment message allows a BIP70 Payment message to be transmitted through a third party without revealing the details of the transaction. This message allows Store & Forward servers or other third parties to match and authenticate PaymentRequest and Payment messages without revealing the details of the transaction, thereby protecting privacy. - -
-message EncryptedPayment {
-        required bytes  encrypted_payment = 1;
-        required bytes  payment_hash = 2;
-        required bytes  sender_public_key = 3;
-        required bytes  receiver_public_key = 4;
-        required uint64 nonce = 5;
-        optional bytes  signature = 6;
-        optional bytes  identifier = 7;
-}
-
{| class="wikitable" ! Field Name !! Description |- -| encrypted_payment || AES-256-CBC encrypted, serialized BIP70 Payment message -|- -| payment_hash || SHA256 Hash of original non-encrypted, serialized Payment message. MUST be used for verification to prevent oracle attacks. +|message_type || Message Type of serialized_message (using enum ProtocolMessageType) |- -| sender_public_key || Sender's EC public key +|serialized_message || Serialized Payment Protocol Message |- -| receiver_public_key || Receiver's EC public key +|status_code || Payment Protocol Status Code |- -| nonce || The nonce in use for the CBC encryption +|status_message || Human-readable Payment Protocol status message |- -| signature || A signature of this message using Sender's EC key, serialized with a value of "" for signature. REQUIRED if server requires authentication. -|- -| identifier || Use the identifier specified with the EncryptedPaymentRequest, if any. +|identifier || Unique key to identify this entire exchange on the server. SHA256 of initial serialized InvoiceRequest SHOULD be used by default |} -===EncryptedPaymentACK=== - -An encrypted version of the BIP70 PaymentAck. - +===EncryptedProtocolMessage=== +The EncryptedProtocolMessage message is an encapsualting 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 so the protocol does not rely on transport-layer error handling.
-message EncryptedPaymentACK {
-        required bytes  encrypted_payment_ack = 1;
-        required bytes  payment_ack_hash = 2;
-        required bytes  receiver_public_key = 3;
-        required bytes  sender_public_key = 4;
-        required uint64 nonce = 5;
-        required bytes  signature = 6;
-        optional bytes  identifier = 7;
+message EncryptedProtocolMessage {
+    required ProtocolMessageType message_type = 1;
+    required bytes encrypted_message = 2;
+    required bytes receiver_public_key = 3;
+    required bytes sender_public_key = 4;
+    required uint64 nonce = 5;
+    optional bytes signature = 6;
+    optional bytes identifier = 7;
+    optional uint64 status_code = 8;
+    optional string status_message = 9;
 }
 
{| class="wikitable" -! Field Name !! Description +! Field Name !! Description +| message_type || Message Type of Decrypted encrypted_message |- -| encrypted_payment_ack || AES-256-CBC encrypted, serialized BIP70 PaymentACK message +| encrypted_message || AES-256-GCM Encrypted (as defined in BIP75) Payment Protocol Message |- -| payment_ack_hash || SHA256 Hash of original non-encrypted, serialized Payment message. MUST be used for verification to prevent oracle attacks. +| receiver_public_key || Receiver's DER-encoded EC Public Key |- -| receiver_public_key || Receiver's EC public key +| sender_public_key || Sender's DER-encoded EC Public Key |- -| sender_public_key || Sender's EC public key +| nonce || Microseconds since epoch |- -| nonce || The nonce in use for the CBC encryption +| signature || DER-encoded Signature over the full EncryptedProtocolMessage with EC Key Belonging to Sender / Receiver, respectively |- -| signature || A signature of this message using Receiver's EC key, serialized with a value of "" for signature. REQUIRED if server requires authentication. +| identifier || Unique key to identify this entire exchange on the server. SHA256 of initial serialized InvoiceRequest SHOULD be used by default |- -| identifier || Use the identifier specified with the EncryptedPayment, if any. +| status_code || Payment Protocol Status Code +|- +| status_message || Human-readable Payment Protocol status message |} -==Updated Messages== -The BIP70 PaymentRequest, Payment and PaymentACK messages have been updated by this BIP to contain Payment Protocol error communication. The following two extension fields have been added to each of the aforementioned messages: +==Payment Protocol Process with InvoiceRequests== +The full process overview for using InvoiceRequests in the Payment Protocol is defined below. All Payment Protocol messages are to be encapsulated in either a ProtocolMessage or EncryptedProcotolMessage. 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. -
-{
-...
-    optional uint32 status_code = 1000;     // Payment Protocol status code
-    optional string status_message = 1001;  // Human-readable status message
-}
-
+See [[Sending_Encrypted_Payment_Protocol_Messages_using_EncryptedProtocolMessages|Sending Encrypted Payment Protocol Messages using EncryptedProtocolMessages]] and [[Validating_and_Decrypting_Payment_Protocol_Messages_using_EncryptedProtocolMessages|Validating and Decrypting Payment Protocol Messages using EncryptedProtocolMessages]] for the process of communicating using encrypted Payment Protocol messages. -status_code and/or status_message MUST be set to communicate a Payment Protocol error to the message receiver. The message consumer MUST handle status_code and status_message if either field is present. +TODO: See about adding some info about using ProtocolMessages -==InvoiceRequest / PaymentRequest Process== -The process overview for using InvoiceRequests and receiving encrypted PaymentRequests is defined below in two sections. Optionally, the Sender MAY choose to encrypt the InvoiceRequest message and therefore MUST follow the '''Encrypted InvoiceRequest Overview''' process below. - -===Non-Encrypted InvoiceRequest Overview=== # Sender creates InvoiceRequest -# Sender transmits InvoiceRequest to Receiver -# Receiver validates InvoiceRequest +# Sender encapsulates InvoiceRequest in (Encrypted)ProtocolMessage +# Sender sends (Encrypted)ProtocolMessage to Receiver +# Receiver retrieves InvoiceRequest from (Encrypted)ProtocolMessage # Receiver creates PaymentRequest -# Receiver encrypts the PaymentRequest -# Receiver creates EncryptedPaymentRequest (containing an encrypted PaymentRequest) -# Receiver transmits EncryptedPaymentRequest to Sender -# Sender validates EncryptedPaymentRequest -# Sender decrypts and validates encrypted PaymentRequest -# The PaymentRequest is processed according to BIP70, including optional Payment and PaymentACK messages - +# Receiver encapsulates PaymentRequest in EncryptedProtocolMessage +# Receiver transmits EncryptedProtocolMessage to Sender +# Sender validates PaymentRequest +# The PaymentRequest is processed according to BIP70, including optional Payment and PaymentACK messages encapsulated in EncryptedProtocolMessage messages. -Flow diagram of Non-Encrypted InvoiceRequest - -===Encrypted InvoiceRequest Overview=== -# Sender retrieves Receiver InvoiceRequest Public Key -# Sender creates InvoiceRequest -# Sender encrypts the InvoiceRequest -# Sender creates EncryptedInvoiceRequest (containing an encrypted InvoiceRequest) -# Sender transmits EncryptedInvoiceRequest to Receiver -# Receiver decrypts and validates EncryptedInvoiceRequest -# Receiver validates InvoiceRequest -# Receiver creates PaymentRequest -# Receiver encrypts the PaymentRequest -# Receiver creates EncryptedPaymentRequest (containing an encrypted PaymentRequest) -# Receiver transmits EncryptedPaymentRequest to Sender -# Sender validates EncryptedPaymentRequest -# Sender decrypts and validates encrypted PaymentRequest -# The PaymentRequest is processed according to BIP70, including optional EncryptedPayment and EncryptedPaymentACK messages - -'''NOTE:''' See section [[#Initial_Public_Key_Retrieval_for_InvoiceRequest_Encryption|Initial Public Key Retrieval for InvoiceRequest Encryption]] below for possible options to retrieve Receiver InvoiceRequest public keys. +'''NOTE:''' See section [[#Initial_Public_Key_Retrieval_for_InvoiceRequest_Encryption|Initial Public Key Retrieval for InvoiceRequest Encryption]] below for possible options to retrieve Receiver's public key. Flow diagram of Encrypted InvoiceRequest @@ -300,48 +207,44 @@ When communicated via HTTP, these messages MUST be transmitted via TLS-protected {| class="wikitable" ! Message Type !! Content Type |- -| InvoiceRequest || application/bitcoin-invoicerequest -|- -| EncryptedInvoiceRequest || application/bitcoin-encrypted-invoicerequest -|- -| EncryptedPaymentRequest || application/bitcoin-encrypted-paymentrequest +| ProtocolMessage || application/bitcoin-paymentprotocol-message |- -| EncryptedPayment || application/bitcoin-encrypted-payment -|- -| EncryptedPaymentACK || application/bitcoin-encrypted-paymentack +| EncryptedProtocolMessage || application/bitcoin-encrypted-paymentprotocol-message |} -===Payment Protocol Errors=== +===Payment Protocol Status Communication=== -Payment Protocol errors MUST be communicated to the party that initiated the communication via the status_code and status_message extension fields present in the PaymentRequest, Payment and PaymentACK messages. For example, if the provided hash of each message does not match the contents of the message once decrypted, a general error MUST be returned to prevent oracle attacks. +In the case of an error that causes the Payment Protocol process to be stopped or retried for a transaction, a ProtocolMessage or EncryptedProtocolMessage MUST be sent by the party generating the error. The content of the message must contain the same serialized_message or encrypted_message and identifier (if used) and MUST have the status_code set appropriately. The status_message value SHOULD be set with a human readable explanation of the status code. For example, if in an EncryptedProtocolMessage, the provided hash of the serialized message does not match the contents of the message once decrypted, a general error (100) MUST be returned to prevent oracle attacks. ====Payment Protocol Status Codes==== {| class="wikitable" ! Status Code !! Description +|- +| 1 || OK |- -| 1 || General / Unknown Error +| 100 || General / Unknown Error |- -| 2 || Authentication Failed +| 102 || Authentication Failed |- -| 3 || Encrypted Message Required +| 102 || Encrypted Message Required |- -| 100 || Amount Too High +| 200 || Amount Too High |- -| 101 || Amount Too Low +| 201 || Amount Too Low |- -| 102 || Amount Invalid +| 202 || Amount Invalid |- -| 103 || Payment Does Not Meet PaymentRequest Requirements +| 203 || Payment Does Not Meet PaymentRequest Requirements |- -| 200 || Certificate Required +| 300 || Certificate Required |- -| 201 || Certificate Expired +| 301 || Certificate Expired |- -| 202 || Certificate Invalid for Transaction +| 302 || Certificate Invalid for Transaction |- -| 203 || Certificate Revoked +| 303 || Certificate Revoked |- -| 204 || Certificate Not Well Rooted +| 304 || Certificate Not Well Rooted |- |} @@ -349,7 +252,8 @@ Payment Protocol errors MUST be communicated to the party that initiated the com Communications errors MUST be communicated to the party that initiated the communication via the communication layer's existing error messaging faciltiies. In the case of TLS-protected HTTP, this SHOULD be done through standard HTTP Status Code messaging ([https://tools.ietf.org/html/rfc7231 RFC 7231 Section 6]). -==Process Step Details== +==New Process Details== +This BIP extends the Payment Protocol as defined in BIP70. 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. @@ -358,7 +262,6 @@ Where used, '''nonce''' MUST be set to a non-repeating number AND MUST be chosen ===InvoiceRequest Message Creation=== * Create an InvoiceRequest message * sender_public_key MUST be set to the public key of an EC keypair -* nonce MUST be set according to the requirement above. * Amount is optional. If the amount is not specified by the InvoiceRequest, the Receiver MAY specify the amount in the returned PaymentRequest. If an amount is specified by the InvoiceRequest and a PaymentRequest cannot be generated for that amount, the InvoiceRequest SHOULD return a PaymentRequest with the status_code and status_message fields set appropriately. * Memo is optional. This MAY be set to a human readable description of the InvoiceRequest * Set notification_url to URL that the Receiver will submit completed EncryptedPaymentRequest to @@ -369,97 +272,57 @@ Where used, '''nonce''' MUST be set to a non-repeating number AND MUST be chosen ** Sign InvoiceRequest with signature = "" using the X509 Certificate's private key ** Set signature value to the computed signature -===EncryptedInvoiceRequest Message Creation=== -* Create an EncryptedInvoiceRequest -* Retrieve endpoint public key to use in '''ECDH Point Generation''' as specified in [[#Initial_Public_Key_Retrieval_for_InvoiceRequest_Encryption|Initial Public Key Retrieval for InvoiceRequest Encryption]] (see below) -* sender_public_key MUST be set to the public key of the Sender's EC keypair -* receiver_public_key MUST be set to the public key of the Receiver's EC keypair -* invoice_request_hash MUST be set to the SHA256 hash of the serialized InvoiceRequest (without encryption) -* Encrypt the serialized InvoiceRequest using AES-256-CBC setup as described in [[#ECDH_Point_Generation_and_AES256_CBC_Mode_Setup|ECDH Point Generation and AES-256 (CBC Mode) Setup]] (see below) -* encrypted_invoice_Request MUST be set to the encrypted values of the InvoiceRequest -* nonce MUST be set to the nonce used in the AES-256-CBC encryption operation -* Set identifier to invoice_request_hash - ===InvoiceRequest Validation=== -* Validate sender_public_key is a valid EC public key -* The nonce MUST not be repeated. The service receiving the InvoiceRequest MAY use whatever method to make sure that the nonce is never repeated. +* Validate sender_public_key is a valid EC public key * Validate notification_url if set, contains characters deemed valid for a URL (avoiding XSS related characters, etc). * If pki_type is None, InvoiceRequest is VALID * If pki_type is x509+sha256 and signature is valid for the serialized InvoiceRequest where signature is set to "", InvoiceRequest is VALID -===EncryptedPaymentRequest Message Creation and PaymentRequest Encryption=== -* Encrypt the serialized PaymentRequest using AES-256-CBC setup as described in [[#ECDH_Point_Generation_and_AES256_CBC_Mode_Setup|ECDH Point Generation and AES-256 (CBC Mode) Setup]] (see below) -* Create EncryptedPaymentRequest message -* Set encrypted_payment_request to be the encrypted value of the PaymentRequest -* Set payment_request_hash to generated SHA256 hash of the serialized PaymentRequest (without encryption) +===Sending Encrypted Payment Protocol Messages using EncryptedProtocolMessages=== +* Encrypt the serialized Payment Protocol message using AES-256-CBC setup as described in [[#ECDH_Point_Generation_and_AES256_GCM_Mode_Setup|ECDH Point Generation and AES-256 (GCM Mode) Setup]] (see below) +* Create EncryptedProtocolMessage message +* Set encrypted_message to be the encrypted value of the Payment Protocol message * sender_public_key MUST be set to the public key of the Sender's EC keypair * receiver_public_key MUST be set to the public key of the Receiver's EC keypair * nonce MUST be set to the nonce used in the AES-256-CBC encryption operation -* requires_payment_message MAY be set to true if the PaymentRequest requires a Payment message -* Set identifier to the value received in EncryptedInvoiceRequest +* requires_payment_message MAY be set to true if the PaymentRequest requires a Payment message '''TODO: How are we doing this now?''' +* Set identifier to the identifier value received in the originating InvoiceRequest's ProtocolMessage or EncryptedProtocolMessage wrapper message * Set signature to "" -* Sign the serialized EncryptedPayment message with the Receiver's EC public key +* Sign the serialized EncryptedProtocolMessage message with the communicating party's EC public key * Set signature to the result of the signature operation above -===EncryptedPaymentRequest Validation and Decryption=== -* Decrypt the serialized PaymentRequest using AES-256-CBC setup as described in [[#ECDH_Point_Generation_and_AES256_CBC_Mode_Setup|ECDH Point Generation and AES-256 (CBC Mode) Setup]] (see below) -* Validate payment_request_hash matches SHA256 of the decrypted, serialized PaymentRequest -* Deserialize the serialized PaymentRequest +'''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. + +===Validating and Decrypting Payment Protocol Messages using EncryptedProtocolMessages=== +* The nonce MUST not be repeated. The service receiving the InvoiceRequest MAY use whatever method to make sure that the nonce is never repeated. +* Decrypt the serialized Payment Protocol message using AES-256-GCM setup as described in [[#ECDH_Point_Generation_and_AES256_GCM_Mode_Setup|ECDH Point Generation and AES-256 (GCM Mode) Setup]] (see below) +* Deserialize the serialized Payment Protocol message -===ECDH Point Generation and AES-256 (CBC Mode) Setup=== +===ECDH Point Generation and AES-256 (GCM Mode) Setup=== +'''NOTE''': AES-256-GCM is used because it provides authenticated encryption facilities, thus negating the need for a separate message hash for authentication. * Generate the '''secret point''' using [https://en.wikipedia.org/wiki/Elliptic_curve_Diffie–Hellman ECDH] using the local entity's private key and the remote entity's public key as inputs. * Initialize [http://csrc.nist.gov/publications/nistpubs/800-90A/SP800-90A.pdf HMAC_DRBG] -** Use '''secret point's''' X value for Entropy +** Use '''SHA256(secret point's X value)''' for Entropy ** Use the given message's nonce field for Nonce -* Initialize AES-256 in CBC Mode +* Initialize AES-256 in GCM Mode ** Use HMAC_DRBG.GENERATE(32) as the Encryption Key (256 bits) ** Use HMAC_DRBG.GENERATE(16) as the Initialization Vector (IV) (128 bits) ===Initial Public Key Retrieval for InvoiceRequest Encryption=== -Initial public key retrieval for InvoiceRequest encryption can be done in a number of ways including, but not limited to, the following: +Initial public key retrieval for InvoiceRequest encryption in EncryptedProtocolMessage can be done in a number of ways including, but not limited to, the following: * Wallet Name public key asset type resolution - DNSSEC-validated name resolution returns Base64 encoded DER-formatted EC public key via TXT Record [https://www.ietf.org/rfc/rfc5480.txt RFC 5480] * Key Server lookup - Key Server lookup (similar to PGP's pgp.mit.edu) based on key server identifier (i.e., e-mail address) returns Base64 encoded DER-formatted EC public key [https://www.ietf.org/rfc/rfc5480.txt RFC 5480] * QR Code - Use of QR-code to encode DER-formatted EC public key [https://www.ietf.org/rfc/rfc5480.txt RFC 5480] - -==EncryptedPayment and EncryptedPaymentACK Details== - -===EncryptedPayment Message Creation=== -* Encrypt the serialized Payment using AES-256-CBC using secret key calculated in the [[#EncryptedPaymentRequest_Message_Creation_and_PaymentRequest_Encryption|EncryptedPaymentRequest Message Creation and PaymentRequest Encryption]] step (see above) -* Create EncryptedPayment message -* Set encrypted_payment to be the encrypted value of the Payment -* Set payment_hash to generated SHA256 hash of the serialized Payment (without encryption) -* sender_public_key MUST be set to the public key of the Sender's EC keypair -* receiver_public_key MUST be set to the public key of the Receiver's EC keypair -* nonce MUST be set to the nonce used in the AES-256-CBC encryption operation -* Set identifier to the value received in EncryptedPaymentRequest -* Set signature to "" -* Sign the serialized EncryptedPayment message with the Sender's EC public key -* Set signature to the result of the signature operation above - -===EncryptedPaymentACK Message Creation=== -* Encrypt the serialized PaymentACK using AES-256-CBC using secret key calculated in the [[#EncryptedPaymentRequest_Message_Creation_and_PaymentRequest_Encryption|EncryptedPaymentRequest Message Creation and PaymentRequest Encryption]] step (see above) -* Create EncryptedPaymentACK message -* Set encrypted_payment_ack to be the encrypted value of the PaymentACK -* Set payment_ack_hash to generated SHA256 hash of the serialized PaymentACK (without encryption) -* sender_public_key MUST be set to the public key of the Sender's EC keypair -* receiver_public_key MUST be set to the public key of the Receiver's EC keypair -* nonce MUST be set to the nonce used in the AES-256-CBC encryption operation -* Set identifier to the value received in EncryptedPaymentRequest -* Set signature to "" -* Sign the serialized EncryptedPaymentACK message with the Receiver's EC public key -* Set signature to the result of the signature operation above - - -'''SIGNATURE NOTE:''' EncryptedPaymentRequest, EncryptedPayment, and EncryptedPaymentACK 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. +* Address Service Public Key Exposure ==Payment / PaymentACK Messages with a Store & Forward Server== -When a Store & Forward server is in use during the Payment Protocol exchange, an EncryptedPayment message generated as the result of a EncryptedPaymentRequest with the requires_payment_message flag set to true MUST be accepted by a Store & Forward server. The accepted Payment message is NOT validated as the Store & Forward server does not have access to encrypted data. +When a Store & Forward server is in use during the Payment Protocol exchange, a Payment message generated as the result of a PaymentRequest with the '''requires_payment_message''' (TODO: Should add something more generic to the encapsulating messages?) flag set to true MUST be accepted by a Store & Forward server. The accepted Payment message is NOT validated as the Store & Forward server does not have access to encrypted data. -Store & Forward servers MAY accept and/or overwrite EncryptedPayment messages until an EncryptedPaymentACK message with matching identifier and valid Receiver signature is received, after which the server MAY reject all further EncryptedPayment messages matching that identifier. This feature SHOULD be used for updating Payment metadata or replacing invalid transactions with valid ones. 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. +Store & Forward servers MAY accept and/or overwrite Payment messages until an PaymentACK message with matching identifier and valid Receiver signature is received, after which the server MAY reject all further Payment messages matching that identifier. This feature SHOULD be used for updating Payment metadata or replacing invalid transactions with valid ones. 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. ==Public Key & Signature Encoding== -* Each EC public key (sender_public_key, receiver_public_key) included in any message defined in this BIP MUST be DER [ITU.X690.1994] encoded. -* Each ECC signature included in any message defined in this BIP MUST use the SHA-256 hashing algorithm and MUST be DER [ITU.X690.1994] encoded. +* All EC public keys (sender_public_key, receiver_public_key) included in any message defined in this BIP MUST be DER [ITU.X690.1994] encoded. +* All ECC signatures included in any message defined in this BIP MUST use the SHA-256 hashing algorithm and MUST be DER [ITU.X690.1994] encoded. ==Implementation== A reference implementation for a Store & Forward server supporting this proposal can be found here: @@ -468,7 +331,7 @@ A reference implementation for a Store & Forward server supporting this proposal A reference client implementation can be found in the InvoiceRequest functional testing for Addressimo here: -[https://github.com/netkicorp/addressimo/blob/master/functest/functest_ir.py InvoiceRequest Client Reference Implementation] +[https://github.com/netkicorp/addressimo/blob/master/functest/functest_bip75.py BIP75 Client Reference Implementation] ==BIP70 Extension== The following flowchart is borrowed from BIP70 and expanded upon in order to visually describe how this BIP is an extension to BIP70. -- cgit v1.2.3 From 6c9625e8322359866c2bffc6812da5691e755d3d Mon Sep 17 00:00:00 2001 From: Matt David Date: Tue, 26 Apr 2016 18:12:29 -0700 Subject: - Fix formatting + fix/add links - Update images --- bip-0075.mediawiki | 141 ++++++++++++++++++++++++++--------------------------- 1 file changed, 69 insertions(+), 72 deletions(-) (limited to 'bip-0075.mediawiki') diff --git a/bip-0075.mediawiki b/bip-0075.mediawiki index 3b0ba1f..a439cd6 100644 --- a/bip-0075.mediawiki +++ b/bip-0075.mediawiki @@ -30,9 +30,9 @@ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "S ==Motivation== -The motivation for defining this extension to the BIP70 Payment Protocol is to allow 2 parties to exchange payment information in a permissioned and encrypted way such that wallet address communication can become a more automated process. Additionally, this extension allows for the requester of a PaymentRequest to supply a certificate and signature in order to facilitate identification for address release. This also allows for automated creation of off blockchain transaction logs that are human readable, containing who you transacted with, in addition to the information that it contains today. +The motivation for defining this extension to the [[bip-0070.mediawiki|BIP70]] Payment Protocol is to allow 2 parties to exchange payment information in a permissioned and encrypted way such that wallet address communication can become a more automated process. Additionally, this extension allows for the requester of a PaymentRequest to supply a certificate and signature in order to facilitate identification for address release. This also allows for automated creation of off blockchain transaction logs that are human readable, containing who you transacted with, in addition to the information that it contains today. -The motivation for this extension to BIP70 is threefold: +The motivation for this extension to [[bip-0070.mediawiki|BIP70]] is threefold: # Ensure that the payment details can only be seen by the participants in the transaction, and not by any third party. @@ -58,7 +58,7 @@ With this BIP, Bitcoin wallets could maintain an "address book" that only needs 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, BIP70 specifies that the Merchant Server respond to a "pay now" style request with a PaymentRequest, releasing address and X.509 certificate identity information of the potential receiving party. +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-0070.mediawiki|BIP70]] specifies that the Merchant Server respond to a "pay now" style request with a PaymentRequest, releasing address and X.509 certificate identity information of the potential receiving party. With this BIP, Bitcoin wallets could prompt a wallet user to release payment information while displaying identity information about the potential sending party via an included certificate. This gives the receiving party more control over who receives their payment and identity information, and could be helpful for businesses that need to follow KYC policies or wallets that want to focus on privacy. @@ -71,10 +71,10 @@ With this BIP, returned payment information is encrypted with an ECDH-computed s ==New Messages== 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. +'''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. ===InvoiceRequest=== -The InvoiceRequest message allows a Sender to send information to the Receiver such that the Receiver can create and return a PaymentRequest. +The '''InvoiceRequest''' message allows a Sender to send information to the Receiver such that the Receiver can create and return a PaymentRequest.
 message InvoiceRequest {
@@ -107,7 +107,7 @@ message InvoiceRequest {
 |}
 
 ===ProtocolMessageType Enum===
-The ProtocolMessageType enum is defined in an extensible way to allow for new message type additions to the Payment Protocol. This enum is used in the newly defined ProtocolMessage and EncryptedProtocolMessage messages to define the serialized message type.
+This enum is used in the newly defined [[#ProtocolMessage|ProtocolMessage]] and [[#EncryptedProtocolMessage|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 {
     INVOICE_REQUEST = 0;
@@ -118,7 +118,7 @@ enum ProtocolMessageType {
 
===ProtocolMessage=== -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 so the protocol does not rely on transport-layer error handling. +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 ProtocolMessageType message_type = 1;
@@ -132,7 +132,7 @@ message ProtocolMessage {
 {| class="wikitable"
 ! Field Name !! Description
 |-
-|message_type               || Message Type of serialized_message (using enum ProtocolMessageType)
+|message_type               || Message Type of serialized_message
 |-
 |serialized_message         || Serialized Payment Protocol Message
 |-
@@ -144,7 +144,7 @@ message ProtocolMessage {
 |}
 
 ===EncryptedProtocolMessage===
-The EncryptedProtocolMessage message is an encapsualting 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 so the protocol does not rely on transport-layer error handling.
+The '''EncryptedProtocolMessage''' message is an encapsualting 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 ProtocolMessageType message_type = 1;
@@ -160,6 +160,7 @@ message EncryptedProtocolMessage {
 
{| class="wikitable" ! Field Name !! Description +|- | message_type || Message Type of Decrypted encrypted_message |- | encrypted_message || AES-256-GCM Encrypted (as defined in BIP75) Payment Protocol Message @@ -180,30 +181,28 @@ message EncryptedProtocolMessage { |} ==Payment Protocol Process with InvoiceRequests== -The full process overview for using InvoiceRequests in the Payment Protocol is defined below. All Payment Protocol messages are to be encapsulated in either a ProtocolMessage or EncryptedProcotolMessage. 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. - -See [[Sending_Encrypted_Payment_Protocol_Messages_using_EncryptedProtocolMessages|Sending Encrypted Payment Protocol Messages using EncryptedProtocolMessages]] and [[Validating_and_Decrypting_Payment_Protocol_Messages_using_EncryptedProtocolMessages|Validating and Decrypting Payment Protocol Messages using EncryptedProtocolMessages]] for the process of communicating using encrypted Payment Protocol messages. +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|ProtocolMessage]] or [[#EncryptedProcotolMessage|EncryptedProtocolMessage]. Once the process begins using [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] messages, all subsequent communications MUST use [[#EncryptedProtocolMessage|EncryptedProtocolMessages]]. All Payment Protocol messages SHOULD be communicated using [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] encapsulating messages with the exception that an [[#InvoiceRequest|InvoiceRequest]] MAY be communicated using the [[#ProtocolMessage|ProtocolMessage]] if the receiver's public key is unknown. -TODO: See about adding some info about using ProtocolMessages +The process of communicating using encrypted Payment Protocol messages is enumerated in [[#Sending_Encrypted_Payment_Protocol_Messages_using_EncryptedProtocolMessages|Sending Encrypted Payment Protocol Messages using EncryptedProtocolMessages]] and [[#Validating_and_Decrypting_Payment_Protocol_Messages_using_EncryptedProtocolMessages|Validating and Decrypting Payment Protocol Messages using EncryptedProtocolMessages]]. # Sender creates InvoiceRequest # Sender encapsulates InvoiceRequest in (Encrypted)ProtocolMessage # Sender sends (Encrypted)ProtocolMessage to Receiver -# Receiver retrieves InvoiceRequest from (Encrypted)ProtocolMessage +# Receiver retrieves InvoiceRequest in (Encrypted)ProtocolMessage from Sender # Receiver creates PaymentRequest # Receiver encapsulates PaymentRequest in EncryptedProtocolMessage # Receiver transmits EncryptedProtocolMessage to Sender -# Sender validates PaymentRequest -# The PaymentRequest is processed according to BIP70, including optional Payment and PaymentACK messages encapsulated in EncryptedProtocolMessage messages. +# Sender validates PaymentRequest retrieved from the EncryptedProtocolMessage +# The PaymentRequest is processed according to [[bip-0070.mediawiki|BIP70]], including optional Payment and PaymentACK messages encapsulated in EncryptedProtocolMessage messages. -'''NOTE:''' See section [[#Initial_Public_Key_Retrieval_for_InvoiceRequest_Encryption|Initial Public Key Retrieval for InvoiceRequest Encryption]] below for possible options to retrieve Receiver's public key. +'''NOTE:''' See section [[#Initial_Public_Key_Retrieval_for_InvoiceRequest_Encryption|Initial Public Key Retrieval for InvoiceRequest Encryption]] for possible options to retrieve Receiver's public key. Flow diagram of Encrypted InvoiceRequest ==Message Interaction Details== -===New Message HTTP Content Types=== -When communicated via HTTP, these messages MUST be transmitted via TLS-protected HTTP using the appropriate Content-Type header as defined per message type here: +===HTTP Content Types for New Message Types=== +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 |- @@ -214,7 +213,9 @@ When communicated via HTTP, these messages MUST be transmitted via TLS-protected ===Payment Protocol Status Communication=== -In the case of an error that causes the Payment Protocol process to be stopped or retried for a transaction, a ProtocolMessage or EncryptedProtocolMessage MUST be sent by the party generating the error. The content of the message must contain the same serialized_message or encrypted_message and identifier (if used) and MUST have the status_code set appropriately. The status_message value SHOULD be set with a human readable explanation of the status code. For example, if in an EncryptedProtocolMessage, the provided hash of the serialized message does not match the contents of the message once decrypted, a general error (100) MUST be returned to prevent oracle attacks. +In the case of an error that causes the Payment Protocol process to be stopped or requires that message be retried, a [[#ProtocolMessage|ProtocolMessage]] or [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] MUST be sent 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. For example, if in an [[#EncryptedProtocolMessage|EncryptedProtocolMessage]], the AES-256-GCM decryption fails to authenticate, an Authentication Failed (102) '''status_code''' MUST be returned to prevent oracle attacks. ====Payment Protocol Status Codes==== {| class="wikitable" @@ -248,54 +249,53 @@ In the case of an error that causes the Payment Protocol process to be stopped o |- |} -===Communication Errors=== +===Transport Layer Communication Errors=== Communications errors MUST be communicated to the party that initiated the communication via the communication layer's existing error messaging faciltiies. In the case of TLS-protected HTTP, this SHOULD be done through standard HTTP Status Code messaging ([https://tools.ietf.org/html/rfc7231 RFC 7231 Section 6]). ==New Process Details== -This BIP extends the Payment Protocol as defined in BIP70. +This BIP extends the Payment Protocol as defined in [[bip-0070.mediawiki|BIP70]]. 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. -Where used, '''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. +'''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. ===InvoiceRequest Message Creation=== -* Create an InvoiceRequest message -* sender_public_key MUST be set to the public key of an EC keypair -* Amount is optional. If the amount is not specified by the InvoiceRequest, the Receiver MAY specify the amount in the returned PaymentRequest. If an amount is specified by the InvoiceRequest and a PaymentRequest cannot be generated for that amount, the InvoiceRequest SHOULD return a PaymentRequest with the status_code and status_message fields set appropriately. -* Memo is optional. This MAY be set to a human readable description of the InvoiceRequest -* Set notification_url to URL that the Receiver will submit completed EncryptedPaymentRequest to -* If NOT including certificate, set pki_type to "none" +* Create an [[#InvoiceRequest|InvoiceRequest]] message +* '''sender_public_key''' MUST be set to the public key of an EC keypair +* '''amount''' is optional. If the amount is not specified by the [[#InvoiceRequest|InvoiceRequest]], the Receiver MAY specify the amount in the returned PaymentRequest. If an amount is specified by the [[#InvoiceRequest|InvoiceRequest]] and a PaymentRequest cannot be generated for that amount, the [[#InvoiceRequest|InvoiceRequest]] SHOULD return the same [[#InvoiceRequest|InvoiceRequest]] in a [[#ProtocolMessage|ProtocolMessage]] or [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] with the status_code and status_message fields set appropriately. +* '''memo''' is optional. This MAY be set to a human readable description of the InvoiceRequest +* Set '''notification_url''' to URL that the Receiver will submit completed PaymentRequest (encapsulated in an [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] to +* If NOT including certificate, set '''pki_type''' to "none" * If including certificate: -** Set pki_type to "x509+sha256" -** Set pki_data as it would be set in BIP-0070 (see [https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki#Certificates Certificates]) section) -** Sign InvoiceRequest with signature = "" using the X509 Certificate's private key -** Set signature value to the computed signature +** Set '''pki_type''' to "x509+sha256" +** Set '''pki_data''' as it would be set in BIP-0070 (see [https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki#Certificates Certificates]) section) +** Sign [[#InvoiceRequest|InvoiceRequest]] with signature = "" using the X509 Certificate's private key +** Set '''signature''' value to the computed signature ===InvoiceRequest Validation=== -* Validate sender_public_key is a valid EC public key -* Validate notification_url if set, contains characters deemed valid for a URL (avoiding XSS related characters, etc). -* If pki_type is None, InvoiceRequest is VALID -* If pki_type is x509+sha256 and signature is valid for the serialized InvoiceRequest where signature is set to "", InvoiceRequest is VALID +* Validate '''sender_public_key''' is a valid EC public key +* Validate '''notification_url''', if set, contains characters deemed valid for a URL (avoiding XSS related characters, etc). +* If '''pki_type''' is None, [[#InvoiceRequest|InvoiceRequest]] is VALID +* If '''pki_type''' is x509+sha256 and '''signature''' is valid for the serialized [[#InvoiceRequest|InvoiceRequest]] where signature is set to "", [[#InvoiceRequest|InvoiceRequest]] is VALID ===Sending Encrypted Payment Protocol Messages using EncryptedProtocolMessages=== * Encrypt the serialized Payment Protocol message using AES-256-CBC setup as described in [[#ECDH_Point_Generation_and_AES256_GCM_Mode_Setup|ECDH Point Generation and AES-256 (GCM Mode) Setup]] (see below) -* Create EncryptedProtocolMessage message -* Set encrypted_message to be the encrypted value of the Payment Protocol message -* sender_public_key MUST be set to the public key of the Sender's EC keypair -* receiver_public_key MUST be set to the public key of the Receiver's EC keypair -* nonce MUST be set to the nonce used in the AES-256-CBC encryption operation -* requires_payment_message MAY be set to true if the PaymentRequest requires a Payment message '''TODO: How are we doing this now?''' -* Set identifier to the identifier value received in the originating InvoiceRequest's ProtocolMessage or EncryptedProtocolMessage wrapper message -* Set signature to "" -* Sign the serialized EncryptedProtocolMessage message with the communicating party's EC public key -* Set signature to the result of the signature operation above - -'''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. +* Create [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] message +* Set '''encrypted_message''' to be the encrypted value of the Payment Protocol message +* '''sender_public_key''' MUST be set to the public key of the Sender's EC keypair +* '''receiver_public_key''' MUST be set to the public key of the Receiver's EC keypair +* '''nonce''' MUST be set to the nonce used in the AES-256-CBC encryption operation +* Set '''identifier''' to the identifier value received in the originating InvoiceRequest's ProtocolMessage or EncryptedProtocolMessage wrapper message +* Set '''signature''' to "" +* Sign the serialized [#EncryptedProtocolMessage|EncryptedProtocolMessage]] message with the communicating party's EC public key +* Set '''signature''' to the result of the signature operation above + +'''SIGNATURE NOTE:''' [[#EncryptedProtocolMessage|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. ===Validating and Decrypting Payment Protocol Messages using EncryptedProtocolMessages=== -* The nonce MUST not be repeated. The service receiving the InvoiceRequest MAY use whatever method to make sure that the nonce is never repeated. -* Decrypt the serialized Payment Protocol message using AES-256-GCM setup as described in [[#ECDH_Point_Generation_and_AES256_GCM_Mode_Setup|ECDH Point Generation and AES-256 (GCM Mode) Setup]] (see below) +* The '''nonce''' MUST not be repeated. The service receiving the [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] MAY use whatever method to make sure that the nonce is never repeated. +* Decrypt the serialized Payment Protocol message using AES-256-GCM setup as described in [[#ECDH_Point_Generation_and_AES256_GCM_Mode_Setup|ECDH Point Generation and AES-256 (GCM Mode) Setup]] * Deserialize the serialized Payment Protocol message ===ECDH Point Generation and AES-256 (GCM Mode) Setup=== @@ -303,25 +303,27 @@ Where used, '''nonce''' MUST be set to a non-repeating number AND MUST be chosen * Generate the '''secret point''' using [https://en.wikipedia.org/wiki/Elliptic_curve_Diffie–Hellman ECDH] using the local entity's private key and the remote entity's public key as inputs. * Initialize [http://csrc.nist.gov/publications/nistpubs/800-90A/SP800-90A.pdf HMAC_DRBG] ** Use '''SHA256(secret point's X value)''' for Entropy -** Use the given message's nonce field for Nonce +** Use the given message's '''nonce''' field for Nonce * Initialize AES-256 in GCM Mode ** Use HMAC_DRBG.GENERATE(32) as the Encryption Key (256 bits) ** Use HMAC_DRBG.GENERATE(16) as the Initialization Vector (IV) (128 bits) ===Initial Public Key Retrieval for InvoiceRequest Encryption=== -Initial public key retrieval for InvoiceRequest encryption in EncryptedProtocolMessage can be done in a number of ways including, but not limited to, the following: -* Wallet Name public key asset type resolution - DNSSEC-validated name resolution returns Base64 encoded DER-formatted EC public key via TXT Record [https://www.ietf.org/rfc/rfc5480.txt RFC 5480] -* Key Server lookup - Key Server lookup (similar to PGP's pgp.mit.edu) based on key server identifier (i.e., e-mail address) returns Base64 encoded DER-formatted EC public key [https://www.ietf.org/rfc/rfc5480.txt RFC 5480] -* QR Code - Use of QR-code to encode DER-formatted EC public key [https://www.ietf.org/rfc/rfc5480.txt RFC 5480] -* Address Service Public Key Exposure +Initial public key retrieval for [[#InvoiceRequest|InvoiceRequest]] encryption via [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] encapsulation can be done in a number of ways including, but not limited to, the following: +# Wallet Name public key asset type resolution - DNSSEC-validated name resolution returns Base64 encoded DER-formatted EC public key via TXT Record [https://www.ietf.org/rfc/rfc5480.txt RFC 5480] +# Key Server lookup - Key Server lookup (similar to PGP's pgp.mit.edu) based on key server identifier (i.e., e-mail address) returns Base64 encoded DER-formatted EC public key [https://www.ietf.org/rfc/rfc5480.txt RFC 5480] +# QR Code - Use of QR-code to encode DER-formatted EC public key [https://www.ietf.org/rfc/rfc5480.txt RFC 5480] +# Address Service Public Key Exposure -==Payment / PaymentACK Messages with a Store & Forward Server== -When a Store & Forward server is in use during the Payment Protocol exchange, a Payment message generated as the result of a PaymentRequest with the '''requires_payment_message''' (TODO: Should add something more generic to the encapsulating messages?) flag set to true MUST be accepted by a Store & Forward server. The accepted Payment message is NOT validated as the Store & Forward server does not have access to encrypted data. +==Payment / PaymentACK Messages with a HTTP Store & Forward Server== +A Store & Forward server SHOULD store PaymentRequest messages until either a timeout expires the message or a Payment message for the PaymentRequest message has been received. The timeout SHOULD be greater than 24 hours. + +When a Store & Forward server is used for a Payment Protocol exchange, a Payment message generated as the result of a PaymentRequest MUST be accepted by a Store & Forward server if the associated PaymentRequest message exists on the Store & Forward server, otherwise an HTTP 404 Not Found message should be returned. The accepted Payment message is NOT validated as the Store & Forward server does not have access to encrypted data. Store & Forward servers MAY accept and/or overwrite Payment messages until an PaymentACK message with matching identifier and valid Receiver signature is received, after which the server MAY reject all further Payment messages matching that identifier. This feature SHOULD be used for updating Payment metadata or replacing invalid transactions with valid ones. 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. ==Public Key & Signature Encoding== -* All EC public keys (sender_public_key, receiver_public_key) included in any message defined in this BIP MUST be DER [ITU.X690.1994] encoded. +* All EC public keys ('''sender_public_key''', '''receiver_public_key''') included in any message defined in this BIP MUST be DER [ITU.X690.1994] encoded. * All ECC signatures included in any message defined in this BIP MUST use the SHA-256 hashing algorithm and MUST be DER [ITU.X690.1994] encoded. ==Implementation== @@ -334,26 +336,21 @@ A reference client implementation can be found in the InvoiceRequest functional [https://github.com/netkicorp/addressimo/blob/master/functest/functest_bip75.py BIP75 Client Reference Implementation] ==BIP70 Extension== -The following flowchart is borrowed from BIP70 and expanded upon in order to visually describe how this BIP is an extension to BIP70. +The following flowchart is borrowed from [[bip-0070.mediawiki|BIP70]] and expanded upon in order to visually describe how this BIP is an extension to [[bip-0070.mediawiki|BIP70]]. Flowchart explaining how this BIP extends BIP 70 ==Mobile to Mobile Examples== -===EncryptedPayment Required=== -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, an EncryptedPaymentRequest (with require_payment_message = true), an EncryptedPayment and an EncryptedPaymentACK. In this case, the Receiver submits the transaction to the Bitcoin network. - -EncryptedPayment Required flow diagram - -===EncryptedPayment NOT Required=== -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, and an EncryptedPaymentRequest (with require_payment_message = false). In this case, the Sender submits the transaction to the Bitcoin network. +===Full Payment Protocol=== +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|EncryptedProtocolMessage]] '''and''' the Receiver submits the transaction to the Bitcoin network. -EncryptedPayment NOT Required flow diagram +Payment Required flow diagram -===Using EncryptedInvoiceRequest Message=== -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 EncryptedInvoiceRequest, a Store & Forward server, and an EncryptedPaymentRequest (with require_payment_message = false). In this case, the Sender submits the transaction to the Bitcoin network. +===Encrypting Initial InvoiceRequest via EncryptedProtocolMessage=== +The following diagram shows a sample flow in which one mobile client is sending value to a second mobile client using an [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] to transmit the InvoiceRequest using encryption, Store & Forward server, and PaymentRequest. In this case, all Payment Protocol messages are encrypting using [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] '''and''' the Sender submits the transaction to the Bitcoin network. -EncryptedInvoiceRequest without payment +Encrypted InvoiceRequest without payment ==References== -- cgit v1.2.3 From c2a73346a3b2c4da8189cbdd0278069a062e6ee0 Mon Sep 17 00:00:00 2001 From: Matt David Date: Tue, 26 Apr 2016 18:14:14 -0700 Subject: - Fix straggling EncryptedPaymentRequest reference --- bip-0075.mediawiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bip-0075.mediawiki') diff --git a/bip-0075.mediawiki b/bip-0075.mediawiki index a439cd6..51bb1ec 100644 --- a/bip-0075.mediawiki +++ b/bip-0075.mediawiki @@ -101,7 +101,7 @@ message InvoiceRequest { |- | memo || Human-readable description of invoice request for the receiver |- -| notification_url || Secure (usually TLS-protected HTTP) location where an [[#EncryptedPaymentRequest|EncryptedPaymentRequest]] (see below) SHOULD be sent when ready +| notification_url || Secure (usually TLS-protected HTTP) location where an [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] (see below) SHOULD be sent when ready |- | signature || PKI-dependent signature |} -- cgit v1.2.3 From 32d9f9d266f7bca15ea248b15a75092a46a61902 Mon Sep 17 00:00:00 2001 From: Matt David Date: Tue, 26 Apr 2016 18:51:54 -0700 Subject: Adding linebreaks and fixing some bad links --- bip-0075.mediawiki | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'bip-0075.mediawiki') diff --git a/bip-0075.mediawiki b/bip-0075.mediawiki index 51bb1ec..32649c9 100644 --- a/bip-0075.mediawiki +++ b/bip-0075.mediawiki @@ -101,7 +101,7 @@ message InvoiceRequest { |- | memo || Human-readable description of invoice request for the receiver |- -| notification_url || Secure (usually TLS-protected HTTP) location where an [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] (see below) SHOULD be sent when ready +| notification_url || Secure (usually TLS-protected HTTP) location where an [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] SHOULD be sent when ready |- | signature || PKI-dependent signature |} @@ -181,8 +181,12 @@ message EncryptedProtocolMessage { |} ==Payment Protocol Process with InvoiceRequests== -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|ProtocolMessage]] or [[#EncryptedProcotolMessage|EncryptedProtocolMessage]. Once the process begins using [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] messages, all subsequent communications MUST use [[#EncryptedProtocolMessage|EncryptedProtocolMessages]]. All Payment Protocol messages SHOULD be communicated using [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] encapsulating messages with the exception that an [[#InvoiceRequest|InvoiceRequest]] MAY be communicated using the [[#ProtocolMessage|ProtocolMessage]] if the receiver's public key is unknown. - +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|ProtocolMessage]] or [[#EncryptedProcotolMessage|EncryptedProtocolMessage]]. Once the process begins using [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] messages, all subsequent communications MUST use [[#EncryptedProtocolMessage|EncryptedProtocolMessages]]. +
+All Payment Protocol messages SHOULD be communicated using [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] encapsulating messages with the exception that an [[#InvoiceRequest|InvoiceRequest]] MAY be communicated using the [[#ProtocolMessage|ProtocolMessage]] if the receiver's public key is unknown. +
The process of communicating using encrypted Payment Protocol messages is enumerated in [[#Sending_Encrypted_Payment_Protocol_Messages_using_EncryptedProtocolMessages|Sending Encrypted Payment Protocol Messages using EncryptedProtocolMessages]] and [[#Validating_and_Decrypting_Payment_Protocol_Messages_using_EncryptedProtocolMessages|Validating and Decrypting Payment Protocol Messages using EncryptedProtocolMessages]]. # Sender creates InvoiceRequest @@ -195,7 +199,7 @@ The process of communicating using encrypted Payment Protocol messages is enumer # Sender validates PaymentRequest retrieved from the EncryptedProtocolMessage # The PaymentRequest is processed according to [[bip-0070.mediawiki|BIP70]], including optional Payment and PaymentACK messages encapsulated in EncryptedProtocolMessage messages. -'''NOTE:''' See section [[#Initial_Public_Key_Retrieval_for_InvoiceRequest_Encryption|Initial Public Key Retrieval for InvoiceRequest Encryption]] for possible options to retrieve Receiver's public key. +'''NOTE:''' See [[#Initial_Public_Key_Retrieval_for_InvoiceRequest_Encryption|Initial Public Key Retrieval for InvoiceRequest Encryption]] for possible options to retrieve Receiver's public key. Flow diagram of Encrypted InvoiceRequest @@ -203,6 +207,7 @@ The process of communicating using encrypted Payment Protocol messages is enumer ===HTTP Content Types for New Message Types=== 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 |- @@ -213,8 +218,8 @@ When communicated via '''HTTP''', the listed messages MUST be transmitted via TL ===Payment Protocol Status Communication=== -In the case of an error that causes the Payment Protocol process to be stopped or requires that message be retried, a [[#ProtocolMessage|ProtocolMessage]] or [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] MUST be sent 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. - +In the case of an error that causes the Payment Protocol process to be stopped or requires that message be retried, a [[#ProtocolMessage|ProtocolMessage]] or [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] MUST be returned by the party generating the error status_code. 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. For example, if in an [[#EncryptedProtocolMessage|EncryptedProtocolMessage]], the AES-256-GCM decryption fails to authenticate, an Authentication Failed (102) '''status_code''' MUST be returned to prevent oracle attacks. ====Payment Protocol Status Codes==== @@ -253,7 +258,7 @@ The status_message value SHOULD be set with a human readable explanation of the Communications errors MUST be communicated to the party that initiated the communication via the communication layer's existing error messaging faciltiies. In the case of TLS-protected HTTP, this SHOULD be done through standard HTTP Status Code messaging ([https://tools.ietf.org/html/rfc7231 RFC 7231 Section 6]). -==New Process Details== +==Extended Payment Protocol Process Details== This BIP extends the Payment Protocol as defined in [[bip-0070.mediawiki|BIP70]]. 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. @@ -265,11 +270,11 @@ For the following we assume the Sender already knows the Receiver's public key, * '''sender_public_key''' MUST be set to the public key of an EC keypair * '''amount''' is optional. If the amount is not specified by the [[#InvoiceRequest|InvoiceRequest]], the Receiver MAY specify the amount in the returned PaymentRequest. If an amount is specified by the [[#InvoiceRequest|InvoiceRequest]] and a PaymentRequest cannot be generated for that amount, the [[#InvoiceRequest|InvoiceRequest]] SHOULD return the same [[#InvoiceRequest|InvoiceRequest]] in a [[#ProtocolMessage|ProtocolMessage]] or [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] with the status_code and status_message fields set appropriately. * '''memo''' is optional. This MAY be set to a human readable description of the InvoiceRequest -* Set '''notification_url''' to URL that the Receiver will submit completed PaymentRequest (encapsulated in an [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] to +* Set '''notification_url''' to URL that the Receiver will submit completed PaymentRequest (encapsulated in an [[#EncryptedProtocolMessage|EncryptedProtocolMessage]]) to * If NOT including certificate, set '''pki_type''' to "none" * If including certificate: ** Set '''pki_type''' to "x509+sha256" -** Set '''pki_data''' as it would be set in BIP-0070 (see [https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki#Certificates Certificates]) section) +** Set '''pki_data''' as it would be set in BIP-0070 ([https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki#Certificates Certificates]) ** Sign [[#InvoiceRequest|InvoiceRequest]] with signature = "" using the X509 Certificate's private key ** Set '''signature''' value to the computed signature @@ -280,7 +285,7 @@ For the following we assume the Sender already knows the Receiver's public key, * If '''pki_type''' is x509+sha256 and '''signature''' is valid for the serialized [[#InvoiceRequest|InvoiceRequest]] where signature is set to "", [[#InvoiceRequest|InvoiceRequest]] is VALID ===Sending Encrypted Payment Protocol Messages using EncryptedProtocolMessages=== -* Encrypt the serialized Payment Protocol message using AES-256-CBC setup as described in [[#ECDH_Point_Generation_and_AES256_GCM_Mode_Setup|ECDH Point Generation and AES-256 (GCM Mode) Setup]] (see below) +* Encrypt the serialized Payment Protocol message using AES-256-CBC setup as described in [[#ECDH_Point_Generation_and_AES256_GCM_Mode_Setup|ECDH Point Generation and AES-256 (GCM Mode) Setup]] * Create [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] message * Set '''encrypted_message''' to be the encrypted value of the Payment Protocol message * '''sender_public_key''' MUST be set to the public key of the Sender's EC keypair @@ -288,7 +293,7 @@ For the following we assume the Sender already knows the Receiver's public key, * '''nonce''' MUST be set to the nonce used in the AES-256-CBC encryption operation * Set '''identifier''' to the identifier value received in the originating InvoiceRequest's ProtocolMessage or EncryptedProtocolMessage wrapper message * Set '''signature''' to "" -* Sign the serialized [#EncryptedProtocolMessage|EncryptedProtocolMessage]] message with the communicating party's EC public key +* Sign the serialized [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] message with the communicating party's EC public key * Set '''signature''' to the result of the signature operation above '''SIGNATURE NOTE:''' [[#EncryptedProtocolMessage|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. @@ -317,9 +322,9 @@ Initial public key retrieval for [[#InvoiceRequest|InvoiceRequest]] encryption v ==Payment / PaymentACK Messages with a HTTP Store & Forward Server== A Store & Forward server SHOULD store PaymentRequest messages until either a timeout expires the message or a Payment message for the PaymentRequest message has been received. The timeout SHOULD be greater than 24 hours. - +
When a Store & Forward server is used for a Payment Protocol exchange, a Payment message generated as the result of a PaymentRequest MUST be accepted by a Store & Forward server if the associated PaymentRequest message exists on the Store & Forward server, otherwise an HTTP 404 Not Found message should be returned. The accepted Payment message is NOT validated as the Store & Forward server does not have access to encrypted data. - +
Store & Forward servers MAY accept and/or overwrite Payment messages until an PaymentACK message with matching identifier and valid Receiver signature is received, after which the server MAY reject all further Payment messages matching that identifier. This feature SHOULD be used for updating Payment metadata or replacing invalid transactions with valid ones. 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. ==Public Key & Signature Encoding== -- cgit v1.2.3 From b5517bab86c7039e654cc1c1f6584808a3cbba39 Mon Sep 17 00:00:00 2001 From: Matt David Date: Tue, 26 Apr 2016 18:53:05 -0700 Subject: Add more linebreaks --- bip-0075.mediawiki | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'bip-0075.mediawiki') diff --git a/bip-0075.mediawiki b/bip-0075.mediawiki index 32649c9..95e620f 100644 --- a/bip-0075.mediawiki +++ b/bip-0075.mediawiki @@ -182,11 +182,11 @@ message EncryptedProtocolMessage { ==Payment Protocol Process with InvoiceRequests== 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|ProtocolMessage]] or [[#EncryptedProcotolMessage|EncryptedProtocolMessage]]. Once the process begins using [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] messages, all subsequent communications MUST use [[#EncryptedProtocolMessage|EncryptedProtocolMessages]]. -
+

All Payment Protocol messages SHOULD be communicated using [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] encapsulating messages with the exception that an [[#InvoiceRequest|InvoiceRequest]] MAY be communicated using the [[#ProtocolMessage|ProtocolMessage]] if the receiver's public key is unknown. -
+

The process of communicating using encrypted Payment Protocol messages is enumerated in [[#Sending_Encrypted_Payment_Protocol_Messages_using_EncryptedProtocolMessages|Sending Encrypted Payment Protocol Messages using EncryptedProtocolMessages]] and [[#Validating_and_Decrypting_Payment_Protocol_Messages_using_EncryptedProtocolMessages|Validating and Decrypting Payment Protocol Messages using EncryptedProtocolMessages]]. # Sender creates InvoiceRequest @@ -219,7 +219,7 @@ When communicated via '''HTTP''', the listed messages MUST be transmitted via TL ===Payment Protocol Status Communication=== In the case of an error that causes the Payment Protocol process to be stopped or requires that message be retried, a [[#ProtocolMessage|ProtocolMessage]] or [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] MUST be returned by the party generating the error status_code. 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. For example, if in an [[#EncryptedProtocolMessage|EncryptedProtocolMessage]], the AES-256-GCM decryption fails to authenticate, an Authentication Failed (102) '''status_code''' MUST be returned to prevent oracle attacks. ====Payment Protocol Status Codes==== @@ -322,9 +322,9 @@ Initial public key retrieval for [[#InvoiceRequest|InvoiceRequest]] encryption v ==Payment / PaymentACK Messages with a HTTP Store & Forward Server== A Store & Forward server SHOULD store PaymentRequest messages until either a timeout expires the message or a Payment message for the PaymentRequest message has been received. The timeout SHOULD be greater than 24 hours. -
+

When a Store & Forward server is used for a Payment Protocol exchange, a Payment message generated as the result of a PaymentRequest MUST be accepted by a Store & Forward server if the associated PaymentRequest message exists on the Store & Forward server, otherwise an HTTP 404 Not Found message should be returned. The accepted Payment message is NOT validated as the Store & Forward server does not have access to encrypted data. -
+

Store & Forward servers MAY accept and/or overwrite Payment messages until an PaymentACK message with matching identifier and valid Receiver signature is received, after which the server MAY reject all further Payment messages matching that identifier. This feature SHOULD be used for updating Payment metadata or replacing invalid transactions with valid ones. 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. ==Public Key & Signature Encoding== -- cgit v1.2.3 From 7d9e11dbcbb9b14fa748848b4c75c69b9299d054 Mon Sep 17 00:00:00 2001 From: Matt David Date: Wed, 27 Apr 2016 09:52:22 -0700 Subject: - Add information about the use of GCM Authentication tag - Add requirement of additional authenticated data in the case that either status_code and/or status_message are in use --- bip-0075.mediawiki | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'bip-0075.mediawiki') diff --git a/bip-0075.mediawiki b/bip-0075.mediawiki index 95e620f..ef10c08 100644 --- a/bip-0075.mediawiki +++ b/bip-0075.mediawiki @@ -312,6 +312,13 @@ For the following we assume the Sender already knows the Receiver's public key, * Initialize AES-256 in GCM Mode ** Use HMAC_DRBG.GENERATE(32) as the Encryption Key (256 bits) ** Use HMAC_DRBG.GENERATE(16) as the Initialization Vector (IV) (128 bits) +

+ +====AES-256 GCM Authentication Tag Use==== +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. + +====AES-256 GCM Additional Authenticated Data==== +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=== Initial public key retrieval for [[#InvoiceRequest|InvoiceRequest]] encryption via [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] encapsulation can be done in a number of ways including, but not limited to, the following: -- cgit v1.2.3 From 1e6e914ca7ba8946614abff02fcd6d917771af0e Mon Sep 17 00:00:00 2001 From: Matt David Date: Wed, 27 Apr 2016 09:54:06 -0700 Subject: - Fix spacing --- bip-0075.mediawiki | 1 - 1 file changed, 1 deletion(-) (limited to 'bip-0075.mediawiki') diff --git a/bip-0075.mediawiki b/bip-0075.mediawiki index ef10c08..9cbc605 100644 --- a/bip-0075.mediawiki +++ b/bip-0075.mediawiki @@ -312,7 +312,6 @@ For the following we assume the Sender already knows the Receiver's public key, * Initialize AES-256 in GCM Mode ** Use HMAC_DRBG.GENERATE(32) as the Encryption Key (256 bits) ** Use HMAC_DRBG.GENERATE(16) as the Initialization Vector (IV) (128 bits) -

====AES-256 GCM Authentication Tag Use==== 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. -- cgit v1.2.3 From dcbbc871dc552f946a1ddf56190f3bf22ed1fcdf Mon Sep 17 00:00:00 2001 From: Matt David Date: Wed, 27 Apr 2016 09:54:43 -0700 Subject: - Fix spacing --- bip-0075.mediawiki | 1 - 1 file changed, 1 deletion(-) (limited to 'bip-0075.mediawiki') diff --git a/bip-0075.mediawiki b/bip-0075.mediawiki index 9cbc605..b3e3498 100644 --- a/bip-0075.mediawiki +++ b/bip-0075.mediawiki @@ -200,7 +200,6 @@ The process of communicating using encrypted Payment Protocol messages is enumer # The PaymentRequest is processed according to [[bip-0070.mediawiki|BIP70]], including optional Payment and PaymentACK messages encapsulated in EncryptedProtocolMessage messages. '''NOTE:''' See [[#Initial_Public_Key_Retrieval_for_InvoiceRequest_Encryption|Initial Public Key Retrieval for InvoiceRequest Encryption]] for possible options to retrieve Receiver's public key. - Flow diagram of Encrypted InvoiceRequest ==Message Interaction Details== -- cgit v1.2.3 From 057591da8c25e296e71333b355d12fe6fa6e81d2 Mon Sep 17 00:00:00 2001 From: Matt David Date: Wed, 27 Apr 2016 10:01:03 -0700 Subject: Fix spacing again and pull IV size down to 12 bytes in accord with NIST 800-38D --- bip-0075.mediawiki | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'bip-0075.mediawiki') diff --git a/bip-0075.mediawiki b/bip-0075.mediawiki index b3e3498..27dbc44 100644 --- a/bip-0075.mediawiki +++ b/bip-0075.mediawiki @@ -200,6 +200,7 @@ The process of communicating using encrypted Payment Protocol messages is enumer # The PaymentRequest is processed according to [[bip-0070.mediawiki|BIP70]], including optional Payment and PaymentACK messages encapsulated in EncryptedProtocolMessage messages. '''NOTE:''' See [[#Initial_Public_Key_Retrieval_for_InvoiceRequest_Encryption|Initial Public Key Retrieval for InvoiceRequest Encryption]] for possible options to retrieve Receiver's public key. + Flow diagram of Encrypted InvoiceRequest ==Message Interaction Details== @@ -310,11 +311,11 @@ For the following we assume the Sender already knows the Receiver's public key, ** Use the given message's '''nonce''' field for Nonce * Initialize AES-256 in GCM Mode ** Use HMAC_DRBG.GENERATE(32) as the Encryption Key (256 bits) -** Use HMAC_DRBG.GENERATE(16) as the Initialization Vector (IV) (128 bits) +** Use HMAC_DRBG.GENERATE(12) as the Initialization Vector (IV) (96 bits) ====AES-256 GCM Authentication Tag Use==== 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. - + ====AES-256 GCM Additional Authenticated Data==== 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. @@ -367,6 +368,7 @@ The following diagram shows a sample flow in which one mobile client is sending * [[bip-0070.mediawiki|BIP70 - Payment Protocol]] * [https://en.wikipedia.org/wiki/Elliptic_curve_Diffie–Hellman ECDH] * [http://csrc.nist.gov/publications/nistpubs/800-90A/SP800-90A.pdf HMAC_DRBG] +* [http://csrc.nist.gov/publications/nistpubs/800-38D/SP-800-38D.pdf NIST Special Publication 800-38D - Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC] * [https://tools.ietf.org/html/rfc6979 RFC6979] * [https://en.bitcoin.it/wiki/Address_reuse Address Reuse] * [http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf FIPS 180-4 (Secure Hash Standard)] -- cgit v1.2.3 From a79432ac99e0ccda46720047166ef2500cabc8a6 Mon Sep 17 00:00:00 2001 From: Matt David Date: Thu, 28 Apr 2016 16:39:16 -0700 Subject: - Spacing - Recommit mistakently deleted encrypted invoicerequest flow diagram --- bip-0075.mediawiki | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bip-0075.mediawiki') diff --git a/bip-0075.mediawiki b/bip-0075.mediawiki index 27dbc44..b5110e0 100644 --- a/bip-0075.mediawiki +++ b/bip-0075.mediawiki @@ -306,9 +306,11 @@ For the following we assume the Sender already knows the Receiver's public key, ===ECDH Point Generation and AES-256 (GCM Mode) Setup=== '''NOTE''': AES-256-GCM is used because it provides authenticated encryption facilities, thus negating the need for a separate message hash for authentication. * Generate the '''secret point''' using [https://en.wikipedia.org/wiki/Elliptic_curve_Diffie–Hellman ECDH] using the local entity's private key and the remote entity's public key as inputs. + * Initialize [http://csrc.nist.gov/publications/nistpubs/800-90A/SP800-90A.pdf HMAC_DRBG] ** Use '''SHA256(secret point's X value)''' for Entropy ** Use the given message's '''nonce''' field for Nonce + * Initialize AES-256 in GCM Mode ** Use HMAC_DRBG.GENERATE(32) as the Encryption Key (256 bits) ** Use HMAC_DRBG.GENERATE(12) as the Initialization Vector (IV) (96 bits) -- cgit v1.2.3 From f8f05f0ac943ec5fc688914c28b733fc9b31497f Mon Sep 17 00:00:00 2001 From: jmacwhyte Date: Thu, 28 Apr 2016 16:47:37 -0700 Subject: Updated S&F suggestions, some other tweaks and typos. --- bip-0075.mediawiki | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'bip-0075.mediawiki') diff --git a/bip-0075.mediawiki b/bip-0075.mediawiki index 27dbc44..7a24a0e 100644 --- a/bip-0075.mediawiki +++ b/bip-0075.mediawiki @@ -187,7 +187,10 @@ All Payment Protocol messages MUST be encapsulated in either a [[#ProtocolMessag

All Payment Protocol messages SHOULD be communicated using [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] encapsulating messages with the exception that an [[#InvoiceRequest|InvoiceRequest]] MAY be communicated using the [[#ProtocolMessage|ProtocolMessage]] if the receiver's public key is unknown.

-The process of communicating using encrypted Payment Protocol messages is enumerated in [[#Sending_Encrypted_Payment_Protocol_Messages_using_EncryptedProtocolMessages|Sending Encrypted Payment Protocol Messages using EncryptedProtocolMessages]] and [[#Validating_and_Decrypting_Payment_Protocol_Messages_using_EncryptedProtocolMessages|Validating and Decrypting Payment Protocol Messages using EncryptedProtocolMessages]]. + +The process of creating encrypted Payment Protocol messages is enumerated in [[#Sending_Encrypted_Payment_Protocol_Messages_using_EncryptedProtocolMessages|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|Validating and Decrypting Payment Protocol Messages using EncryptedProtocolMessages]]. + +A standard exchange from start to finish would look like the following: # Sender creates InvoiceRequest # Sender encapsulates InvoiceRequest in (Encrypted)ProtocolMessage @@ -256,7 +259,7 @@ The status_message value SHOULD be set with a human readable explanation of the ===Transport Layer Communication Errors=== -Communications errors MUST be communicated to the party that initiated the communication via the communication layer's existing error messaging faciltiies. In the case of TLS-protected HTTP, this SHOULD be done through standard HTTP Status Code messaging ([https://tools.ietf.org/html/rfc7231 RFC 7231 Section 6]). +Communication errors MUST be communicated to the party that initiated the communication via the communication layer's existing error messaging faciltiies. In the case of TLS-protected HTTP, this SHOULD be done through standard HTTP Status Code messaging ([https://tools.ietf.org/html/rfc7231 RFC 7231 Section 6]). ==Extended Payment Protocol Process Details== This BIP extends the Payment Protocol as defined in [[bip-0070.mediawiki|BIP70]]. @@ -327,11 +330,14 @@ Initial public key retrieval for [[#InvoiceRequest|InvoiceRequest]] encryption v # Address Service Public Key Exposure ==Payment / PaymentACK Messages with a HTTP Store & Forward Server== -A Store & Forward server SHOULD store PaymentRequest messages until either a timeout expires the message or a Payment message for the PaymentRequest message has been received. The timeout SHOULD be greater than 24 hours. -

-When a Store & Forward server is used for a Payment Protocol exchange, a Payment message generated as the result of a PaymentRequest MUST be accepted by a Store & Forward server if the associated PaymentRequest message exists on the Store & Forward server, otherwise an HTTP 404 Not Found message should be returned. The accepted Payment message is NOT validated as the Store & Forward server does not have access to encrypted data. +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: + +* Once an InvoiceRequest or PaymentRequest is received, all subsequent messages using the same identifier must use the same Sender and Receiver public keys. +* For each unique identifier, only one message each of type InvoiceRequest, PaymentRequest, and PaymentACK may be submitted. Payment messages may be submitted/overwritten multiple times. All messages submitted after a PaymentACK is received will be rejected. +* Specific messages are only saved until they have been verifiably received by the intended recipient or a certain amount of time has passed, whichever comes first. +

-Store & Forward servers MAY accept and/or overwrite Payment messages until an PaymentACK message with matching identifier and valid Receiver signature is received, after which the server MAY reject all further Payment messages matching that identifier. This feature SHOULD be used for updating Payment metadata or replacing invalid transactions with valid ones. 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. +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. ==Public Key & Signature Encoding== * All EC public keys ('''sender_public_key''', '''receiver_public_key''') included in any message defined in this BIP MUST be DER [ITU.X690.1994] encoded. -- cgit v1.2.3 From e1d74be3b664798ce869bf4a9b565f96abd5c1ea Mon Sep 17 00:00:00 2001 From: Matt David Date: Wed, 11 May 2016 11:19:30 -0700 Subject: - Update ECDH output to use SHA512 instead of SHA256 - Specify HMAC_DRBG security strength --- bip-0075.mediawiki | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'bip-0075.mediawiki') diff --git a/bip-0075.mediawiki b/bip-0075.mediawiki index b62c753..0552758 100644 --- a/bip-0075.mediawiki +++ b/bip-0075.mediawiki @@ -308,13 +308,14 @@ For the following we assume the Sender already knows the Receiver's public key, ===ECDH Point Generation and AES-256 (GCM Mode) Setup=== '''NOTE''': AES-256-GCM is used because it provides authenticated encryption facilities, thus negating the need for a separate message hash for authentication. -* Generate the '''secret point''' using [https://en.wikipedia.org/wiki/Elliptic_curve_Diffie–Hellman ECDH] using the local entity's private key and the remote entity's public key as inputs. -* Initialize [http://csrc.nist.gov/publications/nistpubs/800-90A/SP800-90A.pdf HMAC_DRBG] -** Use '''SHA256(secret point's X value)''' for Entropy +* Generate the '''secret point''' using [https://en.wikipedia.org/wiki/Elliptic_curve_Diffie–Hellman ECDH] using the local entity's private key and the remote entity's public key as inputs +* Initialize [http://csrc.nist.gov/publications/nistpubs/800-90A/SP800-90A.pdf HMAC_DRBG] +** Use '''SHA512(secret point's X value in Big-Endian bytes)''' for Entropy ** Use the given message's '''nonce''' field for Nonce * Initialize AES-256 in GCM Mode +** Initialize HMAC_DRBG with Security Strength of 256 bits ** Use HMAC_DRBG.GENERATE(32) as the Encryption Key (256 bits) ** Use HMAC_DRBG.GENERATE(12) as the Initialization Vector (IV) (96 bits) @@ -380,3 +381,4 @@ The following diagram shows a sample flow in which one mobile client is sending * [https://tools.ietf.org/html/rfc6979 RFC6979] * [https://en.bitcoin.it/wiki/Address_reuse Address Reuse] * [http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf FIPS 180-4 (Secure Hash Standard)] +* [https://github.com/bitcoin-core/secp256k1/blob/master/src/modules/ecdh/main_impl.h libsecp256k1 ECDH Implementation] -- cgit v1.2.3 From 40d4246d3d83b7f9be213b51bc7ca4ef6e0d3980 Mon Sep 17 00:00:00 2001 From: Matt David Date: Wed, 11 May 2016 12:59:02 -0700 Subject: - Remove libsecp256k1 reference --- bip-0075.mediawiki | 1 - 1 file changed, 1 deletion(-) (limited to 'bip-0075.mediawiki') diff --git a/bip-0075.mediawiki b/bip-0075.mediawiki index 0552758..9ce90f6 100644 --- a/bip-0075.mediawiki +++ b/bip-0075.mediawiki @@ -381,4 +381,3 @@ The following diagram shows a sample flow in which one mobile client is sending * [https://tools.ietf.org/html/rfc6979 RFC6979] * [https://en.bitcoin.it/wiki/Address_reuse Address Reuse] * [http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf FIPS 180-4 (Secure Hash Standard)] -* [https://github.com/bitcoin-core/secp256k1/blob/master/src/modules/ecdh/main_impl.h libsecp256k1 ECDH Implementation] -- cgit v1.2.3