Skip to content

Conversation

khushipy
Copy link

@khushipy khushipy commented Jun 18, 2025

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 cryptography directory
    Implemented modular exponentiation and order-finding methods
    Added tests in cryptography
    Issue Reference: Request to Implement Shor Algorithm #12318

@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Jun 18, 2025
@algorithms-keeper algorithms-keeper bot added the require descriptive names This PR needs descriptive function and/or variable names label Jun 20, 2025
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

from typing import Any


def is_prime(n: int) -> bool:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide descriptive name for the parameter: n

return all(n % i != 0 for i in range(3, r + 1, 2))


def modexp(a: int, b: int, m: int) -> int:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide descriptive name for the parameter: a

Please provide descriptive name for the parameter: b

Please provide descriptive name for the parameter: m

return result


def shor_classical(n: int, max_attempts: int = 10) -> str | tuple[int, int]:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide descriptive name for the parameter: n

@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Jun 20, 2025
@cclauss
Copy link
Member

cclauss commented Oct 14, 2025

Closing require_descriptive_names PRs to prepare for Hacktoberfest

@cclauss cclauss closed this Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed require descriptive names This PR needs descriptive function and/or variable names tests are failing Do not merge until tests pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants