SlideShare a Scribd company logo
1
Bitcoin – Introduction for
programmers
Wojciech Langiewicz @ DRUG #61
2
Live Demo before we start
● Connect to WIFI or make sure you have cellphone reception
● Install Wallets
– Android (Mycelium testnet):
– Online:
● http://testnetwallet.com/
● Create payment requests
for 0.01 BTC / 10mBTC
● Tweet them @xwlk
3
Scope of this talk
● Introduction – What is Bitcoin, History
● Core concepts
– Keys, Addresses
– Wallet
– Clients
– Transaction
– Block
– Mining
– Blockchain
4
What is Bitcoin
● Collection of concepts (and full “ecosystem” of tools)
● Decentralized peer-to-peer system
● Solves 2 main problems:
– Is that money authentic (not counterfeit)
– Is there only singe occurrence of this specific coin (double spends)
● Has much similarities to cash and gold
5
Key elements of the ecosystem
● Decentralized peer-to-peer network (Bitcoin protocol)
● Public transaction ledger (Blockchain)
● Decentralized currency issuing algorithms (mining)
● Decentralized transaction verification (transaction scripts)
6
Images from book “Mastering Bitcoin” by Andreas M. Antonopoulos
Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
7
Few words about history
● Introduced in 2009 by Satoshi Nakamoto
● https://bitcoin.org/bitcoin.pdf
● Combined concepts that existed before
● But have not been combined until then
● POW algorithm + Blockchain
8
Bitcoin Address
● Something like this:
19wQhQEF3ANe6Dsiiahq3BFkdzb4K8XZUf
● Usually shown as QR code:
● Address is a Base58 encoded form
of the public key
● Based on the address prefix, you can figure out what type of
address it is.
● Types of addresses: Pubkey hash, script hash, private key
● Address reuse
● A word about HD Wallets
9
Bitcoin Keys - ECDSA
● Private keys – numbers between 0 and 2^256
● Public key can be calculated from the private key
● Public key can be represented as Base58 encoding, HEX
number, etc
● Private keys can also be encoded as Base58 – this is called
WIF format – most common way to export/import keys
between wallets
10
Wallet
● Client software running on: server, desktop, phone, “in the
cloud”, it manages keys, signs transactions, generates new
keys, etc
● Paper Wallets
● Bitcoin-qt
● Hardware wallets (Trezor)
● Electrum, Armory, Multibit
● Blockchain.info
● Mobile wallets with intermediate server
● Other web wallets
11
Wallet vs HD Wallet
Images from book “Mastering Bitcoin” by Andreas M. Antonopoulos
Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Standard Wallet HD Wallet
12
Trezor
13
Full nodes
● Full nodes store full copy of the blockchain
● Currently over 40GB of data
● Usually need for server-side type of applications
● Provide JSON-RPC API
● Example: Satoshi client, btcd
14
SPV nodes
● Lighweight nodes
● Use Simplified Payment Verification instead of ITV
● Suitable for desktops, phones
● Instead of downloading full blockchain
● Download transactions only for their addresses
● Security and privacy implications
● Example: bitcoinj
15
Transaction
● Coinbase transaction
● Each transaction has 1 or more inputs and 1 or more outputs
● Transaction “moves money” - changes owner
● Transactions take inputs and translate it into outputs
● Those outputs can serve as inputs to the new transaction
16
Images from book “Mastering Bitcoin” by Andreas M. Antonopoulos
Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
17
Spending a transaction - P2PH
● Example of transaction type “Pay to pubkey hash”
● ScriptPubKey:
OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY
OP_CHECKSIG
● scriptSig: <sig> <pubKey>
● Script:
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash>
OP_EQUALVERIFY OP_CHECKSIG
18
19
Executing a script
20
Advanced transaction types
● Multi signature (multisig)
● OP_RETURN
● Anyone can spend
● Pay to script hash
21
Blocks
● Genesis block
● Mining – process of confirming a block
● Each block points to a previous one creating a blockchain
● Quite few similarities to git (instead you can't merge)
22
Mining
● Merges transactions into blocks
● Finds nonce that “solves” the block
● Once the solution is found – block is published
● Published – appended to the blockchain
● Published blocks are verified by other nodes
● This sends coinbase transaction to the miner + all fees
● Proof of Work – 10 minutes per block
● Difficulty
23
Mining pools
● Chance to find a solution to a block are small
● Small miners join in pools where they share a profit
● Instead of finding a block every year and getting 25BTC
● You will get 0.5 BTC per week.
● You have to trust the pool operator or use p2pool
24
Blockchain
● “A chain of blocks”
● Clever approach to consensus problem
● Miners after finding a new block publish it on the network
● You base your security on a height of a transaction
● Ensures that there are no duplication
25
Blockchain fork
● Situation when 2 blocks are found at the same time
● Bitcoin network is in the state of a fork
● 10 minutes later a new block is found that is based on one of
the forks
● All Bitcoin nodes quickly switch to the longer branch
● Transactions from the shorter branch are orphaned and will
be processed shortly after
● Next slides: Fork example
26Images from book “Mastering Bitcoin” by Andreas M. Antonopoulos
Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
27Images from book “Mastering Bitcoin” by Andreas M. Antonopoulos
Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
28Images from book “Mastering Bitcoin” by Andreas M. Antonopoulos
Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
29Images from book “Mastering Bitcoin” by Andreas M. Antonopoulos
Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
30Images from book “Mastering Bitcoin” by Andreas M. Antonopoulos
Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
31
Few words about the 51% attack
● Theoretically possible even with 40-50% of power
● Can be used to destabilize network for some period of time
● Can help to create a double-spend
● In no case you'll be able to spend coins you don't have
● This attack is not practical
● Miners will make more BTC by being honest
32
Please return testnet coins
33
Next time
● More about Bitcoin clients
● Bitcoin-core JSON-RPC API
● Bitcoinj
● Raw transactions
● Blockchain details
● Security
● Bitcoin flaws

More Related Content

What's hot

Introduction to bitcoin
Introduction to bitcoinIntroduction to bitcoin
Introduction to bitcoin
Wolf McNally
 
Blockchain seminar
Blockchain seminarBlockchain seminar
Blockchain seminar
Amiyabablu
 
Blockchain Primer Part 1
Blockchain Primer Part 1Blockchain Primer Part 1
Blockchain Primer Part 1
Sanjay Basu
 
Overview of bitcoin
Overview of bitcoinOverview of bitcoin
Overview of bitcoin
Abdul Nasir
 
The Bitcoin blockchain (en)
The Bitcoin blockchain (en)The Bitcoin blockchain (en)
The Bitcoin blockchain (en)
Davide Carboni
 
Dash(digital cash)
Dash(digital cash)Dash(digital cash)
Dash(digital cash)
Valentin Kalinov
 
Wallets and Transactions #2
Wallets and Transactions #2Wallets and Transactions #2
Wallets and Transactions #2
BCWorkspace
 
YOCoin PowerPoint Presentation
YOCoin PowerPoint PresentationYOCoin PowerPoint Presentation
YOCoin PowerPoint Presentation
Crypto Currency
 
Blockchain Technology - The Next Superpower By Priyank Vaghela
Blockchain Technology - The Next Superpower By Priyank VaghelaBlockchain Technology - The Next Superpower By Priyank Vaghela
Blockchain Technology - The Next Superpower By Priyank Vaghela
PriyankVaghela
 
Hands on with multichain
Hands on with multichainHands on with multichain
Hands on with multichain
Roderik van der Veer
 
MultiChain – Private multicurrency blockchain platform
MultiChain – Private multicurrency blockchain platformMultiChain – Private multicurrency blockchain platform
MultiChain – Private multicurrency blockchain platform
Coin Sciences Ltd
 
Lightning Network
Lightning  NetworkLightning  Network
Lightning Network
Felix Crisan
 
Bitcoin
BitcoinBitcoin
Intro to blockchain
Intro to blockchainIntro to blockchain
Intro to blockchain
Ringaile Valiaugaite
 
Bitcoin Transactions Examples
Bitcoin Transactions ExamplesBitcoin Transactions Examples
Bitcoin Transactions Examples
Jeff Flowers
 
Information security in private blockchains
Information security in private blockchainsInformation security in private blockchains
Information security in private blockchains
Coin Sciences Ltd
 
Bitcoin powerpoint
Bitcoin powerpointBitcoin powerpoint
Bitcoin powerpoint
dcarro11
 
Bitcoin Technology Fundamentals - Tutorial 3 – Bitcoin Mining
Bitcoin Technology Fundamentals - Tutorial 3 – Bitcoin MiningBitcoin Technology Fundamentals - Tutorial 3 – Bitcoin Mining
Bitcoin Technology Fundamentals - Tutorial 3 – Bitcoin Mining
Amitesh Raikwar
 
Quick Understanding of Bitcoin/Cryptocurrency.
Quick Understanding of Bitcoin/Cryptocurrency.Quick Understanding of Bitcoin/Cryptocurrency.
Quick Understanding of Bitcoin/Cryptocurrency.
Satish Mudaliar
 
Bitcoin - the basics
Bitcoin - the basicsBitcoin - the basics
Bitcoin - the basics
Uri Nativ
 

What's hot (20)

Introduction to bitcoin
Introduction to bitcoinIntroduction to bitcoin
Introduction to bitcoin
 
Blockchain seminar
Blockchain seminarBlockchain seminar
Blockchain seminar
 
Blockchain Primer Part 1
Blockchain Primer Part 1Blockchain Primer Part 1
Blockchain Primer Part 1
 
Overview of bitcoin
Overview of bitcoinOverview of bitcoin
Overview of bitcoin
 
The Bitcoin blockchain (en)
The Bitcoin blockchain (en)The Bitcoin blockchain (en)
The Bitcoin blockchain (en)
 
Dash(digital cash)
Dash(digital cash)Dash(digital cash)
Dash(digital cash)
 
Wallets and Transactions #2
Wallets and Transactions #2Wallets and Transactions #2
Wallets and Transactions #2
 
YOCoin PowerPoint Presentation
YOCoin PowerPoint PresentationYOCoin PowerPoint Presentation
YOCoin PowerPoint Presentation
 
Blockchain Technology - The Next Superpower By Priyank Vaghela
Blockchain Technology - The Next Superpower By Priyank VaghelaBlockchain Technology - The Next Superpower By Priyank Vaghela
Blockchain Technology - The Next Superpower By Priyank Vaghela
 
Hands on with multichain
Hands on with multichainHands on with multichain
Hands on with multichain
 
MultiChain – Private multicurrency blockchain platform
MultiChain – Private multicurrency blockchain platformMultiChain – Private multicurrency blockchain platform
MultiChain – Private multicurrency blockchain platform
 
Lightning Network
Lightning  NetworkLightning  Network
Lightning Network
 
Bitcoin
BitcoinBitcoin
Bitcoin
 
Intro to blockchain
Intro to blockchainIntro to blockchain
Intro to blockchain
 
Bitcoin Transactions Examples
Bitcoin Transactions ExamplesBitcoin Transactions Examples
Bitcoin Transactions Examples
 
Information security in private blockchains
Information security in private blockchainsInformation security in private blockchains
Information security in private blockchains
 
Bitcoin powerpoint
Bitcoin powerpointBitcoin powerpoint
Bitcoin powerpoint
 
Bitcoin Technology Fundamentals - Tutorial 3 – Bitcoin Mining
Bitcoin Technology Fundamentals - Tutorial 3 – Bitcoin MiningBitcoin Technology Fundamentals - Tutorial 3 – Bitcoin Mining
Bitcoin Technology Fundamentals - Tutorial 3 – Bitcoin Mining
 
Quick Understanding of Bitcoin/Cryptocurrency.
Quick Understanding of Bitcoin/Cryptocurrency.Quick Understanding of Bitcoin/Cryptocurrency.
Quick Understanding of Bitcoin/Cryptocurrency.
 
Bitcoin - the basics
Bitcoin - the basicsBitcoin - the basics
Bitcoin - the basics
 

Similar to Bitcoin for programmers - part 1 version 2

Introduction to Bitcoin for programmers
Introduction to Bitcoin for programmersIntroduction to Bitcoin for programmers
Introduction to Bitcoin for programmers
Wojciech Langiewicz
 
Blockchain, bitcoin, ethereum and ICOs
Blockchain, bitcoin, ethereum and ICOsBlockchain, bitcoin, ethereum and ICOs
Blockchain, bitcoin, ethereum and ICOs
Bogdan Fiedur
 
Bitcoin, Banking and the Blockchain
Bitcoin, Banking and the BlockchainBitcoin, Banking and the Blockchain
Bitcoin, Banking and the Blockchain
seancarmody
 
Bitcoin Blockchain - Under the Hood
Bitcoin Blockchain - Under the HoodBitcoin Blockchain - Under the Hood
Bitcoin Blockchain - Under the Hood
Galin Dinkov
 
“A bitcoin mining rig”
“A bitcoin mining rig”“A bitcoin mining rig”
“A bitcoin mining rig”
glitterlabs
 
Blockchain (and Bitcoin)
Blockchain (and Bitcoin) Blockchain (and Bitcoin)
Blockchain (and Bitcoin)
Nitin Jain
 
2019 blockchain economy
2019 blockchain economy2019 blockchain economy
2019 blockchain economy
Heung-No Lee
 
Fredericksburg LUG Bitcoin slides
Fredericksburg LUG Bitcoin slidesFredericksburg LUG Bitcoin slides
Fredericksburg LUG Bitcoin slides
Alex Akselrod
 
BCHGraz - Meetup #8 - Intro & Ethereum
 BCHGraz - Meetup #8 - Intro & Ethereum BCHGraz - Meetup #8 - Intro & Ethereum
BCHGraz - Meetup #8 - Intro & Ethereum
BlockchainHub Graz
 
Blockchain & Cryptocurrencies Intro - July 2017
Blockchain & Cryptocurrencies Intro - July 2017Blockchain & Cryptocurrencies Intro - July 2017
Blockchain & Cryptocurrencies Intro - July 2017
🔗Audrey Chaing
 
14 Jan17- Nullmeets -Blockchain concept decoded by Ninad Sarang
14 Jan17- Nullmeets -Blockchain concept decoded by Ninad Sarang14 Jan17- Nullmeets -Blockchain concept decoded by Ninad Sarang
14 Jan17- Nullmeets -Blockchain concept decoded by Ninad Sarang
Ninad Sarang
 
Simone Bronzini - Weaknesses of blockchain applications - Codemotion Milan 2018
Simone Bronzini - Weaknesses of blockchain applications - Codemotion Milan 2018Simone Bronzini - Weaknesses of blockchain applications - Codemotion Milan 2018
Simone Bronzini - Weaknesses of blockchain applications - Codemotion Milan 2018
Codemotion
 
Paradigm shift: from the bitcoin Blockchain to Networked Computing
Paradigm shift: from the bitcoin Blockchain to Networked ComputingParadigm shift: from the bitcoin Blockchain to Networked Computing
Paradigm shift: from the bitcoin Blockchain to Networked Computing
kumar641
 
Blockchain, smart contracts - introduction
Blockchain, smart contracts - introductionBlockchain, smart contracts - introduction
Blockchain, smart contracts - introduction
Lukasz Jarmulowicz
 
Blockchains in agriculture
Blockchains in agricultureBlockchains in agriculture
Blockchains in agriculture
Christopher Brewster
 
A research-oriented introduction to the cryptographic currencies (starting wi...
A research-oriented introduction to the cryptographic currencies (starting wi...A research-oriented introduction to the cryptographic currencies (starting wi...
A research-oriented introduction to the cryptographic currencies (starting wi...
vpnmentor
 
Bitcoin 101 - Certified Bitcoin Professional Training Session
Bitcoin 101 - Certified Bitcoin Professional Training SessionBitcoin 101 - Certified Bitcoin Professional Training Session
Bitcoin 101 - Certified Bitcoin Professional Training Session
Lisa Cheng
 
Tutorial blockchain technical overview-ss
Tutorial blockchain technical overview-ssTutorial blockchain technical overview-ss
Tutorial blockchain technical overview-ss
Howard Anglin
 
BLOCKCHAIN PPT.pptx
BLOCKCHAIN PPT.pptxBLOCKCHAIN PPT.pptx
BLOCKCHAIN PPT.pptx
SohanaAmreen
 
Blockchain with scala
Blockchain with scalaBlockchain with scala
Blockchain with scala
Hongchao Liu
 

Similar to Bitcoin for programmers - part 1 version 2 (20)

Introduction to Bitcoin for programmers
Introduction to Bitcoin for programmersIntroduction to Bitcoin for programmers
Introduction to Bitcoin for programmers
 
Blockchain, bitcoin, ethereum and ICOs
Blockchain, bitcoin, ethereum and ICOsBlockchain, bitcoin, ethereum and ICOs
Blockchain, bitcoin, ethereum and ICOs
 
Bitcoin, Banking and the Blockchain
Bitcoin, Banking and the BlockchainBitcoin, Banking and the Blockchain
Bitcoin, Banking and the Blockchain
 
Bitcoin Blockchain - Under the Hood
Bitcoin Blockchain - Under the HoodBitcoin Blockchain - Under the Hood
Bitcoin Blockchain - Under the Hood
 
“A bitcoin mining rig”
“A bitcoin mining rig”“A bitcoin mining rig”
“A bitcoin mining rig”
 
Blockchain (and Bitcoin)
Blockchain (and Bitcoin) Blockchain (and Bitcoin)
Blockchain (and Bitcoin)
 
2019 blockchain economy
2019 blockchain economy2019 blockchain economy
2019 blockchain economy
 
Fredericksburg LUG Bitcoin slides
Fredericksburg LUG Bitcoin slidesFredericksburg LUG Bitcoin slides
Fredericksburg LUG Bitcoin slides
 
BCHGraz - Meetup #8 - Intro & Ethereum
 BCHGraz - Meetup #8 - Intro & Ethereum BCHGraz - Meetup #8 - Intro & Ethereum
BCHGraz - Meetup #8 - Intro & Ethereum
 
Blockchain & Cryptocurrencies Intro - July 2017
Blockchain & Cryptocurrencies Intro - July 2017Blockchain & Cryptocurrencies Intro - July 2017
Blockchain & Cryptocurrencies Intro - July 2017
 
14 Jan17- Nullmeets -Blockchain concept decoded by Ninad Sarang
14 Jan17- Nullmeets -Blockchain concept decoded by Ninad Sarang14 Jan17- Nullmeets -Blockchain concept decoded by Ninad Sarang
14 Jan17- Nullmeets -Blockchain concept decoded by Ninad Sarang
 
Simone Bronzini - Weaknesses of blockchain applications - Codemotion Milan 2018
Simone Bronzini - Weaknesses of blockchain applications - Codemotion Milan 2018Simone Bronzini - Weaknesses of blockchain applications - Codemotion Milan 2018
Simone Bronzini - Weaknesses of blockchain applications - Codemotion Milan 2018
 
Paradigm shift: from the bitcoin Blockchain to Networked Computing
Paradigm shift: from the bitcoin Blockchain to Networked ComputingParadigm shift: from the bitcoin Blockchain to Networked Computing
Paradigm shift: from the bitcoin Blockchain to Networked Computing
 
Blockchain, smart contracts - introduction
Blockchain, smart contracts - introductionBlockchain, smart contracts - introduction
Blockchain, smart contracts - introduction
 
Blockchains in agriculture
Blockchains in agricultureBlockchains in agriculture
Blockchains in agriculture
 
A research-oriented introduction to the cryptographic currencies (starting wi...
A research-oriented introduction to the cryptographic currencies (starting wi...A research-oriented introduction to the cryptographic currencies (starting wi...
A research-oriented introduction to the cryptographic currencies (starting wi...
 
Bitcoin 101 - Certified Bitcoin Professional Training Session
Bitcoin 101 - Certified Bitcoin Professional Training SessionBitcoin 101 - Certified Bitcoin Professional Training Session
Bitcoin 101 - Certified Bitcoin Professional Training Session
 
Tutorial blockchain technical overview-ss
Tutorial blockchain technical overview-ssTutorial blockchain technical overview-ss
Tutorial blockchain technical overview-ss
 
BLOCKCHAIN PPT.pptx
BLOCKCHAIN PPT.pptxBLOCKCHAIN PPT.pptx
BLOCKCHAIN PPT.pptx
 
Blockchain with scala
Blockchain with scalaBlockchain with scala
Blockchain with scala
 

More from Wojciech Langiewicz

JSON API Specificiation
JSON API SpecificiationJSON API Specificiation
JSON API Specificiation
Wojciech Langiewicz
 
Ionic 2 intro
Ionic 2   introIonic 2   intro
Ionic 2 intro
Wojciech Langiewicz
 
Mutation testing in Java
Mutation testing in JavaMutation testing in Java
Mutation testing in Java
Wojciech Langiewicz
 
2014 hadoop wrocław jug
2014 hadoop   wrocław jug2014 hadoop   wrocław jug
2014 hadoop wrocław jug
Wojciech Langiewicz
 
Introduction to Octopress at DRUG
Introduction to Octopress at DRUGIntroduction to Octopress at DRUG
Introduction to Octopress at DRUG
Wojciech Langiewicz
 

More from Wojciech Langiewicz (7)

JSON API Specificiation
JSON API SpecificiationJSON API Specificiation
JSON API Specificiation
 
Ionic 2 intro
Ionic 2   introIonic 2   intro
Ionic 2 intro
 
Mutation testing in Java
Mutation testing in JavaMutation testing in Java
Mutation testing in Java
 
2014 hadoop wrocław jug
2014 hadoop   wrocław jug2014 hadoop   wrocław jug
2014 hadoop wrocław jug
 
Badanie skalowalności HBase
Badanie skalowalności HBaseBadanie skalowalności HBase
Badanie skalowalności HBase
 
Introduction to Octopress at DRUG
Introduction to Octopress at DRUGIntroduction to Octopress at DRUG
Introduction to Octopress at DRUG
 
Hadoop w NK.pl
Hadoop w NK.plHadoop w NK.pl
Hadoop w NK.pl
 

Recently uploaded

20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 

Recently uploaded (20)

20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 

Bitcoin for programmers - part 1 version 2

  • 1. 1 Bitcoin – Introduction for programmers Wojciech Langiewicz @ DRUG #61
  • 2. 2 Live Demo before we start ● Connect to WIFI or make sure you have cellphone reception ● Install Wallets – Android (Mycelium testnet): – Online: ● http://testnetwallet.com/ ● Create payment requests for 0.01 BTC / 10mBTC ● Tweet them @xwlk
  • 3. 3 Scope of this talk ● Introduction – What is Bitcoin, History ● Core concepts – Keys, Addresses – Wallet – Clients – Transaction – Block – Mining – Blockchain
  • 4. 4 What is Bitcoin ● Collection of concepts (and full “ecosystem” of tools) ● Decentralized peer-to-peer system ● Solves 2 main problems: – Is that money authentic (not counterfeit) – Is there only singe occurrence of this specific coin (double spends) ● Has much similarities to cash and gold
  • 5. 5 Key elements of the ecosystem ● Decentralized peer-to-peer network (Bitcoin protocol) ● Public transaction ledger (Blockchain) ● Decentralized currency issuing algorithms (mining) ● Decentralized transaction verification (transaction scripts)
  • 6. 6 Images from book “Mastering Bitcoin” by Andreas M. Antonopoulos Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
  • 7. 7 Few words about history ● Introduced in 2009 by Satoshi Nakamoto ● https://bitcoin.org/bitcoin.pdf ● Combined concepts that existed before ● But have not been combined until then ● POW algorithm + Blockchain
  • 8. 8 Bitcoin Address ● Something like this: 19wQhQEF3ANe6Dsiiahq3BFkdzb4K8XZUf ● Usually shown as QR code: ● Address is a Base58 encoded form of the public key ● Based on the address prefix, you can figure out what type of address it is. ● Types of addresses: Pubkey hash, script hash, private key ● Address reuse ● A word about HD Wallets
  • 9. 9 Bitcoin Keys - ECDSA ● Private keys – numbers between 0 and 2^256 ● Public key can be calculated from the private key ● Public key can be represented as Base58 encoding, HEX number, etc ● Private keys can also be encoded as Base58 – this is called WIF format – most common way to export/import keys between wallets
  • 10. 10 Wallet ● Client software running on: server, desktop, phone, “in the cloud”, it manages keys, signs transactions, generates new keys, etc ● Paper Wallets ● Bitcoin-qt ● Hardware wallets (Trezor) ● Electrum, Armory, Multibit ● Blockchain.info ● Mobile wallets with intermediate server ● Other web wallets
  • 11. 11 Wallet vs HD Wallet Images from book “Mastering Bitcoin” by Andreas M. Antonopoulos Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. Standard Wallet HD Wallet
  • 13. 13 Full nodes ● Full nodes store full copy of the blockchain ● Currently over 40GB of data ● Usually need for server-side type of applications ● Provide JSON-RPC API ● Example: Satoshi client, btcd
  • 14. 14 SPV nodes ● Lighweight nodes ● Use Simplified Payment Verification instead of ITV ● Suitable for desktops, phones ● Instead of downloading full blockchain ● Download transactions only for their addresses ● Security and privacy implications ● Example: bitcoinj
  • 15. 15 Transaction ● Coinbase transaction ● Each transaction has 1 or more inputs and 1 or more outputs ● Transaction “moves money” - changes owner ● Transactions take inputs and translate it into outputs ● Those outputs can serve as inputs to the new transaction
  • 16. 16 Images from book “Mastering Bitcoin” by Andreas M. Antonopoulos Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
  • 17. 17 Spending a transaction - P2PH ● Example of transaction type “Pay to pubkey hash” ● ScriptPubKey: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG ● scriptSig: <sig> <pubKey> ● Script: <sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
  • 18. 18
  • 20. 20 Advanced transaction types ● Multi signature (multisig) ● OP_RETURN ● Anyone can spend ● Pay to script hash
  • 21. 21 Blocks ● Genesis block ● Mining – process of confirming a block ● Each block points to a previous one creating a blockchain ● Quite few similarities to git (instead you can't merge)
  • 22. 22 Mining ● Merges transactions into blocks ● Finds nonce that “solves” the block ● Once the solution is found – block is published ● Published – appended to the blockchain ● Published blocks are verified by other nodes ● This sends coinbase transaction to the miner + all fees ● Proof of Work – 10 minutes per block ● Difficulty
  • 23. 23 Mining pools ● Chance to find a solution to a block are small ● Small miners join in pools where they share a profit ● Instead of finding a block every year and getting 25BTC ● You will get 0.5 BTC per week. ● You have to trust the pool operator or use p2pool
  • 24. 24 Blockchain ● “A chain of blocks” ● Clever approach to consensus problem ● Miners after finding a new block publish it on the network ● You base your security on a height of a transaction ● Ensures that there are no duplication
  • 25. 25 Blockchain fork ● Situation when 2 blocks are found at the same time ● Bitcoin network is in the state of a fork ● 10 minutes later a new block is found that is based on one of the forks ● All Bitcoin nodes quickly switch to the longer branch ● Transactions from the shorter branch are orphaned and will be processed shortly after ● Next slides: Fork example
  • 26. 26Images from book “Mastering Bitcoin” by Andreas M. Antonopoulos Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
  • 27. 27Images from book “Mastering Bitcoin” by Andreas M. Antonopoulos Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
  • 28. 28Images from book “Mastering Bitcoin” by Andreas M. Antonopoulos Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
  • 29. 29Images from book “Mastering Bitcoin” by Andreas M. Antonopoulos Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
  • 30. 30Images from book “Mastering Bitcoin” by Andreas M. Antonopoulos Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
  • 31. 31 Few words about the 51% attack ● Theoretically possible even with 40-50% of power ● Can be used to destabilize network for some period of time ● Can help to create a double-spend ● In no case you'll be able to spend coins you don't have ● This attack is not practical ● Miners will make more BTC by being honest
  • 33. 33 Next time ● More about Bitcoin clients ● Bitcoin-core JSON-RPC API ● Bitcoinj ● Raw transactions ● Blockchain details ● Security ● Bitcoin flaws