0% found this document useful (0 votes)
133 views15 pages

Bitcoin Scripting Language and Its Use-Ankita

Bitcoin Script is a stack-based programming language used for processing transactions on the Bitcoin blockchain, allowing for operations like sending funds and creating multi-user accounts. It employs a limited set of operation codes (OP_CODES) to define transaction conditions, ensuring security by preventing infinite loops and excessive resource consumption. The scripting language is intentionally Turing incomplete, enhancing its security and predictability within the Bitcoin network.

Uploaded by

Lawanya Arora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
133 views15 pages

Bitcoin Scripting Language and Its Use-Ankita

Bitcoin Script is a stack-based programming language used for processing transactions on the Bitcoin blockchain, allowing for operations like sending funds and creating multi-user accounts. It employs a limited set of operation codes (OP_CODES) to define transaction conditions, ensuring security by preventing infinite loops and excessive resource consumption. The scripting language is intentionally Turing incomplete, enhancing its security and predictability within the Bitcoin network.

Uploaded by

Lawanya Arora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

UNIVERSITY INSTITUTE OF

ENGINEERING
COMPUTER SCIENCE ENGINEERING
Bachelor of Engineering (Computer Science & Engineering)
Subject Name: Block chain Technology
Subject Code: CSA-467
Mapped with CO3
Scripting Language

Prepared By: DISCOVER . LEARN . EMPOWER


Er. Ankita Sharma 1
Bitcoin Script

Bitcoin Script is a simple, stack-based programming language that enables


the processing of transactions on the Bitcoin block chain.
• It’s important to note that Bitcoin software (also known as Bitcoin Core) is
not actually written in Bitcoin Script.
• Script itself is implemented using the programming language the Bitcoin
software is written in.
• Bitcoin Script allows to do everything it can do, from sending funds from
a wallet to allowing the creation of multi-user accounts.
• Stack-based
• Stack-oriented programming, is a programming paradigm which
relies on a stack machine model for passing parameters.
• Stack-oriented languages operate on one or more stacks, each of
which may serve a different purpose.
• Items at the top of the stack can be added (pushed) or removed
(popped) in a “Last In, First Out (LIFO)” queue.
• With Bitcoin Script, Book A would need to be the first taken out of the
stack (popped), followed by Book B and Book C, to put anything at the
bottom of the stack (pushed).
• The same concept is applied virtually to operations in a sequence with
Script.
• Bitcoin Script is essentially a set of programmed instructions that are
recorded with every transaction made.
• In Bitcoin order to write program that communicate our wishes,
the opcodes (OP CODES), which serve various functions.
Bit coin Script
1.) First, the original public key of the owner (which is in the scriptSig) of the funds is
duplicated.
2.) The duplicate public key then goes through a hashing process. In this process, a hash is
applied first SHA-256 and a RIPEMD-160 hash is then applied to the result.
3.) The result of the hashes is compared with the hash of the public key that is in the
scriptPubKey to make sure it is EQUALVERIFY (that is, it is the same key and is verified as
valid).
If it matches, the script continues to run and CHECKSIG is performed to verify the signature
with the public key.
What is an OP_CODE or Operation Code?
• In computing, a OP_CODE (Operation Code), is a portion of a machine
language instruction that specifies the operation to be performed.
• Due to the structure in which Bitcoin has been created, there is the
possibility of defining 256 OP_CODES, different of which start from
number 0 to 255.
• Of these 256 OP_CODES, a total of 116 are currently active.
• There are the OP_CODES that in the operation are the following:
• OP_DUP: Duplicate the item on the top stack.
• OP_HASH160: The input is encoded twice: first with SHA-256 and then
with RIPEMD-160.
• OP_EQUALVERIFY: Verify that the data entered is correct and valid.
• 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_CHECKSIG: Verifies that the signature for a transaction input is valid.
Features
• It is simple and requires minimal processing.
• Its functionality is limited, which provides greater security to the system.
• Being a Turing Incomplete language it does not have loops, so it is ensured that the
program stops repeating and ends. Thus, the possibility of errors and malicious
codes to the Bitcoin network is avoided.
• Its simplicity allows it to be implemented on a wide range of devices.
• There is no state before or after the script execution. All the information necessary
to run the script must be contained in it.
• It is based on a stack and can use two types. One main and one alternative. Where
the latter is used for the storage of intermediate step calculation data. In much the
same way as the memory key on calculators.
• Turing Incomplete
• Bitcoin scripting language is not Full Turing because its functionality is
limited and cannot loops.
• So it is not capable of solving any type of problem such as Turing machines.
• Turing incomplete means that Script for Bitcoin and other cryptocurrencies
does not allow infinite loops.
• However, this limitation is intentional as this prevents infinite or endless
looping and error execution.
• Where malicious parts of the program can be free to create complicated
operations to consume the rate of hash and slow down the Bitcoin system
through infinite loops.
• A Turing complete system or programming language is one that can
simulate a Turing machine. In other words, it has the ability to solve any
problem that a Turing machine can solve, given enough time and resources.
Turing completeness is considered a desirable property because it means
that a system or language is capable of expressing any computable
function.
• On the other hand, a Turing incomplete system or programming language
lacks the ability to simulate a Turing machine. It may have certain
limitations or restrictions that prevent it from solving certain types of
problems. This means that there are computational tasks that cannot be
expressed or solved within the confines of a Turing incomplete system or
language.
Features of bit coin scripting
• Bitcoin scripting is a programming language used within the Bitcoin network to
define the conditions under which Bitcoin transactions can be spent. It provides a
set of instructions that govern the locking and unlocking of Bitcoin outputs,
allowing users to enforce specific spending conditions. Here are some key
features of Bitcoin scripting:
• Stack-based language: Bitcoin scripting is based on a stack machine model. It
operates on a stack of data elements and uses various stack manipulation
operations to perform computations and evaluate conditions.
• Script types: Bitcoin scripting supports different script types, including Pay-to-
Public-Key-Hash (P2PKH), Pay-to-Script-Hash (P2SH), and multi-signature (multi-
sig) scripts. Each script type has its own set of rules and conditions for spending
Bitcoin.
• Script evaluation: Bitcoin script execution involves the evaluation of a script
to determine whether it is valid or not. The script is run in a virtual machine
known as the Bitcoin Script Interpreter, and each opcode is executed step by
step.
• Script validation: Bitcoin nodes validate the scripts in transaction inputs to
ensure that they meet the spending conditions specified by the previous
transaction's output script. If the script execution is successful and the
spending conditions are satisfied, the transaction is considered valid.
• Limited computational capabilities: Bitcoin scripting intentionally restricts
the computational capabilities to prevent potential security risks, such as
infinite loops or excessive resource consumption. This limitation ensures that
script execution remains predictable and efficient.
• Turing incompleteness: Bitcoin scripting is intentionally designed to be
Turing incomplete, meaning it does not have the full computational
power of a Turing machine. This limitation enhances security by
preventing potentially harmful or unpredictable computations within
the Bitcoin network.
• Bitcoin scripting provides a flexible mechanism for defining
transaction spending conditions and enabling various types of smart
contracts on the Bitcoin block chain. Its simplicity and security-
focused design make it suitable for the decentralized and trustless
nature of the Bitcoin network.

You might also like