0% found this document useful (0 votes)
84 views41 pages

Module IV

Bitcoin is the first decentralized digital currency, introduced in 2008 by Satoshi Nakamoto, which operates on blockchain technology. It utilizes cryptographic keys for transactions and has various wallet types for storing private keys, including non-deterministic and hierarchical deterministic wallets. Smart contracts, which execute automatically based on predefined conditions, are also a significant aspect of the Bitcoin ecosystem.

Uploaded by

Madhur V
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)
84 views41 pages

Module IV

Bitcoin is the first decentralized digital currency, introduced in 2008 by Satoshi Nakamoto, which operates on blockchain technology. It utilizes cryptographic keys for transactions and has various wallet types for storing private keys, including non-deterministic and hierarchical deterministic wallets. Smart contracts, which execute automatically based on predefined conditions, are also a significant aspect of the Bitcoin ecosystem.

Uploaded by

Madhur V
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

Bitcoin

• Bitcoin is the first application of the blockchain technology.


• Bitcoin has started a revolution with the introduction of the very first
fully decentralized digital currency, and one that has proven to be
extremely secure and stable.
• In 2008, a paper on bitcoin, Bitcoin: A Peer-to-Peer Electronic Cash
System was written by Satoshi Nakamoto. The first key idea
introduced in the paper was that purely peer-to-peer electronic cash
that does need an intermediary bank to transfer payments between
peers.
Bitcoin definition
• Bitcoin can be defined in various ways; it's a protocol, a digital
currency, and a platform.
• It is a combination of peer-to-peer network, protocols, and software
that facilitate the creation and usage of the digital currency named
bitcoin.
• Bitcoin with a capital B is used to refer to the Bitcoin protocol,
whereas bitcoin with a lowercase b is used to refer to bitcoin, the
currency.
Keys and addresses
• Elliptic curve cryptography is used to generate public and private key
pairs in the Bitcoin network.
• The bitcoin address is created by taking the corresponding public key
of a private key and hashing it twice, first with the SHA256 algorithm
and then with RIPEMD160.
• The resultant 160-bit hash is then prefixed with a version number and
finally encoded with a Base58Check encoding scheme.
• The bitcoin addresses are 26-35 characters long and begin with digit 1
or 3.
1ANAguGG8bikEv2fYsTBnRUmx7QUcK58wt

• Currently, there are two types of addresses, the commonly used


P2PKH and another P2SH type, starting with 1 and 3, respectively.
• P2PKH- pay to publilc key hash. From bitaddress.org private key and bitcoin address in a paper wallet

• P2SH- Pay to script hash.


Public keys in bitcoin
• In public key cryptography, public keys are generated from private
keys.
• Bitcoin uses ECC based on the SECP256K1 standard. A private key is
randomly selected and is 256-bit in length.
• Public keys can be presented in an uncompressed or compressed
format.
• Public keys are basically x and y coordinates on an elliptic curve and in
an uncompressed format and are presented with a prefix of 04 in a
hexadecimal format.
• X and Y coordinates are both 32- bit in length. In total, the
compressed public key is 33 bytes long as compared to 65 bytes in the
uncompressed format.
Keys are identified by various prefixes, described as follows:
• Uncompressed public keys used 0x04 as the prefix
• Compressed public key starts with 0x03 if the y 32-bit part of the
public key is odd
• Compressed public key starts with 0x02 if the y 32-bit part of the
public key is even
Private keys in bitcoin
• Private keys are basically 256-bit numbers chosen in the range
specified by the SECP256K1 ECDSA recommendation.
• Any randomly chosen 256-bit number from 0x1 to
• 0xFFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFE BAAE DCE6 AF48 A03B
BFD2 5E8C D036 4140 is a validprivate key.
• Private keys are usually encoded using Wallet Import Format (WIF) in
order to make them easier to copy and use.
Bitcoin currency units
Base58Check encoding
• This encoding is used to limit the confusion between various
characters, such as 0OIl as they can look the same in different fonts.
• The encoding basically takes the binary byte arrays and converts them
into human-readable strings.
• This string is composed by utlilizing a set of 58 alphanumeric symbols.
Vanity addresses
• As bitcoin addresses are based on base 58 encoding, it is possible to
generate addresses that contain human-readable messages.
Public address encoded in
QR
• Vanity addresses are generated using a purely brute-force method. An
example is shown in the following screenshot:
Transactions
• Transactions are at the core of the bitcoin ecosystem.
• Each transaction is composed of at least one input and output.
• Inputs can be thought of as coins being spent that have been created
in a previous transaction and outputs as coins being created.
• If a transaction is minting new coins, then there is no input and
therefore no signature is needed.
• If a transaction is to sends coins to some other user (a bitcoin
address), then it needs to be signed by the sender with their private
key and a reference is also required to the previous transaction in
order to show the origin of the coins.
The transaction life cycle
1. A user/sender sends a transaction using wallet software or some other interface.
2. The wallet software signs the transaction using the sender's private key.
3. The transaction is broadcasted to the Bitcoin network using a flooding algorithm.
4. Mining nodes include this transaction in the next block to be mined.
5. Mining starts once a miner who solves the Proof of Work problem broadcasts the newly mined
block to the network.
6. The nodes verify the block and propagate the block further, and confirmation starts to generate.
7. Finally, the confirmations start to appear in the receiver's wallet and after approximately six
confirmations, the transaction is considered finalized and confirmed. However, six is just a
recommended number; the transaction can be considered final even after the first confirmation.
The key idea behind waiting for six confirmations is that the probability of double spending is
virtually eliminated after six confirmations.
The transaction structure
The transaction structure
MetaData: This part of the transaction contains some values such as the
size of the transaction, the number of inputs and outputs, the hash of
the transaction, and a lock_time field. Every transaction has a prefix
specifying the version number.
Inputs: Generally, each input spends a previous output. Each output is
considered an Unspent Transaction Output (UTXO) until an input
consumes it.
Outputs: Outputs have only two fields, and they contain instructions for
the sending of bitcoins.
Verification: Verification is performed using bitcoin's scripting language.
A sample transaction
The script language
• Bitcoin uses a simple stack-based language called script.
• The various categories of the scripting Opcodes are constants, flow
control, stack, bitwise logic, splice, and arithmetic, cryptography, and
lock time.
• ScriptSig is the unlocking script, whereas ScriptPubKey is the locking
script.
Commonly used Opcodes
most commonly used Opcodes is listed here
Blockchain
• Blockchain is a public ledger of a timestamped, ordered, and
immutable list of all transactions on the bitcoin network.
• Each block is identified by a hash in the chain and is linked to its
previous block by referencing the previous block's hash
The structure
Wallets
• The wallet software is used to store private or public keys and bitcoin
address.
• It performs various functions, such as receiving and sending bitcoins.
• Private keys can be generated in different ways and are used by
different types of wallets.
• Wallets do not store any coins, and there is no concept of wallets
storing balance or coins for a user.
• In the bitcoin network, coins do not exist; instead, only transaction
information is stored on the blockchain
Wallet types
• In bitcoin, there are different types of wallets that can be used to store
private keys.
• Non-deterministic wallets
• Deterministic wallets
• Hierarchical deterministic wallets
• Brain wallets
• Paper wallets
• Hardware wallets
• Online wallets
• Mobile wallets
Non-deterministic wallets
• These wallets contain randomly generated private keys and are also
called Just a Bunch of Key wallets.
• The bitcoin core client generates some keys when first started and
generates keys as and when required.
• Managing a large number of keys is very difficult.
• There is a need to create regular backups of the keys and protect
them appropriately in order to prevent theft or loss.
A non-deterministic wallet does the following:
* It generates private key 1 which in turn creates a corresponding public
address 1.
* It generates private key 2 which in turn creates a corresponding public
address2
etc...

The private keys are randomly generated numbers which are not related to
each other.

You can not derive these private keys with an algorithm.


Hence the words "non-deterministic".
Deterministic wallets
• keys are derived out of a seed value via hash functions.
• This seed number is generated randomly and is commonly
represented by human-readable mnemonic code words.
• Mnemonic code words are defined in BIP39.
• private key management comparatively easier.
• https://iancoleman.io/bip39/
Hierarchical deterministic
wallets
• Defined in BIP32 and BIP44, HD wallets store keys in a tree structure
derived from a seed.
• The seed generates the parent key (master key), which is used to
generate child keys and, subsequently, grandchild keys.
• The complete hierarchy of private keys in an HD wallet is easily
recoverable if the master private key is known.
• It is because of this property that HD wallets are very easy to
maintain and are highly portable.
Brain wallets
• The master private key can also be derived from the hash of
passwords that are memorized.
• The key idea is that this passphrase is used to derive the private key
and if used in HD wallets, this can result in a full HD wallet that is
derived from a single memorized password.
• brain wallets can be stored as a sequence of 12-24 words (often called
a mnemonic).
Paper wallets
• As the name implies, this is a paper-based wallet with the required
key material printed on it.
• It requires physical security to be stored.
• h t t p s ://w w w . b i t a d d r e s s . o r g /.
Hardware wallets

Another method is to use a tamper-resistant device to store keys. This


tamper-resistant device can be custom-built or with the advent of NFC-
enabled phones, this can also be a secure element (SE) in NFC phones.
Trezor and Ledger wallets (various types) are the most commonly used
bitcoin hardware wallets.
Online wallets

Online wallets, as the name implies, are stored entirely online and are

provided as a service usually via cloud. They provide a web interface to

the users to manage their wallets and perform various functions such

as making and receiving payments.


Mobile wallets
Mobile wallets, as the name suggests, are
installed on mobile devices. They can provide
various methods to make payments, most
notably the ability to use smart phone cameras
to scan QR codes quickly and make payments.
Mobile wallets are available for the Android
platform and iOS, for example, breadwallet,
copay, and Jaxx.
Smart Contracts
• Smart contracts are described by

“A smart contract is a computerized transaction protocol that executes


the terms of a contract. The general objectives are to satisfy common
contractual conditions (such as payment terms, liens, confidentiality,
and even enforcement), minimize exceptions both malicious and
accidental, and minimize the need for trusted intermediaries. Related
economic goals include lowering fraud loss, arbitrations and
enforcement costs, and other transaction costs.”
Definition
“A smart contract is a secure and unstoppable computer program
representing an agreement that is automatically executable and
enforceable.”
• smart contract is in fact a computer program that is written in a
language that a computer or target machine can understand.
• smart contracts are automatically executed when certain conditions are
met.
• They are enforceable, which means that all contractual terms are
executed as defined and expected, even in the presence of adversaries.
work on the principle that code is law, meaning that there is no need
for an arbitrator or a third party to control or influence the execution of
the smart contract.
they are secure and unstoppable, which means that these computer
programmes are required to be designed in such a fashion that they are
fault tolerant and executable in reasonable amount of time.
These programmes should be able to execute and maintain a healthy
internal state, even if external factors are unfavorable.
For example,
Imagine a normal computer programme which is encoded with some
logic and executes according to the instruction coded within it, but if
the environment it is running in or external factors it relies on deviate
from the normal or expected state, the programme may react
arbitrarily or simply abort. It is important that smart contracts are
immune to this type of issue.
unstoppable properties: This will allow researchers to focus on these
aspects from the start and will help to build strong foundations on
which further research can then be based.

Suggestion by some researchers that smart contracts need not be


automatically executable; instead they can be what's called
automatable, due to manual human input required in certain scenarios.

You might also like