Monday, September 26, 2016

How the next Edward Snowden should access Internet for maintaining privacy? - Rethink VPN & TOR


In the present era of Mass Surveillance by intelligence agencies like NSA, GCHQ & RAW, you should know that every border you cross, every purchase you make, every call you dial, every cell phone tower you pass, friend you keep, article you write, site you visit, subject line you type, and packet you route is in the hands of some electronic system whose reach is unlimited, but whose safeguards are questionable. This amount of metadata collected about you is more than enough to create simulations of you and predict your behaviour in any given circumstance. It involves a systematic interference with individual’s right to privacy in terms of subjection to significant indiscrimination, monitoring and censorship. Hence, Privacy & Anonymity are rising concerns among informed citizens, journalists, whistleblowers and Edward Snowdens of the world. 


When it comes to technology, privacy and anonymity enthusiasts extensively use encrypted proxy services like VPN & TOR Anonymity network to hide their identities & activities online. But let’s understand how useful & worthy they are, what are the differences and how can we leverage the potential of both.

VPN is faster than TOR, and is suitable for P2P downloading. The major downside however (and reason VPN is said to provide privacy rather than anonymity) is that it requires your trust the VPN provider. This is because, should it wish to (or is compelled to), your VPN provider can “see” what you get up to on the internet. VPN also allows you to easily spoof your geographic location.

On the contrary, TOR is much slower because of the built-in Onion Routing, is often blocked by websites, and is unsuitable for P2P, but it does not require your truston anybody, and is therefore much more secure & truly anonymous.

Interestingly, VPN & TOR can be clubbed and used together in order to provide an extra layer of security, and to mitigate some of the drawbacks of using either technology exclusively. The main downside, however, of doing so combines the speed hit of both technologies, making connections more secure but slow. It is also important to understand the difference between connecting VPN to TOR and connecting TOR to VPN for accessing the Internet. Order Matters!

Thursday, August 18, 2016

Micropayment Channels


If we go to any grocery store purchase a small item worth 55 and when you give your card to swipe for payment, the storekeeper would ask you to render the exact change or buy items worth some value let us say 300. Here the storekeeper is looking to avoid the minimum transaction fee(thereby avoiding the loss that could occur) and you are forced buy unintended items.




What if you are a regular customer to the store and would like to pay lump sum at the end of month, then the storekeeper thinks ‘what if he does not pay back’.
What if you would pay some advance to the storekeeper, good but you might think ‘what if you were unable to spend the whole amount and shopkeeper doesn’t return the balance’ or ‘what if you were busy and unable to visit the shop thereafter’ or ‘what if shopkeeper says he doesn’t know you’.  

But won’t it be good if you can pay only for items that you took whether it is 55 or even 1 for that matter. The topology that enables such provision is micropayment channel.
To understand micropayment channels, we need to understand multi-sig technology and lock-time feature of bitcoin transactions.

Multi-sig 
In any transaction a person holding btc can spend them using his signature, but if an organization or group of people hold the btc then it might require 2 or more person signature to spend the btc, and this is possible with multi-sig technology where it requires m of n keys to spend the btc.
For btc to be added to such organization, we need to send btc to P2SH (supports arbitrary sets of N keys of which M are required to transact) instead of P2PKH (single key address).



Lock-time
Lock-Time feature of transaction makes a transaction inadmissible to the network until certain time, i.e. only when the lock time has reached the transaction could be added to the network.
Lock-Time types firstly if lock time is less than 500 million then it means block height, so transaction could be added to network after such block height is reached, Secondly if it is above 500 million then it is the time (mentioned in seconds since January 1st 1970) at which it could be added to network.


Micropayment explained

Micropayment enables us to pay transaction fees only once though you have done several such transactions within specific time and with the same person, as it facilitates collection of transaction fee for one final settlement transaction instead of collecting fee for every small transaction.
Back to the grocery store, you make a deal with him by writing a transaction that would put 100 m-btc of your wallet in to a 2 of 2 multi-sig with your key and shopkeeper’s key and if this is added to network 100 m-btc could be spend only when both you and shopkeeper sign(Escrow lock).
But before this gets added to the network you write another transaction that sends 100 m-btc back to your address (Refund) with one month lock time signed by shopkeeper. So this makes sure you get your money back if the shopkeeper disappears. 



