Encoding Systems
Relevant source files
The following files were used as context for generating this wiki page:The qib13 project is a reproducible multi-deviation seed recovery system. Its core functionality revolves around a set of deterministically generated Encoding Systems. These systems transform a short, memorable 13-character "generator code" into a secure 55-character seed. The entire process is seeded by a user-provided "master seed," ensuring that the same set of encoding systems can be reproduced for encoding or decoding.
The primary purpose of this architecture is to provide high reliability for seed recovery. By generating multiple "deviation" systems from a single master seed, the system creates several valid encoding/decoding paths. This allows a user to recover their original generator code from a seed even if they are unsure which specific system was used, or if one system's parameters are somehow compromised.
Sources: README.md:10-15, index.html:81-87
System Architecture
The qib13 system is built on four main components that work together to encode and decode information. The master seed is the root of trust, from which all encoding systems are deterministically derived.
This diagram shows the relationship between the core components of the qib13 system.
Sources: README.md:17-26
Core Components
| Component | Description | Constraints / Format |
|---|---|---|
| Master Seed | A string of any length that serves as the primary source of entropy for deterministically generating all encoding systems. | Any length string. A default is provided, but custom seeds are recommended. |
| Generator Code | A 13-character string that is the input message to be encoded. | Exactly 13 lowercase letters (a-z). |
| Encoding Systems | A set of algorithms, derived from the master seed, used to transform the generator code into a seed. Includes one 'Original' and N 'Deviation' systems. | Generated objects containing matrices and permutations. |
| Seed | A 55-character string produced by an encoding system, containing the generator code and parity data. | Exactly 55 lowercase letters (a-z). |
Sources: README.md:19-41, index.html:641-645, index.html:734-738
System Generation
All encoding systems are generated deterministically from the master seed. This process uses a cryptographically secure random number generator (CryptoSeededRandom) to ensure reproducibility. The number of deviation systems to generate is configurable.
The flow for generating the full suite of systems is as follows:
This diagram illustrates the process of creating both the original and deviation encoding systems from a master seed.
Sources: index.html:818-868, README.md:32-38
Cryptographic RNG
The system's determinism relies on a custom seeded random number generator, CryptoSeededRandom. This class uses HMAC-SHA256 in counter mode. It is initialized with a seed string (derived from the master seed). For each request for random data, it computes HMAC-SHA256(key, counter), where the key is derived from the initial seed and the counter is incremented. This ensures a reproducible, cryptographically secure stream of random numbers. A fallback pure-JS implementation of SHA-256 and HMAC is included for environments without the Web Crypto API.
Sources: index.html:206-441, README.md:143-144
EncodingSystem Class
The core logic for encoding and decoding is encapsulated in the EncodingSystem class. Each instance represents either an 'original' or 'deviation' system.
This diagram outlines the structure of the EncodingSystem class, which holds the system's parameters and methods.
Sources: index.html:444-620
System Types
Original System
The first system generated (ID 1) is the "original" system. It uses a single 42x13 matrix (P) to generate 42 parity characters from the 13-character message.
- Message length: 13
- Parity length: 42
- Total codeword length: 55 (13 + 42)
- Matrix
Pdimensions: 42x13
The createOriginalSystem function is responsible for its creation.
// index.html:870-882
function createOriginalSystem(id, seed) {
const rng = new CryptoSeededRandom(seed + "-original-" + id);
const matrixP = generateRandomMatrix(42, 13, rng);
const permutation = generateRandomPermutation(55, rng);
const inversePermutation = generateInversePermutation(permutation);
return new EncodingSystem(
id,
'original',
{ P: matrixP },
permutation,
inversePermutation
);
}
Sources: index.html:870-882, index.html:507-516, README.md:34-36
Deviation Systems
All subsequent systems are "deviation" systems. They use two matrices, P1 (15x13) and P2 (27x13), to generate two separate sets of parity characters. This results in a different codeword structure.
- Message length: 13
- Parity 1 length: 15
- Parity 2 length: 27
- Total codeword length: 55 (13 + 15 + 27)
- Matrix
P1dimensions: 15x13 - Matrix
P2dimensions: 27x13
The createDeviationSystem function is used to create these.
// index.html:884-896
function createDeviationSystem(id, seed) {
const rng = new CryptoSeededRandom(seed);
const matrixP1 = generateRandomMatrix(15, 13, rng);
const matrixP2 = generateRandomMatrix(27, 13, rng);
const permutation = generateRandomPermutation(55, rng);
const inversePermutation = generateInversePermutation(permutation);
return new EncodingSystem(
id,
'deviation',
{ P1: matrixP1, P2: matrixP2 },
permutation,
inversePermutation
);
}
Sources: index.html:884-896, index.html:524-536, README.md:34-36
Data Flow
Encoding Process
The encoding process transforms a 13-letter generator code into a 55-letter seed.
This flowchart details the steps to encode a generator code into a seed for both original and deviation systems.
Sources: README.md:159-166, index.html:498-536
Decoding Process
Decoding is the reverse process, recovering the generator code from a seed. The critical step is the parity check, which validates that the seed is valid for the given encoding system.
This flowchart shows the decoding and validation process. A mismatch in the parity check (Step L) results in an error, and the decoder must try a different system.
Sources: README.md:168-176, index.html:538-591
Conclusion
The Encoding Systems are the foundation of qib13's reliability and security model. By using a master seed to deterministically generate a suite of distinct Original and Deviation systems, qib13 provides multiple recovery paths for a single piece of information. The use of matrix multiplication for parity generation and a cryptographically secure RNG for system creation ensures that while the generator codes can be simple and memorable, the resulting seeds are complex and secure, with their integrity verifiable upon decoding. This architecture balances user convenience with cryptographic robustness.
Sources: README.md:209-218