From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Fri, 27 Dec 2024 05:52:17 -0800 Received: from mail-ot1-f61.google.com ([209.85.210.61]) by mail.fairlystable.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tRAlE-0003oj-Le for bitcoindev@gnusha.org; Fri, 27 Dec 2024 05:52:17 -0800 Received: by mail-ot1-f61.google.com with SMTP id 46e09a7af769-71e4219cf37sf2307569a34.1 for ; Fri, 27 Dec 2024 05:52:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1735307530; cv=pass; d=google.com; s=arc-20240605; b=ecpI9DEp+zict3JsOWERIszxf/RnqaSV3K04/XLiz50Z6B2XMvI6SkDNSEk0yJcxeJ gyFrPPwL2aVVfFImMIUKjMC2M8sgYbD5Lz/2x9pF3qEW3edS9TpE8g1MDig+ccUXWqFE PlPW+w1wpFMDOpY1W1PycGcY4F/EJv3FohIGccBHVV2J+59RISKEcxBkzBUJKkScp5jK SgKx2BA/fwNA517qGMgpuFiW/rM6+L/7nDzfetSLkg8TNuZnx9cAtwwZbcOR3YCc/yRg LPwsc4lmL2eOQGSkNvBkUctqK1dTXl/27Ms4qvVOkc8YoT8IeiVZAboYQow3+9mEQvi+ fuoA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:mime-version:feedback-id :message-id:subject:from:to:date:dkim-signature; bh=DsTcEoAB45yxXmO6Lz/t4i3M8MP3IhHMGFtEnsSNFAs=; fh=Qc7V475NSoZlK5annaH9kNv2z4Nt+spqdNaUfyg9CvQ=; b=dVUp8YRTvB69Q6c+OZJNB2PwBRD6eroioKZJM0J9cGmBMwmZAl+Dw70WoHTccfhk9L 3r6bhW5BZ6E6wXzf7Fxa1wMkJNsurm+wtQXLfanTjt4y9TT2wgHP5iIbPtNqSPqmwER+ guosDngQaXF15irPkevMXporAGd+bIUiNjjSabGOJ0n9A4C5LhJcqXw0BESgrJtKunhK 1niJfioOo3F5Cqr+u/Jd4qfUy8zXonasNvnqSdRnDH3SIDJqHL97xKrOauPGXkwwZMPr GG9RFwlIfyhOtpzhapN/nwA2LJnUTLGToWEgou7kBQ1ynoniu7ZmSnwp4kfTrkwaLG0B 7Sug==; darn=gnusha.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=oUi0q5X2; spf=pass (google.com: domain of moonsettler@protonmail.com designates 79.135.106.103 as permitted sender) smtp.mailfrom=moonsettler@protonmail.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1735307530; x=1735912330; darn=gnusha.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:mime-version :feedback-id:message-id:subject:from:to:date:from:to:cc:subject:date :message-id:reply-to; bh=DsTcEoAB45yxXmO6Lz/t4i3M8MP3IhHMGFtEnsSNFAs=; b=ddbNyYAaE1pkPlxPc3DSamwfkEY/yFue37iJkk809+ZLQ2YDa5cW3d27a1EkK7+vx5 FR4n6L3clZmh97sIF35RqLlcSN5p/QE5h6jreXu81nz1fUGiWJk7d2iXmH05lh88xAgA bvvBgqLROklh3xe4CuB/GdYbLj1UJX/D479w7ZMZtnkJJyRRksvR03Pg9QKJXP9Pyto/ A3eBW+xGNsPhkdo/Z/9EOKjHkhRWbHhraHnixK3obgGdzG7x5BkcIIL+KvrCM+tRujpY HDtbcb2XhHYqA6fDIlGR7eq+9U03dW2C2sgFxj+Yxn3kWipb+uFwz2rJhF/Lo4yUZqEb vBzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735307530; x=1735912330; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:mime-version :feedback-id:message-id:subject:from:to:date:x-beenthere :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DsTcEoAB45yxXmO6Lz/t4i3M8MP3IhHMGFtEnsSNFAs=; b=lgKtlBYOcQh3YZdgOzM/1XhBmuc9fs+kjEE5cXBiYX3Ptv/XXXIFLWnQSkDK8Ds9tQ pohgE7HDsVJgVBBYgTSj1HKpo18Qipx8KedqULxvBE8kklz9AMnsD2UMjKJAVuNto1fw ZgeJRj/ycTBJtkVLn3iL1HokfYdGWhq1Gs4vtnBAHPboekVmkbzGyKnD8aCID1pSk4NV 09Ur93L9XHMKgShrkTGMEj6psED04FVISXt2s87Q+bWCTWmxt9y5nWcdo/VOuWcv9C/I sREUwxb2o54aVLM7tYqcc0hhxJUuH8Hc976WMBZSUeotlLg7Uw7blxi2SS9IufqCc2Mv lTsQ== X-Forwarded-Encrypted: i=2; AJvYcCWt6dIUpyOwvY0OFkKDzDbbFYupbDn0Tv7Qdno+yTvTN8F/usaXIwR2kPr+rj1Dx4503DQu7m+b7U44@gnusha.org X-Gm-Message-State: AOJu0YxKkcI5PUtUG1MVqLd8IfXppONixyFxo4KsFIA27Nlyx5ImDEQh w0bUhoU1qXs+nb9AvoizTe8tvP6kFFuK/5FQdIPxgbq7BiXvw4KV X-Google-Smtp-Source: AGHT+IHOA2UC11WMKMTPh8XMl0yOPGPnQroZLDLH+QEXesiWtmUOTsYqh3ZTBIcF56dw4wk7qq1iVg== X-Received: by 2002:a05:6830:2b06:b0:71d:5336:df80 with SMTP id 46e09a7af769-720ff8b03e9mr17280447a34.20.1735307529898; Fri, 27 Dec 2024 05:52:09 -0800 (PST) X-BeenThere: bitcoindev@googlegroups.com Received: by 2002:a4a:de9a:0:b0:5f4:c50e:519a with SMTP id 006d021491bc7-5f4d81a0ae4ls1812634eaf.2.-pod-prod-06-us; Fri, 27 Dec 2024 05:52:07 -0800 (PST) X-Received: by 2002:a05:6808:f16:b0:3eb:3d21:9d02 with SMTP id 5614622812f47-3ed890a9591mr13669548b6e.32.1735307527445; Fri, 27 Dec 2024 05:52:07 -0800 (PST) Received: by 2002:a05:6808:46:b0:3ea:54d0:9259 with SMTP id 5614622812f47-3ecfde47b44msb6e; Wed, 25 Dec 2024 12:57:29 -0800 (PST) X-Received: by 2002:a05:6a20:4308:b0:1e0:c8d9:3382 with SMTP id adf61e73a8af0-1e5e0847084mr34195196637.45.1735160248834; Wed, 25 Dec 2024 12:57:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735160248; cv=none; d=google.com; s=arc-20240605; b=QTA3QORv2mek2eXxQ48IOaRsi+xidA/eogPeJG8wMwuhP4ziUpaQhZDPAKyOZEpCqH O5WGjBpGBTL60GInUmblbDRMzJJa+nC1I29ADhdFKkdGdNpoaSQGhNgjNo8d123q7sKf RKYUwmFgbvyIOV7UgVezOkl5gHcnJ88AUFbUMRczvct/9dp7lfWdt9vysm/HKnYdToZO kZHN4ufB7MyUheDyuuGm4kKJGaAr9+snlbIZE0BNNNCToTsW7D/WvzhrD5LTvJesKvBC DtRWb3knFsnyR5ygBxNO5PQWCwroFSKvGRVTELVRSVEpwAdUtk0yEjv98gvmny2n6kyB hwnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:mime-version:feedback-id:message-id :subject:from:to:date:dkim-signature; bh=Txx4HT32K09BFyFYbQ7GT3dhgWrrjLiQyva6Nsdzynk=; fh=DMP0F9ULS1guKiqimntQRCN8ZraraesEgQuVcn7F0Z0=; b=AEiMXpEW967O7fXd2blFp7jPWyh2It6u2JbgrjJ+kbGJ02zcqB4XYwJB9zSr59vhVl q6jDomRTMXWsmr/upNbox5fXR848snvGHKvW7+4fbBMnq3Ok1FLMtRZ536SAIkG7b+wc NuNfdLSLhDPZQOOvIVu3FgPyI+f/tGl8m6QT3TCKTxTU5JU5u5De2Khg+QmxLuyWjH3I sDcHqGTaQoambB0M4eKZ+SHE+QtjFKeB8+yQ8zPauuq+p4B3RVNufdV/71U4szAYcYBW vtqPlBtsPnhgsWg3Fl8OgJExhXtusVpMF8YHBz0bD7CMSQQ3AYf6hPOpMtRf70zuygh8 XYJw==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=oUi0q5X2; spf=pass (google.com: domain of moonsettler@protonmail.com designates 79.135.106.103 as permitted sender) smtp.mailfrom=moonsettler@protonmail.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: from mail-106103.protonmail.ch (mail-106103.protonmail.ch. [79.135.106.103]) by gmr-mx.google.com with ESMTPS id d2e1a72fcca58-72aad836c3bsi573685b3a.2.2024.12.25.12.57.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Dec 2024 12:57:28 -0800 (PST) Received-SPF: pass (google.com: domain of moonsettler@protonmail.com designates 79.135.106.103 as permitted sender) client-ip=79.135.106.103; Date: Wed, 25 Dec 2024 20:57:21 +0000 To: Bitcoin Development Mailing List From: "'moonsettler' via Bitcoin Development Mailing List" Subject: [bitcoindev] CTV++ OP_TEMPLATEHASH & OP_INPUTAMOUNTS Message-ID: Feedback-ID: 38540639:user:proton X-Pm-Message-ID: 3d85a6c0e4131bbabea10be71a9cf149424cb52e MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Original-Sender: moonsettler@protonmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=oUi0q5X2; spf=pass (google.com: domain of moonsettler@protonmail.com designates 79.135.106.103 as permitted sender) smtp.mailfrom=moonsettler@protonmail.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com X-Original-From: moonsettler Reply-To: moonsettler Precedence: list Mailing-list: list bitcoindev@googlegroups.com; contact bitcoindev+owners@googlegroups.com List-ID: X-Google-Group-Id: 786775582512 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , X-Spam-Score: -1.0 (-) Hi List, There have been complaints voiced about being too paiful to work with CTV. Especially when it comes to Vaults. OP_TX and OP_TXHASH/VERIFY are examples how developers sought to overcome certain pain points. However they expand the scope considerably and also rely on 64 bit integer arithmetic to handle amounts. Here we aim to show and alternative approach that covers a lot of useful ground in the in-between without state-carrying covenants or general detailed introspection. https://gist.github.com/moonsettler/d2369e043473c42ff7fa52878dd064a5 ## CTV++ Two additional opcodes to consider as an addition to `OP_CHECKTEMPLATEVERIFY`: * OP_TEMPLATEHASH * OP_INPUTAMOUNTS Together they relax the strict limitations that `OP_CHECKTEMPLATEVERIFY` imposes, because it explicitly commits to the output amounts and therefore implicitly commits to the spendable input amounts in a lot of cases. ### OP_TEMPLATEHASH Builds the CTV template hash from the stack. ``` # FOR i = inputCount-1; i >= 0; i--; LOOP # END LOOP # FOR j = outputCount-1; j >= 0; j--; LOOP # END LOOP OP_TEMPLATEHASH OP_CHECKTEMPLATEVERIFY ``` ### OP_INPUTAMOUNTS Taproot only. Consumes a 32 bit signed integer `n` as parameter * `n = 0` return the SUM of all input amounts with same script * `n < 0` return the SUM of last abs(n) input amounts including current input * `n > 0` return the SUM of first n input amounts of the transaction fails if * `n < 0` and `abs(n) > inputIndex + 1` * `n > inputCount` ``` OP_INPUTAMOUNTS ``` #### Example use: This contract below allows the comining of UTXOs locked by the same script for something like a withdrawal from a Vault contract to a staging address where the relative time lock can begin. It works with any amount UTXOs unlike basic CTV Vaults. Also allows for paying fees endogenously and registering a change address. The fee paying input would sign with SIGHASH_ALL. ``` ### Witness stack BEGIN ### # FOR i = inputCount-1; i >= 0; i--; LOOP # END LOOP # out[1].amount # out[1].script ### Witness stack END ### <0> # sum of all inputs with same script OP_INPUTAMOUNTS # out[0].amount # out[0].script 33 bytes for P2TR <2> # outputCount <2> # nVersion OP_TEMPLATEHASH OP_CHECKTEMPLATEVERIFY ``` ### Credits: * Jeremy Rubin who have already came up with everything many years ago * James O'Beirne for his awesome work on OP_VAULT * Salvatore Ingala for his work on CCV/MATT and to generalize state carrying covenants * Many others who have explored the covenant design space and CTV in particular BR, moonsettler -- You received this message because you are subscribed to the Google Groups "Bitcoin Development Mailing List" group. To unsubscribe from this group and stop receiving emails from it, send an email to bitcoindev+unsubscribe@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/bitcoindev/rqgc7ysr5Px28EKRJu2nmE9cAsm47jPWKnEUAiY-9cw69B6bOUsPT1302MrX6r_6nlXZgayr1WKlBEe3x1UsgYnCX_1EJbAdiQDh95FVQBA%3D%40protonmail.com.