brainflayer icon indicating copy to clipboard operation
brainflayer copied to clipboard

Possible brainflayer not work correctly at the end of seed

Open agent-0007 opened this issue 3 years ago • 4 comments

Hi. Possible brainflayer not work correctly at the end of seed.

The first valid private key in hexadecimal is 0000000000000000000000000000000000000000000000000000000000000001 and the last valid private key in hexadecimal is fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140

brainflayer -v -I fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140 -b example.blf secp256k1/src/field_impl.h:238: test condition failed: secp256k1_fe_normalizes_to_zero_var(&c) Aborted

I also try fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413b, and result the same.

agent-0007 avatar Sep 04 '20 14:09 agent-0007

Looks like it dies when

fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141

is within the very first batch of keys brainflayer processes, but will handle a zero key fine otherwise.

ryancdotorg avatar Nov 23 '20 12:11 ryancdotorg

If you set the starting key to fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0360000 it will work fine and then wrap around, but i should see if i can turn off the asserts in libsecp256k1

ryancdotorg avatar Nov 23 '20 23:11 ryancdotorg

This is minor bug, i think the reason in brainflayer start. I haven't looked closely at your code, but suppose that when brainflayer start calculating it trys to calculate 300000+ values, and when seed in the end, it can't do that. If you run bf with values (fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140 - 7A120) it will work correctly and start searchng at the start of seed 0000...001. I repot this, because don't know it's a bug or a future. May be seed have undocumented featuers.

agent-0007 avatar Nov 24 '20 07:11 agent-0007

Starting with fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142, values aren't valid private keys, most implementations just wrap around to 0000000000000000000000000000000000000000000000000000000000000001. Doesn't seem worth the performance hit to special case.

ryancdotorg avatar Nov 24 '20 08:11 ryancdotorg