Why is SHA-256 mining secure? My understanding is the when you are mining bitcoin you are looking for a string, or maybe a binary number (a) such that if you 'add' a to the block (b) you get a number (c) whose hash begins with a bunch of zeros.
My question is: Say I know that the message b 'added' with the number a gets mapped to my desired output. Why is it not possible for me, given a different block (b2) to find a corresponding number (a2), such that the hash of the result will map to the same number c?
What is the operation that combines the block b with the number a that makes this impossible? Is it simple appending?
My question is: Say I know that the message b 'added' with the number a gets mapped to my desired output. Why is it not possible for me, given a different block (b2) to find a corresponding number (a2), such that the hash of the result will map to the same number c?

It's not possible because there are 2^256 (approximately 1 followed by 77 zeroes) possible hash results. You would have to try an awful lot of possible values for a2 to find one that happened to produce precisely the same hash output. The stars would burn out first.

What is the operation that combines the block b with the number a that makes this impossible? Is it simple appending?

No, it is not simple appending. That would produce very, very long numbers. It's an operation that has three important characteristics:

It produces an output smaller than its input. This makes it irreversible because information is lost. You cannot reverse the hashing operation just as you cannot reverse addition. If I add two numbers and get 10, you cannot tell me which two numbers I added because that information has been lost.

A small change in the input produces large changes in the output. That is, changing a single bit of the input changes roughly half of the bits of the output, and it is not easily predictable which bits that will be. It mixes the input quite thoroughly to produce its output.

The output is long, 256 bits. As a result, brute force trial and error to get particular outputs is not practical.


You can read more on the SHA-2 family of functions (which includes SHA-256) here.