# <center><i class="fa fa-edit"></i> 3.2 Bitcoin Scripts </center> ###### tags: `Blockchain` The following notes are taken from [Coursera](https://www.coursera.org/learn/cryptocurrency/home/week/2) --- ### KEY :::info | Color | Represents | | -------- | -------- | | pink | input address | | orange | output address| ::: ### Example Concatenated: ![](https://i.imgur.com/iYiq78Z.jpg) :::success **TO VERIFY**: Concatenated script must execute completely with no errors ::: ### Bitcoin Scripting Languge (Script) Design Goals: - Built for Bitcoin (Inspired by Forth) - Simple, compact - Support for cryptography - Stack-based - Limits on time/memory - No looping ### Bitcoin Script Execution Example ![](https://i.imgur.com/23I71yq.jpg) ### Bitcoin Script Transaction 256 opcodes total (15 disabled, 75 reserved) - Arithmetic - if/then - Logic/data handling - Crypto - Hashes - Signature verification - Multi-signature verification ### Multi-Signature Verification `OP_CHECKMULTISIG` - Built-in support for joint signatures - Specify `n` public keys - Specify `t` (threshold) - Verification requires `t` signatures -> `t` out of `n` valid public keys :::danger **BUG**: Extra data value popped from stack and ignored ::: ### Bitcoin Scripts in Practice (as of 2014) - Most nodes whitelist known scripts - 99.9% are simple signature checks - ~ 0.01% are `MULTISIG` - ~ 0.01% are pay-to-script-hash - Remainder are errors (proof-of-burn) ### Proof-of-Burn - Coins destroyed - Output address throws an error if ever reached and crashes 1. Write arbitrary data into Bitcoin 2. Bootstrap an alternative to Bitcoin by forcing people to destroy Bitcoin in order to gain coins in the new systems ![](https://i.imgur.com/yl1mRn4.png) ### Script (Pay-to-Script-Hash) Idea: Use hash of redemption - Reduces complexity - Efficient **First time execution:** ![](https://i.imgur.com/58TCrQB.jpg) **Second time execution:** - Deserialized ![](https://i.imgur.com/JR0SW4j.png)