Skip to content

Commit

Permalink
reformating
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeisel committed Mar 21, 2024
1 parent db89952 commit 2513c93
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/helperfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ def find_period(result_list: [(int, int, int)], n: int, p: int, g: int) -> int:
p + 1
) # init to p+1 (sth larger than the real result)
for (y1, _, _) in result_list:
meas_div = y1 / (2**n)
meas_div = y1 / (2 ** n)
frac_meas = Fraction(meas_div).limit_denominator(p - 1)

# check if denominator fits
r_candidate = frac_meas.denominator
if g**r_candidate % p == 1:
if g ** r_candidate % p == 1:
# fits
if r_candidate < smallest_fitting_denominator:
smallest_fitting_denominator = r_candidate
Expand Down
6 changes: 3 additions & 3 deletions app/services/objective_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ def generate_shor_discrete_log_objective_response(
r = find_period(res, n, input.p, input.g)

# k is inferred from the measurement result from first stage
k = int(round((y1 * r) / (2**n), 0))
k = int(round((y1 * r) / (2 ** n), 0))
print("k = ", k)

# m (the discrete log) is calculated by using the congruence:
# ((km mod r)/r)*2^n = m_stage2
# v = m_stage2*r/2^n
v = (y2 * r) / (2**n)
v = (y2 * r) / (2 ** n)
# print("v=", v) # = km mod r

# k inverse exists?
Expand All @@ -137,7 +137,7 @@ def generate_shor_discrete_log_objective_response(
# print("found m=", m)

# check if this m actually fits
if (input.g**m % input.p) == input.b:
if (input.g ** m % input.p) == input.b:
correct_m = m

graphic = None
Expand Down

0 comments on commit 2513c93

Please sign in to comment.