Skip to content

Add Pollard’s Rho algorithm for discrete logarithm #13656

@saha2997

Description

@saha2997

Feature description

Description

The repository currently includes pollard_rho.py for integer factorization, but it does not include an implementation for Pollard’s Rho algorithm for discrete logarithm — a related but distinct algorithm used in modular arithmetic and cryptographic computations.

Proposed addition

Add a new file pollard_rho_discrete_log.py under the maths/ directory implementing:

def pollards_rho_discrete_log(g: int, h: int, p: int) -> int:
"""
Returns x such that g^x ≡ h (mod p), using Pollard's Rho discrete logarithm algorithm.
"""

Example

pollards_rho_discrete_log(2, 22, 29)
11

since 2^11 % 29 = 22

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThis PR modified some existing files

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions