SlideShare une entreprise Scribd logo
1  sur  18
LOGGING-IN with BITCOIN
( a guide to life without email based registrations and paywalls )
A DEVELOPER WITHOUT CHOICE IS AN UNHAPPY DEVELOPER
WHY SHOULD WEB
DEVELOPERS CARE
ABOUT BITCOIN…?
BITCOIN SUCKS
914,000 RESULTS
https://www.google.com/search?q=bitcoin+sucks
BITCOIN ROCKS
58,800,000 RESULTS
https://www.google.com/search?q=bitcoin+rocks
64 TIMES AS GOOD AS ITS NOT
( according to Google – Nov 2013 )
WHO AM I TO TELL YOU…?
Mark Smalley – http://twitter.com/m_smalley
R1 DOT MY Sdn Bhd – http://r1.my

Been Living in Malaysia for 16 Years
Developing Web-Applications for 15 Years
MongoDB Master / NoSQL Specialist
Passion for Community Management
Family Involved with Equity Fund Management
WE ALREADY HAVE CHOICE – WE EVEN HAVE PAYPAL

• Square, Stripe, V.me, Simple, etc …
• Only available to developers in States / Europe
• Local alternatives are complicated, costly & useless
• No options for instant starts …
• No options for anonymity or the billions of us unbanked
• In Malaysia we only have PayPal and iPay88
BITCOIN THE TECHNOLOGY STACK

• Uses LevelDB to access (via JSON) a globally distributed
public ledger of all transactions
• Send and receive payments instantly and directly via
JSON-RPC calls from any server-side language …
• Existing wrappers, frameworks, documentation, libraries
and support for PHP, Ruby, NodeJS
• Still in Beta (0.8) with Market Cap of US$12.8 Billion (Nov 2013)
• Version 0.9 to bring payment requests and receipts!
THE POWER OF DISTRIBUTED LEDGERS

• Removes central point of control (and failure)
– For developers this means an ALWAYS on API

• Can be used for things other than transactions
– For developers this means timestamps and cookies

• Provides a public record and optional anonymity
– For developers this means instant sign-up without verification
LET’S BUILD SOMETHING – LOGIN WITHOUT EMAIL

Before we begin, let’s ask why do such a crazy thing…?
• We do not need to manage our own database!
• We can integrate sign-up and payment as one process
• We do not force our users to provide their identity
• Nobody needs to sign-up or apply for accounts
• We can do business globally with anyone who has internet
JUMPING INTO CODE :: TABLE OF CONTENTS
https://github.com/msmalley/BCE/tree/master/php-login

// Include BTC login class
$login = new mongobase_btc_login();

// Get user information
$user = $login->user();
// Check if user is logged-in or not...?
$logged_in = $login->logged_in($user['uid']);
// Create and display relevant HTML
$html = $login->html($logged_in, $user['address']);
echo $html;
PART ONE – GET USER INFO
$user = $login->user();

// Check if got existing UID cookie
if(isset($_COOKIE[$cookie_name]))
{
$uid = $_COOKIE[$cookie_name];
// Get existing BTC address
$addresses = $this::$btc->query(array(
'function‘ => 'getaddressesbyaccount',
'options‘ => $cookie_name.'_'.$uid
));
$address = $addresses[0];
}
PART ONE – GET USER INFO (continued)
$user = $login->user();

// Else create a new UID cookie
}else{
// Gather server settings
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$user_time = $_SERVER['REQUEST_TIME'];
// Generate unique ID
$uid = hash('sha256',$user_salt.$user_agent.$user_time);
// Set UID cookie
setcookie($cookie_name, $uid, time() + $cookie_life);
// Create new BTC address
$address = $this::$btc->query(array(
'function‘ => 'getnewaddress',
'options‘ => $cookie_name.'_'.$uid
));
}
PART TWO – CHECK IF LOGGED-IN
$logged_in = $login->logged_in($user['uid']);

// Not by default
$logged_in = false;
// Check if got balance
$uid_balance = $this::$btc->query(array(
'function’ => 'getbalance',
'options’ => $cookie_name.'_'.$uid
));
// Check if logged-in
$details = $this->timed_cookies();
$logged_in = $details['logged_in'];
if(!$logged_in && $uid_balance > 0)
{
// Not logged-in but got transactions
$logged_in = $this->set_cookies();
}
return $logged_in;
PART TWO – CHECK IF LOGGED-IN (continued)
$details = $this->timed_cookies(); // excluding sanity checks

foreach($_COOKIE as $key => $value){
$key_array = explode('_', $key);
if(count($key_array) == 2 && $key_array[0] == $cookie_name) {
$temp_uid = $key_array[1];
$txid = $_COOKIE[$cookie_name.'_'.$temp_uid];
$transactions = $this::$btc->query(array(
'function'=>'listtransactions',
'options'=>$cookie_name.'_'.$temp_uid
));
foreach($transactions as $transaction) {
$hashed_id = hash('sha256', $txid_salt.$transaction['txid']);
if($hashed_id == $txid) {
$uid = $temp_uid;
$address = $this::$btc->query(array(
'function'=>'getaddressesbyaccount',
'options'=>$cookie_name.'_'.$uid
));
$logged_in = true;
}
}
}
}
PART TWO – CHECK IF LOGGED-IN (continued)
$logged_in = $this->set_cookies(); // excluding sanity checks

$logged_in = false;
$recent_transactions = $this::$btc->query(array(
'function'=>'listtransactions',
'options'=>$cookie_name.'_'.$uid
));
$txid = $recent_transactions[0]['txid'];
$amount = $recent_transactions[0]['amount'];
if($amount > 0)
{
$logged_in = true;
$number_of_days_bought = $amount / $btc_per_day;
$new_cookie_life = 86400 * $number_of_days_bought;
// Manage Cookies
$id = hash('sha256',$txid_salt.$txid),;
setcookie($cookie_name.'_'.$uid, $id, time() + $new_cookie_life);
setcookie($this::$cookie_name, false, time() - 1);
}
return $logged_in;

Source Code: https://github.com/msmalley/BCE/tree/master/php-login
THANKS FOR LISTENING
LEARN MORE - @m_smalley

HAPPY-HACKING

Contenu connexe

Similaire à Logging-In with Bitcoin - Paywalls without Emails

Practical Secure Coding Workshop - {DECIPHER} Hackathon
Practical Secure Coding Workshop - {DECIPHER} HackathonPractical Secure Coding Workshop - {DECIPHER} Hackathon
Practical Secure Coding Workshop - {DECIPHER} HackathonStefan Streichsbier
 
Skytap Google Apps
Skytap Google AppsSkytap Google Apps
Skytap Google AppsSkytap
 
NZYP Project Casestudy using SilverStripe CMS
NZYP Project Casestudy using SilverStripe CMSNZYP Project Casestudy using SilverStripe CMS
NZYP Project Casestudy using SilverStripe CMSCam Findlay
 
INSTASUITE REVIEW – DISCOUNT AND HUGE BONUS
INSTASUITE REVIEW – DISCOUNT AND HUGE BONUSINSTASUITE REVIEW – DISCOUNT AND HUGE BONUS
INSTASUITE REVIEW – DISCOUNT AND HUGE BONUSĐức Nguyễn
 
Automating some google things
Automating some google thingsAutomating some google things
Automating some google thingsScott Sunderland
 
Externalizing Authorization in Micro Services world
Externalizing Authorization in Micro Services worldExternalizing Authorization in Micro Services world
Externalizing Authorization in Micro Services worldSitaraman Lakshminarayanan
 
Digging Deeper into Desktop and Mobile App Security
Digging Deeper into Desktop and Mobile App SecurityDigging Deeper into Desktop and Mobile App Security
Digging Deeper into Desktop and Mobile App SecuritySalesforce Developers
 
Efficient Search Campaigns SAScon May 2012
Efficient Search Campaigns SAScon May 2012Efficient Search Campaigns SAScon May 2012
Efficient Search Campaigns SAScon May 2012Steve Lock
 
