Reading Assignment: Script

#1

Welcome to this reading assignment on the Script programming language. If you haven’t already, read through the wiki page (https://en.bitcoin.it/wiki/Script) describing all the op-codes in script and answer the following questions. Post your answers in this forum thread.

  1. What is the practical difference between OP_OP_CHECKSIG and OP_OP_CHECKSIGVERIFY?
  2. What is the “Pop” functions called in Script? (It is not called OP_POP)
  3. What is the hexadecimal OP Code for OP_CHECKMULTISIG?
0 Likes

#2
  1. What is the practical difference between OP_OP_CHECKSIG and OP_OP_CHECKSIGVERIFY?
    Answer:
    OP_CHECKSIG returns either 1 or 0 for True/False; thus, OP_OP_CHECKSIG would be OP of the return value from the first operation which is OP_1 or OP_0 (still returns True or False)
    OP_CHECKSIGVERIFY performs first the operations which is OP_CHECKSIG; returns stated above, thereafter performs OP_VERIFY on the return. This would return fail (mark the transaction invalid and remove it from the top of the stack) if the input value is false.
    So OP_OPCHECKSIGVERIFY would be the OP of the return from OP_CHECKSIGVERIFY.
  2. What are the “Push” and “Pop” functions called in Script? (They are not called OP_PUSH and OP_POP)
    Answer
    No idea (help me out)
  3. What is the hexadecimal OP Code for OP_CHECKMULTISIG?
    Answer: 174
0 Likes

#3
  1. Hint. Look through the script wiki page and go down to the script section with op-codes. There you will find them: https://en.bitcoin.it/wiki/Script
  2. Correct, but in hex it is 0xae
0 Likes

#4

1. What is the practical difference between OP_OP_CHECKSIG and OP_OP_CHECKSIGVERIFY?
OP_CHECKSIG will push TRUE (1) or FALSE (0) to the stack after evaluating 2 input parameters (public key and signature of the script). OP_CHECKSIGVERIFY (is combination of OP_CHECKSIG and OP_VERIFY) leaves nothing on the stack after evaluation and will fail the script if the OP_CHECKSIG doesn’t return true.

2. What are the “Push” and “Pop” functions called in Script? (They are not called OP_PUSH and OP_POP)
POP: OP_DROP (removes the top item from the stack but doesn’t do anything with it, there are other OPcodes that pop items from the stack, for example: OP_NIP, OP_2DROP, …)

PUSH: no specific OPcode found for this. But there are OPcodes that push data onto the stack (OP_DUP, OP_OVER, OP_2DUP, …)

3. What is the hexadecimal OP Code for OP_CHECKMULTISIG?
it is 0xae

0 Likes

#5

1. What is the practical difference between OP_CHECKSIG and OP_CHECKSIGVERIFY?
OP_CHECKSIG checks to see if the hash is true (1) or false (0) giving the corresponding output.
OP_CHECKSIGVERIFY does the same thing then calls OP_VERIFY which checks the top stack value. If the value is false (0) it marks it as invalid and then removes it.

2. What are the “Push” and “Pop” functions called in Script? (They are not called OP_PUSH and OP_POP)

Push: The functions listed from @filip’s hint are not directly a Push OP but could be any of the following which adds a constant to the stack:
OP_CHECKLOCKTIMEVERIFY
OP_DROP
OP_DUP
OP_HASH160 <pubKeyHash>
OP_EQUALVERIFY
OP_CHECKSIG

POP: OP_DROP

3. What is the hexadecimal OP Code for OP_CHECKMULTISIG?
0xae

1 Like

#6

That’s a good point. I’ve edited the question now to make it easier.

0 Likes

#7
  1. The practical difference between them is that OP_CHECKSIGVERIFY calls OP_VERIFY in the end, which means that it returns nothing or fails instead of returning true/false like in OP_CHECKSIG
  2. OP_DROP is the opcode to only remove the top stack item, but there are two others to remove (pop) items like OP_NIP which removes the second from the top and OP_2DROP that removes the top two.
  3. 0xae
1 Like

#8
  • What is the practical difference between OP_OP_CHECKSIG and OP_OP_CHECKSIGVERIFY?

OP_CHECKSIGVERIFY combines OP_CHECKSIG and OP_VERIFY (OP_VERIFY is pushed to stack after the result of OP_CHECKSIG. Actually, after OP_CHECKSIG itself).

  • What is the “Pop” functions called in Script? (It is not called OP_POP)

Not sure I understand this question. Is it about OP_DROP removing the top element from the stack?

  • What is the hexadecimal OP Code for OP_CHECKMULTISIG?
    0xAE
1 Like