Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Neural network for helping compute SHA256 (specifically for bitcoin)

2,079 views
Skip to first unread message

Tim Engler

unread,
Jun 6, 2011, 2:20:13 PM6/6/11
to
I am a total newbie when it comes to neural networks, but my basic
question is, if you have an output for a neural network that can have
multiple right answers, what is a good "desired output" to give it for
back propagation?

Also, if you notice any other glaring errors in my approach
(inappropriate neural network size, wrong algorithm, too small/large
training size), please tell me.

My specific details are below:

I'm trying to use a neural network (specifically, FANN) to help speed
up bitcoin mining. If you are unfamiliar with bitcoin, check it out
at: bitcoin.org . For bitcoin mining, the basic idea is that you have
a set of data, and a 32 bit nonce. You are tasked to choose difference
nonces so that the result of performing the SHA256 hash twice will
result in an 512 bit output number that is equal to or less than a
target.

For example, the target could be
0x00000000ffff0000000000000000000000000000000000000000000000000000

It will have succeeded if it chooses a nonce so the hash is less than
the target. For example, the following would be a success:
0x00000000e5f38948f89f8f98f923398f9129089f908f790ed98b9c0a9890398f

My hope is that a NN could choose nonces that were more likely to
succeed than others. Here is what I tried so far.

I create an ANN (details at the bottom of this message with 224 inputs
and 32 outputs, which represents the 224 bit values of the data being
hashed and the 32 bits that are the nonce.
I then took actual live data from bitcoin, feeding in the 224 input
bits and having the neural network choose a 32 bit nonce as a set of
32 floats which range from (-1 to 1).
Then I rounded each of the float bits to either -1 or 1, and
translated that so -1 == 0 and 1 == 1. This I set as the starting
point, or "best guess".
From there I continually calculated the SHA256 hash as the bitcoin
code does, and updated the best guess by flipping bits iteratively in
binary counting style, starting with the outputs that were closest to
zero (ie. where the NN was the least decided on what the bit should
be) until I found a hash under the hash target value.

For example, suppose there were only 4 bits of output instead of 32
for simplicity. if for a given training example the NN came up with
-0.9
0.1
-0.8
0.3

This would translate to a guess of 0101. Then I hash it, and if it was
not below the target, I flip the bits as follows
0001
^--- flipped first because 0.1 is closest to zero
0100
^- flipped second because -0.3 is second closest to zero
0000
^-^-- both flipped
0111
^-- -0.8 is third closest to zero
0011
^^-- and so on.. basic binary iteration
0110
^^
0010
^^^
1000
^
... (and so on)


The above yields a total number of tries before a successful hash has
been found. I use this number as an error amount. Since there are
multiple solutions, I'm not sure what to give as a "desired output"
for back propagation. I've tried these ideas but both with absolute no
success after 10,000 trainings each:

1. Use the nonce that produced the target after bit flipping from the
"best guess".
2. Use a random value and compute a strength of error based on num
tries: 1. - (x) / ( (x) + (num_tries) )
where (x) is a constant. Then choose a "desired output" for back
propagation with: (actual output) * (1 - (strength of error)) + (1 or
-1 randomly) * (strength of error)
for each output
3. A combination of 1 and 2, where I use the result from 1 and the
strength computed from 2 to come up with a "desired output"

Neural network settings:

Library: Fast Artificial Neural Network Library (FANN) http://leenissen.dk/

Activation function: Sigmoid Symetric
Num inputs: 224
Hidden layer 1: 168
Hidden layer 2: 112
Hidden layer 3: 56
Num outputs: 56
Num trainings: 10,000 - each train a unique input.

I also tried a networks with 1 hidden layer of 112 neurons.

Thanks,

Tim

Stephen Wolstenholme

unread,
Jun 7, 2011, 5:17:12 AM6/7/11
to
On Mon, 6 Jun 2011 11:20:13 -0700 (PDT), Tim Engler <eng...@gmail.com>
wrote:

>I am a total newbie when it comes to neural networks, but my basic
>question is, if you have an output for a neural network that can have
>multiple right answers, what is a good "desired output" to give it for
>back propagation?

Use all of the correct answers with different training examples.

Steve

--
Neural network software applications, help and support.

Neural Planner Software www.NPSL1.com

Shirley Nott

unread,
Jun 7, 2011, 9:40:30 AM6/7/11
to

"Tim Engler" <eng...@gmail.com> wrote in message
news:6c035f5d-d786-4582...@b1g2000yql.googlegroups.com...

My advice. Some problems are too hard for NNs. This is one.

m3tz...@gmail.com

unread,
Feb 24, 2013, 11:39:18 AM2/24/13
to
I want to ask if anyone get good result in using NN in mining
0 new messages