question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Discrete Log needs a Cutoff

See original GitHub issue

Right now, the discrete log code will happily run forever if you give it a really huge number. Such a thing might manifest when decrypting a corrupt ciphertext, where the discrete log of a “random” number is likely to be enormous. Or worse, it might not have a solution at all. (Most elements mod P are not reachable from the generator.)

Quick summary

The discrete log function needs to take as input an optional “maximum” value. If the dlog cache computation reaches a number greater than the maximum, then we declare that there does not exist a discrete log and trigger an error.

How to indicate the error

We could return None, changing the type signature of the code from returning int to Optional[int]. Or, we could return something obviously out-of-bounds like -1. Either way, the ability for discrete-log to fail needs to propagate through all the decryption code that calls it.

What’s a reasonable bound for triggering the error

The simplest answer is “how many ballots are there”, then multiply a fudge factor. If we’re dealing with an election with a million ballots, then we’re not going to have any homomorphic sums greater than a million, so bounding at 1.1 million seems reasonable. The hard part is propagating the error bound from the high-level computation (here I am computing a homomorphic tally) down to the low-level computation (here I am decrypting a single ElGamal ciphertext).

Setting the bound

Have a dlog_set_global_error_bound method or some such thing which can be called from far away, and store the state in a private variable inside the dlog package. Have a default value which is on the big-ish side, but which isn’t completely bonkers. What’s the biggest number we might ever reasonably want to decrypt? What’s the population of the largest state in the U.S.? That would be California (~40 million). So a conservative default upper bound might be 100 million, and then we could make it much smaller if/when we knew any better for any specific computation.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jpiccommented, Dec 6, 2020

Also affected, just had to reboot 😂 had the wrong public key though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Discrete logarithm - Wikipedia
Discrete logarithms are quickly computable in a few special cases. However, no efficient method is known for computing them in general. Several important ......
Read more >
From discrete-log to lattices: maybe the real lessons were our ...
Abstract. In the fall of 2018, a professor became obsessed with conspiracy theories of deeper con- nections between discrete-log based cryptography and ...
Read more >
Sage vs. Magma on DLP - Cryptography Stack Exchange
I have read in the Magma documentation that 236 might be a cutoff, but here, the largest prime is below that threshold. A...
Read more >
Quantum algorithms for computing general discrete logarithms ...
Compared to Shor's algorithm for computing general discrete logarithms, this yields a reduction by up to a factor of two in the number...
Read more >
9 The discrete logarithm problem - MIT Mathematics
to compute discrete logarithms in the additive group of a finite field! All we need to do is compute the multiplicative inverse of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found