From 47fed6d9f01d45a8dd2cf222d588967a15ae9d99 Mon Sep 17 00:00:00 2001 From: furszy Date: Mon, 16 Dec 2024 17:01:43 -0500 Subject: [PATCH] Raw() as subscript for descriptors --- bip-0391.mediawiki | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 bip-0391.mediawiki diff --git a/bip-0391.mediawiki b/bip-0391.mediawiki new file mode 100644 index 0000000000..f760cfeaff --- /dev/null +++ b/bip-0391.mediawiki @@ -0,0 +1,76 @@ +
+  BIP: ???
+  Layer: Applications
+  Title: raw() as subscript in Output Script Descriptors
+  Author: Matias Furszyfer mfurszy@protonmail.com
+  Comments-Summary: No comments yet.
+  Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-???
+  Status: Draft
+  Type: Informational
+  Created: 2024-12-16
+  License: BSD-2-Clause
+
+ +==Abstract== + +This document specifies raw() as subscript for output script descriptors. +raw() encapsulates a raw hex script. This BIP allows raw() to be used in +the context of other descriptors. + +==Copyright== + +This BIP is licensed under the BSD 2-clause license. + +==Motivation== + +To ensure no information is lost during conversion to descriptors, it’s useful to wrap +arbitrary hex data in a sh(), wsh(), or even within the TREE argument of a tr(KEY, TREE) +descriptor. + +The absence of this feature creates a challenge in representing non-standard redeem and +witness scripts within the descriptor language. Currently, they can only be represented +as top-level raw(HEX) descriptors, which retain only the output script information and +lack the ability to preserve the actual script. + +Additionally, as noted [https://github.com/bitcoin/bitcoin/issues/24114#issuecomment-1127978154 here], +there are other useful scenarios for this feature. For example, it allows representing +in a descriptor that we lack full knowledge of all solvability paths but can still solve +the output, such as a taproot tree where we know only one of its paths, or even also +participating in signing a script without knowing all participants' keys, relying solely +on the script structure. + +==Specification== + +Allow raw(HEX) to be accepted within the context of sh(), wsh() and tr() descriptors. +The output script produced by this descriptor must represent the arbitrary data within +the provided context. For example, a P2SH output script (OP_HASH160 OP_EQUAL) +must be created from the provided hex data when a sh(raw(HEX)) descriptor is provided. + +==Test Vectors== + +Valid descriptors followed by the scripts they produce. + +* sh(raw(5387)) +** a9149e02f205612b4d7fe9466a789764b0eafe7eb07287 +* sh(wsh(raw(5387))) +** a9140d1a6a9fd7e20b6e4091e2c10284fb1130afd46787 +* wsh(raw(5387)) +** 00205c5fc1afc3d712a8e8602cee8590234ab2213be58943fca65436439f08017a64 +* tr(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd,raw(5387)) +** 51206f108fa13b6f1cdd89d8de731712e2357e3b833f1959c0a93c26127c3a6264bb +* tr(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd,{pk(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5),raw(%s)}) +** 51206f4954bd11741938d74e744be6b6fa87076660696ddfa3c41c1f834906e17c8e + +Invalid descriptors + +* Non-hex script: sh(raw(asdf)) +* raw in the key path tr: tr(raw(5387), pk(key)) + +==Backwards Compatibility== + +raw() as a subscript descriptors use the format and general operation specified in [[bip-0380.mediawiki|380]]. +As this is a wholly new descriptor, it is not compatible with any implementation. + +==Reference Implementation== + +# TODO: add Bitcoin-Core PR..