kryptos-solver
v1.0.0
Published
Kryptos K1-style Vigenere solver using beam search, chi-squared, IoC, and bigram scoring. Adopted from https://github.com/chillhackr/kryptos
Maintainers
Readme
kryptos-solver
Kryptos K1-style Vigenere solver using beam search, chi-squared, IoC, and bigram scoring. K2 in dev.
Install
npm install kryptos-solverkryptos-solver
A cryptographic toolset in development for analyzing and solving Jim Sanborn's Kryptos sculpture. Ported from the Go logic, this package uses various techniques to recover keys without prior knowledge, targeted at solving KRYPTOS with as limited knowledge as possible.
🚀 Installation
The Workflow
This package includes a run-me.js script to help you get started immediately.
node run-me.jsBasic Usage
import { K1Solver } from 'kryptos-solver';
const solver = new K1Solver();
const k1cipher = "EMUFPHZLRFAXYUSDJKZLDKRNSHGNFIVJYQTQUXQBQVYUVLLTREVJYQTMKYRDMFD";
// solve(ciphertext, minKeyLen, maxKeyLen, beamWidth, frozenPositions)
const results = solver.solve(k1cipher, 8, 8, 10000);
console.log(`Top Key: ${results[0].key}`);
console.log(`Decrypted: ${results[0].plaintext}`);Poking from the Unknown: kryptos-solver doesn't just decrypt; it analyzes.
- Statistical Scoring The solver evaluates candidates using:
Chi-Squared Analysis: Measuring how closely a decryption matches English letter frequencies.
Index of Coincidence (IoC): Detecting the "burstiness" of the text to filter out noise.
Bigram Scoring: Checking for common English pairs like "TH", "HE", and "IN". (more should be considered)
Beam Search Instead of brute-forcing trillions of combinations, we use a Beam Search algorithm. It keeps only the most promising key prefixes at each step, allowing you to tweak and analysis different key lengths.
Frozen Positions If you suspect part of the key (e.g., the first two letters are "PA"), you can "freeze" them to drastically speed up the search:
//const frozen = { 0: 'P', 1: 'A' };
//solver.solve(ciphertext, 10, 10, 5000, frozen);
solver.solve(ciphertext, 10, 10, 5000); // run with default, no freezingHistory & The Keyed Alphabet K1 is what I understand to be a Keyed Vigenère cipher, but there may be a more accurate term Quagmire III. Its security relies on two things:
The Indicator Key: (PALIMPSEST)
The Keyed Alphabet: (KRYPTOS)
Can we solve it if the alphabet is unknown? Yes. While this package defaults to the known KRYPTOS alphabet, the methodology remains the same. An analyst would use this solver inside a loop, testing different potential "Alphabet Keywords" from a dictionary until the Chi-Squared scores "spike" toward a solution. This is where all the fun lies.
Notes
Test Logic: npm run test (Runs native Node.js tests)
It is expected the key will not return, the idea is to tweak this based on observed results and different settings.
Dev Mode: npm run dev (Watch mode for your run-me.js)
Roadmap
K1 Quagmire III Solver
Beam Search Algorithm
[ ] K2 Transposition Analysis (Coming Soon)
