From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id A615BC000E for ; Sat, 10 Jul 2021 01:47:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 9A7D482ED2 for ; Sat, 10 Jul 2021 01:47:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Spam-Flag: NO X-Spam-Score: -1.498 X-Spam-Level: X-Spam-Status: No, score=-1.498 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, KHOP_HELO_FCRDNS=0.399, SPF_HELO_NONE=0.001, SPF_NONE=0.001, UNPARSEABLE_RELAY=0.001] autolearn=no autolearn_force=no Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UmWkH5TfAKDa for ; Sat, 10 Jul 2021 01:47:42 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0 Received: from azure.erisian.com.au (cerulean.erisian.com.au [139.162.42.226]) by smtp1.osuosl.org (Postfix) with ESMTPS id C13B082DDE for ; Sat, 10 Jul 2021 01:47:41 +0000 (UTC) Received: from aj@azure.erisian.com.au (helo=sapphire.erisian.com.au) by azure.erisian.com.au with esmtpsa (Exim 4.92 #3 (Debian)) id 1m225h-00087C-7t; Sat, 10 Jul 2021 11:47:39 +1000 Received: by sapphire.erisian.com.au (sSMTP sendmail emulation); Sat, 10 Jul 2021 11:47:32 +1000 Date: Sat, 10 Jul 2021 11:47:32 +1000 From: Anthony Towns To: Antoine Riard , Bitcoin Protocol Discussion Message-ID: <20210710014732.GA5164@erisian.com.au> References: <20210708111716.GC1339@erisian.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Score-int: -18 X-Spam-Bar: - Subject: Re: [bitcoin-dev] A Stroll through Fee-Bumping Techniques : Input-Based vs Child-Pay-For-Parent X-BeenThere: bitcoin-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Bitcoin Protocol Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jul 2021 01:47:42 -0000 On Fri, Jul 09, 2021 at 09:19:45AM -0400, Antoine Riard via bitcoin-dev wrote: > > The easy way to avoid O(n^2) behaviour in (3) is to disallow partial > > overlaps. So let's treat the tx as being distinct bundles of x-inputs > > and y-outputs, and we'll use the annex for grouping, since that is > > committed to by singatures. Call the annex field "sig_group_count". > > When processing inputs, setup a new state pair, (start, end), initially > > (0,0). > > When evaluating an input, lookup sig_group_count. If it's not present, > > then set start := end. If it's present and 0, leave start and end > > unchanged. Otherwise, if it's present and greather than 0, set > > start := end, and then set end := start + sig_group_count. > IIUC the design rationale, the "sig_group_count" lockdowns the hashing of > outputs for a given input, thus allowing midstate reuse across signatures > input. No midstates, the message being signed would just replace SIGHASH_SINGLE's: sha_single_output: the SHA256 of the corresponding output in CTxOut format with sha_group_outputs: the SHA256 of the serialization of the group outputs in CTxOut format. ie, you'd take span{start,end}, serialize it (same as if it were a vector of just those CTxOuts), and sha256 it. > Let's say you want to combine {x_1, y_1} and {x_2, y_2} where {x, y} denotes > bundles of Lightning commitment transactions. > x_1 is dual-signed by Alice and Bob under the SIGHASH_GROUP flag with > `sig_group_count`=3. > x_2 is dual-signed by Alice and Caroll under the SIGHASH_GROUP flag, with > `sig_group_count`=2. > y_1 and y_2 are disjunctive. > At broadcast, Alice is not able to combine {x_1,y_1} and {x_2, y_2} for the > reason that x_1, x_2 are colliding on the absolute output position. So the sha256 of the span of the group doesn't commit to start and end -- it just serializes a vector, so commits to the number of elements, the order, and the elements themselves. So you're taking serialize(y_1) and serialize(y_2), and each of x_1 signs against the former, and each of x_2 signs against the latter. (Note that the annex for x_1_0 specifies sig_group_count=len(y_1) and the annex for x_1_{1..} specifies sig_group_count=0, for "reuse previous input's group", and the signatures for each input commit to the annex anyway) > One fix could be to skim the "end > num_ouputs" semantic, That's only there to ensure the span doesn't go out of range, so I don't think it makes any sense to skip it? > I think this SIGHASH_GROUP proposal might solve other use-cases, but if I > understand the semantics correctly, it doesn't seem to achieve the batch > fee-bumping of multiple Lightning commitment with O(1) onchain footprint I was > thinking of for IOMAP... Does the above resolve that? Cheers, aj