From: weichu deng <weichudeng@stu2024•jnu.edu.cn>
To: Bitcoin Development Mailing List <bitcoindev@googlegroups.com>
Subject: [bitcoindev] New Proposal:String Substring Search in Bitcoin Script - OP_ISSUBSTR
Date: Mon, 17 Mar 2025 09:14:05 -0700 (PDT) [thread overview]
Message-ID: <f844a85e-8be8-4429-8687-bc19dd4b96ffn@googlegroups.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 4263 bytes --]
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.
[-- Attachment #1.2: Type: text/html, Size: 6308 bytes --]
next reply other threads:[~2025-03-17 16:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-17 16:14 weichu deng [this message]
2025-03-17 16:54 ` Peter Todd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f844a85e-8be8-4429-8687-bc19dd4b96ffn@googlegroups.com \
--to=weichudeng@stu2024$(echo .)jnu.edu.cn \
--cc=bitcoindev@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox