summaryrefslogtreecommitdiff
path: root/d0/73263b3c68c94a683f4ec3ddc3f07d1f0cb9eb
blob: 11caa8c066493b3f9004536c55be1c3ab502157e (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
Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192]
	helo=mx.sourceforge.net)
	by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76)
	(envelope-from <kalle@rosenbaum.se>) id 1YWVhY-0008Oj-Pg
	for bitcoin-development@lists.sourceforge.net;
	Fri, 13 Mar 2015 19:56:56 +0000
X-ACL-Warn: 
Received: from mail-qc0-f177.google.com ([209.85.216.177])
	by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128)
	(Exim 4.76) id 1YWVhW-0002kb-TO
	for bitcoin-development@lists.sourceforge.net;
	Fri, 13 Mar 2015 19:56:56 +0000
Received: by qcvp6 with SMTP id p6so29399800qcv.1
	for <bitcoin-development@lists.sourceforge.net>;
	Fri, 13 Mar 2015 12:56:49 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20130820;
	h=x-gm-message-state:mime-version:date:message-id:subject:from:to
	:content-type;
	bh=VADmhPmrKLQ6lo+GQuz1nPcjoXIJWfgDkkHljTY5XHM=;
	b=ctZYLo371skAZuV7KTsseKn5sGGcrtzE30lOPLqZZqA43v/FEaZWQ+Rw7TWp4qYbK9
	Jrx6ryUT6SVUG9WstmkLN18hX0e1wl8XxGO9HaDfKpiIeNqsRvXWrriZXV/LCH676F1p
	/Dq9rh8kbu7w+o4r7p6rjcXpcGPZugELPKs1HxMKej4i8x5bAcNuSnHPivThBbfTH+fX
	za5llxBNiICLAhG2TrKQDzODeyarn3vjjmkQiz2iFlwIgj3wW0WpD9AbdOQ2UGRM3jU2
	9bC276F3VK+sPcpMU6xTKkgYbeNTxU3wBDveLvP+3DnPe/oHr3IoL9fyPl6HZGr8+tAz
	rY2Q==
X-Gm-Message-State: ALoCoQmrHPJPyt6TMpBXmxOtor9LHMUmvZX7cQ28dGBLaNo6RhdfAJi0Zowqh5G27pc/143rf1eX
MIME-Version: 1.0
X-Received: by 10.140.148.216 with SMTP id 207mr64371770qhu.62.1426274983039; 
	Fri, 13 Mar 2015 12:29:43 -0700 (PDT)
Received: by 10.96.145.9 with HTTP; Fri, 13 Mar 2015 12:29:42 -0700 (PDT)
Date: Fri, 13 Mar 2015 20:29:42 +0100
Message-ID: <CAPswA9zzVDxW8_WXg5833r2Z4pxZOppYtNLHMQ=Nw-H72cMz7w@mail.gmail.com>
From: Kalle Rosenbaum <kalle@rosenbaum.se>
To: bitcoin-development@lists.sourceforge.net
Content-Type: multipart/alternative; boundary=001a113769d0b76e14051130851f
X-Spam-Score: 1.0 (+)
X-Spam-Report: Spam Filtering performed by mx.sourceforge.net.
	See http://spamassassin.org/tag/ for more details.
	1.0 HTML_MESSAGE           BODY: HTML included in message
X-Headers-End: 1YWVhW-0002kb-TO
Subject: [Bitcoin-development] Proof of Payment
X-BeenThere: bitcoin-development@lists.sourceforge.net
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: <bitcoin-development.lists.sourceforge.net>
List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/bitcoin-development>,
	<mailto:bitcoin-development-request@lists.sourceforge.net?subject=unsubscribe>
List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=bitcoin-development>
List-Post: <mailto:bitcoin-development@lists.sourceforge.net>
List-Help: <mailto:bitcoin-development-request@lists.sourceforge.net?subject=help>
List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/bitcoin-development>,
	<mailto:bitcoin-development-request@lists.sourceforge.net?subject=subscribe>
X-List-Received-Date: Fri, 13 Mar 2015 19:56:56 -0000

--001a113769d0b76e14051130851f
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi all,

I've been thinking about how a person can prove that she has made a
payment. I came up with an idea I call Proof of Payment (PoP) and I would
highly appreciate your comments. Has something like this been discussed
somewhere before?

*Use cases*

There are several scenarios in which it would be useful to prove that you
have paid for something. For example:

   - A pre-paid hotel room where your PoP functions as a key to the door.
   - An online video rental service where you pay for a video and watch it
   on any device.
   - An ad-sign where you pay in advance for e.g. 2-weeks exclusivity.
   During this period you can upload new content to the sign whenever you l=
ike
   using PoP.
   - A lottery where all participants pay to the same address, and the
   winner of the T-shirt is selected among the transactions to that address=
.
   You exchange the T-shirt for a PoP for the winning transaction.

These use cases can be achieved without any personal information (no
accounts, no e-mails, etc) being involved.
Desirable properties:

   1. A PoP should be generated on demand.
   2. It should only be usable once to avoid issues due to theft.
   3. It should be able to create a PoP for any payment, regardless of
   script type (P2SH, P2PKH, etc.).

Current methods of proving a payment, as I know of:

   - BIP0070, The PaymentRequest together with the transactions fulfilling
   the payment makes some sort of proof. However, it does not meet 1 or 2 a=
nd
   it obviously only meets 3 if the payment is made through BIP0070. Also,
   there's no standard way to request/provide the proof.
   - Signing messages, chosen by the entity that the proof is provided to,
   with the private keys used to sign the transaction. This could meet 1 an=
d 2
   but probably not 3. This is not standardized either.

*Proof of Payment, the data structure*

A proof of payment for a transaction T, PoP(T), is used to prove that one
has ownership of the credentials needed to unlock all the inputs of T. It
has the exact same structure as a bitcoin transaction with the same inputs
as T and with a single OP_RETURN output:

OP_RETURN PoP <txid> <nonce>

| Field     | Size [B] | Description                        |
|-----------|----------|------------------------------------|
| PoP       | 3        | Literal identifying this as a PoP  |
| <txid>    | 32       | The transaction to Prove           |
| <nonce>   | 5        | Unsigned integer                   |

The PoP is signed using the same signing process that is used for bitcoin
transactions. The purpose of the nonce is to make it harder to use a stolen
PoP. Once the PoP has reached the destination, that PoP is useless since
the destination will generate a new nonce for every PoP.

*Proof of Payment, the process*

   1. A proof of payment request is sent from the server to the wallet. The
   request contains:
      1. a random nonce
      2. a destination where to send the PoP, for example a https URL
      3. data hinting the wallet which transaction to create a proof for.
      For example:
      - txid, if known by the server
         - PaymentRequest.PaymentDetails.merchant_data (in case of a
         BIP0070 payment)
         - amount
         - label, message or other information from a BIP0021 URL
      2. The wallet identifies the transaction T, if possible. Otherwise
   asks the user to select among the ones that fit the hints in 1.3.
   3. The wallet checks that T is on the blockchain, meaning all the inputs
   are spent.
   4. The wallet creates an unsigned PoP (UPoP) for T, and asks the user to
   sign it.
   5. The user confirms
   6. The UPoP(T) is signed by the wallet, creating PoP(T).
   7. The PoP is sent to the destination in 1.2.
   8. The server receiving the PoP validates it and responds with =E2=80=9C=
valid=E2=80=9D
   or =E2=80=9Cinvalid=E2=80=9D
   9. The wallet displays the response in some way to the user.

Remarks:

   - The method of transferring the PoP request at step 1 is not very well
   thought through, but I think we can extend BIP0021 to cater for this. Fo=
r
   example read a URI, representing a PoP request, using QR code or NFC. A
   more advanced approach would be to extend BIP0070.
   - The nonce must be randomly generated by the server for every new PoP
   request.

*Validating a PoP*

The server needs to validate the PoP and reply with =E2=80=9Cvalid=E2=80=9D=
 or =E2=80=9Cinvalid=E2=80=9D.
That process is outlined below:

   1. Check the format of the PoP. It must pass normal transaction checks,
   except for the inputs being already spent.
   2. Check the output script. It must conform to the OP_RETURN output
   format outlined above.
   3. Check that the nonce is the same as the one you requested.
   4. Check that the txid in the output is the transaction you actually
   want proof for. If you don=E2=80=99t know what transaction you want proo=
f for,
   check that the transaction actually pays for the product/service you
   deliver (in the video rental case, find the transaction among all paymen=
ts
   for that specific video).
   5. Check that the inputs of the PoP are exactly the same as in
   transaction T.
   6. Check the signatures of all the inputs, as would be done on a normal
   transaction.
   7. If the signatures are valid, the PoP is valid.

