<p>Bitcoin hashes the <a href="https://en.bitcoin.it/wiki/Protocol_specification#Block_Headers" rel="nofollow">block headers</a> through SHA-256(SHA-256(header)) hashing. The result of that hash has to be smaller than the current <a href="https://en.bitcoin.it/wiki/Target" rel="nofollow">target</a>, which is commonly represented by <a href="https://en.bitcoin.it/wiki/Difficulty" rel="nofollow">difficulty</a>.</p>

<p>Those computations are performed many, many times during mining, so there are some slight optimisations for the process. Namely, the use of <a href="https://bitcointalk.org/?topic=2416.0" rel="nofollow">midstate</a>. Generally, before the header can be hashed, it needs to be split in half due to the SHA-256 algorithm (which operates on data smaller than the header). Half of that data does not change with iterations over the nonce, so it is useful to calculate the midstate of that half of the hashing to use in the algorithm, saving you some computational time during each check.</p>

<p>Asides from that, there is more complexity to it (ah, the damned endianness and so forth), but this should make things clearer for you.</p>

CC BY-SA 3.0
2012-09-20T06:21:21.320Z
2012-09-20T06:21:21.320Z
ThePiachu
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="https://bitcoin.stackexchange.com/questions/148/what-exactly-is-mining">What exactly is Mining?</a>  </p>
</blockquote>



<p>What are the exact computations dies Bitcoin is performing during the mining?</p>

<p>I understood that it has to do something with hashes and proof-of-work.</p>

<p>And as far as I got, here is an idea:</p>

<pre><code>SHA-256(something) = specific string
</code></pre>

<p>where specific string starts with some zeros, but what is this something?</p>

CC BY-SA 3.0
2012-09-19T22:40:47.950Z
Do you mean when mining? Could you please edit your question to clarify that
Highly Irregular
CC BY-SA 3.0
2012-09-20T06:27:25.010Z
I edited the question a bit to clarify the problem and conform with Higly Irregular's comment. I hope it is more acceptable to the community now.
ThePiachu
<blockchain><hash>
What computations does Btcoin perform during mining?
Salvador Dali
# What computations does Btcoin perform during mining?

(Asked by: username_0 on 2012-09-19)

> **Possible Duplicate:**  
> [What exactly is Mining?](https://bitcoin.stackexchange.com/questions/148/what-exactly-is-mining)

What are the exact computations dies Bitcoin is performing during the mining?

I understood that it has to do something with hashes and proof-of-work.

And as far as I got, here is an idea:

```
SHA-256(something) = specific string

```

where specific string starts with some zeros, but what is this something?

**Tags:** blockchain, hash

> **Comments:**
> **username_1**: Do you mean when mining? Could you please edit your question to clarify that  
> **username_2**: I edited the question a bit to clarify the problem and conform with Higly username_1's comment. I hope it is more acceptable to the community now.  

---

## 1 answers

### Answer by username_2 on 2012-09-20. Score: 1

Bitcoin hashes the [block headers](https://en.bitcoin.it/wiki/Protocol_specification#Block_Headers) through SHA-256(SHA-256(header)) hashing. The result of that hash has to be smaller than the current [target](https://en.bitcoin.it/wiki/Target), which is commonly represented by [difficulty](https://en.bitcoin.it/wiki/Difficulty).

Those computations are performed many, many times during mining, so there are some slight optimisations for the process. Namely, the use of [midstate](https://bitcointalk.org/?topic=2416.0). Generally, before the header can be hashed, it needs to be split in half due to the SHA-256 algorithm (which operates on data smaller than the header). Half of that data does not change with iterations over the nonce, so it is useful to calculate the midstate of that half of the hashing to use in the algorithm, saving you some computational time during each check.

Asides from that, there is more complexity to it (ah, the damned endianness and so forth), but this should make things clearer for you.


---