Now keeping the refund transaction with you, upload the escrow lock transaction to the network. So when you go the store, buy some item worth 5 m-btc you sign the transaction that pays 5 m-btc to shopkeeper and 95 m-btc back to you, and give the 1st transaction to shopkeeper who retains it (doesn’t immediately upload the transaction).On your second visit if you buy item worth 10 m-btc now you sign the transaction that pays 15 m-btc to shopkeeper and 85 m-btc back to you, and give the 2nd transaction to shopkeeper who again retains it, after few more such visits let us say after your nth visit  and before the lock time(one month) the shopkeeper uploads the nth transaction that pays k m-btc to shopkeeper and (100-k)m-btc back to you, thereby paying the transaction fee only for one instead of n transactions.

Thus we have  μ-payment transactions which are beneficial to both the sender and receiver.


Thursday, August 11, 2016

EVERYTHING YOU NEED HOW BITCOIN FLOWS


Reality

If anyone says they have 5 bitcoins in their wallet they actually mean, they have unspent transaction outputs (utxo) which, clubbed together sum up to 5 bitcoins. And to have utxo they should first have a bitcoin address which consists version, public key hash followed by check sum, and bitcoin address could be shared by QR Code.

Begin Transaction

When buyer pays 3 bitcoins to seller it means, he has transferred 3 bitcoins to seller’s bitcoin address i.e. he has initiated a transaction which converts his existing utxo(specified by txid) to seller’s address (specified either by P2PKH or P2SH) along with buyer’s signature(specified by buyer’s full public key) and pub key script(instructions, that allows anyone to spend amount who control buyer’s private key).

Spend Transaction

Now if the seller who received 3 bitcoins would like to transfer them, he adds prev-txid, vout, script sig to the Input, where prev-txid is txid of buyer to seller, vout is output index of buyer to seller, script sigs which is collection of data parameters (receivers public key, signature) that satisfied conditions placed by pub key script of buyer to seller.

With the above input, amount and new txid along with new pub script will be send to the new indented bitcoin address and transaction is uploaded to the network.  

Transaction validation or Mining

Once uploaded the transaction has to be validated and then will be added to the block chain(which provides bitcoins public ledger and is an ordered and time stamped record of transactions). A transaction that is added to the network will be validated by bitcoin miners by proof of work which avoids double spending of bitcoins.

For validation miners check two things in a transaction, first that you are actual recipients of utxo, Second that you have not already used those utxo. If everything is proper the miner will add transaction to his personal list of valid transactions, and every few minutes one miner will be given chance to add their personal list i.e. a block to the official block chain.

A block will be added to the official block chain if miner transactions are valid and miner correctly guessed a random number called nonce. So miner adds previous block signature, 
and the transaction.

Mining Rewards

Not just that miners get rewarded in two ways viz. few bitcoins as reward, small transaction fee from the person who has initiated the transaction. So to gain such rewards  many miners compete to add transaction to network, bitcoin rules ask miners to generate a difficult hash (like one that starts with certain number of zeros), which involves a combination of inputs one of which is a random number called ‘nonce’ that miners will have to guess, and miners with powerful computers can make such guess faster, so miners usually invest in high performance computing.

Multi Ouput transactions

A single transaction can create multiple outputs, as would be the case when sending to multiple addresses, but each output of a particular transaction can only be used as an input once in the block chain. It means if you have utxo of 1BTC, 1.5BTC and if you need to pay 0.5BTC to seller then, you have to sign utxo of 1BTC to seller with output of 0.5 BTC to seller and change of 0.5BTC to your own bitcoin address.

Any bitcoin transaction can have multiple inputs (n1btc, n2btc, n3btc) and multiple outputs (r1btc, r2btc) with condition r1+r2=n1+n2+n3,  but to be noted that n1btc cannot be divided directly to be used in two transactions (but has to generated as new utxo with (n-k)btc).Hence either  of n1,n2,n3 btc cannot be reused in another transaction avoiding double spending.