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
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
|
Return-Path: <shiva@blockonomics.co>
Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org
[172.17.192.35])
by mail.linuxfoundation.org (Postfix) with ESMTPS id 6103B5A9
for <bitcoin-dev@lists.linuxfoundation.org>;
Sat, 9 Sep 2017 14:08:45 +0000 (UTC)
X-Greylist: from auto-whitelisted by SQLgrey-1.7.6
Received: from blockonomics.co (blockonomics.co [52.10.115.182])
by smtp1.linuxfoundation.org (Postfix) with ESMTPS id A4C7AA1
for <bitcoin-dev@lists.linuxfoundation.org>;
Sat, 9 Sep 2017 14:08:43 +0000 (UTC)
Received: from mail-vk0-f45.google.com (mail-vk0-f45.google.com
[209.85.213.45])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
(No client certificate requested)
by blockonomics.co (Postfix) with ESMTPSA id B939C1E280B
for <bitcoin-dev@lists.linuxfoundation.org>;
Sat, 9 Sep 2017 14:08:42 +0000 (UTC)
Received: by mail-vk0-f45.google.com with SMTP id o22so6028201vke.1
for <bitcoin-dev@lists.linuxfoundation.org>;
Sat, 09 Sep 2017 07:08:42 -0700 (PDT)
X-Gm-Message-State: AHPjjUjfMErm9ztCqaoP2VH9Vg9KEF7bSAZXXGMOs0VESdL9mXweIz9/
NL3DcGCF1PR4CW2Cttl4K5t43p139Q==
X-Google-Smtp-Source: AOwi7QAZmql4RNO9FsIpZz+UhI+1yMZBgKdIM7QaQFq8j75IZFwsExFkpPbReVQ91K1pW9VI0JgVBETEDkOB4xFGpyg=
X-Received: by 10.31.171.139 with SMTP id u133mr4275021vke.141.1504966121671;
Sat, 09 Sep 2017 07:08:41 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.176.75.9 with HTTP; Sat, 9 Sep 2017 07:08:21 -0700 (PDT)
From: shiva sitamraju <shiva@blockonomics.co>
Date: Sat, 9 Sep 2017 19:38:21 +0530
X-Gmail-Original-Message-ID: <CABuOfuhN6jXgd+KTjFLjM+YkDOVg9=G3tWpeKBJvpUAkpkzjDg@mail.gmail.com>
Message-ID: <CABuOfuhN6jXgd+KTjFLjM+YkDOVg9=G3tWpeKBJvpUAkpkzjDg@mail.gmail.com>
To: bitcoin-dev@lists.linuxfoundation.org
Content-Type: multipart/alternative; boundary="001a11438e8814d4c70558c23b7b"
X-Spam-Status: No, score=0.5 required=5.0 tests=HTML_MESSAGE,
RCVD_IN_SORBS_SPAM,RP_MATCHES_RCVD autolearn=disabled version=3.3.1
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on
smtp1.linux-foundation.org
X-Mailman-Approved-At: Sat, 09 Sep 2017 14:11:18 +0000
Subject: Re: [bitcoin-dev] Proposal: Extended serialization format for BIP-32
X-BeenThere: bitcoin-dev@lists.linuxfoundation.org
X-Mailman-Version: 2.1.12
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: Sat, 09 Sep 2017 14:08:45 -0000
--001a11438e8814d4c70558c23b7b
Content-Type: text/plain; charset="UTF-8"
Hi,
I understand the motivation of adding the birthdate field. However, not
very comfortable with having this in the public key serialization. There
are privacy implication of both the birthday field and having the complete
derivation path, which takes space.
I am fine with Thomas proposal of {x,y,z}. Having additional version byte
field looks modular but since since we already have the big enough version
field in bip32, better to use that instead of adding more bytes.
Thomas, can you please explain why we require different version for P2WPKH
or P2WSH versus (P2WPKH or P2WSH) nested in P2SH. It looked to me that they
would have the same output bitcoin address and under same account.
On Fri, Sep 8, 2017 at 2:09 AM, <
bitcoin-dev-request@lists.linuxfoundation.org> wrote:
> Send bitcoin-dev mailing list submissions to
> bitcoin-dev@lists.linuxfoundation.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
> or, via email, send a message with subject or body 'help' to
> bitcoin-dev-request@lists.linuxfoundation.org
>
> You can reach the person managing the list at
> bitcoin-dev-owner@lists.linuxfoundation.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of bitcoin-dev digest..."
>
>
> Today's Topics:
>
> 1. Re: Proposal: Extended serialization format for BIP-32
> wallets (Andreas Schildbach)
> 2. Re: Proposal: Extended serialization format for BIP-32
> wallets (Pavol Rusnak)
> 3. Re: Fast Merkle Trees (Mark Friedenbach)
> 4. Re: Proposal: Extended serialization format for BIP-32
> wallets (Thomas Voegtlin)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 7 Sep 2017 21:35:49 +0200
> From: Andreas Schildbach <andreas@schildbach.de>
> To: bitcoin-dev@lists.linuxfoundation.org
> Subject: Re: [bitcoin-dev] Proposal: Extended serialization format for
> BIP-32 wallets
> Message-ID: <oos72e$rjp$1@blaine.gmane.org>
> Content-Type: text/plain; charset=utf-8
>
> On 09/07/2017 06:23 PM, Pavol Rusnak via bitcoin-dev wrote:
> > On 07/09/17 06:29, Thomas Voegtlin via bitcoin-dev wrote:
> >> A solution is still needed to wallets who do not wish to use BIP43
> >
> > What if we added another byte field OutputType for wallets that do not
> > follow BIP43?
> >
> > 0x00 - P2PKH output type
> > 0x01 - P2WPKH-in-P2SH output type
> > 0x02 - native Segwit output type
> >
> > Would that work for you?
>
> I think that would work.
>
> > The question is whether this field should be present only if depth==0x00
> > or at all times. What is your suggestion, Thomas?
>
> In case of Bitcoin Wallet, the depth is not null (m/0'/[0,1]) and still
> we need this field. I think it should always be present if a chain is
> limited to a certain script type.
>
> There is however the case where even on one chain, script types are
> mixed. In this case the field should be omitted and the wallet needs to
> scan for all (known) types. Afaik Bitcoin Core is taking this path.
>
>
>
> ------------------------------
>
> Message: 2
> Date: Thu, 7 Sep 2017 22:00:05 +0200
> From: Pavol Rusnak <stick@satoshilabs.com>
> To: Andreas Schildbach <andreas@schildbach.de>, Bitcoin Protocol
> Discussion <bitcoin-dev@lists.linuxfoundation.org>
> Subject: Re: [bitcoin-dev] Proposal: Extended serialization format for
> BIP-32 wallets
> Message-ID: <40ed03a1-915c-33b0-c4ac-e898c8c733ba@satoshilabs.com>
> Content-Type: text/plain; charset=windows-1252
>
> On 07/09/17 21:35, Andreas Schildbach via bitcoin-dev wrote:
> > In case of Bitcoin Wallet, the depth is not null (m/0'/[0,1]) and still
> > we need this field.
>
> But the depth of exported public key will be null. It does not make
> sense to export xpub for m or m/0' for your particular case.
>
> > I think it should always be present if a chain is
> > limited to a certain script type.
>
> I am fine with having the path there all the time.
>
> > There is however the case where even on one chain, script types are
> > mixed. In this case the field should be omitted and the wallet needs to
> > scan for all (known) types. Afaik Bitcoin Core is taking this path.
>
> Is that really the case? Why come up with a hierarchy and then don't use
> it?
>
> --
> Best Regards / S pozdravom,
>
> Pavol "stick" Rusnak
> CTO, SatoshiLabs
>
>
> ------------------------------
>
> Message: 3
> Date: Thu, 7 Sep 2017 13:04:30 -0700
> From: Mark Friedenbach <mark@friedenbach.org>
> To: Russell O'Connor <roconnor@blockstream.io>
> Cc: Bitcoin Protocol Discussion
> <bitcoin-dev@lists.linuxfoundation.org>
> Subject: Re: [bitcoin-dev] Fast Merkle Trees
> Message-ID: <40D6F502-3380-4B64-BCD9-80D361EED35C@friedenbach.org>
> Content-Type: text/plain; charset="us-ascii"
>
> TL;DR I'll be updating the fast Merkle-tree spec to use a different
> IV, using (for infrastructure compatability reasons) the scheme
> provided by Peter Todd.
>
> This is a specific instance of a general problem where you cannot
> trust scripts given to you by another party. Notice that we run into
> the same sort of problem when doing key aggregation, in which you must
> require the other party to prove knowledge of the discrete log before
> using their public key, or else key cancellation can occur.
>
> With script it is a little bit more complicated as you might want
> zero-knowledge proofs of hash pre-images for HTLCs as well as proofs
> of DL knowledge (signatures), but the basic idea is the same. Multi-
> party wallet level protocols for jointly constructing scriptPubKeys
> should require a 'delinearization' step that proves knowledge of
> information necessary to complete each part of the script, as part of
> proving the safety of a construct.
>
> I think my hangup before in understanding the attack you describe was
> in actualizing it into a practical attack that actually escalates the
> attacker's capabilities. If the attacker can get you to agree to a
> MAST policy that is nothing more than a CHECKSIG over a key they
> presumably control, then they don't need to do any complicated
> grinding. The attacker in that scenario would just actually specify a
> key they control and take the funds that way.
>
> Where this presumably leads to an actual exploit is when you specify a
> script that a curious counter-party actually takes the time to
> investigate and believes to be secure. For example, a script that
> requires a signature or pre-image revelation from that counter-party.
> That would require grinding not a few bytes, but at minimum 20-33
> bytes for either a HASH160 image or the counter-party's key.
>
> If I understand the revised attack description correctly, then there
> is a small window in which the attacker can create a script less than
> 55 bytes in length, where nearly all of the first 32 bytes are
> selected by the attacker, yet nevertheless the script seems safe to
> the counter-party. The smallest such script I was able to construct
> was the following:
>
> <fake-pubkey> CHECKSIGVERIFY HASH160 <preimage> EQUAL
>
> This is 56 bytes and requires only 7 bits of grinding in the fake
> pubkey. But 56 bytes is too large. Switching to secp256k1 serialized
> 32-byte pubkeys (in a script version upgrade, for example) would
> reduce this to the necessary 55 bytes with 0 bits of grinding. A
> smaller variant is possible:
>
> DUP HASH160 <fake-pubkey-hash> EQUALVERIFY CHECKSIGVERIFY HASH160
> <preimage> EQUAL
>
> This is 46 bytes, but requires grinding 96 bits, which is a bit less
> plausible.
>
> Belts and suspenders are not so terrible together, however, and I
> think there is enough of a justification here to look into modifying
> the scheme to use a different IV for hash tree updates. This would
> prevent even the above implausible attacks.
>
>
> > On Sep 7, 2017, at 11:55 AM, Russell O'Connor <roconnor@blockstream.io>
> wrote:
> >
> >
> >
> > On Thu, Sep 7, 2017 at 1:42 PM, Mark Friedenbach <mark@friedenbach.org
> <mailto:mark@friedenbach.org>> wrote:
> > I've been puzzling over your email since receiving it. I'm not sure it
> > is possible to perform the attack you describe with the tree structure
> > specified in the BIP. If I may rephrase your attack, I believe you are
> > seeking a solution to the following:
> >
> > Want: An innocuous script and a malign script for which
> >
> > double-SHA256(innocuous)
> >
> > is equal to either
> >
> > fast-SHA256(double-SHA256(malign) || r) or
> > fast-SHA256(r || double-SHA256(malign))
> >
> > or fast-SHA256(fast-SHA256(double-SHA256(malign) || r1) || r0)
> > or fast-SHA256(fast-SHA256(r1 || double-SHA256(malign)) || r0)
> > or ...
> >
> > where r is a freely chosen 32-byte nonce. This would allow the
> > attacker to reveal the innocuous script before funds are sent to the
> > MAST, then use the malign script to spend.
> >
> > Because of the double-SHA256 construction I do not see how this can be
> > accomplished without a full break of SHA256.
> >
> > The particular scenario I'm imagining is a collision between
> >
> > double-SHA256(innocuous)
> >
> > and
> >
> > fast-SHA256(fast-SHA256(fast-SHA256(double-SHA256(malign) || r2) ||
> r1) || r0).
> >
> > where innocuous is a Bitcoin Script that is between 32 and 55 bytes long.
> >
> > Observe that when data is less than 55 bytes then double-SHA256(data) =
> fast-SHA256(fast-SHA256(padding-SHA256(data)) || 0x8000...100) (which is
> really the crux of the matter).
> >
> > Therefore, to get our collision it suffices to find a collision between
> >
> > padding-SHA256(innocuous)
> >
> > and
> >
> > fast-SHA256(double-SHA256(malign) || r2) || r1
> >
> > r1 can freely be set to the second half of padding-SHA256(innocuous), so
> it suffices to find a collision between
> >
> > fast-SHA256(double-SHA256(malign) || r2)
> >
> > and the first half of padding-SHA256(innocuous) which is equal to the
> first 32 bytes of innocuous.
> >
> > Imagine the first opcode of innocuous is the push of a value that the
> attacker claims to be his 33-byte public key.
> > So long as the attacker doesn't need to prove that they know the
> discrete log of this pubkey, they can grind r2 until the result of
> fast-SHA256(double-SHA256(malign) || r2) contains the correct first
> couple of bytes for the script header and the opcode for a 33-byte push. I
> believe that is only about 3 or 4 bytes of they need to grind out.
> >
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://lists.linuxfoundation.org/pipermail/bitcoin-dev/
> attachments/20170907/63af0292/attachment-0001.html>
>
> ------------------------------
>
> Message: 4
> Date: Thu, 7 Sep 2017 22:39:17 +0200
> From: Thomas Voegtlin <thomasv@electrum.org>
> To: "bitcoin-dev@lists.linuxfoundation.org"
> <bitcoin-dev@lists.linuxfoundation.org>
> Subject: Re: [bitcoin-dev] Proposal: Extended serialization format for
> BIP-32 wallets
> Message-ID: <9e74dc17-105c-b43c-7780-4fa690043fe2@electrum.org>
> Content-Type: text/plain; charset=windows-1252
>
>
>
> On 07.09.2017 18:23, Pavol Rusnak wrote:
> > On 07/09/17 06:29, Thomas Voegtlin via bitcoin-dev wrote:
> >> A solution is still needed to wallets who do not wish to use BIP43
> >
> > What if we added another byte field OutputType for wallets that do not
> > follow BIP43?
> >
> > 0x00 - P2PKH output type
> > 0x01 - P2WPKH-in-P2SH output type
> > 0x02 - native Segwit output type
> >
> > Would that work for you?
> >
> > The question is whether this field should be present only if depth==0x00
> > or at all times. What is your suggestion, Thomas?
> >
>
>
> well, in my initial proposal, I wrote that this value should be user
> visible. That is why I used version bytes. If you create an extra byte
> field, and then use base58 or bech32 encoding, the value will not be
> user visible anymore.
>
> The initial implementation of segwit xpub/xprv in Electrum used a flag
> that was not user visible (I added 1 to the bip32 version bytes, which
> leaves the xpub/xprv prefix unchanged). I have experimented with that
> invisible flag for more than 6 months now, and I am now convinced that
> it is better to make that flag user visible.
>
> The reason is that when users create wallets with multisig scripts, they
> need to combine several master public keys. However, these master public
> keys should all be of the same type: it would not make sense to create a
> 2 of 3 multisig wallet with a one xpub, one ypub and one zpub. By
> imposing that all master keys are of the same type, we ensure that all
> cosigners agree on the script type that will be used to derive addresses.
>
> In other words, if users are exposed to master keys and need to
> manipulate them, it is better to let them see what they are doing.
>
> OTOH if you do not plan to expose your users to these keys, you probably
> do not need a serialization format.
>
>
> ------------------------------
>
> _______________________________________________
> bitcoin-dev mailing list
> bitcoin-dev@lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
>
>
> End of bitcoin-dev Digest, Vol 28, Issue 17
> *******************************************
>
--001a11438e8814d4c70558c23b7b
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><div><div>Hi,<br><br></div>I understand the motivatio=
n of adding the birthdate field. However, not very comfortable with having =
this in the public key serialization. There are privacy implication of both=
the birthday field and having the complete derivation path, which takes sp=
ace.<br><br></div>I am fine with Thomas proposal of {x,y,z}. Having additio=
nal version byte field looks modular but since since we already have the bi=
g enough version field in bip32, better to use that instead of adding more =
bytes.<br><br></div>Thomas, can you please explain why we require different=
version for P2WPKH or P2WSH versus (P2WPKH or P2WSH) nested in P2SH. It lo=
oked to me that they would have the same output bitcoin address and under s=
ame account.<br><div><div><div><div><div><div><div><div><div class=3D"gmail=
_extra">=C2=A0<br><div class=3D"gmail_quote">On Fri, Sep 8, 2017 at 2:09 AM=
, <span dir=3D"ltr"><<a href=3D"mailto:bitcoin-dev-request@lists.linuxf=
oundation.org" target=3D"_blank">bitcoin-dev-request@lists.linuxfoundation.=
org</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"mar=
gin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1=
ex">Send bitcoin-dev mailing list submissions to<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 <a href=3D"mailto:bitcoin-dev@lists.linuxfounda=
tion.org">bitcoin-dev@lists.<wbr>linuxfoundation.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 <a href=3D"https://lists.linuxfoundation.org/ma=
ilman/listinfo/bitcoin-dev" rel=3D"noreferrer" target=3D"_blank">https://li=
sts.linuxfoundation.<wbr>org/mailman/listinfo/bitcoin-<wbr>dev</a><br>
or, via email, send a message with subject or body 'help' to<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 <a href=3D"mailto:bitcoin-dev-request@lists.lin=
uxfoundation.org">bitcoin-dev-request@lists.<wbr>linuxfoundation.org</a><br=
>
<br>
You can reach the person managing the list at<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 <a href=3D"mailto:bitcoin-dev-owner@lists.linux=
foundation.org">bitcoin-dev-owner@lists.<wbr>linuxfoundation.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of bitcoin-dev digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
=C2=A0 =C2=A01. Re: Proposal: Extended serialization format for=C2=A0 =C2=
=A0BIP-32<br>
=C2=A0 =C2=A0 =C2=A0 wallets (Andreas Schildbach)<br>
=C2=A0 =C2=A02. Re: Proposal: Extended serialization format for BIP-32<br>
=C2=A0 =C2=A0 =C2=A0 wallets (Pavol Rusnak)<br>
=C2=A0 =C2=A03. Re: Fast Merkle Trees (Mark Friedenbach)<br>
=C2=A0 =C2=A04. Re: Proposal: Extended serialization format for BIP-32<br>
=C2=A0 =C2=A0 =C2=A0 wallets (Thomas Voegtlin)<br>
<br>
<br>
------------------------------<wbr>------------------------------<wbr>-----=
-----<br>
<br>
Message: 1<br>
Date: Thu, 7 Sep 2017 21:35:49 +0200<br>
From: Andreas Schildbach <<a href=3D"mailto:andreas@schildbach.de">andre=
as@schildbach.de</a>><br>
To: <a href=3D"mailto:bitcoin-dev@lists.linuxfoundation.org">bitcoin-dev@li=
sts.<wbr>linuxfoundation.org</a><br>
Subject: Re: [bitcoin-dev] Proposal: Extended serialization format for<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 BIP-32 wallets<br>
Message-ID: <oos72e$rjp$<a href=3D"mailto:1@blaine.gmane.org">1@blaine.g=
mane.org</a><wbr>><br>
Content-Type: text/plain; charset=3Dutf-8<br>
<br>
On 09/07/2017 06:23 PM, Pavol Rusnak via bitcoin-dev wrote:<br>
> On 07/09/17 06:29, Thomas Voegtlin via bitcoin-dev wrote:<br>
>> A solution is still needed to wallets who do not wish to use BIP43=
<br>
><br>
> What if we added another byte field OutputType for wallets that do not=
<br>
> follow BIP43?<br>
><br>
> 0x00 - P2PKH output type<br>
> 0x01 - P2WPKH-in-P2SH output type<br>
> 0x02 - native Segwit output type<br>
><br>
> Would that work for you?<br>
<br>
I think that would work.<br>
<br>
> The question is whether this field should be present only if depth=3D=
=3D0x00<br>
> or at all times. What is your suggestion, Thomas?<br>
<br>
In case of Bitcoin Wallet, the depth is not null (m/0'/[0,1]) and still=
<br>
we need this field. I think it should always be present if a chain is<br>
limited to a certain script type.<br>
<br>
There is however the case where even on one chain, script types are<br>
mixed. In this case the field should be omitted and the wallet needs to<br>
scan for all (known) types. Afaik Bitcoin Core is taking this path.<br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Thu, 7 Sep 2017 22:00:05 +0200<br>
From: Pavol Rusnak <<a href=3D"mailto:stick@satoshilabs.com">stick@satos=
hilabs.com</a>><br>
To: Andreas Schildbach <<a href=3D"mailto:andreas@schildbach.de">andreas=
@schildbach.de</a>>, Bitcoin Protocol<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Discussion <<a href=3D"mailto:bitcoin-dev@li=
sts.linuxfoundation.org">bitcoin-dev@lists.<wbr>linuxfoundation.org</a>>=
<br>
Subject: Re: [bitcoin-dev] Proposal: Extended serialization format for<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 BIP-32 wallets<br>
Message-ID: <<a href=3D"mailto:40ed03a1-915c-33b0-c4ac-e898c8c733ba@sato=
shilabs.com">40ed03a1-915c-33b0-c4ac-<wbr>e898c8c733ba@satoshilabs.com</a>&=
gt;<br>
Content-Type: text/plain; charset=3Dwindows-1252<br>
<br>
On 07/09/17 21:35, Andreas Schildbach via bitcoin-dev wrote:<br>
> In case of Bitcoin Wallet, the depth is not null (m/0'/[0,1]) and =
still<br>
> we need this field.<br>
<br>
But the depth of exported public key will be null. It does not make<br>
sense to export xpub for m or m/0' for your particular case.<br>
<br>
> I think it should always be present if a chain is<br>
> limited to a certain script type.<br>
<br>
I am fine with having the path there all the time.<br>
<br>
> There is however the case where even on one chain, script types are<br=
>
> mixed. In this case the field should be omitted and the wallet needs t=
o<br>
> scan for all (known) types. Afaik Bitcoin Core is taking this path.<br=
>
<br>
Is that really the case? Why come up with a hierarchy and then don't us=
e it?<br>
<br>
--<br>
Best Regards / S pozdravom,<br>
<br>
Pavol "stick" Rusnak<br>
CTO, SatoshiLabs<br>
<br>
<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Thu, 7 Sep 2017 13:04:30 -0700<br>
From: Mark Friedenbach <<a href=3D"mailto:mark@friedenbach.org">mark@fri=
edenbach.org</a>><br>
To: Russell O'Connor <<a href=3D"mailto:roconnor@blockstream.io">roc=
onnor@blockstream.io</a>><br>
Cc: Bitcoin Protocol Discussion<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 <<a href=3D"mailto:bitcoin-dev@lists.linuxfo=
undation.org">bitcoin-dev@lists.<wbr>linuxfoundation.org</a>><br>
Subject: Re: [bitcoin-dev] Fast Merkle Trees<br>
Message-ID: <<a href=3D"mailto:40D6F502-3380-4B64-BCD9-80D361EED35C@frie=
denbach.org">40D6F502-3380-4B64-BCD9-<wbr>80D361EED35C@friedenbach.org</a>&=
gt;<br>
Content-Type: text/plain; charset=3D"us-ascii"<br>
<br>
TL;DR I'll be updating the fast Merkle-tree spec to use a different<br>
=C2=A0 =C2=A0 =C2=A0 IV, using (for infrastructure compatability reasons) t=
he scheme<br>
=C2=A0 =C2=A0 =C2=A0 provided by Peter Todd.<br>
<br>
This is a specific instance of a general problem where you cannot<br>
trust scripts given to you by another party. Notice that we run into<br>
the same sort of problem when doing key aggregation, in which you must<br>
require the other party to prove knowledge of the discrete log before<br>
using their public key, or else key cancellation can occur.<br>
<br>
With script it is a little bit more complicated as you might want<br>
zero-knowledge proofs of hash pre-images for HTLCs as well as proofs<br>
of DL knowledge (signatures), but the basic idea is the same. Multi-<br>
party wallet level protocols for jointly constructing scriptPubKeys<br>
should require a 'delinearization' step that proves knowledge of<br=
>
information necessary to complete each part of the script, as part of<br>
proving the safety of a construct.<br>
<br>
I think my hangup before in understanding the attack you describe was<br>
in actualizing it into a practical attack that actually escalates the<br>
attacker's capabilities. If the attacker can get you to agree to a<br>
MAST policy that is nothing more than a CHECKSIG over a key they<br>
presumably control, then they don't need to do any complicated<br>
grinding. The attacker in that scenario would just actually specify a<br>
key they control and take the funds that way.<br>
<br>
Where this presumably leads to an actual exploit is when you specify a<br>
script that a curious counter-party actually takes the time to<br>
investigate and believes to be secure. For example, a script that<br>
requires a signature or pre-image revelation from that counter-party.<br>
That would require grinding not a few bytes, but at minimum 20-33<br>
bytes for either a HASH160 image or the counter-party's key.<br>
<br>
If I understand the revised attack description correctly, then there<br>
is a small window in which the attacker can create a script less than<br>
55 bytes in length, where nearly all of the first 32 bytes are<br>
selected by the attacker, yet nevertheless the script seems safe to<br>
the counter-party. The smallest such script I was able to construct<br>
was the following:<br>
<br>
=C2=A0 =C2=A0 <fake-pubkey> CHECKSIGVERIFY HASH160 <preimage> E=
QUAL<br>
<br>
This is 56 bytes and requires only 7 bits of grinding in the fake<br>
pubkey. But 56 bytes is too large. Switching to secp256k1 serialized<br>
32-byte pubkeys (in a script version upgrade, for example) would<br>
reduce this to the necessary 55 bytes with 0 bits of grinding. A<br>
smaller variant is possible:<br>
<br>
=C2=A0 =C2=A0 DUP HASH160 <fake-pubkey-hash> EQUALVERIFY CHECKSIGVERI=
FY HASH160 <preimage> EQUAL<br>
<br>
This is 46 bytes, but requires grinding 96 bits, which is a bit less<br>
plausible.<br>
<br>
Belts and suspenders are not so terrible together, however, and I<br>
think there is enough of a justification here to look into modifying<br>
the scheme to use a different IV for hash tree updates. This would<br>
prevent even the above implausible attacks.<br>
<br>
<br>
> On Sep 7, 2017, at 11:55 AM, Russell O'Connor <<a href=3D"mailt=
o:roconnor@blockstream.io">roconnor@blockstream.io</a>> wrote:<br>
><br>
><br>
><br>
> On Thu, Sep 7, 2017 at 1:42 PM, Mark Friedenbach <<a href=3D"mailto=
:mark@friedenbach.org">mark@friedenbach.org</a> <mailto:<a href=3D"mailt=
o:mark@friedenbach.org">mark@friedenbach.org</a>>> wrote:<br>
> I've been puzzling over your email since receiving it. I'm not=
sure it<br>
> is possible to perform the attack you describe with the tree structure=
<br>
> specified in the BIP. If I may rephrase your attack, I believe you are=
<br>
> seeking a solution to the following:<br>
><br>
> Want: An innocuous script and a malign script for which<br>
><br>
>=C2=A0 =C2=A0 double-SHA256(innocuous)<br>
><br>
> is equal to either<br>
><br>
>=C2=A0 =C2=A0 fast-SHA256(double-SHA256(<wbr>malign) || r) or<br>
>=C2=A0 =C2=A0 fast-SHA256(r || double-SHA256(malign))<br>
><br>
> or=C2=A0 fast-SHA256(fast-SHA256(<wbr>double-SHA256(malign) || r1) || =
r0)<br>
> or=C2=A0 fast-SHA256(fast-SHA256(r1 || double-SHA256(malign)) || r0)<b=
r>
> or ...<br>
><br>
> where r is a freely chosen 32-byte nonce. This would allow the<br>
> attacker to reveal the innocuous script before funds are sent to the<b=
r>
> MAST, then use the malign script to spend.<br>
><br>
> Because of the double-SHA256 construction I do not see how this can be=
<br>
> accomplished without a full break of SHA256.<br>
><br>
> The particular scenario I'm imagining is a collision between<br>
><br>
>=C2=A0 =C2=A0 =C2=A0double-SHA256(innocuous)<br>
><br>
> and<br>
><br>
>=C2=A0 =C2=A0 =C2=A0fast-SHA256(fast-SHA256(fast-<wbr>SHA256(double-SHA=
256(malign) || r2) || r1) || r0).<br>
><br>
> where innocuous is a Bitcoin Script that is between 32 and 55 bytes lo=
ng.<br>
><br>
> Observe that when data is less than 55 bytes then double-SHA256(data) =
=3D fast-SHA256(fast-SHA256(<wbr>padding-SHA256(data)) || 0x8000...100) (wh=
ich is really the crux of the matter).<br>
><br>
> Therefore, to get our collision it suffices to find a collision betwee=
n<br>
><br>
>=C2=A0 =C2=A0 =C2=A0padding-SHA256(innocuous)<br>
><br>
> and<br>
><br>
>=C2=A0 =C2=A0 =C2=A0fast-SHA256(double-SHA256(<wbr>malign) || r2) || r1=
<br>
><br>
> r1 can freely be set to the second half of padding-SHA256(innocuous), =
so it suffices to find a collision between<br>
><br>
>=C2=A0 =C2=A0 fast-SHA256(double-SHA256(<wbr>malign) || r2)<br>
><br>
> and the first half of padding-SHA256(innocuous) which is equal to the =
first 32 bytes of innocuous.<br>
><br>
> Imagine the first opcode of innocuous is the push of a value that the =
attacker claims to be his 33-byte public key.<br>
> So long as the attacker doesn't need to prove that they know the d=
iscrete log of this pubkey, they can grind r2 until the result of fast-SHA2=
56(double-SHA256(<wbr>malign) || r2) contains the correct first couple of b=
ytes for the script header and the opcode for a 33-byte push.=C2=A0 I belie=
ve that is only about 3 or 4 bytes of they need to grind out.<br>
><br>
<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href=3D"http://lists.linuxfoundation.org/pipermail/bitcoin-dev/=
attachments/20170907/63af0292/attachment-0001.html" rel=3D"noreferrer" targ=
et=3D"_blank">http://lists.linuxfoundation.<wbr>org/pipermail/bitcoin-dev/<=
wbr>attachments/20170907/63af0292/<wbr>attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 4<br>
Date: Thu, 7 Sep 2017 22:39:17 +0200<br>
From: Thomas Voegtlin <<a href=3D"mailto:thomasv@electrum.org">thomasv@e=
lectrum.org</a>><br>
To: "<a href=3D"mailto:bitcoin-dev@lists.linuxfoundation.org">bitcoin-=
dev@lists.<wbr>linuxfoundation.org</a>"<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 <<a href=3D"mailto:bitcoin-dev@lists.linuxfo=
undation.org">bitcoin-dev@lists.<wbr>linuxfoundation.org</a>><br>
Subject: Re: [bitcoin-dev] Proposal: Extended serialization format for<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 BIP-32 wallets<br>
Message-ID: <<a href=3D"mailto:9e74dc17-105c-b43c-7780-4fa690043fe2@elec=
trum.org">9e74dc17-105c-b43c-7780-<wbr>4fa690043fe2@electrum.org</a>><br=
>
Content-Type: text/plain; charset=3Dwindows-1252<br>
<br>
<br>
<br>
On 07.09.2017 18:23, Pavol Rusnak wrote:<br>
> On 07/09/17 06:29, Thomas Voegtlin via bitcoin-dev wrote:<br>
>> A solution is still needed to wallets who do not wish to use BIP43=
<br>
><br>
> What if we added another byte field OutputType for wallets that do not=
<br>
> follow BIP43?<br>
><br>
> 0x00 - P2PKH output type<br>
> 0x01 - P2WPKH-in-P2SH output type<br>
> 0x02 - native Segwit output type<br>
><br>
> Would that work for you?<br>
><br>
> The question is whether this field should be present only if depth=3D=
=3D0x00<br>
> or at all times. What is your suggestion, Thomas?<br>
><br>
<br>
<br>
well, in my initial proposal, I wrote that this value should be user<br>
visible. That is why I used version bytes. If you create an extra byte<br>
field, and then use base58 or bech32 encoding, the value will not be<br>
user visible anymore.<br>
<br>
The initial implementation of segwit xpub/xprv in Electrum used a flag<br>
that was not user visible (I added 1 to the bip32 version bytes, which<br>
leaves the xpub/xprv prefix unchanged). I have experimented with that<br>
invisible flag for more than 6 months now, and I am now convinced that<br>
it is better to make that flag user visible.<br>
<br>
The reason is that when users create wallets with multisig scripts, they<br=
>
need to combine several master public keys. However, these master public<br=
>
keys should all be of the same type: it would not make sense to create a<br=
>
2 of 3 multisig wallet with a one xpub, one ypub and one zpub. By<br>
imposing that all master keys are of the same type, we ensure that all<br>
cosigners agree on the script type that will be used to derive addresses.<b=
r>
<br>
In other words, if users are exposed to master keys and need to<br>
manipulate them, it is better to let them see what they are doing.<br>
<br>
OTOH if you do not plan to expose your users to these keys, you probably<br=
>
do not need a serialization format.<br>
<br>
<br>
------------------------------<br>
<br>
______________________________<wbr>_________________<br>
bitcoin-dev mailing list<br>
<a href=3D"mailto:bitcoin-dev@lists.linuxfoundation.org">bitcoin-dev@lists.=
<wbr>linuxfoundation.org</a><br>
<a href=3D"https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev" =
rel=3D"noreferrer" target=3D"_blank">https://lists.linuxfoundation.<wbr>org=
/mailman/listinfo/bitcoin-<wbr>dev</a><br>
<br>
<br>
End of bitcoin-dev Digest, Vol 28, Issue 17<br>
******************************<wbr>*************<br>
</blockquote></div><br></div></div></div></div></div></div></div></div></di=
v></div>
--001a11438e8814d4c70558c23b7b--
|