SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Semelhante a 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 Payments Webinar
Social Gold In-Flash Payments WebinarSocial Gold In-Flash Payments Webinar
Social Gold In-Flash Payments WebinarSocial Gold
 
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
 
SPSRED - BCS, REST ans Subscriptions
SPSRED - BCS, REST ans SubscriptionsSPSRED - BCS, REST ans Subscriptions
SPSRED - BCS, REST ans SubscriptionsChris Givens
 
SwatiNaikResumeAug2016
SwatiNaikResumeAug2016SwatiNaikResumeAug2016
SwatiNaikResumeAug2016swati Naik
 

Semelhante a 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 Payments Webinar
Social Gold In-Flash Payments WebinarSocial Gold In-Flash Payments Webinar
Social Gold In-Flash Payments Webinar
 
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
 
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
 

Mais 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
 

Mais 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
 

Último

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 

Último (20)

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 

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