summaryrefslogtreecommitdiff
path: root/bip-0075.mediawiki
blob: cdb2f6317fb201f5e1bac05c665889d5f77eb93d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
<pre>
  BIP:     75
  Title:   Out of Band Address Exchange using Payment Protocol Encryption
  Authors: Justin Newton <justin@netki.com>
           Matt David <mgd@mgddev.com>
           Aaron Voisine <voisine@gmail.com>
           James MacWhyte <macwhyte@gmail.com>
  Status:  Draft
  Type:    Standards Track
  Created: 2015-11-20
</pre>

==Abstract==

This BIP is an extension to BIP 70 that provides two enhancements to the existing Payment Protocol.

# It allows the requestor (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 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.

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.

==Definitions==
{| class="wikitable"
| Sender    || Entity wishing to transfer value that they control
|-
| Receiver  || Entity receiving a value transfer
|}

==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 requestor 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:

# Ensure that the payment details can only be seen by the participants in the transaction, and not by any third party.  

# Enhance the Payment Protocol to allow for store and forward servers in order to allow, for example, mobile wallets to sign and serve Payment Requests.

# Allow a sender of funds the option of sharing their identity with the receiver.  This information could then be used to:

#* Make bitcoin logs more human readable 
#* Give the user the ability to decide who to release payment details to 
#* Allow an entity such as a political campaign to ensure donors match regulatory and legal requirements 
#* Allow for an open standards based way for regulated financial entities to meet regulatory requirements
#* Automate the active exchange of payment addresses, so static addresses and BIP32 X-Pubs can be avoided to maintain privacy and convenience

In short we wanted to make bitcoin more human, while at the same time improving transaction privacy.

==Example Use Cases==

1. Address Book

A Bitcoin wallet developer would like to offer the ability to store an "address book" of payees, so users could 
send multiple payments to known entities without having to request an address every time. Static addresses compromise 
privacy, and address reuse is considered a security risk. BIP32 X-Pubs allow the generation of unique addresses, but 
watching an X-Pub chain for each person you wish to receive funds from is too resource-intensive for mobile applications, 
and there is always a risk of unknowingly sending funds to an X-Pub address after the owner has lost access to the 
corresponding private key.

With this BIP, Bitcoin wallets could maintain an "address book" that only needs to store each payee's public key. Adding 
an entry to one's address book could be done by using a Wallet Name, scanning a QR code, sending a URI through a text message or e-mail, or 
searching a public repository. When the user wishes to make a payment, their wallet would do all the work in the background 
to communicate with the payee's wallet to receive a unique payment address. If the payee's wallet has been lost, replaced, 
or destroyed, no communication will be possible, and the sending of funds to a "dead" address is prevented.

2. Individual Permissioned Address Release

A Bitcoin wallet developer would like to allow users to view a potential sending party's identifying information before deciding whether or not to share payment information with them. Currently, 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.

3. Using Store & Forward Servers

A Bitcoin wallet developer would like to use a public Store & Forward service for an asynchronous address 
exchange. This is a common case for mobile and offline wallets.

With this BIP, returned payment information is encrypted with an ECDH-computed shared key before sending to a Store & Forward 
service. In this case, a successful attack against a Store & Forward service would not be able to read or modify wallet address 
or payment information, only delete encrypted messages.

==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.

===InvoiceRequest===
The InvoiceRequest message allows a Sender to send information to the Receiver such that they can create and return a PaymentRequest.

<pre>
message InvoiceRequest {
        required bytes  sender_public_key = 1;
        optional uint64 amount = 2 [default = 0];
        optional string pki_type = 3 [default = "none"];
        optional bytes  pki_data = 4;
        optional string memo = 5;
        optional string notification_url = 6;
        optional bytes  signature = 7;
}
</pre>

{| class="wikitable"
! Field Name !! Description
|-
| sender_public_key     || Sender's EC public key
|-
| amount                || amount is integer-number-of-satoshis (default: 0)
|-
| pki_type              || none / x509+sha256 (default: "none")
|-
| pki_data              || Depends on pki_type
|-
| memo                  || Human-readable description of invoice request for the receiver
|-
| notification_url      || Secure (usually HTTPS) location where an EncryptedPaymentRequest (see below) SHOULD be sent when ready
|-
| 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.
<pre>
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;
    
}
</pre>

{| class="wikitable"
! Field Name</b> !! 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.

<pre>
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;
}
</pre>
{| class="wikitable"
! Field Name</b> !! 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.

<pre>
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;
}
</pre>
{| class="wikitable"
! Field Name</b> !! 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.
|-
| 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                || Use the identifier specified with the EncryptedPaymentRequest, if any.
|}

===EncryptedPaymentACK===

An encrypted version of the BIP70 PaymentAck.