Cross-Platform Authentication with Google+ Sign-In
Cross-Platform Authentication with Google+ Sign-InCross-Platform Authentication with Google+ Sign-In
Cross-Platform Authentication with Google+ Sign-InPeter Friese
 
Jessica Herndon Sql Portfolio
Jessica Herndon Sql PortfolioJessica Herndon Sql Portfolio
Jessica Herndon Sql PortfolioJessicaLHerndon
 
The Power of Document Generation with Nintex
The Power of Document Generation with NintexThe Power of Document Generation with Nintex
The Power of Document Generation with NintexBrian Caauwe
 
API Security - OWASP top 10 for APIs + tips for pentesters
API Security - OWASP top 10 for APIs + tips for pentestersAPI Security - OWASP top 10 for APIs + tips for pentesters
API Security - OWASP top 10 for APIs + tips for pentestersInon Shkedy
 
Social Gold in-Flash Webinar Jan 2010
Social Gold in-Flash Webinar Jan 2010Social Gold in-Flash Webinar Jan 2010
Social Gold in-Flash Webinar Jan 2010Social Gold
 
Social Gold In-Flash Payments Webinar
Social Gold In-Flash Payments WebinarSocial Gold In-Flash Payments Webinar
Social Gold In-Flash Payments WebinarSocial Gold
 
SPSRED - BCS, REST ans Subscriptions
SPSRED - BCS, REST ans SubscriptionsSPSRED - BCS, REST ans Subscriptions
SPSRED - BCS, REST ans SubscriptionsChris Givens
 
SwatiNaikResumeAug2016
SwatiNaikResumeAug2016SwatiNaikResumeAug2016
SwatiNaikResumeAug2016swati Naik
 

Similaire à Logging-In with Bitcoin - Paywalls without Emails (20)

Practical Secure Coding Workshop - {DECIPHER} Hackathon
Practical Secure Coding Workshop - {DECIPHER} HackathonPractical Secure Coding Workshop - {DECIPHER} Hackathon
Practical Secure Coding Workshop - {DECIPHER} Hackathon
 
Skytap Google Apps
Skytap Google AppsSkytap Google Apps
Skytap Google Apps
 
NZYP Project Casestudy using SilverStripe CMS
NZYP Project Casestudy using SilverStripe CMSNZYP Project Casestudy using SilverStripe CMS
NZYP Project Casestudy using SilverStripe CMS
 
INSTASUITE REVIEW – DISCOUNT AND HUGE BONUS
INSTASUITE REVIEW – DISCOUNT AND HUGE BONUSINSTASUITE REVIEW – DISCOUNT AND HUGE BONUS
INSTASUITE REVIEW – DISCOUNT AND HUGE BONUS
 
CS-Cart Block.io Bitcoin Wallet
CS-Cart Block.io Bitcoin WalletCS-Cart Block.io Bitcoin Wallet
CS-Cart Block.io Bitcoin Wallet
 
Automating some google things
Automating some google thingsAutomating some google things
Automating some google things
 
Externalizing Authorization in Micro Services world
Externalizing Authorization in Micro Services worldExternalizing Authorization in Micro Services world
Externalizing Authorization in Micro Services world
 
Digging Deeper into Desktop and Mobile App Security
Digging Deeper into Desktop and Mobile App SecurityDigging Deeper into Desktop and Mobile App Security
Digging Deeper into Desktop and Mobile App Security
 
Efficient Search Campaigns SAScon May 2012
Efficient Search Campaigns SAScon May 2012Efficient Search Campaigns SAScon May 2012
Efficient Search Campaigns SAScon May 2012
 
Cross-Platform Authentication with Google+ Sign-In
Cross-Platform Authentication with Google+ Sign-InCross-Platform Authentication with Google+ Sign-In
Cross-Platform Authentication with Google+ Sign-In
 
Jessica Herndon Sql Portfolio
Jessica Herndon Sql PortfolioJessica Herndon Sql Portfolio
Jessica Herndon Sql Portfolio
 
The Power of Document Generation with Nintex
The Power of Document Generation with NintexThe Power of Document Generation with Nintex
The Power of Document Generation with Nintex
 
API Security - OWASP top 10 for APIs + tips for pentesters
API Security - OWASP top 10 for APIs + tips for pentestersAPI Security - OWASP top 10 for APIs + tips for pentesters
API Security - OWASP top 10 for APIs + tips for pentesters
 
power
powerpower
power
 
Social Gold in-Flash Webinar Jan 2010
Social Gold in-Flash Webinar Jan 2010Social Gold in-Flash Webinar Jan 2010
Social Gold in-Flash Webinar Jan 2010
 
Social Gold In-Flash Payments Webinar
Social Gold In-Flash Payments WebinarSocial Gold In-Flash Payments Webinar
Social Gold In-Flash Payments Webinar
 
Features of the Ventaforce Network Marketing Software
Features of the Ventaforce Network Marketing SoftwareFeatures of the Ventaforce Network Marketing Software
Features of the Ventaforce Network Marketing Software
 
www.mel d.net.in
www.mel d.net.inwww.mel d.net.in
www.mel d.net.in
 
SPSRED - BCS, REST ans Subscriptions
SPSRED - BCS, REST ans SubscriptionsSPSRED - BCS, REST ans Subscriptions
SPSRED - BCS, REST ans Subscriptions
 
SwatiNaikResumeAug2016
SwatiNaikResumeAug2016SwatiNaikResumeAug2016
SwatiNaikResumeAug2016
 

Plus de Mark Smalley

An Introduction to Upgradable Smart Contracts
An Introduction to Upgradable Smart ContractsAn Introduction to Upgradable Smart Contracts
An Introduction to Upgradable Smart ContractsMark Smalley
 
Blockchain Developers Malaysia Meetup #4 - CRUDy Ethereum Contracts, Wallet W...
Blockchain Developers Malaysia Meetup #4 - CRUDy Ethereum Contracts, Wallet W...Blockchain Developers Malaysia Meetup #4 - CRUDy Ethereum Contracts, Wallet W...
Blockchain Developers Malaysia Meetup #4 - CRUDy Ethereum Contracts, Wallet W...Mark Smalley
 
BDM Meetup 2 - Blockchain Basics - Generating Keys for BloqPress
BDM Meetup 2 - Blockchain Basics - Generating Keys for BloqPressBDM Meetup 2 - Blockchain Basics - Generating Keys for BloqPress
BDM Meetup 2 - Blockchain Basics - Generating Keys for BloqPressMark Smalley
 
BDM Meetup #1 - Blockchains for Developers - Part 01
BDM Meetup #1 - Blockchains for Developers - Part 01BDM Meetup #1 - Blockchains for Developers - Part 01
BDM Meetup #1 - Blockchains for Developers - Part 01Mark Smalley
 
Banking on The Future of Blockchains
Banking on The Future of BlockchainsBanking on The Future of Blockchains
Banking on The Future of BlockchainsMark Smalley
 
LVLUPKL - My Life on The Blockchain
LVLUPKL - My Life on The BlockchainLVLUPKL - My Life on The Blockchain
LVLUPKL - My Life on The BlockchainMark Smalley
 
Blockstrap at FOSS Asia - 2015 - Building Browser-Based Blockchain Applications
Blockstrap at FOSS Asia - 2015 - Building Browser-Based Blockchain ApplicationsBlockstrap at FOSS Asia - 2015 - Building Browser-Based Blockchain Applications
Blockstrap at FOSS Asia - 2015 - Building Browser-Based Blockchain ApplicationsMark Smalley
 
Bitcoin is Still Technology - Presented at Bitcoin World Conference KL - 2014
Bitcoin is Still Technology - Presented at Bitcoin World Conference KL - 2014Bitcoin is Still Technology - Presented at Bitcoin World Conference KL - 2014
Bitcoin is Still Technology - Presented at Bitcoin World Conference KL - 2014Mark Smalley
 
Programmable Money - Visual Guide to Bitcoin as a Technology
Programmable Money - Visual Guide to Bitcoin as a TechnologyProgrammable Money - Visual Guide to Bitcoin as a Technology
Programmable Money - Visual Guide to Bitcoin as a TechnologyMark Smalley
 
