Exetools  

Go Back   Exetools > General > General Discussion

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #10  
Old 10-25-2016, 00:19
chants chants is offline
VIP
 
Join Date: Jul 2016
Posts: 826
Rept. Given: 47
Rept. Rcvd 50 Times in 31 Posts
Thanks Given: 737
Thanks Rcvd at 1,140 Times in 529 Posts
chants Reputation: 51
The general number field sieve is faster than a naive brute force, and there are a variety of other techniques to reduce prime checking in DLs. It is sub-exponential but seems to be above polynomial in time to find a solution.

I would suggest studying discrete mathematics, computer algebra, cryptography and algorithms if you want to be great at reversing these types of scenarios. Sitting and looking at assembly code is not so helpful if you are not versed in the algorithms and mathematics behind what is going on. However it is a theoretical and long journey to master. You can known Fermat's little theorem and Carmichael numbers and other useful tools in primality testing and modular exponentiation and so forth.

An example solution which is more efficient than exhaustive brute force is as follows: given b^l=n (mod p) and you want to solve for the smallest l with just normal integer sizes:

Code:
		unsigned int c;
		long long an = 1; //x0 = b ^ sqrt(p) % p
		for (c = 0; c * c < p; c++) {
			an = an * b % p;
		}
		unsigned int d = c; //sqrt(p)
		std::map<long long, long long> m;
		long long cur = an; //x(i) = b ^ sqrt(p) % p to b ^ (sqrt(p) ^ sqrt(p)) % p
		for (c = 1; c <= d; c++) {
			if (!m.count(cur))
				m[cur] = c;
			cur = cur * an % p;
		}
		cur = n; //y(i) = nb % p to n(b ^ sqrt(p)) % p
		long long minans = -1;
		for (c = 0; c <= d; c++) {
			if (m.count(cur)) {
				long long ans = m[cur] * d - c;
				if (ans < p) {
					minans = minans == -1 ? ans : (ans < minans ? ans : minans);
				}
			}
			cur = cur * b % p;
		}
		if (minans != -1) std::cout << minans << std::endl;
		else std::cout << "no solution" << std::endl;
If you can explain the mathematics behind it, then you will be at a very good problem solving level in this area.

Last edited by chants; 10-25-2016 at 00:29.
Reply With Quote
The Following 2 Users Gave Reputation+1 to chants For This Useful Post:
mr.exodia (10-26-2016), tonyweb (10-29-2016)
The Following 2 Users Say Thank You to chants For This Useful Post:
Cryo (11-08-2016), tonyweb (10-29-2016)
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pointers in Delphi chessgod101 Source Code 1 04-06-2014 23:54
Need some pointers with a .Net target Sailor_EDA General Discussion 10 03-03-2010 12:18
x64 Website Pointers Evilcry x64 OS 3 10-01-2009 22:25
Need some pointers lorn General Discussion 8 11-04-2004 13:20


All times are GMT +8. The time now is 23:21.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )