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

Added classical implementation of Shor’s Algorithm #12545

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

adityakrmishra
Copy link

  • Implemented a classical simulation of Shor’s Algorithm in algorithms/cryptography/shor_algorithm.py
  • The algorithm factors a composite number N without using quantum computing libraries
  • Uses modular exponentiation and order-finding to determine factors
  • Includes an example usage for testing

Describe your change:

Summary

This PR adds a classical implementation of Shor’s Algorithm to the cryptography module. The algorithm factors a given composite number N by:

  • Checking for trivial factors using GCD
  • Finding the order of a random integer a modulo N
  • Using the order to derive factors of N

Changes

  • Added shor_algorithm.py in algorithms/cryptography/
  • Implemented modular exponentiation and order-finding methods
  • Included an example usage for verification

Issue Reference

Closes #12318

Testing

  • Manually tested with N = 15, 21, 35, 55
  • Outputs correct factor pairs in all cases

Possible Improvements

  • Add unit tests in tests/cryptography/test_shor_algorithm.py
  • Optimize order-finding using more efficient methods

Looking forward to feedback! 🚀

adityakrmishra and others added 2 commits January 29, 2025 19:47
- Implemented a classical simulation of Shor’s Algorithm in `algorithms/cryptography/shor_algorithm.py`
- The algorithm factors a composite number N without using quantum computing libraries
- Uses modular exponentiation and order-finding to determine factors
- Includes an example usage for testing
@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests are failing Do not merge until tests pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request to Implement Shor Algorithm
1 participant