Constant-time programming
Constant-time programming is the practice of designing algorithms whose execution behavior does not depend on secret data or varying input values.
Hacking Cryptography
A constant-time implementation is software or hardware whose execution behavior does not depend on secret-dependent values or control flow.
- How it is used
- Protects cryptographic operations from timing attacks and side-channel analysis by removing secret-dependent execution differences.
- How deep it goes
- Explains power-analysis failures, ladder operations, and branchless control flow, while deferring many Montgomery optimization details.
- Examples
- Uses RSA exponentiation traces, the Montgomery ladder, and GCC inline-assembly summation with conditional moves.
- What you can do after
- Apply it via fixed-operation algorithms, branchless control flow, and constant-time validation for sensitive cryptographic inputs.
Read how Hacking Cryptography explains constant-time programming →
Real-World Cryptography
A constant-time algorithm executes in a pattern whose duration does not depend on secret data.
- How it is used
- Defends sensitive cryptographic computations against timing and related software side-channel attacks.
- How deep it goes
- Explains branch-free comparisons and algorithmic patterns, while stopping short of formal proofs or implementation-level completeness.
- Examples
- Uses Go authentication-tag comparison, Montgomery’s ladder, and RSA square-and-multiply-always.
- What you can do after
- Apply it by removing secret-dependent branches and memory accesses from cryptographic implementations.
Read how Real-World Cryptography explains constant-time programming →
Related concepts
- timing attackaddresses · A timing attack is a side-channel attack that infers information, often secret data, by measuring differences in the time taken to process inputs or perform computations.
- conditional moveuses · A conditional move is a processor instruction that transfers a value when a Boolean predicate holds without branching to a different instruction path.
- side-channel attackaddresses · A side-channel attack infers secret information from unintended physical or operational leakage produced by a system’s implementation rather than its intended outputs.
- cache attackaddresses · A cache attack infers a victim's secret-dependent computation by observing the timing or state changes of shared processor memory caches.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

