gchq/CyberChef · error · OperationError

Χ3 start must be between 1 and 29

Error message

Χ3 start must be between 1 and 29

What it means

Thrown by the Lorenz operation when the Χ3 (chi-3) wheel start position is out of range. The Χ3 wheel has 29 cams, so the 1-indexed start must be in [1, 29]. Guard is on line 274 of src/core/operations/Lorenz.mjs.

Source

Thrown at src/core/operations/Lorenz.mjs:274

            m61 = args[13],
            x1 = args[14],
            x2 = args[15],
            x3 = args[16],
            x4 = args[17],
            x5 = args[18];

        this.reverseTable();

        if (s1<1 || s1>43) throw new OperationError("Ψ1 start must be between 1 and 43");
        if (s2<1 || s2>47) throw new OperationError("Ψ2 start must be between 1 and 47");
        if (s3<1 || s3>51) throw new OperationError("Ψ3 start must be between 1 and 51");
        if (s4<1 || s4>53) throw new OperationError("Ψ4 start must be between 1 and 53");
        if (s5<1 || s5>59) throw new OperationError("Ψ5 start must be between 1 and 59");
        if (m37<1 || m37>37) throw new OperationError("Μ37 start must be between 1 and 37");
        if (m61<1 || m61>61) throw new OperationError("Μ61 start must be between 1 and 61");
        if (x1<1 || x1>41) throw new OperationError("Χ1 start must be between 1 and 41");
        if (x2<1 || x2>31) throw new OperationError("Χ2 start must be between 1 and 31");
        if (x3<1 || x3>29) throw new OperationError("Χ3 start must be between 1 and 29");
        if (x4<1 || x4>26) throw new OperationError("Χ4 start must be between 1 and 26");
        if (x5<1 || x5>23) throw new OperationError("Χ5 start must be between 1 and 23");

        // Initialise chosen wheel pattern
        let chosenSetting = "";
        if (pattern === "Custom") {
            const re = new RegExp("^[.xX]*$");
            if (lugs1.length !== 43 || !re.test(lugs1)) throw new OperationError("Ψ1 custom lugs must be 43 long and can only include . or x ");
            if (lugs2.length !== 47 || !re.test(lugs2)) throw new OperationError("Ψ2 custom lugs must be 47 long and can only include . or x");
            if (lugs3.length !== 51 || !re.test(lugs3)) throw new OperationError("Ψ3 custom lugs must be 51 long and can only include . or x");
            if (lugs4.length !== 53 || !re.test(lugs4)) throw new OperationError("Ψ4 custom lugs must be 53 long and can only include . or x");
            if (lugs5.length !== 59 || !re.test(lugs5)) throw new OperationError("Ψ5 custom lugs must be 59 long and can only include . or x");
            if (lugm37.length !== 37 || !re.test(lugm37)) throw new OperationError("M37 custom lugs must be 37 long and can only include . or x");
            if (lugm61.length !== 61 || !re.test(lugm61)) throw new OperationError("M61 custom lugs must be 61 long and can only include . or x");
            if (lugx1.length !== 41 || !re.test(lugx1)) throw new OperationError("Χ1 custom lugs must be 41 long and can only include . or x");
            if (lugx2.length !== 31 || !re.test(lugx2)) throw new OperationError("Χ2 custom lugs must be 31 long and can only include . or x");
            if (lugx3.length !== 29 || !re.test(lugx3)) throw new OperationError("Χ3 custom lugs must be 29 long and can only include . or x");
            if (lugx4.length !== 26 || !re.test(lugx4)) throw new OperationError("Χ4 custom lugs must be 26 long and can only include . or x");

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Set the Χ3 start argument to an integer in [1, 29].
  2. Clamp generated values with `((n - 1) % 29) + 1`.
  3. Reset wheel-start fields to 1 and re-enter.

Example fix

// before: args[16] = 30  -> throws
// after:  args[16] = 1   -> ok
Defensive patterns

Strategy: validation

Validate before calling

// Χ3 start (args[16]) must be in [1, 29]
function clampWheelStart(n, size) {
  if (!Number.isFinite(n)) throw new Error(`start must be a number, got ${n}`);
  return ((Math.floor(n) - 1) % size + size) % size + 1;
}
args[16] = clampWheelStart(args[16], 29);

Type guard

const isChi3Start = (v) => Number.isInteger(v) && v >= 1 && v <= 29;

Try / catch

try {
  lorenz.run(input, args);
} catch (err) {
  if (err instanceof OperationError && /Χ3 start/.test(err.message)) {
    args[16] = 1;
  } else throw err;
}

Prevention

When it happens

Trigger: Calling Lorenz.run() with args[16] ('Χ3 start (1-29)') less than 1 or greater than 29.

Common situations: Chi wheel set to 0; value from Χ1/Χ2 reused without adjusting for Χ3's smaller range; off-by-one.

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/1ba09332065ed534. Report an issue: GitHub.