Subject: Re: [bitcoindev] New Proposal：String Substring Search in Bitcoin Script - OP_ISSUBSTR

From: Peter Todd <[email-masked]>
Date: Mon, 17 Mar 2025 16:54:19 +0000

On Mon, Mar 17, 2025 at 09:14:05AM -0700, weichu deng wrote:
> 
> 
> 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.

Bitcoin scripts are about validation. Not computation.

This means that substring search and concatenation are equivalent. For
every script that validates a substring search, you can instead
concatenate the substring with the rest of the string, and validate
equality instead.

Basically speaking:

	foobar foo IsSubStr

is equivalent to:

	foobar foo bar Cat Equal

A real-world example would be more complex. But I hope that illustrates
my point sufficiently.

-- 
https://petertodd.org 'peter'[:-1]@petertodd.org

-- 
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 [email-masked].
To view this discussion visit https://groups.google.com/d/msgid/bitcoindev/Z9hTu2TjMlLr5-Eg%40petertodd.org.