diffsquare
From the Author
Created by Abhrankan Chakrabarti, this project implements an efficient version of Fermat’s Difference of Squares method for factoring large integers. Written in Rust, it leverages the malachite crate for high-performance arbitrary-precision arithmetic.
Recent Update – v0.3.2
✅ New in v0.3.2: Added test suite for factoring large semiprimes using the difference_of_squares method.
Key Features
diffsquare is a fast and lightweight CLI utility for factoring large integers using Fermat’s Difference of Squares method.
- Efficient Fermat's Difference of Squares factorization.
- Support for decimal, hexadecimal, and scientific notation input.
- Command-line interface with interactive fallback.
- Quiet mode (
-q) disables interactive prompts and hides intermediate output — useful for piping or scripting. - JSON output mode (
--json) for scripting and automation. --time-onlyflag for displaying only the execution time (useful for benchmarking).- Optional control over iteration starting point and precision.
- Scientific notation used in verbose mode for large integer readability.
- Execution time displayed after successful factorization.
GitHub Repository:
diffsquare
Installation
Install via Cargo:
Ensure $HOME/.cargo/bin is in your PATH:
Build Instructions
To build from source manually:
🔧 Usage Examples
Run diffsquare interactively or use flags for automation:
# 🔹 Fully interactive: prompts for modulus, iteration, and precision
# 🔹 Provide a decimal modulus
# 🔹 Provide a hexadecimal modulus
# 🔹 Specify starting iteration (modulus still required)
# 🔹 Use custom precision for verbose scientific output
# 🔹 Combine all options and suppress output (precision not required in quiet mode)
# 🔹 JSON output for scripting and automation
# 🔹 Show only execution time (no output of factors)
# 🔹 Check installed version
Command-Line Flags
| Short | Long | Description |
|---|---|---|
-n |
--mod |
Number to factor (supports 0x for hex or scientific notation) |
-i |
--iter |
Starting iteration value |
-p |
--prec |
Precision for verbose scientific output |
-q |
--quiet |
Suppress prompts and intermediate output |
--json |
Print result as JSON (suppresses all other output) | |
--time-only |
Display only the execution time (useful for benchmarking) | |
-h |
--help |
Show usage help |
-v |
--version |
Show version |
Tags
Tags
#RustLang #NumberTheory #OpenSource #BigInteger #Cryptography #Fermat #AbhrankanChakrabarti #Malachite