This question already has an answer here:

disclaimer: I'm completely new at this, basic computer skills limited to GUI point-&-click

  1. I took a look at how difficulty was explained, that it is "increased" by requiring the SHA-256 generation of blocks with more leading 0 bits, thus a string of 0s at the start of the hash which is more and more rare. Unless this has not been explained in a way I understand properly I think this means that you can cheat the Bitcoin difficulty and make blocks whenever you want? You simply need a custom SHA-256 hash generation program which non-randomly generates the specified number of 0s followed by a random SHA-256 hash shortened by the number of digits equal to the number of 0s in front, or simply generates a SHA-256 hash and then replaces the leading bits with 0 bits to meet the difficulty target thus forging a block hash. So from what I'm told it's A) easy to cheat; OR B) not well enough explained.

  2. Isn't higher difficulty less and less secure a block hash because it is less and less random? Like if the difficulty were theoretically to rise high enough wouldn't it require the entire hash to be ONLY 0 bits instead of just the first part? Doesn't that ruin the security of Bitcoin the harder it gets? Hashes are seemingly easier to crack the higher difficulty is, easier to guess randomly and easier to forge. Couldn't I or someone else just spam strings of 0 and be rewarded with blocks just as fast as they could spam enough 0s to complete a hash?

I realize the answer to both questions is probably "no it's not like that" but that is the way it's been explained on the wiki and wikipedia and various other places.

I think it's more like, miners actually process transactions, not just (or maybe not even because those could be coming from both parties of the transaction) randomly generate hashes. Also there is probably some encryption involved which has not been properly explained and which when difficulty rises is added in many more multiple layers, encrypting and re-encrypting the already encrypted data.

The explanation about 0 strings also doesn't allow for a infinitely variable difficulty above 1 and for this reason it also doesn't seem to make sense.

I'd like more transparency in how the actual technical process is explained even if it's so long that I don't care to read it. It'd also be great to find links to the full publicly released SHA standards and documentation.

The more transparent the security is the more likely it is that someone will find a way to break or breach it if this is possible and while it is not desirable for that to happen it's better that it happen sooner rather than later if it can happen at all. Thus more robust standards blocking that sort of breach can be implemented.

marked as duplicate by Stephen Gornick, o0'., Nick ODell, David Ogren, jgm Apr 24 '13 at 20:43

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Hashes are one-way functions. sha256("DataGoesHere") --> HashResult but given just a HashResult, you cannot then determine what was the value of the data that got hashed.

If you change even one bit of that HashResult (e.g., prefix it with a zero) then that data it corresponds to will be completely different. So it is easy to get the HashResult. It is essentially impossible to go the other direction and determine the value of the data.

As you expected, the answer to both is no :-)

For the generation of hashes: the miner attempts to find an input that, fed into a specified function, gives an output that satisfies certain properties. In Bitcoin the property is that the output is required to have a given number of zeroes. As your peers will recalculate the hash from the input you provide them with (the block) they will notice that the hash does not match the property and discard it. In fact the hash is not even directly relayed, but only the block from which the hash can be calculated.

For the target being unreachable, this question has been asked a number of times before. The gist of it is that H(block) < target. An increase in difficulty reduces the number of possible solutions, but not the set in which you have to look for them, making it harder to find one.

A hash function is a mathematical function that is easy to perform in one direction, but for which there is no known way to easily perform in the other direction.

So, why don't you generate a SHA-256 hash and replace the beginning of the hash with zeroes? Because then it wouldn't be the hash anymore. It is (by definition of a hash function) easy for anyone to verify the hash.

Why don't you write a custom SHA-256 program that generates a hash that starts with the prerequisite number of zeros? Because (again, by definition) a hash function means that there is no way to perform the function in the reverse direction: you can't predict the result of the hash (or even part of the hash, such as the leading zeroes.) There's no way to write such a program, otherwise SHA-256 would be considered "broken" and wouldn't be used as a hash.

Essentially what mining is (as described in the linked article) is repeatedly hashing the block, varying only one field called the "nonce". A miner will try millions of possible nonces, hoping that the resulting has the required number of zeroes at the beginning.

Not the answer you're looking for? Browse other questions tagged or ask your own question.