gchq/CyberChef · error · OperationError

Error: ${err}

Error message

Error: ${err}

What it means

Thrown by the Scrypt operation as a catch-all wrapper around the scryptsy library. Any exception from scryptsy — most commonly invalid parameters (N must be a power of two, N/r/p too large) or out-of-memory conditions — is caught and re-thrown as an OperationError with the original message.

Source

Thrown at src/core/operations/Scrypt.mjs:84

        const salt = Buffer.from(Utils.convertToByteArray(args[0].string || "", args[0].option)),
            iterations = args[1],
            memFactor = args[2],
            parallelFactor = args[3],
            keyLength = args[4];

        try {
            const data = scryptsy(
                input, salt, iterations, memFactor, parallelFactor, keyLength,
                p => {
                    // Progress callback
                    if (isWorkerEnvironment())
                        self.sendStatusMessage(`Progress: ${p.percent.toFixed(0)}%`);
                }
            );

            return data.toString("hex");
        } catch (err) {
            throw new OperationError("Error: " + err.toString());
        }
    }

}

export default Scrypt;

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Read the embedded 'err' message — scryptsy states which parameter is invalid.
  2. Ensure N (Iterations) is a power of two (e.g. 16384 = 2^14); start low and increase.
  3. Reduce r or p if memory is the constraint; memory is roughly 128*N*r bytes.
  4. Keep key length positive (default 64).

Example fix

// before
scrypt.run("password", [{string:"salt",option:"UTF8"}, 10000, 8, 1, 64])
// after — N must be a power of two
scrypt.run("password", [{string:"salt",option:"UTF8"}, 16384, 8, 1, 64])
Defensive patterns

Strategy: validation

Validate before calling

function validateScryptParams(N, r, p, keyLen) {
  if (!Number.isInteger(N) || N < 2 || (N & (N - 1)) !== 0) {
    throw new Error("N must be a power of two >= 2");
  }
  if (r <= 0 || p <= 0 || keyLen <= 0) {
    throw new Error("r, p, and keyLength must be positive");
  }
  const approxBytes = 128 * N * r;
  if (approxBytes > 256 * 1024 * 1024) {
    throw new Error(`N*r too large (~${approxBytes} bytes); reduce N or r`);
  }
}

Type guard

function isScryptPowerOfTwo(N) { return Number.isInteger(N) && N >= 2 && (N & (N - 1)) === 0; }

Try / catch

try {
  const data = scryptsy(input, salt, N, r, p, keyLen, cb);
} catch (err) {
  throw new OperationError("Error: " + err.toString());
}

Prevention

When it happens

Trigger: Calling Scrypt with an N (iterations) value that is not a power of two, or N/r/p combinations whose memory footprint (128 * N * r bytes) exceeds available memory. Empty input or salt edge cases can also surface here depending on scryptsy version.

Common situations: Setting N=10000 (not a power of two); very large N (e.g. 2^20) combined with r=8 exhausting worker heap; negative or zero key length; a salt toggle mismatch producing unexpected bytes.

Related errors


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