<pre>
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;
}
</pre>
{| class="wikitable"
! Field Name</b> !! Description
|-
| encrypted_payment_ack         || AES-256-CBC encrypted, serialized BIP70 PaymentACK 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 EC public key
|-
| sender_public_key             || Sender's EC public key
|-
| nonce                         || The nonce in use for the CBC encryption
|-
| signature                     || A signature of this message using Receiver's EC key, serialized with a value of "" for signature. REQUIRED if server requires authentication.
|-
| identifier                    || Use the identifier specified with the EncryptedPayment, if any.
|}

==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 <b>Encrypted InvoiceRequest Overview</b> process.

===Non-Encrypted InvoiceRequest Overview===
# Sender creates InvoiceRequest
# Sender transmits InvoiceRequest to Receiver
# 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 Payment and PaymentACK messages


<img src="bip-0075/invoice-request-process.png"></img>

===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

<b>NOTE:</b> See section <b>Initial Public Key Retrieval for InvoiceRequest Encryption</b> below for possible options to retrieve Receiver InvoiceRequest public keys.

<img src="bip-0075/encrypted-invoice-request-process.png"></img>

==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:
{| class="wikitable"
! Message Type !! Content Type
|-
| InvoiceRequest                    || application/bitcoin-invoicerequest
|-
| EncryptedInvoiceRequest           || application/bitcoin-encrypted-invoicerequest
|-
| EncryptedPaymentRequest           || application/bitcoin-encrypted-paymentrequest
|-
| EncryptedPayment                  || application/bitcoin-encrypted-payment
|-
| 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.

==Process Step Details==

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, <b>nonce</b> 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 <b>nonce</b> MAY use whatever method to make sure that the <b>nonce</b> is never repeated.

===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 be rejected with HTTP status code 406.
* 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"
* 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

===EncryptedInvoiceRequest Message Creation===
* Create an EncryptedInvoiceRequest
* Retrieve endpoint public key to use in <b>ECDH Point Generation</b> as specified in <b>Initial Public Key Retrieval for InvoiceRequest Encryption</b> (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 <b>ECDH Point Generation and AES-256 (CBC Mode) Setup (see below)</b>
* 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 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 <b>ECDH Point Generation and AES-256 (CBC Mode) Setup (see below)</b>
* 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)
* 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
* Set signature to ""
* Sign the serialized EncryptedPayment message with the Receiver'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 <b>ECDH Point Generation and AES-256 (CBC Mode) Setup (see below)</b>
* Validate payment_request_hash matches SHA256 of the decrypted, serialized PaymentRequest
* Deserialize the serialized PaymentRequest

===ECDH Point Generation and AES-256 (CBC Mode) Setup===
* 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 the given message's nonce field for Nonce
* Initialize AES-256 in CBC 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:
* 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 <b>EncryptedPaymentRequest Message Creation and PaymentRequest Encryption</b> 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 <b>EncryptedPaymentRequest Message Creation and PaymentRequest Encryption</b> 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


<b>SIGNATURE NOTE:</b> 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 concious 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.

==Payment / PaymentACK Messages with a Store & Foward 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.

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.

==Implementation==
A reference implementation for a Store & Forward server supporting this proposal can be found here: 

[https://github.com/netkicorp/addressimo Addressimo]

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]

==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.

<img src="bip-0075/bip70-extension.png"></img>

==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.

<img src="bip-0075/mobile-sf-ir-with-payment.png"></img>

===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.

<img src="bip-0075/mobile-sf-ir-without-payment.png"></img>

===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.

<img src="bip-0075/mobile-sf-encrypted-ir-without-payment.png"></img>

==Extending BIP70 PaymentDetails==

To keep up with recent advancements in transaction type and common use cases, three version 1 fields will be added to the BIP 70 PaymentDetails message, as described in the BIP 70 section titled [[bip-0070.mediawiki#extensibility|Extensibilit]]y:

<pre>
message PaymentDetails {
        ...
        optional uint64 subtractable_fee = 1000;
        optional uint64 fee_per_kb = 1001;
        optional bool replace_by_fee = 1002;
}
</pre>

{| class="wikitable"
! Field Name !! Field Number !! Description
|-
| subtractable_fee      ||  1000   || In some situations the receiver may be willing to cover the cost of the transaction fee. If present, this field indicates how many Satoshis can be subtracted from the requested amount and instead applied towards the fee.
|-
| fee_per_kb            ||  1001   || This field allows the receiver (merchant) to specify the minimum transaction fee that must be included with the transaction in order for it to be accepted with zero confirmations.
|-
| replace_by_fee        ||  1002   || If "true," indicates the sender can enable the Replace By Fee flag for this transaction and the receiver will still consider it accepted with zero confirmations. Otherwise, RBF transactions will not be accepted by the receiver until they are confirmed.
|}

==References==

* [[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]
* [https://tools.ietf.org/html/rfc6979 RFC6979]
* [https://en.bitcoin.it/wiki/Address_reuse Address Reuse]