BitcoinJS Webtuesday Presentation

Preview:

Citation preview

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

A divorce and new beginnings

Stefan Thomas • WeUseCoins.com

BitcoinJS

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

login

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

login

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

login

- Web developer 13 years

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

login

- Web developer 13 years

- Bitcoin evangelist

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

login

- Web developer 13 years

- Bitcoin evangelist 6 months

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

login

- Web developer 13 years

- Bitcoin evangelist 6 months

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

login

- Web developer 13 years

- Bitcoin evangelist 6 months

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

ls

- What’s Bitcoin? (1 slide version) - Things that are... sub-optimal - Node.js to the rescue!

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

man bitcoin

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

man bitcoin

- Limited set of tokens

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

man bitcoin

- Limited set of tokens - Decentralized

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

man bitcoin

- Limited set of tokens - Decentralized - Open-Source

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

man bitcoin

- Limited set of tokens - Decentralized - Open-Source

= Internet Money

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

wget blk*.dat

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

wget blk*.dat

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

wget blk*.dat

140000 x

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

wget blk*.dat

140000 x

= 620 MB

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

wget blk*.dat

140000 x

= 620 MB => 6-24 hours

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

wget blk*.dat

140000 x

= 620 MB => 6-24 hours

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

rm wallet.dat

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

rm wallet.dat

VirtualBox Dropbox Ironkey +

Truecrypt

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

rm wallet.dat

VirtualBox Dropbox Ironkey +

Truecrypt

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

rm wallet.dat

VirtualBox Dropbox Ironkey +

Truecrypt

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

rm wallet.dat

VirtualBox Dropbox Ironkey +

Truecrypt

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

rm wallet.dat

VirtualBox Dropbox Ironkey +

Truecrypt

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

rm wallet.dat

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

rm wallet.dat

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

scp wallet.dat

These additions include nine new SCADA exploits, improved 64-

bit Linux payloads, exploits for Firefox and Internet Explorer,

full-HTTPS and HTTP Meterpreter stagers, and post-exploitation

modules for dumping passwords from Outlook, WSFTP,

CoreFTP, SmartFTP, TotalCommander, BitCoin and many other

applications.

Metasploit 4.0

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

scp wallet.dat

These additions include nine new SCADA exploits, improved 64-

bit Linux payloads, exploits for Firefox and Internet Explorer,

full-HTTPS and HTTP Meterpreter stagers, and post-exploitation

modules for dumping passwords from Outlook, WSFTP,

CoreFTP, SmartFTP, TotalCommander, BitCoin and many other

applications.

Metasploit 4.0

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

scp wallet.dat

Metasploit 4.0 blah new post exploitation modules

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

scp wallet.dat

Metasploit 4.0 blah new post exploitation modules

blah blah for dumping passwords blah

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

scp wallet.dat

Metasploit 4.0

Blah, BitCoin, Blah, …

blah new post exploitation modules

blah blah for dumping passwords blah

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

scp wallet.dat

Metasploit 4.0

Blah, BitCoin, Blah, …

blah new post exploitation modules

blah blah for dumping passwords blah

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

cat cmn_sense.txt

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

cat cmn_sense.txt

Block chain

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

uml blockchain

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

cat cmn_sense.txt

Block chain

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

cat cmn_sense.txt

Block chain UI

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

cat cmn_sense.txt

Block chain UI Wallet

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

cat cmn_sense.txt

Block chain UI Wallet

• HUGE!! • Global • Public

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

cat cmn_sense.txt

Block chain UI Wallet

• HUGE!! • Global • Public

-> Server

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

cat cmn_sense.txt

Block chain UI Wallet

• HUGE!! • Global • Public

• Complex • Personal • Private

-> Server

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

cat cmn_sense.txt

Block chain UI Wallet

• HUGE!! • Global • Public

• Complex • Personal • Private

-> Server -> Client

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

cat cmn_sense.txt

Block chain UI Wallet

• HUGE!! • Global • Public

• Complex • Personal • Private

• Simple • Personal • Secret!!

-> Server -> Client

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

cat cmn_sense.txt

Block chain UI Wallet

• HUGE!! • Global • Public

• Complex • Personal • Private

• Simple • Personal • Secret!!

-> Server -> Client -> Hardware (ideally)

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

find platform

Block chain server • Peer-to-peer node

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

find platform

Block chain server • Peer-to-peer node • Realtime

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

find platform

Block chain server • Peer-to-peer node • Realtime • JSON-RPC

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

find platform

Block chain server • Peer-to-peer node • Realtime • JSON-RPC • Lots of concurrent users

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

find platform

Block chain server • Peer-to-peer node • Realtime • JSON-RPC • Lots of concurrent users

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

find platform

Block chain server • Peer-to-peer node • Realtime • JSON-RPC • Lots of concurrent users

+

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

d8 server.js

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

d8 server.js

Memory leaks! Example: MongooseJS

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

d8 server.js

Memory leaks! Collection.prototype.addQueue = function (name, args) { this.queue.push([name, args]); return this; }; Collection.prototype.doQueue = function () { for (var i = 0, l = this.queue.length; i < l; i++){ this[this.queue[i][0]].apply(this, this.queue[i][1]); } return this; };

