Monday 1 April 2013

Bitcoins Mine

One of the biggest problems I ran into when I was looking to start mining Bitcoin for investment and profit was most of the sites were written for the advanced user. I am not a professional coder, I have no experience with Ubuntu, Linux and minimal experience with Mac. So, this is for the individual or group that wants to get started the easy way.
First thing you need to do is get a “Bitcoin Wallet”. Because Bitcoin is an internet based currency, you need a place to keep your Bitcoins. Got to http://www.bitcoin.org and download the Bitcoin client for your Operating System. Install it the client will begin to download the blockchain. Downloading the blockchain can take a long time and will be over 6GB of data. If you have data caps, I would recommend ordering a copy of the blockchain on DVD to keep from going over as it is growing exponentially. Click to order the bitcoin blockchain by mail. Once the client is up to date, click “New” to get your wallet address. It will be a long sequence of letters and numbers. One of most important things you can do is make sure you have a copy of the wallet.dat file on a thumb drive and print a copy out and keep it in a safe location. You can view a tutorial on how to create a secure wallet by clicking the link on the top of the page. The reason is that if you computer crashes and you do not have a copy of your wallet.dat file, you will lose all of your Bitcoins. They won’t go to someone else, they will disappear forever. It is like burning cash.
Now that you have a wallet and the client, you are probably roaring to go, but if you actually want to make Bitcoin (money), you probably need to join a pool. A pool is a group that combines their computing power to make more Bitcoins. The reason you shouldn’t go it alone is that Bitcoins are awarded in blocks, usually 50 at a time, and unless you get extremely lucky, you will not be getting any of those coins. In a pool, you are given smaller and easier algorithms to solve and all of your combined work will make you more likely to solve the bigger algorithm and earn Bitcoins that are spread out throughout the pool based on your contribution. Basically, you will make a more consistent amount of Bitcoins and will be more likely to receive a good return on your investment.
The pool that I’m involved in is called Slush’s Pool so I will be giving instructions on how to join there but feel free to look at other options. Follow the link to go to their site and click the “Sign up here” link at the top of their site and follow their step by step instructions. After you have your account set up, you will need to add a “Worker”. Basically, for every miner that you have running, you will need to have a worker ID so the pool can keep track of your contributions.
Most of the mining programs out there are pretty complicated to setup and will frustrate your average user. Recently a great program has come out to get the most basic of users started. The program is called GUIMiner. Click the link and download the program (Be careful, some of the ads are set up to look like the file download). Install and run the program and add in your information from Slush’s Pool. Remember that the user name is actually the worker name. The worker name will be your user name, dot, worker ID (username.worker ID) and the password from that worker ID.
Now that you are set up you can start mining. If you feel like you want to make more Bitcoins, you might want to invest in mining hardware.

First I want to cover why I recommend why I suggest joining a pool. The reason is that bitcoins are mined in blocks of 50. You can’t mine just 1 at a time. So unless you have a massive mining machine, the odds of you actually discovering a block at the current difficulty is extremely low. It actually might never happen. That being said, it can still be done, but it would be an extraordinary lucky occurrence. In a pool, you are working together to discover a block and you will receive a lot of smaller payouts with much more consistency.
That being said, if you want to mine on your own you need to run bitcoin.exe. Not bitcoind.exe. When you run bitcoin.exe it will create a wallet for you. I am assuming you are using Ubuntu or Linux because you mentioned the bitcoind.exe program so just run the correct program and you will see your bitcoin address in the program. Just leave it running and see if you get lucky. If you are solo mining don’t expect to see any funds go into the account. You might see nothing for 2 months and then all the sudden there is 50 bitcoins in there. You might never see any go into your account. That’s the risk of solo mining. I would also recommend looking at my article on creating a secure bitcoin wallet as that might help you to understand how the wallet works and how to keep it safe.
Also, there is no username or password required for the bitcoin.exe program. I haven’t used the minerd program but if if requires a user name or password it is probably used for mining in a pool. The user name and password are to let the pool know who you are so they can keep track of how many shares of the next discovered block will be going to you.
I hope this clears things up and please contact me or reply to this post if you have any other questions.

Cryptography

