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 ) 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 ; 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 To: Bitcoin Development Mailing List Message-Id: 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: X-Google-Group-Id: 786775582512 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , 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

Dear fellow Bitcoin developers,

=C2=A0

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


Abstract<= /p>

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.=

=C2=A0

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.

=C2=A0

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 r= esult onto the stack.
  4. If the opcode is OP_ISSUBSTRVERIFY, do not push t= he 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.

=C2=A0

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.

=C2=A0

Advantages

  1. Enhanced Script Functionality and Flexibility<= /span> 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.
  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 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.
  4. Simplified Address Verification Logic 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.
  5. Integration with Modern Programming Languages<= /span> Modern languages widely support string oper= ations. OP_ISSUBSTR makes Bitcoin scripts more aligned with these languages, lowering the barrier for developers.

=C2=A0

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

=

Thank you for your feedback!=C2=A0

With respect,

Weichu Deng

=C2=A0weichudeng@stu2024.jnu.edu.cn

=C2=A0

--
You received this message because you are subscribed to the Google Groups &= quot;Bitcoin Development Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to bitcoind= ev+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/bitcoind= ev/f844a85e-8be8-4429-8687-bc19dd4b96ffn%40googlegroups.com.
------=_Part_276941_2063444441.1742228045178-- ------=_Part_276940_2028202810.1742228045178--