Design Goals
-
Built for Bitcoin (inspired by Forth)
-
Simple, compact
-
Support for cryptography
-
Stack-based
-
Limits on time/memory
-
No looping
Script Executable Example
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIGOP_DUP : Take values on the top of the stack, pop it off, write two copies back to the stack.
HASH160 : Take the top value and convert into a hash
OP_EQUALVERIFY : Verifying the top values of the stack are equal. If error, exec will stop.
OP_CHECKSIG : Checks the signature from both the ends.
Script Instructions
-
256 opcodes total [1 byte each] (15 disabled, 75 reserved)
- Arithmetic
- if/then
- Logic/Data Handling
- Crypto
-
Hashes
-
Signature Verification
-
Multi-Signature Verification
-
OP_CHECKMULTISIG lets you check multiple signatures at once - Has built in support for joint signatures - Specify n public keys and parameter t - Verification requires t signatures
Sender’s Script (Has to send the complete hash)
OP_HASH160 <hash of redemption script> OP_EQUALReceiver’s Script (Has to verify the whole hash sender sent)
<signature> <<pubkey> OP_CHECKSIG>Applications of Scripting
-
Escrow Transactions : Involving 3rd parties in the transaction pipe with MULTISIG
-
Green Addresses : Involving a bank in the transaction. (Not used much in practice)
-
Efficient Micro-Payments : All of the transactions could be double spend.
