Encoding Process Flow
Relevant source files
The following files were used as context for generating this wiki page:
The encoding process flow in qib13 is a deterministic system that transforms a 13-character generator code into a 55-character seed. This process relies on a user-provided Master Seed to generate one or more Encoding Systems, each capable of performing the transformation. The core purpose is to create a reproducible and reliable method for seed generation, where a simple, memorable generator code can be expanded into a more complex seed.
The system supports two types of encoding: an "Original" system and multiple "Deviation" systems. Each system uses a unique set of matrices and permutations derived from the master seed, ensuring that the same generator code produces different seeds depending on the system used. This adds a layer of security and provides multiple recovery paths.
Sources: README.md:9-14, index.html:828-857
System Architecture
The encoding process is managed by the EncodingSystem class, which encapsulates the logic for both "Original" and "Deviation" type systems. The generation of these systems is handled by factory functions (createOriginalSystem, createDeviationSystem) that use a cryptographically secure random number generator, CryptoSeedenRandom, seeded by the master seed.
Sources: index.html:620-626, 923-952
Core Components
The encoding architecture is built upon two main JavaScript classes.
This diagram illustrates the relationship between the main classes responsible for the encoding process.
Sources: index.html:430-520, 620-776
System Generation
Before encoding can occur, one or more EncodingSystem instances must be generated. This is initiated by the generateSystems() function, which orchestrates the creation of both the original and deviation systems.
- Master Seed: A user-provided string serves as the root seed. A default is used if none is provided.
- RNG Initialization: A
CryptoSeededRandominstance is created for each system. The seed for the RNG is a combination of the master seed and a system-specific suffix (e.g.,my-master-seed-original-1ormy-master-seed-deviation-2). - Matrix & Permutation Generation: The seeded RNG is used to generate random matrices and a random permutation array.
- System Instantiation: An
EncodingSystemobject is created with the generated matrices and permutation.
This flowchart shows the process of creating the encoding systems from a master seed.
Sources: index.html:859-921, 923-952, README.md:27-35
Seed Generation Flow
The generateSeed() method of the EncodingSystem class is the entry point for encoding a generator code. It internally calls either generateSeedOriginal() or generateSeedDeviation() based on the system's type.
Sources: index.html:627-633
Encoding Steps
The following diagram details the sequence of operations to convert a 13-character generator code into a 55-character seed.
Sources: index.html:639-669, 1010-1056
Encoding System Comparison
The two types of encoding systems differ in their matrix structure and the resulting parity information.
| Property | Original System | Deviation System |
|---|---|---|
| Type Identifier | original | deviation |
| Matrices | One matrix P (42x13) | Two matrices: P1 (15x13) and P2 (27x13) |
| Parity Size | 42 numbers | 42 numbers (15 from P1 + 27 from P2) |
| Codeword Structure | [message (13)] + [negated_parity (42)] | [message (13)] + [neg_parity1 (15)] + [neg_parity2 (27)] |
| Total Codeword Size | 55 numbers | 55 numbers |
Sources: index.html:639-669, 923-952, README.md:32-33
Key Functions
The encoding process relies on several mathematical and data transformation helper functions.
lettersToNumbers(letters): Converts a string of 'a'-'z' characters into an array of numbers (0-25).// index.html:730-736 lettersToNumbers(letters) { const numbers = []; for (let i = 0; i < letters.length; i++) { numbers.push(letters.charCodeAt(i) - 97); } return numbers; }matrixVectorMultiplyMod26(matrix, vector): Performs matrix-vector multiplication over the finite field Z₂₆.// index.html:746-756 matrixVectorMultiplyMod26(matrix, vector) { const result = []; for (let i = 0; i < matrix.length; i++) { let sum = 0; for (let j = 0; j < matrix[i].length; j++) { sum += matrix[i][j] * vector[j]; } result.push(sum % 26); } return result; }applyPermutation(vector, perm): Reorders the elements of a vector according to a permutation array.// index.html:758-765 applyPermutation(vector, perm) { const result = new Array(vector.length); for (let i = 0; i < perm.length; i++) { result[i] = vector[perm[i]]; } return result; }numbersToLetters(numbers): Converts an array of numbers (0-25) back into a string of 'a'-'z' characters.// index.html:738-744 numbersToLetters(numbers) { let letters = ''; for (let i = 0; i < numbers.length; i++) { letters += String.fromCharCode(numbers[i] + 97); } return letters; }
Conclusion
The encoding process flow in qib13 is a well-defined, deterministic procedure for transforming a short, memorable generator code into a 55-character seed. By leveraging a master seed to create distinct "Original" and "Deviation" encoding systems, it provides both reproducibility and enhanced security. The flow is a sequence of discrete mathematical operations: character-to-number conversion, matrix multiplication for parity generation, codeword assembly, permutation, and finally, number-to-character conversion to produce the final seed.
Sources: README.md:9-14, 102-105