<p>While this certainly <em>could</em> work, the chances of the hashes ever being valid are next to zero.</p>

<p>The reason is, the hashes must not only meet the target requirements, but they must also be a valid hash of the block header, which changes with each block.</p>

CC BY-SA 4.0
2019-03-12T01:11:10.213Z
So most of them would be invalid or low diff shares?
Crypthusiast
CC BY-SA 4.0
2019-03-12T01:33:00.787Z
You might have some high diff hashes (after a lot of hashes) but they would all be invalid.
JBaczuk
CC BY-SA 4.0
2019-03-12T15:20:44.090Z
would it would still be possible tho?
Crypthusiast
CC BY-SA 4.0
2019-03-12T15:51:37.603Z
If by chance you happened to use the right block header data as input to the hash function. But you'd have to guess 80 bytes correctly.
JBaczuk
CC BY-SA 4.0
2019-03-12T21:45:11.953Z
How _could_ you make it be able to have shares every  time that _are_ compatable with the block header?
Crypthusiast
CC BY-SA 4.0
2019-03-12T22:20:53.587Z
Just pass the block header in to the hash function as input
JBaczuk
CC BY-SA 4.0
2019-03-13T00:38:26.673Z
No, like with this whole put the hashes into a file thing?
Crypthusiast
CC BY-SA 4.0
2019-03-13T14:23:57.823Z
You can't. The only way is to actually hash the block header data. When I say it _could_ work, I mean it would take a trillion trillion .... more zeroes ... years
JBaczuk
CC BY-SA 4.0
2019-03-11T17:31:47.553Z
2019-03-11T17:31:47.553Z
JBaczuk
<p>I have been wondering if it would be possible to generate hashes, store them in a file, then use them as hashes when mining. When you would mine, you would not generate the hashes, but instead, just compare them to the target. This would be much more efficient, right? Anyway, here is some psudo python code i made up:</p>

<pre><code>import hashlib
while True:
    hash = hashlib generate random hashes
    file = open('hashes.txt', 'w')
    file.write(hash)
</code></pre>

<p>or something like that.</p>

CC BY-SA 4.0
2019-03-12T03:41:18.750Z
Creating ‘random hashes’ will **always** fail. A valid blockhash must not only be below a target value, it must also use the header of an otherwise valid block as input.
chytrik
<mining-theory>
Would it be possible to store hashes generated in a file, then brush through them to find out if they are under the target?
Crypthusiast
# Would it be possible to store hashes generated in a file, then brush through them to find out if they are under the target?

(Asked by: username_0 on 2019-03-11)

I have been wondering if it would be possible to generate hashes, store them in a file, then use them as hashes when mining. When you would mine, you would not generate the hashes, but instead, just compare them to the target. This would be much more efficient, right? Anyway, here is some psudo python code i made up:

```
import hashlib
while True:
    hash = hashlib generate random hashes
    file = open('hashes.txt', 'w')
    file.write(hash)

```

or something like that.

**Tags:** mining-theory

> **Comments:**
> **username_1**: Creating ‘random hashes’ will **always** fail. A valid blockhash must not only be below a target value, it must also use the header of an otherwise valid block as input.  

---

## 1 answers

### Answer by username_2 on 2019-03-11. Score: 3 | Accepted answer

While this certainly *could* work, the chances of the hashes ever being valid are next to zero.

The reason is, the hashes must not only meet the target requirements, but they must also be a valid hash of the block header, which changes with each block.

> **Comments:**
> **username_0**: So most of them would be invalid or low diff shares?  
> **username_2**: You might have some high diff hashes (after a lot of hashes) but they would all be invalid.  
> **username_0**: would it would still be possible tho?  
> **username_2**: If by chance you happened to use the right block header data as input to the hash function. But you'd have to guess 80 bytes correctly.  
> **username_0**: How _could_ you make it be able to have shares every  time that _are_ compatable with the block header?  
> **username_2**: Just pass the block header in to the hash function as input  
> **username_0**: No, like with this whole put the hashes into a file thing?  
> **username_2**: You can't. The only way is to actually hash the block header data. When I say it _could_ work, I mean it would take a trillion trillion .... more zeroes ... years  

---

