12

Why are the substring opcodes disabled? I understand that OP_CAT is disabled because it can blow up the stack easily (in combination with OP_DUP). But the substring opcodes reduce the stack size.

Context:

I'd like to use OP_LEFT to implement a proof of work requirement to spend a transaction. A substring operation is needed because OP_ADD (for salting) and OP_GREATERTHAN only work on 32bit values.

Michael Folkson
  • 14,337
  • 3
  • 11
  • 45
hrobeers
  • 133
  • 8

1 Answers1

15

I'm afraid that my answer here can't be better than "Ask Satoshi".

There was a series of bugs found in Bitcoin's early life, and the response by its creator was to disable a number of scripting opcodes. Some of these may have been bad choices (or very wise ones...), but we don't know, and it does not matter. For all intents and purposes, these opcodes do not exist, as "reenabling" them would be just as hard as introducing them as new operations in the first place (i.e. a hard fork).

Pieter Wuille
  • 98,249
  • 9
  • 183
  • 287
  • So do you agree with my analysis, or can you see potential issues with these substring operations? Thanks for taking the time to answer my question! – hrobeers Sep 23 '16 at 11:31
  • I do not see any issues with those operations, no. – Pieter Wuille Sep 23 '16 at 11:57
  • Looking at it from a software-development standpoint, string-manipulation operations (OP_CAT, OP_SUBSTR, OP_LEFT, and OP_RIGHT) are prone to implementation bugs with the potential for buffer overflows or other security issues. – Mark Oct 31 '22 at 23:57