I am doing some tutorial and in this chapter we are suppose to reproduce the Script scripting language

I am struggling to understand one of the exercises, here it is:

Create a ScriptSig that can unlock this ScriptPubKey:

and the answer is 0x52 so that :

>>> from script import Script
>>> script_pubkey = Script([0x76, 0x76, 0x95, 0x93, 0x56, 0x87])
>>> script_sig = Script([0x52])
>>> combined_script = script_sig + script_pubkey
>>> print(combined_script.evaluate(0))

and that OP_2 or 52 will satisfy the equation x² + x – 6 = 0.

I guess I get the whole part execution except when the OP_6 is pushed on the stack, how does it become negative ?

  • 1
    It doesn't. The script implements "x^2 + x = 6". The last opcode is OP_EQUAL. Of course, the script cannot work because it uses the disabled opcode OP_MUL. – Pieter Wuille Dec 1 '19 at 8:15

I was not sure how it would work there but it is in fact basic arithmetic, we have this x^2 + x = 6 then we substract 6 from both sides x^2 + x - 6 = 6 - 6 then we simplify x^2 + x - 6 = 0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.