Constant-Time Analysis
Analyze cryptographic code to detect operations that leak secret data through execution timing variations.
When to Use
User writing crypto code? ──yes──> Use this skill
│
no
│
v
User asking about timing attacks? ──yes──> Use this skill
│
no
│
v
Code handles secret keys/tokens? ──yes──> Use this skill
│
no
│
v
Skip this skill
Concrete triggers:
- User implements signature, encryption, or key derivation
- Code contains
/ or % operators on secret-derived values
- User mentions "constant-time", "timing attack", "side-channel", "KyberSlash"
- Reviewing functions named
sign, verify, encrypt, decrypt, derive_key
When NOT to Use
- Non-cryptographic code (business logic, UI, etc.)
- Public data processing where timing leaks don't matter
- Code that doesn't handle secrets, keys, or authentication tokens
- High-level API usage where timing is handled by the library
Language Selection
Based on the file extension or language context, refer to the appropriate guide:
| Language |
File Extensions |
Guide |
| C, C++ |
.c, .h, .cpp, .cc, .hpp |
references/compiled.md |
| Go |
.go |
references/compiled.md |
| Rust |
.rs |
references/compiled.md |
| Swift |
.swift |
references/swift.md |
| Java |
.java |
references/vm-compiled.md |
| Kotlin |
.kt, .kts |
references/kotlin.md |
| C# |
.cs |
references/vm-compiled.md |
| PHP |
.php |
references/php.md |
| JavaScript |
.js, .mjs, .cjs |
references/javascript.md |
| TypeScript |
.ts, .tsx |
references/javascript.md |
| Python |
.py |
references/python.md |
| Ruby |
.rb |
references/ruby.md |
Quick Start
# Analyze any supported file type
uv run {baseDir}/ct_analyzer/analyzer.py <source_file>
# Include conditional branch warnings
uv run {baseDir}/ct_analyzer/analyzer.py --warnings <source_file>
# Filter to specific functions
uv run {baseDir}/ct_analyzer/analyzer.py --func 'sign|verify' <source_file>
# JSON output for CI
uv run {baseDir}/ct_analyzer/analyzer.py --json <source_file>
Native Compiled Languages Only (C, C++, Go, Rust)
# Cross-architecture testing (RECOMMENDED)
uv run {baseDir}/ct_analyzer/analyzer.py --arch x86_64 crypto.c
uv run {baseDir}/ct_analyzer/analyzer.py --arch arm64 crypto.c
# Multiple optimization levels
uv run {baseDir}/ct_analyzer/analyzer.py --opt-level O0 crypto.c
uv run {baseDir}/ct_analyzer/analyzer.py --opt-level O3 crypto.c
VM-Compiled Languages (Java, Kotlin, C#)
# Analyze Java bytecode
uv run {baseDir}/ct_analyzer/analyzer.py CryptoUtils.java
# Analyze Kotlin bytecode (Android/JVM)
uv run {baseDir}/ct_analyzer/analyzer.py CryptoUtils.kt
# Analyze C# IL
uv run {baseDir}/ct_analyzer/analyzer.py CryptoUtils.cs
Note: Java, Kotlin, and C# compile to bytecode (JVM/CIL) that runs on a virtual machine with JIT compilation. The analyzer examines the bytecode directly, not the JIT-compiled native code. The --arch and --opt-level flags do not apply to these languages.
Swift (iOS/macOS)
# Analyze Swift for native architecture
uv run {baseDir}/ct_analyzer/analyzer.py crypto.swift
# Analyze for specific architecture (iOS devices)
uv run {baseDir}/ct_analyzer/analyzer.py --arch arm64 crypto.swift
# Analyze with different optimization levels
uv run {baseDir}/ct_analyzer/analyzer.py --opt-level O0 crypto.swift
Note: Swift compiles to native code like C/C++/Go/Rust, so it uses assembly-level analysis and supports --arch and --opt-level flags.
Prerequisites
| Language |
Requirements |
| C, C++, Go, Rust |
Compiler in PATH (gcc/clang, go, rustc) |
| Swift |
Xcode or Swift toolchain (swiftc in PATH) |
| Java |
JDK with javac and javap in PATH |
| Kotlin |
Kotlin compiler (kotlinc) + JDK (javap) in PATH |
| C# |
.NET SDK + ilspycmd (dotnet tool install -g ilspycmd) |
| PHP |
PHP with VLD extension or OPcache |
| JavaScript/ |
|
1---2name: constant-time-analysis3description: Analyze cryptographic code to detect operations that leak secret data through execution timing variations. 4category: Security & Systems5source: antigravity6tags: [python, javascript, typescript, node, api, ai, document, vulnerability, cro]7url: https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/constant-time-analysis8metadata:9 source: https://skillmd.com/skills/sickn33/constant-time-analysis10---111213# Constant-Time Analysis1415Analyze cryptographic code to detect operations that leak secret data through execution timing variations.1617## When to Use18```text19User writing crypto code? ──yes──> Use this skill20 │21 no22 │23 v24User asking about timing attacks? ──yes──> Use this skill25 │26 no27 │28 v29Code handles secret keys/tokens? ──yes──> Use this skill30 │31 no32 │33 v34Skip this skill35```3637**Concrete triggers:**3839- User implements signature, encryption, or key derivation40- Code contains `/` or `%` operators on secret-derived values41- User mentions "constant-time", "timing attack", "side-channel", "KyberSlash"42- Reviewing functions named `sign`, `verify`, `encrypt`, `decrypt`, `derive_key`4344## When NOT to Use4546- Non-cryptographic code (business logic, UI, etc.)47- Public data processing where timing leaks don't matter48- Code that doesn't handle secrets, keys, or authentication tokens49- High-level API usage where timing is handled by the library5051## Language Selection5253Based on the file extension or language context, refer to the appropriate guide:5455| Language | File Extensions | Guide |56| ---------- | --------------------------------- | -------------------------------------------------------- |57| C, C++ | `.c`, `.h`, `.cpp`, `.cc`, `.hpp` | references/compiled.md |58| Go | `.go` | references/compiled.md |59| Rust | `.rs` | references/compiled.md |60| Swift | `.swift` | references/swift.md |61| Java | `.java` | references/vm-compiled.md |62| Kotlin | `.kt`, `.kts` | references/kotlin.md |63| C# | `.cs` | references/vm-compiled.md |64| PHP | `.php` | references/php.md |65| JavaScript | `.js`, `.mjs`, `.cjs` | references/javascript.md |66| TypeScript | `.ts`, `.tsx` | references/javascript.md |67| Python | `.py` | references/python.md |68| Ruby | `.rb` | references/ruby.md |6970## Quick Start7172```bash73# Analyze any supported file type74uv run {baseDir}/ct_analyzer/analyzer.py <source_file>7576# Include conditional branch warnings77uv run {baseDir}/ct_analyzer/analyzer.py --warnings <source_file>7879# Filter to specific functions80uv run {baseDir}/ct_analyzer/analyzer.py --func 'sign|verify' <source_file>8182# JSON output for CI83uv run {baseDir}/ct_analyzer/analyzer.py --json <source_file>84```8586### Native Compiled Languages Only (C, C++, Go, Rust)8788```bash89# Cross-architecture testing (RECOMMENDED)90uv run {baseDir}/ct_analyzer/analyzer.py --arch x86_64 crypto.c91uv run {baseDir}/ct_analyzer/analyzer.py --arch arm64 crypto.c9293# Multiple optimization levels94uv run {baseDir}/ct_analyzer/analyzer.py --opt-level O0 crypto.c95uv run {baseDir}/ct_analyzer/analyzer.py --opt-level O3 crypto.c96```9798### VM-Compiled Languages (Java, Kotlin, C#)99100```bash101# Analyze Java bytecode102uv run {baseDir}/ct_analyzer/analyzer.py CryptoUtils.java103104# Analyze Kotlin bytecode (Android/JVM)105uv run {baseDir}/ct_analyzer/analyzer.py CryptoUtils.kt106107# Analyze C# IL108uv run {baseDir}/ct_analyzer/analyzer.py CryptoUtils.cs109```110111Note: Java, Kotlin, and C# compile to bytecode (JVM/CIL) that runs on a virtual machine with JIT compilation. The analyzer examines the bytecode directly, not the JIT-compiled native code. The `--arch` and `--opt-level` flags do not apply to these languages.112113### Swift (iOS/macOS)114115```bash116# Analyze Swift for native architecture117uv run {baseDir}/ct_analyzer/analyzer.py crypto.swift118119# Analyze for specific architecture (iOS devices)120uv run {baseDir}/ct_analyzer/analyzer.py --arch arm64 crypto.swift121122# Analyze with different optimization levels123uv run {baseDir}/ct_analyzer/analyzer.py --opt-level O0 crypto.swift124```125126Note: Swift compiles to native code like C/C++/Go/Rust, so it uses assembly-level analysis and supports `--arch` and `--opt-level` flags.127128### Prerequisites129130| Language | Requirements |131| ---------------------- | --------------------------------------------------------- |132| C, C++, Go, Rust | Compiler in PATH (`gcc`/`clang`, `go`, `rustc`) |133| Swift | Xcode or Swift toolchain (`swiftc` in PATH) |134| Java | JDK with `javac` and `javap` in PATH |135| Kotlin | Kotlin compiler (`kotlinc`) + JDK (`javap`) in PATH |136| C# | .NET SDK + `ilspycmd` (`dotnet tool install -g ilspycmd`) |137| PHP | PHP with VLD extension or OPcache |138| JavaScript/