Python Forum
RSA_ddprx_search - Integer Factorization Tool - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: Code sharing (https://python-forum.io/forum-5.html)
+--- Thread: RSA_ddprx_search - Integer Factorization Tool (/thread-44170.html)



RSA_ddprx_search - Integer Factorization Tool - fosuwxb - Mar-26-2025

RSA_ddprx_search - Integer Factorization Tool
A parallel processing tool designed to find prime factors of integers using optimized algorithms.

Features
Multi-process parallel computation for faster factorization
Intelligent Monte Carlo-style search algorithm
Checkpoint capability to resume interrupted calculations
Auto-recovery from errors
Progress tracking and detailed logging
Support for various output formats
[attachment=3251]
We construct a dataset by which a certain number of integers can be calculated to compute the greatest common divisor with an integer to be factorized. We also design a dynamic distributed parallel network to perform the search on the dataset. The network is grid alike, aopen to all the computers willing to take part in the computation.

We post our source codes here for interesters to vent.

Requirements
  • Python 3.6+
  • Optional: gmpy2 library for faster GCD calculations
Installation
Install the optional dependency:
pip install gmpy2

Usage
Basic usage:
python RSA_ddprx_search.py -n 1438236853

Command Line Arguments
Argument Description Default
-n, --number Number to factorize 1438236853
-g, --step Densification repetition rate 30
-m, --processes Number of parallel processes CPU count
-c, --chunk-size Calculation chunk size 5,000,000
-o, --output Output filename rgTable.txt
--checkpoint Checkpoint filename checkpoint.json
--disable-checkpoint Disable checkpoint feature False
--resume Resume from last checkpoint False
--encoding File encoding utf-8
--no-pretty Disable pretty output formatting False
-v, --verbose Show verbose output False
--auto-continue Wait time in seconds before auto-continue on failure, 0 to disable None

Examples
  • Basic Factorization
    python RSA_ddprx_search.py -n 2809686223 -g 20
  • With More Processes
    python RSA_ddprx_search.py -n 2809686223 -m 8
  • Enabling Auto-Continue
    python RSA_ddprx_search.py -n 2809686223 --auto-continue 30
  • Resuming From Checkpoint
    python RSA_ddprx_search.py --resume

Output Format
The tool generates a result file (default: rgTable.txt) containing
  • Initial parameters
  • Processing details for each CID (Computation ID)
  • Any found factors
  • Total runtime

Troubleshooting
  1. If you encounter memory errors, try reducing the -c (chunk size) parameter
  2. For performance issues, adjust the number of processes with -m
  3. If the program crashes, use the --resume option to continue from the last checkpoint

How It Works
The algorithm uses a distributed search method to find factors of integers:

  1. Divides the search space into multiple segments (ISZ blocks)
  2. Processes each segment in parallel
  3. Uses a Monte Carlo-style approach to efficiently explore the search space
  4. Applies GCD calculations to find common factors

Performance Tips
  1. The gmpy2 library significantly improves GCD calculation performance
  2. Adjust -g (densification repetition rate) parameter for balance between speed and thoroughness
  3. Set -m to match or slightly exceed your CPU core count
  4. For very large numbers, increase chunk size -c if memory allows