*Security issues*

   - Someone can intercept the PoP-request and change the destination so
   that the user sends the PoP to the bad actor.
   - Someone can intercept the PoP-request and change for example the txid
   to trick the user to sign a PoP for another transaction than the intende=
d.
   This can of course be avoided by actually looking at the UPoP before
   signing it. The bad actor could also set hints for a transaction that th=
e
   user didn=E2=80=99t make, resulting in a broken service.
   - Someone can steal a PoP and try to use the service hoping to get a
   matching nonce. Probability per try: 1/(2^40). The server should have
   mechanism for detecting a brute force attack of this kind, or at least s=
low
   down the process by delaying the PoP request by some 100 ms or so.
   - Even if a wallet has no funds it might still be valuable as a
   generator for PoPs. This makes it important to keep the security of the
   wallet after it has been emptied.

The first two issues are the same as for traditional bitcoin payments. They
could be mitigated by using secure connections and possibly also extending
BIP0070 to support PoPs.

*Further work*

   - Figure out how to make use of, and extend, BIP0070 for the purpose of
   PoPs
   - Define an extension for BIP0021 to support PoP requests (something
   along the lines of BIP0072)
   - Implement a proof-of-concept
   - Possibly propose BIPs for the different parts.

Looking forward to reading your comments
Regards,
Kalle Rosenbaum

--001a113769d0b76e14051130851f
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div>Hi all,<br></div><div><br>I&#39;ve been thinking=
 about how a person can prove that she has made a payment. I came up with a=
n idea I call Proof of Payment (PoP) and I would highly appreciate your com=
ments. Has something like this been discussed somewhere before?<br><br></di=
v><div><b>Use cases</b><br></div><div><br>There are several scenarios in wh=
ich it would be useful to prove that you have paid for something. For examp=
le:<br><ul><li>A pre-paid hotel room where your PoP functions as a key to t=
he door.</li><li>An online video rental service where you pay for a video a=
nd watch it on any device.</li><li>An ad-sign where you pay in advance for =
e.g. 2-weeks exclusivity. During this period you can upload new content to =
the sign whenever you like using PoP.</li><li>A lottery where all participa=
nts pay to the same address, and the winner of the T-shirt is selected amon=
g the transactions to that address. You exchange the T-shirt for a PoP for =
the winning transaction.</li></ul><p>These use cases can be achieved withou=
t any personal information (no accounts, no e-mails, etc) being involved.<b=
r></p>Desirable properties:<br><ol><li>A PoP should be generated on demand.=
</li><li>It should only be usable once to avoid issues due to theft.</li><l=
i>It should be able to create a PoP for any payment, regardless of script t=
ype (P2SH, P2PKH, etc.).<br></li></ol>Current methods of proving a payment,=
 as I know of:<br><ul><li>BIP0070, The PaymentRequest together with the tra=
nsactions fulfilling the payment makes some sort of proof. However, it does=
 not meet 1 or 2 and it obviously only meets 3 if the payment is made throu=
gh BIP0070. Also, there&#39;s no standard way to request/provide the proof.=
</li><li>Signing messages, chosen by the entity that the proof is provided =
to, with the private keys used to sign the transaction. This could meet 1 a=
nd 2 but probably not 3. This is not standardized either.<br></li></ul><b>P=
roof of Payment, the data structure</b><br><br>A proof of payment for a tra=
nsaction T, PoP(T), is used to prove that one has ownership of the credenti=
als needed to unlock all the inputs of T. It has the exact same structure a=
s a bitcoin transaction with the same inputs as T and with a single OP_RETU=
RN output:<br><br><span style=3D"font-family:monospace,monospace">OP_RETURN=
 PoP &lt;txid&gt; &lt;nonce&gt;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 <br>| Field =C2=A0 =C2=A0 | Size [B] | Description=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |<br>|-----------|--------=
--|------------------------------------|<br>| PoP=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 | 3=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | Literal identi=
fying this as a PoP=C2=A0 |<br>| &lt;txid&gt; =C2=A0=C2=A0 | 32=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 | The transaction to Prove=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |<br>| &lt;nonce&gt;=C2=A0=C2=A0 | 5=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | Unsigned integer=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 |</span><br><br>The PoP is signed using the same sign=
ing process that is used for bitcoin transactions. The purpose of the nonce=
 is to make it harder to use a stolen PoP. Once the PoP has reached the des=
