bit-matrix / script-wiz-lib

MIT License
42 stars 5 forks source link

OP_WITHIN is inclusive on both sides and it should only be left inclusive #45

Closed brilliancebitcoin closed 2 years ago

brilliancebitcoin commented 2 years ago

I used scriptwiz to help me create this coinflip app: https://github.com/brilliancebitcoin/coinflip

One op_code I needed was op_within. I use it as part of a blinded bit commitment scheme where both users need to supply input strings that are either 16 or 17 bytes long. In scriptwiz I could check the whether their string was the right length with this code:

<16>
<17>
OP_WITHIN

But that didn't work in actual script because the real OP_WITHIN is left-inclusive but right-exclusive. That is, it checks that the input supplied by the user is greater than or equal to the first number, but it only checks that it is less than the second number -- it cannot be equal because it is not inclusive. So I had to convert my real code to this:

<16>
<18>
OP_WITHIN

Please correct the behavior of OP_WITHIN so that it is left-inclusive but not right-inclusive.