Bitcoin Blockchain System
Bitcoin Blockchain System
a. Simple to execute
b. Lightweight (does not rely on other software
packages).
c. Less computing energy.
d. Built for bitcoin
e. Uses cryptography (hashes, signature verification)
f. Stack-based
g. No loops. Conditional statements supported (If
statements)
h. Validation of multiple nodes supported (MULTISIG
instruction)
Bitcoin Script – Stack-based Architecture
• Step 1: The first two instructions of the script, namely, <Sig> and
<Pubkey> represent the signature and the corresponding public key
used to verify the signature.
• Step 2: OP_DUP duplicates the item on top of the stack.
• Step 3: OP_HASH160 pops the top value from the stack, computes
the hash and then pushes the result back. <PubKeyHash> also
pushes the hash of the public key to the top of the stack.
• Step 4: OP_EQULVERIFY matches the hash generated with the
given hash.
• Step 5: OP_CHECKSIG pushes the value true onto the top of the
stack when the signature (Sig) matches the “public key”.
Sample Bitcoin Script
Sample Bitcoin Script
Sample Flow-Control Related Instructions
WORD OP_CODE Meaning
OP_NOP 97 Does Nothing
OP_IF 99 If the value of the top of the stack is not false, the
statements are executed. The value of the top of the stack
is removed
OP_NOTIF 100 If the value of the top of the stack is false, the statements
are executed. The value of the top of the stack is removed
OP_ENDIF 104 Ends an if/else block. All blocks must end, or the
transaction is invalid. An OP_ENDIF without OP_IF
earlier is also invalid.
OP_VERIFY 105 Marks transaction as invalid if top stack value is not
true. The top stack value is removed.
Common Opcodes in Bitcoin Script
• OP_ADD: Pops two items off the stack, adds them together,
and pushes the result back onto the stack.
• OP_EQUAL: Pops two items from the stack and compares
them to check if they are equal. if they are equal, then it
pushes the result TRUE back onto the stack.
• OP_RETURN: Can be used to store up to 80 bytes of
arbitrary data on the Bitcoin blockchain and also to mark a
transaction output as invalid.
– OP_RETURN transaction outputs are provably unspendable,
making this opcode an efficient way to burn BTC.
– It also makes Komodo's delayed Proof of Work (dPoW) security
mechanism possible.
Common Opcodes in Bitcoin Script