tination, that PoP is useless since the destination will generate a new non=
ce for every PoP.<br><br><b>Proof of Payment, the process</b><br></div><ol>=
<li>A proof of payment request is sent from the server to the wallet. The r=
equest contains:</li><ol><li>a random nonce</li><li>a destination where to =
send the PoP, for example a https URL</li><li>data
 hinting the wallet which transaction to create a proof for. For=20
example:<br></li><ul><li>txid, if known by the server<br></li><li>PaymentRe=
quest.PaymentDetails.merchant_data (in case of a BIP0070 payment)</li><li>a=
mount</li><li>label, message or other information from a BIP0021 URL</li></=
ul></ol><li>The wallet identifies the transaction T, if possible. Otherwise=
 asks the user to select among the ones that fit the hints in 1.3.</li><li>=
The wallet checks that T is on the blockchain, meaning all the inputs are s=
pent.<br></li><li>The wallet creates an unsigned PoP (UPoP) for T, and asks=
 the user to sign it.</li><li>The user confirms</li><li>The UPoP(T) is sign=
ed by the wallet, creating PoP(T).</li><li>The PoP is sent to the destinati=
on in 1.2.</li><li>The server receiving the PoP validates it and responds w=
ith =E2=80=9Cvalid=E2=80=9D or =E2=80=9Cinvalid=E2=80=9D</li><li>The wallet=
 displays the response in some way to the user.</li></ol>Remarks: <br><ul><=
li>The method of transferring the PoP request at step 1 is not very well th=
ought through, but I think we can extend BIP0021 to cater for this. For exa=
mple read a URI, representing a PoP request, using QR code or NFC. A more a=
dvanced approach would be to extend BIP0070. </li><li>The nonce must be ran=
domly generated by the server for every new PoP request.</li></ul><b>Valida=
ting a PoP</b><br><br>The server needs to validate the PoP and reply with =
=E2=80=9Cvalid=E2=80=9D or =E2=80=9Cinvalid=E2=80=9D. That process is outli=
ned below:<br><ol><li>Check the format of the PoP. It must pass normal tran=
saction checks, except for the inputs being already spent.</li><li>Check th=
e output script. It must conform to the OP_RETURN output format outlined ab=
ove.</li><li>Check that the nonce is the same as the one you requested.</li=
><li>Check that the txid in the output is the transaction you actually want=
 proof for. If you don=E2=80=99t know what transaction you want proof for, =
check that the transaction actually pays for the product/service you delive=
r (in the video rental case, find the transaction among all payments for th=
at specific video).</li><li>Check that the inputs of the PoP are exactly th=
e same as in transaction T.</li><li>Check the signatures of all the inputs,=
 as would be done on a normal transaction.</li><li>If the signatures are va=
lid, the PoP is valid. </li></ol><b>Security issues</b><br><ul><li>Someone =
can intercept the PoP-request and change the destination so that the user s=
ends the PoP to the bad actor.</li><li>Someone can intercept the PoP-reques=
t and change for example the txid to trick the user to sign a PoP for anoth=
er transaction than the intended. This can of course be avoided by actually=
 looking at the UPoP before signing it. The bad actor could also set hints =
for a transaction that the user didn=E2=80=99t make, resulting in a broken =
service.</li><li>Someone can steal a PoP and try to use the service hoping =
to get a matching nonce. Probability per try: 1/(2^40). The server should h=
ave mechanism for detecting a brute force attack of this kind, or at least =
slow down the process by delaying the PoP request by some 100 ms or so.</li=
><li>Even if a wallet has no funds it might still be valuable as a generato=
r for PoPs. This makes it important to keep the security of the wallet afte=
r it has been emptied.<br></li></ul>The first two issues are the same as fo=
r traditional bitcoin payments. They could be mitigated by using secure con=
nections and possibly also extending BIP0070 to support PoPs.<br><br></div>=
<b>Further work</b><br><ul><li>Figure out how to make use of, and extend, B=
IP0070 for the purpose of PoPs</li><li>Define an extension for BIP0021 to s=
upport PoP requests (something along the lines of BIP0072)</li><li>Implemen=
t a proof-of-concept</li><li>Possibly propose BIPs for the different parts.=
<br></li></ul><div>Looking forward to reading your comments<br>Regards,<br>=
</div><div>Kalle Rosenbaum<br></div><div><br></div></div>

--001a113769d0b76e14051130851f--