d = 0 when solving discrete logarithms with x = 1
LukasMansour opened this issue · 3 comments
Hi again,
when I try to solve DLPs with x = 1, e.g. 3^d = 1 mod 7 .
I would expect d = 6 as it is the smallest positive integer for r.
However, I receive d = 0.
Example output from my DLP circuit (3^d = 1 mod 7):
{'000 001': 125, '000 100': 209, '000 101': 122, '000 111': 130, '000 011': 127, '000 110': 52, '000 010': 67, '000 000': 168}
My code (it uses g^x = b convention):
from quaspy.logarithmfinding.general.postprocessing import solve_j_k_for_d_given_r
fail_count = 0
success_count = 0
x = -1
for (j, k, freq) in result_list: # note I converted it to [(j,k,freq)] correctly.
x_cand = solve_j_k_for_d_given_r(j, k, n, 0, n, IntegerModRingMulSubgroupElement(g, p),
IntegerModRingMulSubgroupElement(b, p), r)
print(x_cand) # All solutions are 0 from Quaspy??
if x_cand is not None and ((g ** x_cand) % p) == b:
if x != -1:
x = min(x, int(x_cand))
else:
x = int(x_cand)
success_count += freq
else:
fail_count += freq
print("num_fail:", fail_count)
print("num_success:", success_count)
print({"x": x, "success_probability": success_count / shots})
print(f"x={x}")
Unfortunately, I am very busy at the moment with research-related work, so I am quite limited in how much time I can spend on providing support for Quaspy. This being said, the logarithm returned is on the interval
If you wish to find the order of
Using order finding for the special case when b == 1, solved the issue, thank you :).
I think there is avenue to argue the logarithm should be in the interval [1, r], but this solution is perfectly fine.
Thank you for your timely responses and good luck with your research!
Sure!
I think there is avenue to argue the logarithm should be in the interval [1, r], but this solution is perfectly fine.
The post-processing requires the order
If you wish, you can of course check if the solution is