From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id BFFB8C8B for ; Fri, 28 Jun 2019 11:16:58 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 53CC487D for ; Fri, 28 Jun 2019 11:16:58 +0000 (UTC) Received: by mail-io1-f54.google.com with SMTP id r185so11684427iod.6 for ; Fri, 28 Jun 2019 04:16:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blockstream.io; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=muNmRrptca/GQuV3lWFDB/STF5KkCRPWDh0lhfFmgcI=; b=lVXBlM97yfGI/Cl6VYPlsGkBCqV8Jd3pZMI7INw5VovpqeYRVlC5WULFo0fx09jmfq uL3N5CDcy7CiQfTz4sixju2LiFGP+k+BkphOgBS6hSqRI4NSwjbWtSf3aXyWZIHZ6nan oE8kdthBghrDBzdQ3rXL3ZQYdLafWoII4T26g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=muNmRrptca/GQuV3lWFDB/STF5KkCRPWDh0lhfFmgcI=; b=FVj8IuUNLgLuODjQPIQ4XGzk4mcYIn5kxtGPHW+Fb8MiHJyvNO+dPiuex6A1omguRq 2MEghw17/8IsDIkcTS8Cqyx7ltFw7US+M7iJUi8C6fPiL5YGDYYDKD1dO85LVpT9nI3k 6tC6KAuYHFjXBGZiXczaj4yLVLI0T5a9Y6P06oe2wgsdibLbfM/3aqGzT2M5hUnxxWl5 LmN+lZdvV9L42Am5g7UedCVGnpGi0AEJ7lnloye91k5sH5As9YUS1oE3VEjnLDKDJV7W eZOR6K2DGJ28lTLRP+mXU1t4Nc0Iz9tVBHvmCt4YApCaZgFZn41J9iYJnL9DhUCSVHrx 5CCg== X-Gm-Message-State: APjAAAW3JTYgdqLVMHZW1Jv7WrZpkFj3BjtGiqjFfpgEhDsYpxAJXr8O Ev/upsFYd4O5/K1WRxW2Jj6k0VXy71p9+2y5uUPYMD0XGtQ= X-Google-Smtp-Source: APXvYqwiTrJCt+YeJ+DRNz3ktYLtiDo/mBOvVWE0R0S5+sauYz5LH6AV3883XKoCwFocSTUH83mcyDdtDztd7BKL4hg= X-Received: by 2002:a5e:aa15:: with SMTP id s21mr9668171ioe.221.1561720617528; Fri, 28 Jun 2019 04:16:57 -0700 (PDT) MIME-Version: 1.0 References: <20190628094937.u5zisdhdyfc6g5ts@erisian.com.au> In-Reply-To: <20190628094937.u5zisdhdyfc6g5ts@erisian.com.au> From: "Russell O'Connor" Date: Fri, 28 Jun 2019 07:16:46 -0400 Message-ID: To: Anthony Towns Content-Type: multipart/alternative; boundary="000000000000a5a0c7058c606a42" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HTML_MESSAGE, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org X-Mailman-Approved-At: Fri, 28 Jun 2019 14:40:14 +0000 Cc: Bitcoin Protocol Discussion Subject: Re: [bitcoin-dev] Taproot proposal X-BeenThere: bitcoin-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Bitcoin Protocol Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jun 2019 11:16:58 -0000 --000000000000a5a0c7058c606a42 Content-Type: text/plain; charset="UTF-8" Hmm? If I'm following what you mean, that's not the P2P rules, it's the > Unserialize code, in particular: > > compat/assumptions.h:52:static_assert(sizeof(int) == 4, "32-bit int > assumed"); > > serialize.h:289:uint64_t ReadCompactSize(Stream& is) > > serialize.h-679-template typename V> > serialize.h-680-void Unserialize_impl(Stream& is, prevector& v, > const V&) > serialize.h-681-{ > serialize.h-682- v.clear(); > serialize.h:683: unsigned int nSize = ReadCompactSize(is); > > (and other Unserialize_impl implementations) > > However, ReadCompactSize throws "size too large" if the return value is > greater than MAX_SIZE == 0x02000000 =~ 33.5M, which prior to the implicit > cast to 32 bits in Unserialize_impl. And it looks like that check's been > there since Satoshi... > > So as far as I can see, that encoding's just unsupported/invalid, rather > than equivalent/non-canonical? > Thanks for this correction! I totally missed that MAX_SIZE == 0x02000000. I think I mistook it for SIZE_MAX when reviewing this, or just didn't notice it at all. Cheers, > aj > > --000000000000a5a0c7058c606a42 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
Hmm? If I'm following what you mean, that's not the P2P rules, it&#= 39;s the
Unserialize code, in particular:

=C2=A0 compat/assumptions.h:52:static_assert(sizeof(int) =3D=3D 4, "32= -bit int assumed");

=C2=A0 serialize.h:289:uint64_t ReadCompactSize(Stream& is)

=C2=A0 serialize.h-679-template<typename Stream, unsigned int N, typenam= e T, typename V>
=C2=A0 serialize.h-680-void Unserialize_impl(Stream& is, prevector<N= , T>& v, const V&)
=C2=A0 serialize.h-681-{
=C2=A0 serialize.h-682-=C2=A0 =C2=A0 v.clear();
=C2=A0 serialize.h:683:=C2=A0 =C2=A0 unsigned int nSize =3D ReadCompactSize= (is);

=C2=A0 (and other Unserialize_impl implementations)

However, ReadCompactSize throws "size too large" if the return va= lue is
greater than MAX_SIZE =3D=3D 0x02000000 =3D~ 33.5M, which prior to the impl= icit
cast to 32 bits in Unserialize_impl. And it looks like that check's bee= n
there since Satoshi...

So as far as I can see, that encoding's just unsupported/invalid, rathe= r
than equivalent/non-canonical?

Thanks for this correction!=C2=A0 I totally missed that MAX_SIZE = =3D=3D 0x02000000.=C2=A0 I think I mistook it for SIZE_MAX when reviewing t= his, or just didn't notice it at all.
<= br>
Cheers,
aj

--000000000000a5a0c7058c606a42--