Introducing Bitcoin :: The (Mostly) Visual-Guide to Cryptographic Currencies
Introducing Bitcoin :: The (Mostly) Visual-Guide to Cryptographic CurrenciesIntroducing Bitcoin :: The (Mostly) Visual-Guide to Cryptographic Currencies
Introducing Bitcoin :: The (Mostly) Visual-Guide to Cryptographic CurrenciesMark Smalley
 
1st NoSQL Asia Event in Malaysia
1st NoSQL Asia Event in Malaysia1st NoSQL Asia Event in Malaysia
1st NoSQL Asia Event in MalaysiaMark Smalley
 
MongoDB Day KL - 2013 :: Keynote - The State of MongoDB in Malaysia
MongoDB Day KL - 2013 :: Keynote - The State of MongoDB in MalaysiaMongoDB Day KL - 2013 :: Keynote - The State of MongoDB in Malaysia
MongoDB Day KL - 2013 :: Keynote - The State of MongoDB in MalaysiaMark Smalley
 
JSON, The Argonauts and Mark
JSON, The Argonauts and MarkJSON, The Argonauts and Mark
JSON, The Argonauts and MarkMark Smalley
 
JSON and The Argonauts
JSON and The ArgonautsJSON and The Argonauts
JSON and The ArgonautsMark Smalley
 
Serving Images with GridFS
Serving Images with GridFSServing Images with GridFS
Serving Images with GridFSMark Smalley
 
Why I Believe MongoDB is The Dog's Bollocks
Why I Believe MongoDB is The Dog's BollocksWhy I Believe MongoDB is The Dog's Bollocks
Why I Believe MongoDB is The Dog's BollocksMark Smalley
 
Introducing MongoPress
Introducing MongoPressIntroducing MongoPress
Introducing MongoPressMark Smalley
 

Plus de Mark Smalley (18)

An Introduction to Upgradable Smart Contracts
An Introduction to Upgradable Smart ContractsAn Introduction to Upgradable Smart Contracts
An Introduction to Upgradable Smart Contracts
 
Blockchain Developers Malaysia Meetup #4 - CRUDy Ethereum Contracts, Wallet W...
Blockchain Developers Malaysia Meetup #4 - CRUDy Ethereum Contracts, Wallet W...Blockchain Developers Malaysia Meetup #4 - CRUDy Ethereum Contracts, Wallet W...
Blockchain Developers Malaysia Meetup #4 - CRUDy Ethereum Contracts, Wallet W...
 
BDM Meetup 2 - Blockchain Basics - Generating Keys for BloqPress
BDM Meetup 2 - Blockchain Basics - Generating Keys for BloqPressBDM Meetup 2 - Blockchain Basics - Generating Keys for BloqPress
BDM Meetup 2 - Blockchain Basics - Generating Keys for BloqPress
 
BDM Meetup #1 - Blockchains for Developers - Part 01
BDM Meetup #1 - Blockchains for Developers - Part 01BDM Meetup #1 - Blockchains for Developers - Part 01
BDM Meetup #1 - Blockchains for Developers - Part 01
 
Banking on The Future of Blockchains
Banking on The Future of BlockchainsBanking on The Future of Blockchains
Banking on The Future of Blockchains
 
LVLUPKL - My Life on The Blockchain
LVLUPKL - My Life on The BlockchainLVLUPKL - My Life on The Blockchain
LVLUPKL - My Life on The Blockchain
 
Blockstrap at FOSS Asia - 2015 - Building Browser-Based Blockchain Applications
Blockstrap at FOSS Asia - 2015 - Building Browser-Based Blockchain ApplicationsBlockstrap at FOSS Asia - 2015 - Building Browser-Based Blockchain Applications
Blockstrap at FOSS Asia - 2015 - Building Browser-Based Blockchain Applications
 
Bitcoin is Still Technology - Presented at Bitcoin World Conference KL - 2014
Bitcoin is Still Technology - Presented at Bitcoin World Conference KL - 2014Bitcoin is Still Technology - Presented at Bitcoin World Conference KL - 2014
Bitcoin is Still Technology - Presented at Bitcoin World Conference KL - 2014
 
Programmable Money - Visual Guide to Bitcoin as a Technology
Programmable Money - Visual Guide to Bitcoin as a TechnologyProgrammable Money - Visual Guide to Bitcoin as a Technology
Programmable Money - Visual Guide to Bitcoin as a Technology
 
Introducing Bitcoin :: The (Mostly) Visual-Guide to Cryptographic Currencies
Introducing Bitcoin :: The (Mostly) Visual-Guide to Cryptographic CurrenciesIntroducing Bitcoin :: The (Mostly) Visual-Guide to Cryptographic Currencies
Introducing Bitcoin :: The (Mostly) Visual-Guide to Cryptographic Currencies
 
1st NoSQL Asia Event in Malaysia
1st NoSQL Asia Event in Malaysia1st NoSQL Asia Event in Malaysia
1st NoSQL Asia Event in Malaysia
 
MongoDB Day KL - 2013 :: Keynote - The State of MongoDB in Malaysia
MongoDB Day KL - 2013 :: Keynote - The State of MongoDB in MalaysiaMongoDB Day KL - 2013 :: Keynote - The State of MongoDB in Malaysia
MongoDB Day KL - 2013 :: Keynote - The State of MongoDB in Malaysia
 
JSON, The Argonauts and Mark
JSON, The Argonauts and MarkJSON, The Argonauts and Mark
JSON, The Argonauts and Mark
 
JSON and The Argonauts
JSON and The ArgonautsJSON and The Argonauts
JSON and The Argonauts
 
KL MUG 9
KL MUG 9KL MUG 9
KL MUG 9
 
Serving Images with GridFS
Serving Images with GridFSServing Images with GridFS
Serving Images with GridFS
 
Why I Believe MongoDB is The Dog's Bollocks
Why I Believe MongoDB is The Dog's BollocksWhy I Believe MongoDB is The Dog's Bollocks
Why I Believe MongoDB is The Dog's Bollocks
 
Introducing MongoPress
Introducing MongoPressIntroducing MongoPress
Introducing MongoPress
 

Dernier

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 

Dernier (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

Logging-In with Bitcoin - Paywalls without Emails

  • 1. LOGGING-IN with BITCOIN ( a guide to life without email based registrations and paywalls )
  • 2. A DEVELOPER WITHOUT CHOICE IS AN UNHAPPY DEVELOPER
  • 3. WHY SHOULD WEB DEVELOPERS CARE ABOUT BITCOIN…?
  • 6. 64 TIMES AS GOOD AS ITS NOT ( according to Google – Nov 2013 )
  • 7. WHO AM I TO TELL YOU…? Mark Smalley – http://twitter.com/m_smalley R1 DOT MY Sdn Bhd – http://r1.my Been Living in Malaysia for 16 Years Developing Web-Applications for 15 Years MongoDB Master / NoSQL Specialist Passion for Community Management Family Involved with Equity Fund Management
  • 8. WE ALREADY HAVE CHOICE – WE EVEN HAVE PAYPAL • Square, Stripe, V.me, Simple, etc … • Only available to developers in States / Europe • Local alternatives are complicated, costly & useless • No options for instant starts … • No options for anonymity or the billions of us unbanked • In Malaysia we only have PayPal and iPay88
  • 9. BITCOIN THE TECHNOLOGY STACK • Uses LevelDB to access (via JSON) a globally distributed public ledger of all transactions • Send and receive payments instantly and directly via JSON-RPC calls from any server-side language … • Existing wrappers, frameworks, documentation, libraries and support for PHP, Ruby, NodeJS • Still in Beta (0.8) with Market Cap of US$12.8 Billion (Nov 2013) • Version 0.9 to bring payment requests and receipts!
  • 10. THE POWER OF DISTRIBUTED LEDGERS • Removes central point of control (and failure) – For developers this means an ALWAYS on API • Can be used for things other than transactions – For developers this means timestamps and cookies • Provides a public record and optional anonymity – For developers this means instant sign-up without verification
  • 11. LET’S BUILD SOMETHING – LOGIN WITHOUT EMAIL Before we begin, let’s ask why do such a crazy thing…? • We do not need to manage our own database! • We can integrate sign-up and payment as one process • We do not force our users to provide their identity • Nobody needs to sign-up or apply for accounts • We can do business globally with anyone who has internet
  • 12. JUMPING INTO CODE :: TABLE OF CONTENTS https://github.com/msmalley/BCE/tree/master/php-login // Include BTC login class $login = new mongobase_btc_login(); // Get user information $user = $login->user(); // Check if user is logged-in or not...? $logged_in = $login->logged_in($user['uid']); // Create and display relevant HTML $html = $login->html($logged_in, $user['address']); echo $html;
  • 13. PART ONE – GET USER INFO $user = $login->user(); // Check if got existing UID cookie if(isset($_COOKIE[$cookie_name])) { $uid = $_COOKIE[$cookie_name]; // Get existing BTC address $addresses = $this::$btc->query(array( 'function‘ => 'getaddressesbyaccount', 'options‘ => $cookie_name.'_'.$uid )); $address = $addresses[0]; }
  • 14. PART ONE – GET USER INFO (continued) $user = $login->user(); // Else create a new UID cookie }else{ // Gather server settings $user_agent = $_SERVER['HTTP_USER_AGENT']; $user_time = $_SERVER['REQUEST_TIME']; // Generate unique ID $uid = hash('sha256',$user_salt.$user_agent.$user_time); // Set UID cookie setcookie($cookie_name, $uid, time() + $cookie_life); // Create new BTC address $address = $this::$btc->query(array( 'function‘ => 'getnewaddress', 'options‘ => $cookie_name.'_'.$uid )); }
  • 15. PART TWO – CHECK IF LOGGED-IN $logged_in = $login->logged_in($user['uid']); // Not by default $logged_in = false; // Check if got balance $uid_balance = $this::$btc->query(array( 'function’ => 'getbalance', 'options’ => $cookie_name.'_'.$uid )); // Check if logged-in $details = $this->timed_cookies(); $logged_in = $details['logged_in']; if(!$logged_in && $uid_balance > 0) { // Not logged-in but got transactions $logged_in = $this->set_cookies(); } return $logged_in;
  • 16. PART TWO – CHECK IF LOGGED-IN (continued) $details = $this->timed_cookies(); // excluding sanity checks foreach($_COOKIE as $key => $value){ $key_array = explode('_', $key); if(count($key_array) == 2 && $key_array[0] == $cookie_name) { $temp_uid = $key_array[1]; $txid = $_COOKIE[$cookie_name.'_'.$temp_uid]; $transactions = $this::$btc->query(array( 'function'=>'listtransactions', 'options'=>$cookie_name.'_'.$temp_uid )); foreach($transactions as $transaction) { $hashed_id = hash('sha256', $txid_salt.$transaction['txid']); if($hashed_id == $txid) { $uid = $temp_uid; $address = $this::$btc->query(array( 'function'=>'getaddressesbyaccount', 'options'=>$cookie_name.'_'.$uid )); $logged_in = true; } } } }
  • 17. PART TWO – CHECK IF LOGGED-IN (continued) $logged_in = $this->set_cookies(); // excluding sanity checks $logged_in = false; $recent_transactions = $this::$btc->query(array( 'function'=>'listtransactions', 'options'=>$cookie_name.'_'.$uid )); $txid = $recent_transactions[0]['txid']; $amount = $recent_transactions[0]['amount']; if($amount > 0) { $logged_in = true; $number_of_days_bought = $amount / $btc_per_day; $new_cookie_life = 86400 * $number_of_days_bought; // Manage Cookies $id = hash('sha256',$txid_salt.$txid),; setcookie($cookie_name.'_'.$uid, $id, time() + $new_cookie_life); setcookie($this::$cookie_name, false, time() - 1); } return $logged_in; Source Code: https://github.com/msmalley/BCE/tree/master/php-login
  • 18. THANKS FOR LISTENING LEARN MORE - @m_smalley HAPPY-HACKING