Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raise ValueError when discrete_log does not exist #38316

Open
2 tasks done
DaveWitteMorris opened this issue Jun 30, 2024 · 2 comments
Open
2 tasks done

raise ValueError when discrete_log does not exist #38316

DaveWitteMorris opened this issue Jun 30, 2024 · 2 comments
Labels

Comments

@DaveWitteMorris
Copy link
Member

DaveWitteMorris commented Jun 30, 2024

Steps To Reproduce

sage: Kp = GF(5)
sage: g = Kp(3)
sage: a = Kp(1)
sage: dl = discrete_log(a, g, bounds=(1, 2), operation="*")
sage: print(g ** dl == a, dl)
False 2

Expected Behavior

A ValueError should be raised, because there is no solution within the specified bounds.

Actual Behavior

discrete_log returns a value that is not a valid logarithm.

Additional Information

Reported in this sage_devel thread.

Environment

Various.

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide
@grhkm21
Copy link
Contributor

grhkm21 commented Jun 30, 2024

sage: K = GF(2^61 - 1)
sage: d = discrete_log(K(1), K(3), bounds=(1,2^30), algorithm="lambda", operation="*")
sage: d <= 2^30
# False

this too

@DaveWitteMorris
Copy link
Member Author

Probably the "Expected Behavior" that I suggested is not completely correct. I think bounds should be considered to be an aid to the algorithm, not a restriction on the output. So the method should either return a valid logarithm, or raise a ValueError (because there is no logarithm within the specified bounds). And this behaviour should be documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants