Login LoginClose
| Lost password
phpFK - Logo

Pollard's kangaroo with Python 2.7
 1 2 3
20.08.19 13:35
57fe 

Administrator

Pollard's kangaroo with Python 2.7

This board is started because of threads on BitcoinTalk appeared some years ago:

https://bitcointalk.org/index.php?topic=1306983.0

or shortly in Russian here:

https://bitcointalk.org/index.php?topic=932434.0

Up to 30th May of this year the problem was still in the plane of brute force competition, as I think. The more power, the more chances.
30th May 2019 unknown owner of the puzzle makes small outgoing transaction from some wallets, and, therefore makes the puzzle much more interesting. Since this moment it is really can be called "Puzzle", because there are so much beautiful Mathematics behind!
This thread is about most suitable algorithm for the Puzzle - Pollard's kangaroo.

Edited 20.08.19 13:37

20.08.19 13:53
57fe 

Administrator

Re: Pollard's kangaroo with Python 2.7

Here is some code on Python. The code is single-threaded, and its main purpose is to introduce anybody who interested in the game.
The code requires no external modules in their simplest variant. If you wish to speed up calculations by a factor 15 approximately, install gmpy2 module, then uncomment lines 3, 44 and comment line 45.
The simplest variant with modular inversion written on Python is also fast enough, 32-bit problem takes ~30 sec on my Core i5-5xxx.
Any questions and ideas are welcomed!

20.08.19 17:47
niidt 

Re: Pollard's kangaroo with Python 2.7

out of the box is your code looking for problem 32? How to add other problems? Sorry, I'm new to this.

20.08.19 18:29
57fe 

Administrator

Re: Pollard's kangaroo with Python 2.7

niidt:
out of the box is your code looking for problem 32? How to add other problems? Sorry, I'm new to this.

Yes, to change the problem use line 178 in the code. See the list of embedded in the code problems (lines 168..176), it's restricted by set [16, 24, 32, 40, 44, 45, 50, 65, 105]. If you need to solve any other - just add EC-point and problem number in the same manner.

The code solves defined problem N_tests times (default value 3, line 195) with random placing of kangaroos (default number is 8 both for tame and wild herds, line 183, the number is restricted by power of 2 in this version), calculates hops and times of solution, and, finally, prints results in the form Mean+/-Deviation.

20.08.19 18:46
niidt 

Re: Pollard's kangaroo with Python 2.7

I already found this line and tried to search .. Looking healthy! On problem 40, my pc spent 249 seconds. Thanks for the answer. But I certainly quickly absorb, but still do not understand how to designate the EС-point to the problem.

For example, why is problem 105 indicated by '03bcf7ce887ffca5e62c9cabbdb7ffa71dc183c52c04ff4ee5ee82e0c55c39d77b'?


/// наверное, мне надо пойти и попить мат-чай)

20.08.19 19:05
57fe 

Administrator

Re: Pollard's kangaroo with Python 2.7

Look at the transaction dated 31.05.2019:

https://www.blockchain.com/btc/tx/17e4e3...1b4b65717a4b3d3

There are small outputs from wallets with 0.65, 0.70,..., 1.6 BTC. Each of output transfers is signed, and you can find details at bottom of the page. For each output we see something like:


The field PUSHDATA(33) contains X-coordinate (hex) of EC-point in compressed form, and this is exactly we need for our Python code. This point P corresponds to the secret key of wallet: P = secret * G, where G is generator point and (*) means scalar multiplication in EC-group.

/// продолжу писать на английском, раз уж всех зазвал сюда

20.08.19 19:19
niidt 

Re: Pollard's kangaroo with Python 2.7

Thank you, very informative and kind of you to explain.
Now everything falls into place ..

Interesting.
And the last (3) question, I hope you are not very tired of this.
At what point does your code start searching?
With the first key 00000000000000000000000000000000000000000000000000000000000000000000000000000001?
And for example, you can not specify a range?

20.08.19 19:37
57fe 

Administrator

Re: Pollard's kangaroo with Python 2.7

niidt:
At what point does your code start searching?
With the first key 00000000000000000000000000000000000000000000000000000000000000000000000000000001?
And for example, you can not specify a range?

Search range is defined in line 125 of the code by tamed kangaroos placement. Tamed herd placed randomly from (a+b)/2 to (a+b)/2+(b-a), where (a,b) is 'a priory' range for private key to solve. Such selection provides best overlapping of tame and wild herds.
Kangaroo from wild herd has only relative displacement from known EC-point P (line 129). Therefore their offset from P varies from 0 to (b-a) in the Puzzle.

21.08.19 00:08
rex12 
Re: Pollard's kangaroo with Python 2.7

Не,почему.можно и на русском.Зазвал не только англичан.вот у нас в группе возник вопрос что вроде люди уперлись в границу 255 бит в попытке переделать код, а 256 не работает.Ведь в основном нам известен только публичный ключ а не пространство приватного ключа.

21.08.19 00:34
57fe 

Administrator

Re: Pollard's kangaroo with Python 2.7

rex12:
Не,почему.можно и на русском.Зазвал не только англичан.вот у нас в группе возник вопрос что вроде люди уперлись в границу 255 бит в попытке переделать код, а 256 не работает.Ведь в основном нам известен только публичный ключ а не пространство приватного ключа.
Не уверен, что понял правильно. Нужен полный диапазон поиска приватного ключа? Как в методе ро-Полларда? В теории код должен работать и при полном диапазоне приватного ключа. Только в функции сложения надо добавить проверку на dx == 0 и возврат точки Z при этом, на всякий случай. Округления по модулю order в строках 146 и 155 не обязательны, хотя на первый взгляд может показаться, что они там необходимы.

 1 2 3