Crack RSA-32
20x faster RSA factorization using stigmergic ant colony optimization. Built in 1 hour at AI3 Chiang Mai.
Traditional RSA factorization requires checking every prime number one by one. We used ant colony optimization to let 8 virtual ants explore a graph of ~6,500 prime numbers simultaneously, following pheromone trails to find factors faster.
Proven result: n=2,563,079,017 factored in approximately 1,200 evaluations vs ~25,000 for brute force (20x speedup). No ant knows the answer—the solution emerges from their collective trails.
The Challenge
RSA encryption relies on the difficulty of factoring large numbers into their prime factors. While easy to multiply two primes together (p × q = n), finding those primes given only n is computationally expensive. Traditional brute force checks every prime sequentially—extremely slow.
AI3 Chiang Mai Achievement: Using ant colony optimization, we reduced factorization from ~25,000 evaluations (brute force) to ~1,200 evaluations—a 20x speedup. The ants explore a Memgraph of prime numbers, leaving pheromone trails that guide others toward factors.
How It Works
Ant Colony Optimization
Instead of checking primes one by one, we model prime factorization as a graph search problem. 8 virtual ants explore a Memgraph of ~6,500 prime numbers simultaneously, leaving pheromone trails on edges they traverse.
Stigmergic Mechanics
The system uses three key parameters to balance exploration and exploitation:
- Pheromone Evaporation (0.95): Trails decay over time, preventing premature convergence on suboptimal paths
- Exploration Rate (0.2): 20% chance to try random edges, ensuring the colony doesn't get stuck in local optima
- Graph Structure: Memgraph stores prime relationships as nodes and edges, enabling fast graph traversal and pheromone updates
- Probabilistic Selection: Ants choose next prime based on pheromone^α × heuristic^β, where α=1, β=2
Implementation
Results
Factorized n=2,563,079,017 in approximately 1,200 evaluations compared to ~25,000 for brute force sequential checking. Stigmergic coordination dramatically reduces search space.
Comprehensive test suite covering RSA generation, graph construction, pheromone mechanics, ant behavior, and end-to-end factorization scenarios.
Prime number graph with ~6,500 nodes stored in Memgraph. Enables fast pheromone updates and probabilistic edge selection for 8 concurrent virtual ants.
No ant knows the solution individually. The factorization emerges from collective pheromone trail reinforcement—a demonstration of stigmergic problem-solving.
Built in 1 hour at AI3 Chiang Mai Mini Hackathon (December 2025). Proof-of-concept for applying ant colony optimization to cryptographic problems.
Full implementation available on GitHub. Includes RSA key generation, graph construction, pheromone mechanics, and multi-ant orchestration code.
From Proof-of-Concept to Production
"The queen doesn't tell anyone what to do. In fact, nobody tells anybody what to do."
— Deborah Gordon, Stanford biologist studying ant colonies
What started as a 1-hour hackathon experiment became the foundation for production infrastructure hunting real cryptocurrency. The same stigmergic principles that cracked RSA-32 now power a distributed worker network targeting Bitcoin puzzles worth over $600,000.
Proved ant colony optimization works on cryptographic problems. 20x speedup on RSA factorization using stigmergic coordination.
Abstracted the pattern into a reusable package. Anyone can contribute compute with a single command: pip install ants-worker && ants-worker join
Same stigmergic code now hunting Bitcoin Puzzle #71 (7.1 BTC = $600K+). Distributed workers coordinate through pheromone trails to search 2^70 keyspace.
The Evolution
Key Insight
The hackathon proved the fundamental principle: stigmergic coordination beats individual cleverness. No ant needs to be smart. The solution emerges from their collective trails. This insight now powers production infrastructure where the stakes are real.
From 1-hour proof-of-concept to $600K+ production deployment. Same ants. Different puzzle. Same emergence.
Project Status
- ✓ RSA key generation (crack/rsa.py)
- ✓ Memgraph prime graph (crack/graph.py)
- ✓ Pheromone mechanics (crack/pheromones.py)
- ✓ Multi-ant orchestration (crack/swarm.py)
- ✓ 20x brute force speedup
- ✓ n=2,563,079,017 factored
- ✓ ~1,200 vs ~25,000 evals
- ✓ 187 comprehensive tests
- ○ RSA-64 challenges
- ○ GPU acceleration
- ○ Distributed workers
- ○ Larger prime graphs
Technology Stack
Stores ~6,500 prime numbers as nodes with edges representing potential factorization paths. Enables fast pheromone updates and probabilistic edge traversal.
Core implementation in Python with pytest for testing, sympy for number theory, and neo4j driver for Memgraph connectivity.
Generate RSA-32 keypairs using sympy prime number utilities. Graph construction builds bidirectional edges between primes for ant traversal.
Probabilistic edge selection (pheromone^α × heuristic^β), pheromone evaporation (0.95), exploration rate (0.2), and multi-ant parallel execution.
Explore the Code
This is open research. Study the implementation, improve the algorithm, or apply stigmergic optimization to your own problems. The code is yours to build on.
"20x faster than brute force. Not because one ant was smart, but because the colony learned together."
Built at AI3 Chiang Mai Mini Hackathon, December 2025. Proof that collective intelligence beats individual cleverness.