summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Habovštiak <martin.habovstiak@gmail.com>2025-04-01 17:35:53 +0200
committerbitcoindev <bitcoindev@googlegroups.com>2025-04-01 15:38:38 -0700
commit8ac86c6b9b65e009b7442f97368db59b8ac6f20b (patch)
tree74b6ae27fe56cd68db6130ba59bc81f92f2e5487
parent9d37e85d1b395e29f152d1ea8056a95799065787 (diff)
downloadpi-bitcoindev-master.tar.gz
pi-bitcoindev-master.zip
Re: [bitcoindev] New Proposal:String Substring Search in Bitcoin Script - OP_ISSUBSTRHEADmaster
-rw-r--r--91/1e4d9153589d98366e09239cd6bb4744605535339
1 files changed, 339 insertions, 0 deletions
diff --git a/91/1e4d9153589d98366e09239cd6bb4744605535 b/91/1e4d9153589d98366e09239cd6bb4744605535
new file mode 100644
index 000000000..b458f004c
--- /dev/null
+++ b/91/1e4d9153589d98366e09239cd6bb4744605535
@@ -0,0 +1,339 @@
+Delivery-date: Tue, 01 Apr 2025 15:38:38 -0700
+Received: from mail-oo1-f55.google.com ([209.85.161.55])
+ by mail.fairlystable.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
+ (Exim 4.94.2)
+ (envelope-from <bitcoindev+bncBDZPZFXW2IMRBY6VWG7QMGQEQ7HKREI@googlegroups.com>)
+ id 1tzkFh-0000nH-5D
+ for bitcoindev@gnusha.org; Tue, 01 Apr 2025 15:38:38 -0700
+Received: by mail-oo1-f55.google.com with SMTP id 006d021491bc7-603fd09171bsf321327eaf.1
+ for <bitcoindev@gnusha.org>; Tue, 01 Apr 2025 15:38:37 -0700 (PDT)
+ARC-Seal: i=2; a=rsa-sha256; t=1743547111; cv=pass;
+ d=google.com; s=arc-20240605;
+ b=ifLSYKyV+ZmQl/VTBFaFhkktYXDcL/VcMTQ8Thm5+MHAxx3tmk1lMZpDY+Tu6/cTgm
+ TDL3frG7NYzDgM9/tl5kolxwKsA0UArv7QHVR0sVlFC4Rl/u5/VvXc3e5VYNANH8k1s+
+ PzoaB+OV9dJ/Tm7l7sNMQzAjl8od10n2A9XqYXChfT+8ALrdKap1fFwFUGDvFgWHwiJM
+ mEJHp1Jk+/owYbRF71YY0wCFQbqBuEDucHk/Bh6nQ+2W9qXcqG6VqF8L3nLH8fHLedIx
+ Cuij8TVHQQQskLDE1kDw6PiQyy7j16NC+MGmPQcZOD+XDovc0yasUrK8aneb+8yhMtrf
+ uQpA==
+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:cc:to:subject:message-id:date:from
+ :in-reply-to:references:mime-version:sender:dkim-signature
+ :dkim-signature;
+ bh=PFjfduBnjzsQkzi2DI5PY5AK3iMzVsUFQwg9ojp2GPA=;
+ fh=WmXfssJedKHy9Vzrl/7g1B6T6W4WapF59YdUBaRh61k=;
+ b=OH/yCEprhVOCD3SNFTWlYahUWbjJnAwqiTXEyz/QCBLl0xlfyQ4ByQJw83YJooSN7r
+ oxNOClVaOeFy8bNAnOXd388CS/y945RN7BAnbmw4ppuqGyP4Nmes7kyBW94jl8U+lcyM
+ +OzWoKIqB/4VmfQ6WJ+IvgA6aRAeC85ziJpC5P/iXUtH8tO3vtUjsUngBiXGaG7vBPoB
+ nig3EHyvuVwawZLPLG84WA9kf4nePjWMTYAJRorkV9SZTeUbS4FKG/Y5RZnP0jfr+QMd
+ GBB27ea3LMOJMJpvP/u5RXXOw7DrTcOV2Xx/psZgFsMYL8CRYJO/aUg9zjTULfPeobSu
+ hNhQ==;
+ darn=gnusha.org
+ARC-Authentication-Results: i=2; gmr-mx.google.com;
+ dkim=pass header.i=@gmail.com header.s=20230601 header.b="fl5PD/ud";
+ spf=pass (google.com: domain of martin.habovstiak@gmail.com designates 2607:f8b0:4864:20::736 as permitted sender) smtp.mailfrom=martin.habovstiak@gmail.com;
+ dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com;
+ dara=pass header.i=@googlegroups.com
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
+ d=googlegroups.com; s=20230601; t=1743547111; x=1744151911; darn=gnusha.org;
+ h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
+ :list-id:mailing-list:precedence:x-original-authentication-results
+ :x-original-sender:cc:to:subject:message-id:date:from:in-reply-to
+ :references:mime-version:sender:from:to:cc:subject:date:message-id
+ :reply-to;
+ bh=PFjfduBnjzsQkzi2DI5PY5AK3iMzVsUFQwg9ojp2GPA=;
+ b=f74r+UbNfw/kaXInHHKkM70b7mIEsBNbf0iIXRqM/RzrLgivstGCgbEIsgvIL33M2d
+ 9m3Hb0jiKwTDCQzAHzRloKtdxMvLBgKN8TRERq0NcMmX7abOxxmvTL6komNiXgkFCoGN
+ 6vVDU92MQNbiX81niYaj9I+AIl1U2XF2VXpNyPmxjAurxHH4qqa4GpYOC1hqVeMUCjzd
+ td9p2I1I1R8rTz77dFdFmqU222SMEcsdaVExFexre8JS8EO4FBjZ1UpxOlvwUtB1kf7K
+ CekZo0CxrYJawB8AulOv/OD4wOJaNsXuC3mvee8DCZWxqXDGXjYx+eaJ9zFolaSYTEmg
+ KIGg==
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
+ d=gmail.com; s=20230601; t=1743547111; x=1744151911; darn=gnusha.org;
+ h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
+ :list-id:mailing-list:precedence:x-original-authentication-results
+ :x-original-sender:cc:to:subject:message-id:date:from:in-reply-to
+ :references:mime-version:from:to:cc:subject:date:message-id:reply-to;
+ bh=PFjfduBnjzsQkzi2DI5PY5AK3iMzVsUFQwg9ojp2GPA=;
+ b=h69kNIBP914h3Q/a4rs3KzbNiHGDCG4ryS5FOWVXRijBEjuAtug0H/ic1z+Jy72h2n
+ 4nMZsiAIlq6DFVqa4ABQU3tIjkxrvjEquapbvRWZYT08rnzrcxeQx0SBwCDhdXqBIxhE
+ 4qkYcz5Ji/GqpECfTk+8oBv22OdeeKTb17Vo1IGWAYkgcUPaEdq3ZTcjQKoGPqGVdnp7
+ qlTpfy50UEJ3TgaoRfOFjgbs9ZrN//ORTDIgYulOMiHP0HQ9QfJ9V3yJIJI33NS/PVRF
+ hnx2Me6iZBBTNYSDGDkPZ9Vp1UPQPuyfI165Dypug3/msoe3WKQPG7aQRFNBZTzmm/iP
+ c3dA==
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
+ d=1e100.net; s=20230601; t=1743547111; x=1744151911;
+ h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
+ :list-id:mailing-list:precedence:x-original-authentication-results
+ :x-original-sender:cc:to:subject:message-id:date:from:in-reply-to
+ :references:mime-version:x-beenthere:x-gm-message-state:sender:from
+ :to:cc:subject:date:message-id:reply-to;
+ bh=PFjfduBnjzsQkzi2DI5PY5AK3iMzVsUFQwg9ojp2GPA=;
+ b=oErK5kz6rCA26hRaYdH9/bSnEqPPlTDNAjd8X8b2pnOt3uYkvYjh7r/jT+aAr0pwjP
+ CYPk6O1DSdRL1ecz5/JqFqQWo7Giyj91Yu0UVNPXJtcGTVBMk6XtoBtZYmwAd6nr49dM
+ dXxvcUqJQp8W4iqVi4JlsimiyerJuAlLnoYTs8yJE5kA6Zh7BsKxRdAFY07N9oFpHrku
+ 5nZTSpnT9rIOv8X25wkE4fSWCvjHuLHrdU2GXOIOhQWcK6ZchlZtT9APqhWX4iz8PiQA
+ VqjqvmuFZzqq3dobS1mwrhzg2FfRYCUJQYdFgkib2XnTiA2lXAWWcZIaJ/pC78nA+IFA
+ lFvw==
+Sender: bitcoindev@googlegroups.com
+X-Forwarded-Encrypted: i=2; AJvYcCWqrTP+XKcBgWnuAJH5Zw2azyLXk/QZOZOF1XrBhUjAHnMq0UmgkpolSnqT+lt4rkCXfytJNyoJxEJL@gnusha.org
+X-Gm-Message-State: AOJu0YyZekHJirUbadFCHYMHHacNgDtybI9hsNunsWZUQvyvTXqeQ2F2
+ 9dU4kOuWFi4haOBVIK+VDMo7nM6YDA9IHxajSdWOJ0CUJuq7VrS6
+X-Google-Smtp-Source: AGHT+IHYNI0EWh0lIAoM8JXTvRLg30APZrwgr8eDQT2Umej4wgik6dAGeUkssN39h8tk1451iORgyA==
+X-Received: by 2002:a05:6820:2107:b0:603:f777:9801 with SMTP id 006d021491bc7-603f7779c95mr2088125eaf.3.1743547111003;
+ Tue, 01 Apr 2025 15:38:31 -0700 (PDT)
+X-BeenThere: bitcoindev@googlegroups.com; h=ARLLPALZ66IIHkeinGsjmtfFzN9sYIB1V1+5ulGR8BYyeJrZ9A==
+Received: by 2002:a4a:a641:0:b0:603:be8f:a31e with SMTP id 006d021491bc7-603be8fa5c8ls667467eaf.1.-pod-prod-08-us;
+ Tue, 01 Apr 2025 15:38:27 -0700 (PDT)
+X-Forwarded-Encrypted: i=2; AJvYcCUKl9pHxZZYLZmu8hCKaayyYPITelChzTXj/IT4vUpA86/P2ARJXO6a+Az4BFnmUXxvmPWQRRS0J0ar@googlegroups.com
+X-Received: by 2002:a05:6808:2019:b0:3fe:ab15:5e93 with SMTP id 5614622812f47-3ff0f524c93mr9182358b6e.11.1743547107585;
+ Tue, 01 Apr 2025 15:38:27 -0700 (PDT)
+Received: by 2002:a05:6808:985:b0:3fa:6f09:b173 with SMTP id 5614622812f47-3feefbac77emsb6e;
+ Tue, 1 Apr 2025 08:36:05 -0700 (PDT)
+X-Forwarded-Encrypted: i=2; AJvYcCXjxoCibe7zW6VnL+ja4KgqTpbKCw7G82en5Ygdx8E5kwIoBoLaRiIxza+sidqGt52GML5u8AowSfh9@googlegroups.com
+X-Received: by 2002:a17:90b:2e07:b0:2ee:53b3:3f1c with SMTP id 98e67ed59e1d1-30531f7c07cmr19794566a91.5.1743521764783;
+ Tue, 01 Apr 2025 08:36:04 -0700 (PDT)
+ARC-Seal: i=1; a=rsa-sha256; t=1743521764; cv=none;
+ d=google.com; s=arc-20240605;
+ b=NITLkxzZva/ZZNMPhpL7chQEXMhHFxc5gZJB2yS2KAFrq+5ALcsyO0CZs+5W3p+nb1
+ EnT0p8zV/Wwg6C8BEhcQa/9aQ3uZjQ4EM3xY10LnKqkd/ZcHVKyh3m46xL77Ty5fzrFy
+ qMn6j/aQhK07E2nRfyxnsb9vyOC4akia/x/On4SPssEodjeN04uJ3g0d/6GRfbxUNS4A
+ nJ6JnIQLz3M6ticGF/zlWqrP9MJrtLF4HHQypD9AQccK33snIZaje0daSW52JowFuHyS
+ rcQsF9vb0jxWiONr95V5Wt2YD3v4npiQJimEoCGN83maoGb0CMm+3lQEk76H5QEY/sXo
+ Z60w==
+ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605;
+ h=cc:to:subject:message-id:date:from:in-reply-to:references
+ :mime-version:dkim-signature;
+ bh=r2K2TgMkVJjTLkR4tG9GmvR/WYaTX9V++QzBCL7n0PM=;
+ fh=UslS9DHPkWd0noc2pTWy5Ft6VFWJ5hH0DY6AiDFuLK8=;
+ b=gQAflzQw50Gv1svmOUE3AAt6oWuXRwbcsmGYXQb/BEhKFHsZ+nkN8CdutqOvY7rwzg
+ Qkr3QUR7ec59oPkV65WCXXleNWIbhec1RGvzYDAgTVYy5k44qWg3cKP7oYbsynJoZbHT
+ eDLCzZydry0koPOc9tHSBt2Vh6/pB2Oe6YMXiiwfHoIw0jOHoVbfATHtv+H9OoLONUPC
+ 1YprVF/dJzEIz7RSFUi05UsGlrrBQfojD6k0rQPWDfouE4AKFN0QlNGWO9r72YjAakBo
+ k3nuXznLRe4rg9OBz3Y3gOa1YdHN9ZMUf7P0/s8XjI1LJJK5pJZlRY9jvFuaqMKu8IUV
+ bF9Q==;
+ dara=google.com
+ARC-Authentication-Results: i=1; gmr-mx.google.com;
+ dkim=pass header.i=@gmail.com header.s=20230601 header.b="fl5PD/ud";
+ spf=pass (google.com: domain of martin.habovstiak@gmail.com designates 2607:f8b0:4864:20::736 as permitted sender) smtp.mailfrom=martin.habovstiak@gmail.com;
+ dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com;
+ dara=pass header.i=@googlegroups.com
+Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com. [2607:f8b0:4864:20::736])
+ by gmr-mx.google.com with ESMTPS id d9443c01a7336-2291eed881fsi5283895ad.1.2025.04.01.08.36.04
+ for <bitcoindev@googlegroups.com>
+ (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
+ Tue, 01 Apr 2025 08:36:04 -0700 (PDT)
+Received-SPF: pass (google.com: domain of martin.habovstiak@gmail.com designates 2607:f8b0:4864:20::736 as permitted sender) client-ip=2607:f8b0:4864:20::736;
+Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-7c559b3eb0bso328406785a.1
+ for <bitcoindev@googlegroups.com>; Tue, 01 Apr 2025 08:36:04 -0700 (PDT)
+X-Forwarded-Encrypted: i=1; AJvYcCX+QOTXsEHXmJerV8H+y4MBW28nlYkf1GjsBKNx3+ld0sRQX5g/vNnGWELurtxNY+6XIwHqOnykQZ7+@googlegroups.com
+X-Gm-Gg: ASbGncsWq/6CPiIRIdS0+BrKDal09fQIiShz+NaHw0YUSZ+d+Nz+MQlwxUYaD3HWz2B
+ pPIeeeuA9qlbUWOBih0smV4K+jGlwRQMJB6FwyxOVovh8IovT/wY0ghrWcKsxAteQB2Xs1QNMjA
+ Tao1vyR0SWUY1zd+vddJ3t9PMhiQ==
+X-Received: by 2002:a05:620a:4544:b0:7c0:9f12:2b7e with SMTP id
+ af79cd13be357-7c6862ebcdemr1758761285a.11.1743521764058; Tue, 01 Apr 2025
+ 08:36:04 -0700 (PDT)
+MIME-Version: 1.0
+References: <f844a85e-8be8-4429-8687-bc19dd4b96ffn@googlegroups.com>
+ <Z9hTu2TjMlLr5-Eg@petertodd.org> <678d40e3-3e22-4d55-82c0-b25ccafb87ecn@googlegroups.com>
+ <CAD2YOAp=ft+pApAwh6CQvwMpujfZ0ysSK+=7zKA64nBeB5w3nA@mail.gmail.com>
+ <8c823e50-197e-479c-8651-9e0407a4168en@googlegroups.com> <b4594133-e6e5-438b-aa56-98d6171296fan@googlegroups.com>
+ <e8c30db7-b509-4fbd-93ef-0bca0313003cn@googlegroups.com> <frERrHlzWhpskJw74fBQorSrXEaBP1d4XBUgM-Nkww_2ulhc7i2Lqmu2kcAlvh5fd7LzYiBmX5HNBtg7Ownbsa0KZ26ihfJjri6R01kuozA=@wuille.net>
+In-Reply-To: <frERrHlzWhpskJw74fBQorSrXEaBP1d4XBUgM-Nkww_2ulhc7i2Lqmu2kcAlvh5fd7LzYiBmX5HNBtg7Ownbsa0KZ26ihfJjri6R01kuozA=@wuille.net>
+From: =?UTF-8?Q?Martin_Habov=C5=A1tiak?= <martin.habovstiak@gmail.com>
+Date: Tue, 1 Apr 2025 17:35:53 +0200
+X-Gm-Features: AQ5f1Jonb64K8xwBCp_kuJq8yZNRre_fWTfTsBymB-tWsSBmqhpWzVEB--Uz7xU
+Message-ID: <CALkkCJb1RdC646q1QrOP+yQut7EG4NLJNm3cyxW4S1=Ex1NBmQ@mail.gmail.com>
+Subject: =?UTF-8?Q?Re=3A_=5Bbitcoindev=5D_New_Proposal=EF=BC=9AString_Substring_Sea?=
+ =?UTF-8?Q?rch_in_Bitcoin_Script_=2D_OP=5FISSUBSTR?=
+To: Pieter Wuille <bitcoin-dev@wuille.net>
+Cc: Javier Mateos <javierpmateos@gmail.com>,
+ Bitcoin Development Mailing List <bitcoindev@googlegroups.com>
+Content-Type: multipart/alternative; boundary="00000000000067ab4a0631b94b28"
+X-Original-Sender: martin.habovstiak@gmail.com
+X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass
+ header.i=@gmail.com header.s=20230601 header.b="fl5PD/ud"; spf=pass
+ (google.com: domain of martin.habovstiak@gmail.com designates
+ 2607:f8b0:4864:20::736 as permitted sender) smtp.mailfrom=martin.habovstiak@gmail.com;
+ dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com;
+ dara=pass header.i=@googlegroups.com
+Precedence: list
+Mailing-list: list bitcoindev@googlegroups.com; contact bitcoindev+owners@googlegroups.com
+List-ID: <bitcoindev.googlegroups.com>
+X-Google-Group-Id: 786775582512
+List-Post: <https://groups.google.com/group/bitcoindev/post>, <mailto:bitcoindev@googlegroups.com>
+List-Help: <https://groups.google.com/support/>, <mailto:bitcoindev+help@googlegroups.com>
+List-Archive: <https://groups.google.com/group/bitcoindev
+List-Subscribe: <https://groups.google.com/group/bitcoindev/subscribe>, <mailto:bitcoindev+subscribe@googlegroups.com>
+List-Unsubscribe: <mailto:googlegroups-manage+786775582512+unsubscribe@googlegroups.com>,
+ <https://groups.google.com/group/bitcoindev/subscribe>
+X-Spam-Score: -0.5 (/)
+
+--00000000000067ab4a0631b94b28
+Content-Type: text/plain; charset="UTF-8"
+Content-Transfer-Encoding: quoted-printable
+
+Hi,
+
+I was dismissing the proposal for the same reason you do but it just
+occurred to me that substrings might be better than OP_CAT because it's
+possible to make them unabusable without any arbitrary limit on item size.
+
+The idea is to store stack elements on the heap inside struct { ref_count,
+length, data[] } and put struct { pointer_to_item, position, length } on
+the stack. (Rust developers may be familiar with the `bytes` crate that
+does this.)
+Substring operations would only duplicate the pointers with adjusted
+position and length so there's no way to blow up the stack using them.
+
+Of course there's an exception if OP_SHA256 is used on a shorter slice but
+the same is true today - you can already write OP_ZERO OP_SHA256 OP_DUP
+OP_DUP...
+
+Funnily, this can be used to optimize OP_DUP as well which would now add
+constant amount of memory, so the "exploit" above would need to use two
+bytes per every large object.
+
+Anyway, while I would personally prefer not having arbitrary limits on item
+sizes, since the limit is already there, it might not matter. I guess
+something worth considering if any other future soft fork somehow enables
+larger items.
+
+Have a nice day!
+
+Martin
+
+
+D=C5=88a ut 1. 4. 2025, 16:49 Pieter Wuille <bitcoin-dev@wuille.net> nap=C3=
+=ADsal(a):
+
+> On Monday, March 31st, 2025 at 4:41 PM, Javier Mateos <
+> javierpmateos@gmail.com> wrote:
+>
+> The solution of splitting the string and using OP_CAT only works if the
+> exact position of the substring is known. How would a case be handled whe=
+re
+> the substring could be in any position
+>
+>
+> Whoever produces the signature/witness for spending the coin always knows
+> the position already, so the script can always be modified to instead tak=
+e
+> that position as an additional input.
+>
+> This is a general principle: the point of scripts is verifying provided
+> information, not computing it. As another example, this means that there =
+is
+> no need for a division or square root opcode if one has a multiplication
+> opcode.
+>
+> --
+> Pieter
+>
+> --
+> 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/frERrHlzWhpskJw74fBQorSrXEaB=
+P1d4XBUgM-Nkww_2ulhc7i2Lqmu2kcAlvh5fd7LzYiBmX5HNBtg7Ownbsa0KZ26ihfJjri6R01k=
+uozA%3D%40wuille.net
+> <https://groups.google.com/d/msgid/bitcoindev/frERrHlzWhpskJw74fBQorSrXEa=
+BP1d4XBUgM-Nkww_2ulhc7i2Lqmu2kcAlvh5fd7LzYiBmX5HNBtg7Ownbsa0KZ26ihfJjri6R01=
+kuozA%3D%40wuille.net?utm_medium=3Demail&utm_source=3Dfooter>
+> .
+>
+>
+
+--=20
+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 e=
+mail to bitcoindev+unsubscribe@googlegroups.com.
+To view this discussion visit https://groups.google.com/d/msgid/bitcoindev/=
+CALkkCJb1RdC646q1QrOP%2ByQut7EG4NLJNm3cyxW4S1%3DEx1NBmQ%40mail.gmail.com.
+
+--00000000000067ab4a0631b94b28
+Content-Type: text/html; charset="UTF-8"
+Content-Transfer-Encoding: quoted-printable
+
+<div dir=3D"auto">Hi,<div dir=3D"auto"><br></div><div dir=3D"auto">I was di=
+smissing the proposal for the same reason you do but it just occurred to me=
+ that substrings might be better than OP_CAT because it&#39;s possible to m=
+ake them unabusable without any arbitrary limit on item size.</div><div dir=
+=3D"auto"><br></div><div dir=3D"auto">The idea is to store stack elements o=
+n the heap inside struct { ref_count, length, data[] } and put struct { poi=
+nter_to_item, position, length } on the stack. (Rust developers may be fami=
+liar with the `bytes` crate that does this.)</div><div dir=3D"auto">Substri=
+ng operations would only duplicate the pointers with adjusted position and =
+length so there&#39;s no way to blow up the stack using them.</div><div dir=
+=3D"auto"><br></div><div dir=3D"auto">Of course there&#39;s an exception if=
+ OP_SHA256 is used on a shorter slice but the same is true today - you can =
+already write OP_ZERO OP_SHA256 OP_DUP OP_DUP...</div><div dir=3D"auto"><br=
+></div><div dir=3D"auto">Funnily, this can be used to optimize OP_DUP as we=
+ll which would now add constant amount of memory, so the &quot;exploit&quot=
+; above would need to use two bytes per every large object.</div><div dir=
+=3D"auto"><br></div><div dir=3D"auto">Anyway, while I would personally pref=
+er not having arbitrary limits on item sizes, since the limit is already th=
+ere, it might not matter. I guess something worth considering if any other =
+future soft fork somehow enables larger items.</div><div dir=3D"auto"><br><=
+/div><div dir=3D"auto">Have a nice day!</div><div dir=3D"auto"><br></div><d=
+iv dir=3D"auto">Martin</div><br><br><div class=3D"gmail_quote gmail_quote_c=
+ontainer" dir=3D"auto"><div dir=3D"ltr" class=3D"gmail_attr">D=C5=88a ut 1.=
+ 4. 2025, 16:49 Pieter Wuille &lt;<a href=3D"mailto:bitcoin-dev@wuille.net"=
+>bitcoin-dev@wuille.net</a>&gt; nap=C3=ADsal(a):<br></div><blockquote class=
+=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
+ing-left:1ex"><div style=3D"font-family:Arial,sans-serif;font-size:14px"><d=
+iv><div>
+ On Monday, March 31st, 2025 at 4:41 PM, Javier Mateos &lt;<a href=
+=3D"mailto:javierpmateos@gmail.com" target=3D"_blank" rel=3D"noreferrer">ja=
+vierpmateos@gmail.com</a>&gt; wrote:<br>
+ <blockquote type=3D"cite"><div>
+ The solution of splitting the string and using OP_CAT only
+ works if the exact position of the substring is known. How would a case
+ be handled where the substring could be in any position</div></blockquote>=
+<div><br></div><div>Whoever
+ produces the signature/witness for spending the coin always knows the=20
+position already, so the script can always be modified to instead take=20
+that position as an additional input.</div><div><br></div><div>This is a
+ general principle: the point of scripts is verifying provided=20
+information, not computing it. As another example, this means that there
+ is no need for a division or square root opcode if one has a=20
+multiplication opcode.</div><div><br></div><div>-- <br></div><div>Pieter</d=
+iv><br></div></div></div>
+
+<p></p>
+
+-- <br>
+You received this message because you are subscribed to the Google Groups &=
+quot;Bitcoin Development Mailing List&quot; group.<br>
+To unsubscribe from this group and stop receiving emails from it, send an e=
+mail to <a href=3D"mailto:bitcoindev+unsubscribe@googlegroups.com" target=
+=3D"_blank" rel=3D"noreferrer">bitcoindev+unsubscribe@googlegroups.com</a>.=
+<br>
+To view this discussion visit <a href=3D"https://groups.google.com/d/msgid/=
+bitcoindev/frERrHlzWhpskJw74fBQorSrXEaBP1d4XBUgM-Nkww_2ulhc7i2Lqmu2kcAlvh5f=
+d7LzYiBmX5HNBtg7Ownbsa0KZ26ihfJjri6R01kuozA%3D%40wuille.net?utm_medium=3Dem=
+ail&amp;utm_source=3Dfooter" target=3D"_blank" rel=3D"noreferrer">https://g=
+roups.google.com/d/msgid/bitcoindev/frERrHlzWhpskJw74fBQorSrXEaBP1d4XBUgM-N=
+kww_2ulhc7i2Lqmu2kcAlvh5fd7LzYiBmX5HNBtg7Ownbsa0KZ26ihfJjri6R01kuozA%3D%40w=
+uille.net</a>.<br><br>
+</blockquote></div></div>
+
+<p></p>
+
+-- <br />
+You received this message because you are subscribed to the Google Groups &=
+quot;Bitcoin Development Mailing List&quot; group.<br />
+To unsubscribe from this group and stop receiving emails from it, send an e=
+mail to <a href=3D"mailto:bitcoindev+unsubscribe@googlegroups.com">bitcoind=
+ev+unsubscribe@googlegroups.com</a>.<br />
+To view this discussion visit <a href=3D"https://groups.google.com/d/msgid/=
+bitcoindev/CALkkCJb1RdC646q1QrOP%2ByQut7EG4NLJNm3cyxW4S1%3DEx1NBmQ%40mail.g=
+mail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/=
+d/msgid/bitcoindev/CALkkCJb1RdC646q1QrOP%2ByQut7EG4NLJNm3cyxW4S1%3DEx1NBmQ%=
+40mail.gmail.com</a>.<br />
+
+--00000000000067ab4a0631b94b28--
+