summaryrefslogtreecommitdiff
path: root/54/074b95c67950986b8de277f3affdfd191f4b94
blob: 5649d0a76ef671a0a68b9e554cad6e62a5afcdc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
Delivery-date: Mon, 17 Mar 2025 09:33:04 -0700
Received: from mail-yw1-f184.google.com ([209.85.128.184])
	by mail.fairlystable.org with esmtps  (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
	(Exim 4.94.2)
	(envelope-from <bitcoindev+bncBDM4H7UM5ABBBNM54G7AMGQEE3YRWMI@googlegroups.com>)
	id 1tuDOh-0000yc-Dm
	for bitcoindev@gnusha.org; Mon, 17 Mar 2025 09:33:04 -0700
Received: by mail-yw1-f184.google.com with SMTP id 00721157ae682-6fee49e26bcsf62823667b3.3
        for <bitcoindev@gnusha.org>; Mon, 17 Mar 2025 09:33:03 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=googlegroups.com; s=20230601; t=1742229177; x=1742833977; darn=gnusha.org;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:x-original-sender:mime-version
         :subject:message-id:to:from:date:sender:from:to:cc:subject:date
         :message-id:reply-to;
        bh=S9Qn7OJL1YxAyj/I0YL7gDramWohH77YZDUc3J9sAsQ=;
        b=ZGOm81VXehLopr+XSr7gpRAkw+Nk1CFHBRxMhjzOrxebXT6Gzy+0yksI1W2f39LnAJ
         dkfhLvISHwGJDDf8iYaYPZNZbGeRhHhaF0FuBCUYn6+V6P/nfut7I7+LjnHrd7EPHamV
         xrk+P1tlTtgPSHyzhUmtjKOG3P+voICgUk5Y/wRaScQYckkpxqPMOWpsgwSwCdkPxVOA
         /BrUdQyQ0L4E+2YWXAy6NC9Irfs8mgzcTQSXLkwvaj9h8nJv3dop9uHg7cJWfTaq5hn5
         PtpBSBPgLmsrsS0MnmNwufxLslYPoB77bePLudO19v/Ssirpt7+AP1OWioLCiFxF1gSh
         IVXg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1742229177; x=1742833977;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:x-original-sender:mime-version
         :subject:message-id:to:from:date:x-beenthere:x-gm-message-state
         :sender:from:to:cc:subject:date:message-id:reply-to;
        bh=S9Qn7OJL1YxAyj/I0YL7gDramWohH77YZDUc3J9sAsQ=;
        b=HymU6KXCro3cLJiCkzyP7leVbT4THLDbxqbJixq6nJPTmLfVi+VZYx01Q/aqRG6nvP
         0PrqEbRSenfDzO9EmmMdYoOU2t2Q4/Np1K4zcEPvbzufvIG9Etdq2/UWivh/M/9bWwLt
         QWvTnjt3S6JCKRm2OlySC/pZA38F8gqvSOutXAxvZzVRyPMjCRCtUWJNwFj2BsidN/xj
         txhboDGDyrIMmstI06Hd3qHBFYXFhNid/k4ON/vVh9vCZOOQ5pbAru9h5gNZHXY6Vh40
         7k4IP1/fzsMQZOvEs5JSJ3ZIM/uYb3NxiK8yFC5P3Q8k5Rm6WI5DIJlcydxPmcZxSo3s
         tGDg==
Sender: bitcoindev@googlegroups.com
X-Forwarded-Encrypted: i=1; AJvYcCWLtm0LNd3RdF1lQUF+DwOeQGVNazsyvcTMMTpj9HgHnFf+fSDk56m6Xsa6A8y65yEnBOeMn2ohYL7j@gnusha.org
X-Gm-Message-State: AOJu0YyFtyDySqMKYeiyGkj29FygoR3rFP3gEdA3WrT/tNg/pC9ppFV0
	jsKz07+nSwRYb26Dhr7TiS887Jo3Xq2TER648do+zuX5eiDN3aRy
X-Google-Smtp-Source: AGHT+IF9fwzla7YMVbmAN7dlkI9kvD/o8df1sor/ISymMZGcg1XoTt41VXxfDSQnXSANp8Mxplj1PA==
X-Received: by 2002:a05:6902:118f:b0:e5b:45ec:b841 with SMTP id 3f1490d57ef6-e64af12418cmr685682276.12.1742229177476;
        Mon, 17 Mar 2025 09:32:57 -0700 (PDT)
X-BeenThere: bitcoindev@googlegroups.com; h=ARLLPAKuO8GMYpjU3zeYAT3hPfFcTdvZGwm7PBqAHkNpvRvCsA==
Received: by 2002:a25:dcd4:0:b0:e5b:3ee5:4212 with SMTP id 3f1490d57ef6-e643ed10a37ls34254276.0.-pod-prod-01-us;
 Mon, 17 Mar 2025 09:32:53 -0700 (PDT)
X-Received: by 2002:a05:690c:700d:b0:6fd:4849:62ec with SMTP id 00721157ae682-6ff45eb75c9mr156352377b3.12.1742229173632;
        Mon, 17 Mar 2025 09:32:53 -0700 (PDT)
Received: by 2002:a05:690c:9a89:b0:6ef:590d:3213 with SMTP id 00721157ae682-6ff4514f72dms7b3;
        Mon, 17 Mar 2025 09:14:06 -0700 (PDT)
X-Received: by 2002:a05:690c:7006:b0:6fb:1c5a:80f8 with SMTP id 00721157ae682-6ff45f7f483mr159710797b3.15.1742228045419;
        Mon, 17 Mar 2025 09:14:05 -0700 (PDT)
Date: Mon, 17 Mar 2025 09:14:05 -0700 (PDT)
From: weichu deng <weichudeng@stu2024.jnu.edu.cn>
To: Bitcoin Development Mailing List <bitcoindev@googlegroups.com>
Message-Id: <f844a85e-8be8-4429-8687-bc19dd4b96ffn@googlegroups.com>
Subject: =?UTF-8?Q?=5Bbitcoindev=5D_New_Proposal=EF=BC=9AString_Substring_Search_?=
	=?UTF-8?Q?in_Bitcoin_Script_=2D_OP=5FISSUBSTR?=
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_276940_2028202810.1742228045178"
X-Original-Sender: weichudeng@stu2024.jnu.edu.cn
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.7 (/)

------=_Part_276940_2028202810.1742228045178
Content-Type: multipart/alternative; 
	boundary="----=_Part_276941_2063444441.1742228045178"

------=_Part_276941_2063444441.1742228045178
Content-Type: text/plain; charset="UTF-8"



Dear fellow Bitcoin developers,

 

I am pleased to present a new BIP proposal. This proposal introduces a new 
opcode for Bitcoin scripts: OP_ISSUBSTR.


*Abstract*

This BIP introduces two string opcodes, OP_ISSUBSTR and OP_ISSUBSTRVERIFY 
(similar to the relationship between OP_EQUAL and OP_EQUALVERIFY), to 
determine whether one string is a substring of another. As these opcodes do 
not alter any blockchain state, they are secure.

 

*Specification*

These opcodes check if the second string on the stack is a substring of the 
first string. If the opcode is OP_ISSUBSTRVERIFY, it verifies the condition 
and throws an error if false, without retaining the result.

 

*Execution Process*

   1. Take the two strings at the top of the stack. 
   2. Use standard library functions to compare the two strings. 
   3. Pop the two strings from the stack and push the result onto the stack. 
   4. If the opcode is OP_ISSUBSTRVERIFY, do not push the result. 

*Motivation*

The absence of string operations in Bitcoin scripts restricts its 
applicability. When developers need string operations for applications, 
they must simulate these functions through off-chain preprocessing or 
complex scripts, increasing development difficulty and potentially 
introducing centralized dependencies.

 

Early Bitcoin versions supported some string operations, such as OP_SUBSTR, 
which extracted a substring of specified position and length from a string, 
replacing the original string. For security reasons, OP_SUBSTR was disabled 
in Bitcoin v0.3.10 and later versions due to a vulnerability 
(CVE-2010-5137) caused by OP_LSHIFT. To prevent similar overflow 
vulnerabilities, Bitcoin disabled several opcodes, including OP_SUBSTR. As 
Bitcoin adoption grows, the limitations of lacking string operations have 
become more evident. Our proposed OP_ISSUBSTR adds string search 
functionality to Bitcoin scripts without changing any state, making it safe.

 

*Advantages *

   1. *Enhanced Script Functionality and Flexibility* Developers can 
   process string logic on-chain without off-chain reliance. For example, in 
   multi-signature wallets, developers can verify specific signer information 
   or remarks directly in scripts using OP_ISSUBSTR to check transaction 
   comments or signature fields for particular substrings. 
   2. *Support for String Searching* In some scenarios, developers need to 
   verify if parts of a string match a format or contain specific data. For 
   example, checking if a payment transaction's payee name matches a preset 
   value. 
   3. *Conversion of Non-deterministic Algorithms to Deterministic Ones* 
   Some signature algorithms or hash functions produce non-deterministic 
   outputs. OP_ISSUBSTR allows developers to check if these outputs contain 
   known substrings in scripts, converting non-deterministic results to 
   deterministic ones. For example, verifying if a hash value contains a 
   specific hexadecimal sequence (like "0000") to trigger contract logic. 
   4. *Simplified Address Verification Logic* Bitcoin addresses typically 
   start with specific prefixes or suffixes. OP_ISSUBSTR enables direct 
   address format verification in scripts. For example, checking if a 
   transaction target address starts with "bc1" to ensure validity or detect 
   "address pollution" attacks. 
   5. *Integration with Modern Programming Languages* Modern languages 
   widely support string operations. OP_ISSUBSTR makes Bitcoin scripts more 
   aligned with these languages, lowering the barrier for developers. 

 

We have provided detailed documentation and a reference implementation in 
the BIP draft. You can read the full proposal here: 
https://github.com/Weichu-Deng/bips/blob/OP_ISSUBSTR/bip-yongdong%20wu-OP_ISSUBSTR.md


Thank you for your feedback! 

With respect,

Weichu Deng

 weichudeng@stu2024.jnu.edu.cn

 

-- 
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/f844a85e-8be8-4429-8687-bc19dd4b96ffn%40googlegroups.com.

------=_Part_276941_2063444441.1742228045178
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<p><span lang=3D"EN-US">Dear fellow Bitcoin developers,</span></p>

<p><span lang=3D"EN-US">=C2=A0</span></p>

<p><span lang=3D"EN-US">I am pleased to present a new BIP proposal.
This proposal introduces a new opcode for Bitcoin scripts: OP_ISSUBSTR.</sp=
an></p><p><span lang=3D"EN-US"><br /></span></p>

<p><b><span lang=3D"EN-US">Abstract</span></b><span lang=3D"EN-US"></span><=
/p>

<p><span lang=3D"EN-US">This BIP introduces two string opcodes,
OP_ISSUBSTR and OP_ISSUBSTRVERIFY (similar to the relationship between OP_E=
QUAL
and OP_EQUALVERIFY), to determine whether one string is a substring of anot=
her.
As these opcodes do not alter any blockchain state, they are secure.</span>=
</p>

<p><span lang=3D"EN-US">=C2=A0</span></p>

<p><b><span lang=3D"EN-US">Specification</span></b><span lang=3D"EN-US"></s=
pan></p>

<p><span lang=3D"EN-US">These opcodes check if the second string on
the stack is a substring of the first string. If the opcode is
OP_ISSUBSTRVERIFY, it verifies the condition and throws an error if false,
without retaining the result.</span></p>

<p><span lang=3D"EN-US">=C2=A0</span></p>

<p><b><span lang=3D"EN-US">Execution Process</span></b><span lang=3D"EN-US"=
></span></p>

<ol style=3D"margin-top: 0cm;" start=3D"1" type=3D"1">
 <li><span lang=3D"EN-US">Take the two strings at the top of the stack.</sp=
an></li>
 <li><span lang=3D"EN-US">Use standard library functions to compare the two=
 strings.</span></li>
 <li><span lang=3D"EN-US">Pop the two strings from the stack and push the r=
esult onto the
     stack.</span></li>
 <li><span lang=3D"EN-US">If the opcode is OP_ISSUBSTRVERIFY, do not push t=
he result.</span></li>
</ol>

<p><b><span lang=3D"EN-US">Motivation</span></b><span lang=3D"EN-US"></span=
></p>

<p><span lang=3D"EN-US">The absence of string operations in Bitcoin
scripts restricts its applicability. When developers need string operations=
 for
applications, they must simulate these functions through off-chain
preprocessing or complex scripts, increasing development difficulty and
potentially introducing centralized dependencies.</span></p>

<p><span lang=3D"EN-US">=C2=A0</span></p>

<p><span lang=3D"EN-US">Early Bitcoin versions supported some
string operations, such as OP_SUBSTR, which extracted a substring of specif=
ied
position and length from a string, replacing the original string. For secur=
ity
reasons, OP_SUBSTR was disabled in Bitcoin v0.3.10 and later versions due t=
o a
vulnerability (CVE-2010-5137) caused by OP_LSHIFT. To prevent similar overf=
low
vulnerabilities, Bitcoin disabled several opcodes, including OP_SUBSTR. As
Bitcoin adoption grows, the limitations of lacking string operations have b=
ecome
more evident. Our proposed OP_ISSUBSTR adds string search functionality to
Bitcoin scripts without changing any state, making it safe.</span></p>

<p><span lang=3D"EN-US">=C2=A0</span></p>

<p><b><span lang=3D"EN-US">Advantages </span></b><span lang=3D"EN-US"></spa=
n></p>

<ol style=3D"margin-top: 0cm;" start=3D"1" type=3D"1">
 <li><b><span lang=3D"EN-US">Enhanced Script Functionality and Flexibility<=
/span></b><span lang=3D"EN-US"> Developers can process string logic on-chai=
n without off-chain
     reliance. For example, in multi-signature wallets, developers can veri=
fy
     specific signer information or remarks directly in scripts using
     OP_ISSUBSTR to check transaction comments or signature fields for
     particular substrings.</span></li>
 <li><b><span lang=3D"EN-US">Support for String Searching</span></b><span l=
ang=3D"EN-US"> In
     some scenarios, developers need to verify if parts of a string match a
     format or contain specific data. For example, checking if a payment
     transaction's payee name matches a preset value.</span></li>
 <li><b><span lang=3D"EN-US">Conversion of Non-deterministic Algorithms to =
Deterministic
     Ones</span></b><span lang=3D"EN-US"> Some signature algorithms or hash
     functions produce non-deterministic outputs. OP_ISSUBSTR allows develo=
pers
     to check if these outputs contain known substrings in scripts, convert=
ing
     non-deterministic results to deterministic ones. For example, verifyin=
g if
     a hash value contains a specific hexadecimal sequence (like
     "0000") to trigger contract logic.</span></li>
 <li><b><span lang=3D"EN-US">Simplified Address Verification Logic</span></=
b><span lang=3D"EN-US"> Bitcoin addresses typically start with specific pre=
fixes or
     suffixes. OP_ISSUBSTR enables direct address format verification in
     scripts. For example, checking if a transaction target address starts =
with
     "bc1" to ensure validity or detect "address pollution"
     attacks.</span></li>
 <li><b><span lang=3D"EN-US">Integration with Modern Programming Languages<=
/span></b><span lang=3D"EN-US"> Modern languages widely support string oper=
ations. OP_ISSUBSTR
     makes Bitcoin scripts more aligned with these languages, lowering the
     barrier for developers.</span></li>
</ol>

<p style=3D"margin-left: 36pt;"><span lang=3D"EN-US">=C2=A0</span></p>

<p><span lang=3D"EN-US">We have provided detailed documentation and
a reference implementation in the BIP draft. You can read the full proposal
here: <a href=3D"https://github.com/Weichu-Deng/bips/blob/OP_ISSUBSTR/bip-y=
ongdong%20wu-OP_ISSUBSTR.md" target=3D"_blank">https://github.com/Weichu-De=
ng/bips/blob/OP_ISSUBSTR/bip-yongdong%20wu-OP_ISSUBSTR.md</a></span></p><p>=
<br /></p>

<p><span lang=3D"EN-US">Thank you for your feedback!=C2=A0</span></p><p><sp=
an lang=3D"EN-US">With respect,</span></p>

<p><span lang=3D"EN-US">Weichu
Deng</span></p><p>=C2=A0<a href=3D"mailto:weichudeng@stu2024.jnu.edu.cn" ta=
rget=3D"_blank">weichudeng@stu2024.jnu.edu.cn</a></p>

<p><span lang=3D"EN-US">=C2=A0</span></p>

<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/f844a85e-8be8-4429-8687-bc19dd4b96ffn%40googlegroups.com?utm_med=
ium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgid/bitcoind=
ev/f844a85e-8be8-4429-8687-bc19dd4b96ffn%40googlegroups.com</a>.<br />

------=_Part_276941_2063444441.1742228045178--

------=_Part_276940_2028202810.1742228045178--