Parallel discrete logs (continues: modular arithmetic)

Click For Summary
SUMMARY

This discussion focuses on calculating discrete logarithms in GF(p) using the baby-step giant-step algorithm for a single n value across multiple odd primes p, specifically in the range of 10 million to 500 million. The author aims to optimize performance by leveraging the properties of small moduli and the ability to factor p-1 quickly. The implementation of the algorithm has been challenging, requiring additional adjustments to the program, but the author is optimistic about the memory requirements fitting within their L1 cache. The discussion invites insights from others experienced in coding discrete logarithm algorithms.

PREREQUISITES
  • Understanding of discrete logarithms in finite fields (GF(p))
  • Familiarity with the baby-step giant-step algorithm
  • Knowledge of modular arithmetic and prime factorization
  • Experience with performance optimization in algorithm implementation
NEXT STEPS
  • Research advanced techniques for optimizing the baby-step giant-step algorithm
  • Explore the implementation of the number field sieve for discrete logarithms
  • Investigate memory management strategies for large lookup tables
  • Learn about alternative algorithms for discrete logarithm calculations in GF(p)
USEFUL FOR

Mathematicians, cryptographers, and software developers working on algorithms for discrete logarithm problems, particularly those dealing with large prime moduli and performance optimization.

CRGreathouse
Science Advisor
Homework Helper
Messages
2,832
Reaction score
0
I'm working on a problem that involves calculating many discrete logarithms in GF(p): given n and an odd prime p, either find a k with 2^k\equiv n\pmod p or return "failure" if no such k exists. Now there are many algorithms for computing discrete logarithms, some of which are designed for many queries: precalculations are done on a given p which allow queries for each n to be done quickly.

I have the opposite problem: one n value (say, -2131) but many odd primes p. In particular, I have been using the odd primes up to 10 million to 60 million. (I hope to increase this range dramatically, but current methods are too slow.)

Because I'm using sequential primes, I could if desired factor p-1 (or other terms) quickly with a sieve. Certain other calculations that are conventionally 'hard' become easy with such small moduli. In particular, since all numbers I use fit into a single machine word, multiplication is fast relative to its normal cost in multiprecision.

Further, the problem I'm working on has tolerance for gaps. A rare response of "unknown" from the algorithm would not be harmful. Each prime p for which I compute the discrete log contributes 'value' for the problem inversely proportional to the order of 2 mod p, so doubling the speed at the cost of 10% "unknown" values would be worthwhile.

Being wholly ignorant of the subtleties of the various algorithms I've seen, I thought to implement the baby step giant step algorithm to see how long it takes. The memory shouldn't be an issue, I hope -- for primes under a billion it should fit in my 128 kB L1 cache. (Unless I have 64 kB, in which case perhaps it is an issue.) The number field sieve methods seem to be (1) hard to code and (2) too slow for small primes, but the other ones I'm not sure about. Does anyone have experience here?
 
Physics news on Phys.org
OK, I've implemented a basic version of the baby-step giant-step algorithm. It was actually a bit more complicated than I'd hoped: while it's a simple thing of itself, making it run in my program required a number of other changes.

I've set it to run on a huge problem size: the primes up to 500 million. This means 26 million discrete logarithm problems with prime moduli of 8-9 digits. Fortunately the lookup tables aren't bad at all, 90 kB in the worst case.

I inadvertently left the 'sanity checks' in the program, which check the discrete log after calculating it. While it will slow the program down slightly, it'll be nice to know it worked properly if that doesn't fire.


Any thoughts from someone who's actually used or coded some kind of discrete log program would be welcome. Heck, any comments would be appreciated period -- sometimes a second look can tell a lot, and I can miss obvious stuff. ;)
 

Similar threads

  • · Replies 17 ·
Replies
17
Views
7K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 11 ·
Replies
11
Views
7K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K