liveBook · Manning

Modulus

As explained in Hacking Cryptography

The positive integer that defines the modulus and bounds the residue classes in modular arithmetic.

A modulus is the positive integer m that bounds values produced by modular arithmetic. In a linear congruential generator, each state is reduced modulo m: Xₙ₊₁ = (aXₙ + c) mod m. section 2.2.2

The modulus is part of the generator’s parameters, alongside the multiplier, increment, and seed. Recovering it from observed outputs can expose the generator’s full state and enable prediction. section 2.2.2

Recovering an LCG modulus

An exploit collects successive differences between outputs, forms values of the form ΔᵢΔᵢ₋₂ − Δᵢ₋₁², and computes their greatest common divisor. The resulting modulus is then used to recover the multiplier and increment before cloning the generator. section 2.2.2

Equation 2.3
\[X_{n+1} = \left( a X_n + c \right)\bmod m \label{equation:lcg}\]

Shows the modulus operation inside the LCG recurrence. section 2.2.2

How Hacking Cryptography covers it

How deep it goes
Develops the definition through implementation and derives modulus recovery from output differences and greatest common divisors.
Examples
Uses C++ minstd_rand constants, a Go LCG implementation, and an exploit that recovers parameters from generated outputs.
What you can do after
Diagnose/debug with it by implementing an LCG and tracing how recovered parameters reproduce future outputs.
How it connects
Links modular arithmetic with pseudorandom number generators, linear congruential generators, seeds, and generator-state cloning.

Also explained in

Compare how 3 books explain modulus →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Hacking Cryptography. The section links point to the parts of the book it draws on.