There are several cryptographic technologies that make up the essence of Bitcoin.
First is public key cryptography. Each coin is associated with its current owner's public ECDSA key. When you send some bitcoins to someone, you create a message (transaction), attaching the new owner's public key to this amount of coins, and sign it with your private key. When this transaction is broadcast to the bitcoin network, this lets everyone know that the new owner of these coins is the owner of the new key. Your signature on the message verifies for everyone that the message is authentic. The complete history of transactions is kept by everyone, so anyone can verify who is the current owner of any particular group of coins.
This complete record of transactions is kept in the block chain, which is a sequence of records called blocks. All computers in the network have a copy of the block chain, which they keep updated by passing along new blocks to each other. Each block contains a group of transactions that have been sent since the previous block. In order to preserve the integrity of the block chain, each block in the chain confirms the integrity of the previous one, all the way back to the first one, the genesis block. Record insertion is costly because each block must meet certain requirements that make it difficult to generate a valid block. This way, no party can overwrite previous records by just forking the chain.
To make generating bitcoins difficult the Hashcash cost-function is used. Hashcash is the first secure efficiently verifiable cost-function or proof-of-work function. The beauty of hashcash is that is is non-interactive and has no secret keys that have to be managed by a central server or relying party; hashcash is as a result fully distributed and infinitely scalable. (Hashcash uses symmetric key cryptogaphy, namely a one-way hashcash function - typically either SHA1 or SHA-256).
In bitcoin, integrity, block-chaining, and the hashcash cost-function all use SHA256 as the underlying cryptographic hash function.
A cryptographic hash function essentially takes input data which can be of practically any size, and transforms it, in an effectively-impossible to reverse or to predict way, into a relatively compact string (in the case of SHA-256 the hash is 32 bytes). Making the slightest change to the input data changes its hash unpredictably, so nobody can create a different block of data that gives exactly the same hash. Therefore, by being given a compact hash, you can confirm that it matches only a particular input datum, and in bitcoin the input data being a block-chain is significantly larger than the SHA-256 hash. This way, Bitcoin blocks don't have to contain serial numbers, as blocks can be identified by their hash, which serves the dual purpose of identification as well as integrity verification. An identification string that also provides its own integrity is called a self-certifying identifier.
The hashcash difficulty factor is achieved by requiring that the hash output has a number of leading zeros. Technically, to allow more fine-grained control than Hashcash number of leading 0-bits method, Bitcoin extends the hashcash solution definition by treating the hash as a large big-endian integer, and checking that the integer is below a certain threshold. The hashcash cost-function iterates by perturbing data in the block by a nonce value, until the data in the block hashes to produce an integer below the threshold - which takes a lot of processing power. This low hash value for the block serves as an easily-verifiable proof of work - every node on the network can instantly verify that the block meets the required criteria.
With this framework, we are able to achieve the essential functions of the Bitcoin system. We have verifiable ownership of bitcoins, and a distributed database of all transactions, which prevents double spending.

Bitcoin Mining

We have mentioned in the previous section that adding a block to the block chain is difficult, requiring time and processing power to accomplish. The incentive to put forth this time and electricity is that the person who manages to produce a block gets a reward. This reward is two-fold. First, the block producer gets a bounty of some number of bitcoins, which is agreed-upon by the network. (Currently this bounty is 25 bitcoins; this value will halve every 210,000 blocks.) Second, any transaction fees that may be present in the transactions included in the block, get claimed by the block producer.
This gives rise to the activity known as "Bitcoin mining" - using processing power to try to produce a valid block, and as a result 'mine' some bitcoins. The network rules are such that the difficulty is adjusted to keep block production to approximately 1 block per 10 minutes. Thus, the more miners engage in the mining activity, the more difficult it becomes for each individual miner to produce a block. The higher the total difficulty, the harder it is for an attacker to overwrite the tip of the block chain with his own blocks (which enables him to double-spend his coins. See the weaknesses page for more details).
Besides being important for maintaining the transaction database, mining is also the mechanism by which bitcoins get created and distributed among the people in the bitcoin economy. The network rules are such that over the next hundred years, give or take a few decades, a total of 21 million bitcoins will be created. See Controlled Currency Supply. Rather than dropping money out of a helicopter, the bitcoins are awarded to those who contribute to the network by creating blocks in the block chain.

Double spending

The block chain is a common ledger shared by all Bitcoin nodes which details the owner of each bitcoin, or fraction thereof. Unlike conventional banking systems, there is no central place where this ledger of transactions is stored. This is accomplished through the broadcasting of small pieces ("blocks"), each stating that it is a continuation of a previous block. It is possible for the block chain to split; that is, it is possible for two blocks to both point to the same parent block and contain some, but not all, of the same transactions. When this happens, each computer in the network must decide for itself which branch is the "correct" one that should be accepted and extended further.
The rule in this case is to accept the "longest" valid branch. Choose from the branches of blocks that you have received, the path, the total "difficulty" of which is the highest. This is the sequence of blocks that is assumed to have required the most work (CPU time) to generate. For Bitcoin, this will be the "true" order of events, and this is what it will take into account when calculating the balance to show to the user.
It is still possible that, as new blocks are constantly being generated, at some later time, some other branch will become the longest branch. However, it takes significant effort to extend a branch, and nodes work to extend the branch that they have received and accepted (which is normally the longest one). So, the longer this branch becomes compared to the second-longest branch, the more effort it will take for the second-longest branch to catch up and overcome the first in length. Also, the more nodes in the network hear about the longest branch, the more unlikely it becomes for other branches to be extended the next time a block is generated, since the nodes will accept the longest chain.
Therefore, the more time a transaction has been part of the longest block chain, the more likely it is to remain part of the chain indefinitely. This is what makes transactions non-reversible and this is what prevents people from double-spending their coins. What the receiver of each transaction does, after money has been supposedly transferred to him/her is to check how long the block chain following the said transaction has become, because the more blocks are added to the longest branch after the transaction, the less likely is it that some other branch will overcome it.
When the block chain after the transaction has become long enough, it becomes near-impossible for another branch to overcome it, and so people can start accepting the transaction as true. This is why 'blocks' also serve as 'confirmations' for a transaction. Even if another branch does overcome the one with the transaction, most of the blocks will have been generated by people who have no affiliation with the sender of the coins, as a large number of people are working to generate blocks. Since transactions are broadcasted to all nodes in the network, these blocks are just as likely to contain the transaction as the blocks in the previously-accepted branch.
Bitcoin relies on the fact that no single entity can control most of the CPU power on the network for any significant length of time, since, if they could, they would be able to extend any branch of the tree they chose, and faster than any other branch can be extended, making it the longest branch, and then permanently controlling which transactions appear in it.