summaryrefslogtreecommitdiff
path: root/6c/fa09bd1956ab7431fc6f52653d8e4bf0b4eeb7
blob: 0fd7b7f6adaf2e4e5b00cf67c4b56358ae3ce3a9 (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
Return-Path: <riccardo.casatta@gmail.com>
Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])
 by lists.linuxfoundation.org (Postfix) with ESMTP id D272DC003B
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Mon, 27 Apr 2020 20:11:56 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by fraxinus.osuosl.org (Postfix) with ESMTP id C1AC385E91
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Mon, 27 Apr 2020 20:11:56 +0000 (UTC)
X-Virus-Scanned: amavisd-new at osuosl.org
Received: from fraxinus.osuosl.org ([127.0.0.1])
 by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id Noy8MGtVINuE
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Mon, 27 Apr 2020 20:11:55 +0000 (UTC)
X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6
Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com
 [209.85.222.180])
 by fraxinus.osuosl.org (Postfix) with ESMTPS id BF6C1857CE
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Mon, 27 Apr 2020 20:11:55 +0000 (UTC)
Received: by mail-qk1-f180.google.com with SMTP id 20so19426339qkl.10
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Mon, 27 Apr 2020 13:11:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:from:date:message-id:subject:to;
 bh=jAD01V0yoS1/LUgpMPtFBck+GLBhpXJuX2NqmaJfmQQ=;
 b=U/X3Z+GvMn0an9l/nlrXck2XfoRIuqcPYyi6+mkiaISFWd1S1g4z25NGsQUpFvJANC
 md851wubbjir7Se4j/wYoHwgM4b/0Lw7OgWMfpnmGDHLg3jjgNdUADZZhzV6cLdc9c7I
 q6MHRGe9gXL5BdKhFlUgmc90DFNWROFDGoRCS6Qb/oyPj+Mfx0TxurOAhn5Lz6kznYIH
 zMA3TnsCfhGuQF7fpHgmrquJBaYmCRYZ/kGKTHECXPC6jhH+ne+jrOxggVkGiZW9bxWA
 YKr8evfzv3KSJJb9XCqbe22QtTociX4Ohn7lCnyub3HMbatLzJ3FTxGRkhczVovf3XKQ
 gOFg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=jAD01V0yoS1/LUgpMPtFBck+GLBhpXJuX2NqmaJfmQQ=;
 b=ChkkA3uzC8iFr1/v8LSr7OChv6FWpyF9h8JMRl8sTJvn+ILWYH+anAZXyjXAwtvPCR
 /OeG+AsfNaLdR0eoqktFs7/j3WjxIjSeoUL3U9PkeTaHAygKzoO4W4NQUsN+WmZLrOmO
 HJAWHbl/0nSvMFnyZnbQsXxzZK+4VjxpkVTlzijOhh6FdvU4kMC75esvNX4U64iqLAqN
 9o3RfJ3ix+hBLZxo+25ecaPhMJlBtNeIs8NEmbtg/O8Z7ths0tC25kgLPD8POjrBmh94
 EmRzGwmIWncOwp3/EfY7XxaIXinyUxy07iFWzj09bAoo/L4GSo2qkJHAkIMdyFDqpt3L
 /fHg==
X-Gm-Message-State: AGi0Pub0sY56Lwlm2ISSr/QJJGiLclVjucSX3Imw0FTnbWnCg5oBn3tV
 OZzCcFWosNBmmE20Pb1X2aXIhwULrf9JTBOIDHfUPpZa
X-Google-Smtp-Source: APiQypL5rqwfTqxhlZpZv7BHt7B/ni3LJBfUI0/upZF4pHtXB7jqzXceOIllqd3Uh61VnRKnF0PvhrN++BsPia9m1cs=
X-Received: by 2002:a05:620a:1649:: with SMTP id
 c9mr24504194qko.396.1588018314344; 
 Mon, 27 Apr 2020 13:11:54 -0700 (PDT)
