Return-Path: Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 173BEC0051 for ; Thu, 3 Sep 2020 14:38:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id EBDBC20370 for ; Thu, 3 Sep 2020 14:38:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id q5q-KHjP-EeY for ; Thu, 3 Sep 2020 14:38:39 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.ruggedbytes.com (mail.ruggedbytes.com [88.99.30.248]) by silver.osuosl.org (Postfix) with ESMTPS id ABE992036D for ; Thu, 3 Sep 2020 14:38:38 +0000 (UTC) Received: from mail.ruggedbytes.com (localhost [127.0.0.1]) by mail.ruggedbytes.com (Postfix) with ESMTPS id A4820260023D; Thu, 3 Sep 2020 14:38:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simplexum.com; s=mail; t=1599143915; bh=IyJwORduhLQ10abZWWdP+peXZNmHKBX98iDw98QhVMs=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=nVCCyh735B9B9iVYguOvLDGO6FeZ7iM7QX80Ciiw0PvlMuwKH98KzaQw7+m7wHbDV u0l1p0yFgLkUm7zwCNdgY4uuFgP7tuC7UIOs4JC+qDIanAMydv52bMH5SxfWORVmWJ bNTOELZyQI+k52GZZenMYpPsYtIPgylTH1Kd+mis= Date: Thu, 3 Sep 2020 19:42:23 +0500 From: Dmitry Petukhov To: Jeremy Message-ID: <20200903194223.7e763393@simplexum.com> In-Reply-To: References: <20191214122546.5e72eb93@simplexum.com> <20200214161826.5d334196@simplexum.com> Organization: simplexum.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Mailman-Approved-At: Thu, 03 Sep 2020 15:16:50 +0000 Cc: Bitcoin Protocol Discussion Subject: Re: [bitcoin-dev] BIP OP_CHECKTEMPLATEVERIFY 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: Thu, 03 Sep 2020 14:38:43 -0000 Just had an idea that an an "inverse timelock" can be made almost-certainly automatic: a revocation UTXO shall become anyone-can-spend after a timeout, and bear some non-dust amount. Before the timelock expiration, it shall be spendable only along with the covenant-locked 'main' UTXO (via a signature or mutual covenant) This way, after a timeout expires, a multitude of entities will be incentivized to spend this UTXO, because this would be free money for them. It will probably be spend by a miner, as they can always replace the spending transaction with their own and claim the amount. After the revocation UTXO is spent, the covenant path that commits to having it in the inputs will be unspendable, and this would effectively constitute an "inverse timelock". =D0=92 Fri, 14 Feb 2020 11:16:26 -0800 Jeremy wrote: > Hi Dmitry, >=20 > I don't think that this is fundamentally introducing new behavior, but > let's take a closer look. >=20 > We can talk about the issue you bring up purely in terms of a > hypothetical "OP_CHECKINPUTOUTPOINTVERIFY" and > "OP_CHECKINPUTSCRIPTVERIFY" (CIOV, CISV) with obvious implied by name > semantics, as a separate construct from CTV itself. Such opcodes > would be strictly more powerful/flexible than what CTV is enabling. >=20 > Using these opcodes I can make an output that can *only* be spent with > another output -- e.g., >=20 > OP_CISV OP_DROP OP_CHECKSIGVERIFY > OP_CIOV OP_DROP OP_CHECKSIGVERIFY >=20 > Let's look at CISV first: >=20 > 1) Assume that is from the same owner as PK > 2) Assume that is from a different owner than PK >=20 > In case 1, the wallet can create or recreate the appropriate output as > needed if it gets spent/stuck >=20 > In case 2, the wallet can get "frozen" in a reorg until a signer on > re-spends. >=20 >=20 > For CIOV: >=20 > 1) Assume that exists in the chain somewhere > 2) Assume that exists in the mempool somewhere > 3) Assume that does not exist (or, is provably non-creatable > -- h =3D txid(x) | x.IsValid() =3D=3D false) >=20 > In case 2, this is just a fancy op-return. >=20 > Case 1 degrades into case 2 in the event of a reorg. >=20 > In Case 2, if the output is spent in another transaction, our > script becomes provably unspendable (unless a second reorg). >=20 > Otherwise, it is possible to mine a block with our transaction. >=20 >=20 > Compare the above to normal transactions: >=20 > 1) If a reorg occurs, and someone double-spends, your transaction gets > cancelled. > 2) You can re-sign your UTXO onto a different transaction >=20 > However, if you have deleted your key (e.g. using a pre-signing HSM), > or your transaction was using a multi-sig with an uncooperating > party, you will have an output that may be effectively burned. >=20 > These issues are -- as with CTV -- not present in the single input > use case. >=20 > Thus I argue that CTV -- whose semantics are less powerful/flexible > than CISV/CIOV -- aren't introducing something that's not already > present when doing protocols involving more than one input. >=20 > Further, on CTV "monotonic authorization": >=20 > Generally we want Bitcoin Scripts to have the property that once a > condition is reached, it is 'permanently' a true case. E.g., showing > a hash preimage to C x, H(x) =3D=3D C. This can't change with the weather > or anything else. Even things like timelocks -- although not obvious > at first glance -- have this property. They express logic that says > "given the chain is at this height, ...". This means that on any > chain at such a height the txn is valid. CISV/CIOV semantics also > fall in line with this description. It says, "given such an input U, > ...". If that input is realizable one time, it is provably realizable > across reorgs. However, that doesn't mean someone couldn't interrupt > U from being created. But generally, with Reorg + Double spend, or > Reorg > 100 blocks (potentially destroying CB reward), all bets are > off as to the replay-ability of transactions. >=20 > I want to also point out that this "revocation" property -- to the > extent it is something new that can't already be emulated with > pre-signeds or RBF -- is entirely opt-in as far as CTV is concerned. > You have to specify that an output can only be spent with another, > most wallets shouldn't do that, and it can't "infect" other wallets > to an extent more than spending from any recently confirmed output > exposes you to more reorg risk. >=20 > *In sum, we do not need to worry about this for CTV.* >=20 >=20 > Lastly, I want to note that revocation is part of what CTV is > designed to do (absent reorgs). It allows us to prune spending > conditions by playing a transaction forward. >=20 > E.g., spending conditions {Alice & Bob, Preimage(H(X)) + Eve, > CTV({Alice & Bob}, 1 day)} >=20 > Expresses that Eve has 1 day to reveal the preimage to H(X), otherwise > Alice and Bob can take the coin back by removing Eve's HTLC path. > What's cool about this revocation v.s. just {Alice & Bob, > Preimage(H(X)) + Eve} is that Alice and Bob don't need to coordinate > a multisig to revoke Eve. >=20 >=20 >=20 > -- > @JeremyRubin > >=20 >=20 > On Fri, Feb 14, 2020 at 3:17 AM Dmitry Petukhov > wrote: >=20 > > I decided to take this thread back on-list because I beleive that > > the 'revocation utxo' feature enabled by OP_CTV commiting to > > scriptSig may have wider implications that can slightly change the > > behavior of Bitcoin as a system, and some might not expect such > > changes or might not find them desireable (although there is > > already a case for such behaviour with RBF). > > > > There is a principle that some find valuable: "During reorgs of > > depth less than 100, it is always possible to eventually replay > > transactions from the old branch into the new branch as long as no > > double spends are attempted" (quoted from Russel O'Connor from the > > discussion about 'revocation utxo' on Elements Slack channel). > > > > As far as I can tell, this principle can be violated with the use of > > RBF: "(tx) that was included in branch A and then RBF-ed (tx') in > > branch B and then branch A wins -> children of (tx') can't be > > replayed" > > > > Some may hold an opinion that introducing new rules that violate > > that principle should be done with caution. > > > > The 'revocation utxo' feature enabled by OP_CTV essentially > > introduces a manually triggered 'inverse timelock' - normal > > timelocks make tx invalid until certain point in time, and inverse > > timelock make tx invalid _after_ certain point in time, in this > > case by spending an unrelated UTXO. > > > > In a reorg, one branch can have that UTXO spent before the OP_CTV > > transaction that depends on it is included in the block, and the > > OP_CTV transaction and its children can't be replayed. > > > > This is the same issue as an 'automatic inverse timelock' that could > > be enforced by the structure of the transaction itself, if there was > > appropriate mechanism, with the difference that 'revocation utxo' is > > manually triggered. > > > > The absense of 'automatic inverse timelock' mechanism in Bitcoin > > hints that it was not seen as desireable historically. I was not > > able to find the relevant discussions, though. > > > > I would like to add that the behaviour enabled by inverse timelocks > > could be useable in various schemes with covenants, like the vaults > > with access revocable by spending the 'revocation utxo', or in the > > trustless lending schemes where the covenant scripts can enforce > > different amounts of interest paid to lender based on the point in > > time when the loan is returned - the obsolete script paths (with > > smaller interest paid) can be disabled by inverse timelock. > > > > =D0=92 Fri, 13 Dec 2019 23:37:19 -0800 > > Jeremy wrote: > > =20 > > > That's a cool use case. I've thought previously about an > > > OP_CHECKINPUT, as a separate extension. Will need to think about > > > if your construction introduces a hash cycle (unless > > > SIGHASH_ALL|SIGHASH_ANYONECANPAY is used it seems likely). > > > > > > Also re signatures I think it's definitely possible to pick a > > > (signature, message) pair and generate a pk from it, but in > > > general the Bitcoin message commits to the pk so forging isn't > > > possible. > > > > > > On Fri, Dec 13, 2019, 11:25 PM Dmitry Petukhov > > > wrote: > > > =20 > > > > Another idea for smart vaults: > > > > > > > > The ability to commit to scriptSig of a non-segwit input could > > > > be used for on-chain control of spending authorization > > > > (revoking the spending authorization), where CTV ensures that > > > > certain input is present in the transaction. > > > > > > > > scriptSig of that input can contain a signature that commits to > > > > certain prevout. Unless it is possible to forge an identical > > > > signature (and I don't know how strong are guarantees of that), > > > > such an input can only be valid if that prevout was not spent. > > > > > > > > Thus spending such prevout makes it impossible to spend the > > > > input with CTV that commits to such scriptSig, in effect > > > > revoking an ability to spend this input via CTV path, and > > > > alternate spending paths should be used (like, another taproot > > > > branch) > > > > > > > > > > > > =D0=92 Fri, 13 Dec 2019 15:06:59 -0800 > > > > Jeremy via bitcoin-dev > > > > =D0=BF=D0=B8=D1=88=D0=B5=D1=82: =20 > > > > > I've prepared a draft of the changes noted above (some small > > > > > additional modifications on the StandardTemplateHash > > > > > described in the BIP), but have not yet updated the main > > > > > branches for the BIP to leave time for any further feedback. > > > > > > > > > > See below: > > > > > > > > > > BIP: > > > > > https://github.com/JeremyRubin/bips/blob/ctv-v2/bip-ctv.mediawiki > > > > > Implementation: > > > > > https://github.com/JeremyRubin/bitcoin/tree/checktemplateverify-v2 > > > > > > > > > > Thank you for your feedback, > > > > > > > > > > Jeremy > > > > > -- > > > > > @JeremyRubin > > > > > =20 > > > > > > > > =20 > > > > =20