iceland2k14 / bsgs

Find PrivateKey of corresponding Pubkey(s) using BSGS algo
MIT License
109 stars 59 forks source link

does not get the right PVK #28

Closed kuiwang closed 3 years ago

kuiwang commented 3 years ago

when I execute the command: python bsgs_hybrid_dll_gmp.py -pfile testpk.txt -b mybpfile.bin -bl mybloom.bin -keyspace 1:0x1000

the result is: A False collision ignored A False collision ignored A False collision ignored A False collision ignored ============== KEYFOUND ============== BSGS FOUND PrivateKey 0x3

============== KEYFOUND ============== BSGS FOUND PrivateKey 0x3

[+] Range Finished

testpk.txt content in below:

02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a 02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 04f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672

private_key = 0x2 : compressed publickey: 02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 uncompressed publickey: 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a

private_key = 0x3 : compressed publickey: 02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 uncompressed publickey: 04f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672

bsgs_hybrid_dll_gmp.py does NOT find the privatekey when the publickey is generated by 0x2. but it finds the correct result when the publickey is generated by 0x3.

@iceland2k14 something is wrong? could you help me,please

iceland2k14 commented 3 years ago

Yes You Found a Nice Bug. The reason is 2 time subtraction of 1. https://github.com/iceland2k14/bsgs/blob/8020280672cb2559e71ebb0b600b65b26f87605e/v5_secp256k1_bloom_dll/bsgs_hybrid_dll_secp256k1.py#L419 https://github.com/iceland2k14/bsgs/blob/8020280672cb2559e71ebb0b600b65b26f87605e/v5_secp256k1_bloom_dll/bsgs_hybrid_dll_secp256k1.py#L374

In fact i will correct it in a different way. During script initialization, first try with directly matching with the bpfile elements if the search starts with 1.

kuiwang commented 3 years ago

Thanks for your help @iceland2k14

iceland2k14 commented 3 years ago

Fixed in latest commit