MIME-Version: 1.0
From: Riccardo Casatta <riccardo.casatta@gmail.com>
Date: Mon, 27 Apr 2020 22:11:43 +0200
Message-ID: <CADabwBDY8Ja3oTqPm7tBir=x_1CZUL1qPgGgtOa76C2AW6fxeQ@mail.gmail.com>
To: Bitcoin Protocol Discussion <bitcoin-dev@lists.linuxfoundation.org>
Content-Type: multipart/alternative; boundary="00000000000086007c05a44b5397"
X-Mailman-Approved-At: Mon, 27 Apr 2020 20:44:23 +0000
Subject: [bitcoin-dev] PSBT in QR codes
X-BeenThere: bitcoin-dev@lists.linuxfoundation.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Bitcoin Protocol Discussion <bitcoin-dev.lists.linuxfoundation.org>
List-Unsubscribe: <https://lists.linuxfoundation.org/mailman/options/bitcoin-dev>, 
 <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=unsubscribe>
List-Archive: <http://lists.linuxfoundation.org/pipermail/bitcoin-dev/>
List-Post: <mailto:bitcoin-dev@lists.linuxfoundation.org>
List-Help: <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=help>
List-Subscribe: <https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev>, 
 <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=subscribe>
X-List-Received-Date: Mon, 27 Apr 2020 20:11:56 -0000

--00000000000086007c05a44b5397
Content-Type: text/plain; charset="UTF-8"

Hi all,

there is some discussion happening [1] about how to encode a PSBT in QR
codes.

According to the specification (page 15 [2]) a version 40 QR code could
contain up to 3706 bytes of data, however practical limitation are much
lower and a PSBT could grow bigger anyway. so the issue is that a PSBT does
not fit in 1 QR code.

There are proposals suggesting animated QR codes but I don't think it's a
good idea for the following reasons:
* they are not easy to print
* it's not clear, by a human look, how much data it's being transferred,
thus allowing more space for attacks
* old hardware may have resource constraint and not being able to scan

There are proposals suggesting alphanumeric mode for QR codes and a header
(like message 1 of n) to allow data reconstruction. Main argument for this
choices are:
* use of built-in standard scanner
* data is copypasteable
* not a big loose in efficiency comparing to binary with a proper encoding
* industrial QR code scanner put a \r at the end of transmission (making
binary mode difficult to handle with timeouts or similar)

I don't think alphanumeric with custom headers it's a good idea and I think
we should use binary encoding and using the already available mode in QR
code specification called "structured append" (page 55 [2]). Corresponding
counter-points are:
* since data need to be reconstructed, I would avoid built-in scanner and
manual appending of strings anyway.
* we can keep the already used base64 for copypaste
* the best of the encoding we already have, bech32, is 10% less efficient
than binary and if we want to be more efficient we need to introduce a new
specific encoding
* I don't have a strong counter-point on industrial scanner, however if
they use \r to signal end of transmission they don't support well binary at
all, why they don't send how many bytes they read?

There are some doubts about support of structured append in QR code
libraries which is not widely supported. While this is true I verified the
widely diffused zxing library on Android and Luca Vaccaro verified the
Apple built-in scanner, and both this libraries let's you access to the
scanned raw bytes, allowing to parse the structured append header.
For reference, structured append allows to chain up to 16 qr codes, and
contains 1 byte of parity.

[1] https://github.com/cryptoadvance/specter-diy/issues/57
[2]
https://www.swisseduc.ch/informatik/theoretische_informatik/qr_codes/docs/qr_standard.pdf


--
Riccardo Casatta - @RCasatta

