Primal-Core is a robust mathematical utility designed for high-speed, cryptographically secure primality evaluation. Developed in Python, the suite implements a hybrid algorithmic approach, leveraging deterministic prime bounds for standard 64-bit integers and the probabilistic Miller-Rabin test for cryptographic-scale numbers.
Standard trial division approaches operate at a time complexity of
To evaluate the primality of an odd integer
where
$a^d \equiv 1 \pmod{n}$ -
$a^{2^r \cdot d} \equiv -1 \pmod{n}$ for some integer$r$ in the range$0 \le r < s$
For processing performance, the suite does not strictly rely on randomness for standard environments. For integers
- Hybrid Evaluation Engine: Seamless switching between deterministic execution for standard computational bounds and probabilistic evaluation for large-scale cryptographic keys.
- High-Precision Telemetry: Built-in benchmarking tools measuring execution latency down to fractions of a millisecond utilizing CPU hardware counters (
time.perf_counter). - Interactive CLI: An isolated, interactive shell designed for continuous evaluation and high-load stress testing.
It is recommended to deploy Primal-Core within an isolated virtual environment to maintain dependency integrity.
git clone https://github.com/FN-BuildStack/primal-core.git
cd primal-corepython -m venv venv
source venv/bin/activatepython -m venv venv
.\venv\Scripts\Activate.ps1pip install -r requirements.txtInitialize the interactive Command Line Interface by executing the source module directly:
python -m src.cliPerforms a direct primality evaluation on the provided integer and returns the modular exponentiation latency.
[primal-core] > check 2147483647
[*] Evaluating: 2147483647...
[+] Result: PRIME
[+] Execution Time: 0.2287 ms
Triggers a high-load stress test, executing the primality suite against massive random integers up to the 64-bit limit:
Generates a performance matrix upon completion.
[primal-core] > benchmark 50000
[*] Initializing benchmark with 50000 iterations...
The suite includes automated unit tests handled by pytest, verifying:
- Edge cases
- Small primes
- Composite numbers
- Large-scale known primes
Run the test suite with:
pytest tests/