Example: MongooseJS

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

d8 server.js

Memory leaks! Collection.prototype.addQueue = function (name, args) { this.queue.push([name, args]); return this; }; Collection.prototype.doQueue = function () { for (var i = 0, l = this.queue.length; i < l; i++){ this[this.queue[i][0]].apply(this, this.queue[i][1]); } this.queue = []; return this; };

Example: MongooseJS

+

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

d8 server.js

Memory leaks! saw.chain = function () { var ch = Traverse(saw.handlers).map(function (node) { // ... if (typeof node === 'function') { this.update(function () { saw.actions.push({ path : ps, args : [].slice.call(arguments) }); return ch; }); }

Example: node-binary

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

d8 server.js

Lesson

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

d8 server.js

Lesson Node.js libraries can be strange

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

d8 server.js

Lesson Node.js libraries can be strange

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

d8 server.js

Lesson Node.js libraries can be strange

But overall it’s not that bad!

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

d8 server.js

Lesson Node.js libraries can be strange

But overall it’s not that bad!

Also: V8’s GC is very good!

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

d8 server.js

Debugging Tip: “LiveObjectList”

# Compile V8 with LiveObjectList support scons liveobjectlist=on ... # Run your program with debugging node --debug my_leaky_program.js # Connect to your program with D8 d8 --remote_debugger

Getting set up

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

d8 server.js

Debugging Tip: “LiveObjectList”

lol c Capture a heap snapshot lol Show heap snapshots lol list List objects in a snapshot lol diff [s1] [s2] Show differences between snapshots lol path [obj_id] Show retaining paths for an object

Usage

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

d8 server.js moon@clymene:~/opt/node$ deps/v8/d8 --remote_debugger > Type: connect V8-Version: 3.1.8.26 Protocol-Version: 1 Embedding-Host: node v0.4.10 stopped dbg> lol c Captured live object list 1: count 156079 size 8129300 dbg> c (running) > stopped dbg> lol c Captured live object list 2: count 173343 size 8374416 dbg>

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

d8 server.js dbg> gc GC 7809868 => 6710536 (7.4M => 6.4M) dbg> lol diff 1 2 v t Array 1000 objects: [ 1] @222138: size 16, 0xb39bd329 <JSArray> len 0 [ 2] @222139: size 16, 0xb39bd339 <JSArray> len 0 [ 3] @222143: size 16, 0xb39bd3a1 <JSArray> len 0 [ 4] @222144: size 16, 0xb39bd3b1 <JSArray> len 0 [ 5] @222145: size 16, 0xb39bd3c1 <JSArray> len 0 [ 6] @222365: size 16, 0xb39bede5 <JSArray> len 0 [ 7] @222498: size 16, 0xb39bfea5 <JSArray> len 0 [ 8] @222615: size 16, 0xb39c0d55 <JSArray> len 3 ... dbg> lol path @222138

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

d8 server.js | | V [274] @79332 0xb4422699: size 20 : HeapObject DescriptorArray FixedArray 0xb4422699: [FixedArray] - length: 3 [0]: 0xb77b3efd <FixedArray[53]> [1]: 0xb577404d <undefined> [2]: 0xb41eddd9 <JS array[0]> | | V [275] @215108 0xb41eddd9: size 16 : HeapObject JSObject JSArray 0xb41eddd9: [JSObject] - map = 0xb5754861 - prototype = 0xb77b4f49 { #length: 0xb577e581 <Proxy> (callback) #_cast: (null descriptor) } =====================================

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

uname -a

Another thing… 32 bit 64 bit

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

uname -a

Another thing…

- V8 heap limit

32 bit 64 bit

1 GB 1.9 GB

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

uname -a

Another thing…

- V8 heap limit

- MongoDB database

32 bit 64 bit

2.5 GB

1 GB 1.9 GB

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

bitcoinjs run

Now STOP!

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

bitcoinjs run

Demo time! Now STOP!

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

forecast

Lots more to be done!

- GUI

- Wallet

- Shopping Cart Interface

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

git clone bitcoinjs-gui

A matching client!

- JS-based crypto (fun stuff!)

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

git clone bitcoinjs-gui

A matching client!

- JS-based crypto (fun stuff!)

- HTML5 LocalStorage

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

git clone bitcoinjs-gui

A matching client!

- JS-based crypto (fun stuff!)

- HTML5 LocalStorage

- Socket.IO

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

git clone bitcoinjs-gui

A matching client!

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

git clone bitcoinjs-gui

A matching client!

- Beta August 2011

- Screencast: http://www.youtube.com/watch?v=KTmFwnIRG9c

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

wallet 2.0

Ideas for a more secure wallet

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

wallet 2.0

Ideas for a more secure wallet

- Deterministic Wallet

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

wallet 2.0

Ideas for a more secure wallet

- Deterministic Wallet

- Distributed Key Generation

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

wallet 2.0

Ideas for a more secure wallet

- Deterministic Wallet

- Distributed Key Generation

- Hardware Device

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

exit

Thank you And good night!

$

www.bitcoinjs.org Creative Commons 3.0 Attribution

tail -f

Meetup this Saturday! Oliver Twist Pub 16:30

@bitcoinjs

github.com/bitcoinjs