--00000000000086007c05a44b5397
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi all,<br><br>there is some discussion happening [1] abou=
t how to encode a PSBT in QR codes.<br><br>According to the specification (=
page 15 [2]) a version 40 QR code could contain up to 3706 bytes of data, h=
owever practical limitation are much lower and a PSBT could grow bigger any=
way. so the issue is that a PSBT does not fit in 1 QR code.<br><br>There ar=
e proposals suggesting animated QR codes but I don&#39;t think it&#39;s a g=
ood idea for the following reasons: <br>* they are not easy to print<br>* i=
t&#39;s not clear, by a human look, how much data it&#39;s being transferre=
d, thus allowing more space for attacks<br>* old hardware may have resource=
 constraint and not being able to scan<br><br>There are proposals suggestin=
g alphanumeric mode for QR codes and a header<span class=3D"gmail_default" =
style=3D"font-size:small"> (like message 1 of n)</span> to allow data recon=
struction. Main argument for this choices are:<div><span class=3D"gmail_def=
ault">* </span>use of <span class=3D"gmail_default">built-in </span>standar=
d scanner<br>* data is copypasteable<div>* not a big loose in efficiency co=
mparing to binary with a proper encoding<br>* industrial <span class=3D"gma=
il_default" style=3D"font-size:small">QR</span>=C2=A0code scanner put a \r =
at the end of transmission (making binary mode difficult<span class=3D"gmai=
l_default" style=3D"font-size:small"> to handle with timeouts or similar</s=
pan>)</div><div><br>I don&#39;t think<span class=3D"gmail_default" style=3D=
"font-size:small"> alphanumeric with custom headers</span> it&#39;s a good =
idea and I think we should use binary encoding and using the already availa=
ble mode in QR code specification called <span class=3D"gmail_default" styl=
e=3D"font-size:small">&quot;</span>structured append<span class=3D"gmail_de=
fault" style=3D"font-size:small">&quot;</span> (page 55 [2])<span class=3D"=
gmail_default" style=3D"font-size:small">. Corresponding counter-points are=
:</span><div><span class=3D"gmail_default" style=3D"font-size:small"></span=
></div><div><span class=3D"gmail_default" style=3D"font-size:small">* since=
 data need to be=C2=A0reconstructed, I would avoid </span><span class=3D"gm=
ail_default" style=3D"font-size:small">built-in scanner and manual appendin=
g of strings anyway.</span></div><div>* <span class=3D"gmail_default" style=
=3D"font-size:small">we can keep the already used base64 for copypaste</spa=
n></div><div><span class=3D"gmail_default" style=3D"font-size:small">* the =
best of the encoding we already have, bech32, is 10% less efficient than bi=
nary and if we want to be more efficient we need to introduce a new specifi=
c encoding</span></div><div><div class=3D"gmail_default" style=3D"font-size=
:small">* I don&#39;t have a strong counter-point on industrial scanner, ho=
wever if they use \r to signal end of transmission they don&#39;t support w=
ell binary at all, why they don&#39;t send how many bytes they read?</div><=
br><div><div class=3D"gmail_default" style=3D"font-size:small">There are so=
me doubts about support of structured append in QR code libraries which is =
not widely supported. While this is true I verified the widely diffused zxi=
ng library on Android and Luca Vaccaro verified the Apple built-in scanner,=
 and both this libraries=C2=A0let&#39;s you access to the scanned raw bytes=
, allowing to parse the structured append header.</div><div class=3D"gmail_=
default" style=3D"font-size:small">For reference, structured append allows =
to chain up to 16 qr codes, and contains 1 byte of parity.</div><br>[1] <a =
href=3D"https://github.com/cryptoadvance/specter-diy/issues/57">https://git=
hub.com/cryptoadvance/specter-diy/issues/57</a><br>[2]<span class=3D"gmail_=
default" style=3D"font-size:small"> </span><a href=3D"https://www.swisseduc=
.ch/informatik/theoretische_informatik/qr_codes/docs/qr_standard.pdf">https=
://www.swisseduc.ch/informatik/theoretische_informatik/qr_codes/docs/qr_sta=
ndard.pdf</a><br><br><br>--<br>Riccardo Casatta - @RCasatta<br></div></div>=
</div></div></div>

--00000000000086007c05a44b5397--