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 →
What to know first
- digital signatureA digital signature is a cryptographic value associated with data that can be verified to provide evidence of the data’s origin and integrity.
- nonceA nonce is a value intended for one-time use within a specified cryptographic, authentication, or authorization context.
- RSARSA is a public-key cryptosystem based on the computational difficulty of factoring large composite integers and supporting encryption and digital signatures.
- square and multiplySquare and multiply is an exponentiation algorithm that repeatedly squares and conditionally multiplies according to the exponent’s binary representation.
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.
Questions about constant-time programming
What is 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.
Which Manning books explain constant-time programming?
Hacking Cryptography and Real-World Cryptography.
What should I know before learning constant-time programming?
Manning books that teach constant-time programming usually introduce digital signature, nonce, RSA and square and multiply first.
What is constant-time programming also called?
Constant-time programming is also called constant-time algorithm.
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.

