You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: bip-0075.mediawiki
+42-24Lines changed: 42 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -136,46 +136,59 @@ enum ProtocolMessageType {
136
136
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.
137
137
<pre>
138
138
message ProtocolMessage {
139
-
required ProtocolMessageType message_type = 1;
140
-
required bytes serialized_message = 2;
141
-
optional uint64 status_code = 3;
142
-
optional string status_message = 4;
143
-
optional bytes identifier = 5;
139
+
required uint64 version = 1
140
+
required uint64 status_code = 2;
141
+
required ProtocolMessageType message_type = 3;
142
+
required bytes serialized_message = 4;
143
+
optional string status_message = 5;
144
+
optional bytes identifier = 6;
144
145
}
145
146
</pre>
146
147
147
148
{| class="wikitable"
148
149
! Field Name !! Description
149
150
|-
151
+
|version || Protocol version number (Currently 1)
152
+
|-
153
+
|status_code || Payment Protocol Status Code
154
+
|-
150
155
|message_type || Message Type of serialized_message
|status_message || Human-readable Payment Protocol status message
157
160
|-
158
161
|identifier || Unique key to identify this entire exchange on the server. SHA256 of initial serialized InvoiceRequest SHOULD be used by default
159
162
|}
160
163
164
+
===Versioning===
165
+
This BIP introduces version 1 of this protocol. All messages sent using these base requirements MUST use a value of 1 for the version number. Any future BIPs that modify this protocol (encryption schemes, etc) MUST each increment the version number by 1.
166
+
167
+
When initiating communication, the version field of the first message SHOULD be set to the highest verison number the sender understands. All clients MUST be able to understand all version numbers less than the highest number they support. If a client receives a message with a version number higher than they understand, they MUST send the message back to the sender with a status code of 101 ("version too high") and the version field set to the highest version number the recipient understands. The sender must then resend the original message using the same version number returned by the recipient or abort.
168
+
161
169
===EncryptedProtocolMessage===
162
170
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.
163
171
<pre>
164
172
message EncryptedProtocolMessage {
165
-
required ProtocolMessageType message_type = 1;
166
-
required bytes encrypted_message = 2;
167
-
required bytes receiver_public_key = 3;
168
-
required bytes sender_public_key = 4;
169
-
required uint64 nonce = 5;
170
-
optional bytes signature = 6;
171
-
optional bytes identifier = 7;
172
-
optional uint64 status_code = 8;
173
+
required uint64 version = 1 [default = 1];
174
+
required uint64 status_code = 2 [default = 1];
175
+
required ProtocolMessageType message_type = 3;
176
+
required bytes encrypted_message = 4;
177
+
required bytes receiver_public_key = 5;
178
+
required bytes sender_public_key = 6;
179
+
required uint64 nonce = 7;
180
+
optional bytes identifier = 8;
173
181
optional string status_message = 9;
182
+
optional bytes signature = 10;
174
183
}
175
184
</pre>
176
185
{| class="wikitable"
177
186
! Field Name !! Description
178
187
|-
188
+
| version || Protocol version number
189
+
|-
190
+
| status_code || Payment Protocol Status Code
191
+
|-
179
192
| message_type || Message Type of Decrypted encrypted_message
180
193
|-
181
194
| encrypted_message || AES-256-GCM Encrypted (as defined in BIP75) Payment Protocol Message
| signature || DER-encoded Signature over the full EncryptedProtocolMessage with EC Key Belonging to Sender / Receiver, respectively
190
-
|-
191
202
| identifier || Unique key to identify this entire exchange on the server. SHA256 of initial serialized InvoiceRequest SHOULD be used by default
192
203
|-
193
-
| status_code || Payment Protocol Status Code
194
-
|-
195
204
| status_message || Human-readable Payment Protocol status message
205
+
|-
206
+
| signature || DER-encoded Signature over the full EncryptedProtocolMessage with EC Key Belonging to Sender / Receiver, respectively
196
207
|}
197
208
198
209
==Payment Protocol Process with InvoiceRequests==
@@ -236,21 +247,25 @@ When communicated via '''HTTP''', the listed messages MUST be transmitted via TL
236
247
237
248
===Payment Protocol Status Communication===
238
249
239
-
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.
250
+
Every [[#ProtocolMessage|ProtocolMessage]] or [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] MUST include a status code which conveys information about the last message received, if any (for the first message sent, use a status of 1 "OK" even though there was no previous message). In the case of an error that causes the Payment Protocol process to be stopped or requires that message be retried, a ProtocolMessage or EncryptedProtocolMessage SHOULD be returned by the party generating the error. The content of the message MUST contain the same '''serialized_message''' or '''encrypted_message''' and identifier (if present) and MUST have the status_code set appropriately.
240
251
<br/><br/>
241
-
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.
252
+
The status_message value SHOULD be set with a human readable explanation of the status code.
242
253
243
254
====Payment Protocol Status Codes====
244
255
{| class="wikitable"
245
256
! Status Code !! Description
246
257
|-
247
258
| 1 || OK
248
259
|-
260
+
| 2 || Cancel
261
+
|-
249
262
| 100 || General / Unknown Error
250
263
|-
264
+
| 101 || Version Too High
265
+
|-
251
266
| 102 || Authentication Failed
252
267
|-
253
-
| 102 || Encrypted Message Required
268
+
| 103 || Encrypted Message Required
254
269
|-
255
270
| 200 || Amount Too High
256
271
|-
@@ -272,8 +287,10 @@ The status_message value SHOULD be set with a human readable explanation of the
272
287
|-
273
288
|}
274
289
275
-
===Transport Layer Communication Errors===
290
+
+==Canceling A Message==+
291
+
If a participant to a transaction would like to inform the other party that a previous message should be canceled, they can send the same message with a status code of 2 ("Cancel") and, where applicable, an updated nonce. How recipients make use of the "Cancel" message is up to developers. For example, wallet developers may want to offer users the ability to cancel payment requests they have sent to other users, and have that change reflected in the recipient's UI. Developers using the non-encrypted ProtocolMessage may want to ignore "Cancel" messages, as it may be difficult to authenticate that the message originated from the same user.
276
292
293
+
===Transport Layer Communication Errors===
277
294
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]).
278
295
279
296
==Extended Payment Protocol Process Details==
@@ -306,6 +323,7 @@ For the following we assume the Sender already knows the Receiver's public key,
306
323
* 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]]
* Set '''encrypted_message''' to be the encrypted value of the Payment Protocol message
326
+
* '''version''' SHOULD be set to the highest version number the client understands (currently 1)
309
327
* '''sender_public_key''' MUST be set to the public key of the Sender's EC keypair
310
328
* '''receiver_public_key''' MUST be set to the public key of the Receiver's EC keypair
311
329
* '''nonce''' MUST be set to the nonce used in the AES-256-CBC encryption operation
@@ -327,7 +345,7 @@ For the following we assume the Sender already knows the Receiver's public key,
327
345
* 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
optional bytes identifier = 5; // Unique key to identify this entire exchange on the server. SHA256 of initial serialized InvoiceRequest SHOULD be used by default
68
+
required uint64 version = 1 [default = 1]; // Protocol version number
optional bytes identifier = 6; // Unique key to identify this entire exchange on the server. SHA256 of initial serialized InvoiceRequest SHOULD be used by default
73
74
}
74
75
75
76
messageEncryptedProtocolMessage {
76
-
required ProtocolMessageType message_type = 1; // Message Type of Decrypted encrypted_message
77
-
required bytes encrypted_message = 2; // AES-256-GCM Encrypted (as defined in BIP75) Payment Protocol Message
required uint64 nonce = 5; // Microseconds since epoch
81
-
optional bytes signature = 6; // Signature over the full EncryptedProtocolMessage with EC Key Belonging to Sender / Receiver, respectively
82
-
optional bytes identifier = 7; // Unique key to identify this entire exchange on the server. SHA256 of initial serialized InvoiceRequest SHOULD be used by default
83
-
optional uint64 status_code = 8; // Payment Protocol Status Code
required uint64 nonce = 7; // Microseconds since epoch
84
+
optional bytes identifier = 8; // Unique key to identify this entire exchange on the server. SHA256 of initial serialized InvoiceRequest SHOULD be used by default
0 commit comments