constant-time-analysis – skill Dữ liệu & Khoa học cho agent AI
Phân tích mã mật mã để phát hiện các thao tác làm rò rỉ dữ liệu bí mật qua sự khác biệt về thời gian thực thi.
Cài skill constant-time-analysis bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/constant-time-analysis-9bf64.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /constant-time-analysis – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/constant-time-analysis-9bf64.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $constant-time-analysis – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/constant-time-analysis-9bf64.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /constant-time-analysis – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/constant-time-analysis-9bf64.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /constant-time-analysis – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
Bundled upstream support
Supporting files are included at skill-relative paths. See [UPSTREAM-NOTICE.md](UPSTREAM-NOTICE.md) for their pinned sources, licenses, hashes, and import changes.
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 skillConcrete 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 |
Runtime prerequisite and execution boundary
This catalog bundles documentation only; ct_analyzer/analyzer.py is not included.
The commands below and in the language references are illustrative upstream usage,
not an instruction to resolve or execute missing code. Stop if a separately installed,
reviewed analyzer is unavailable. Record its immutable source identity and inspect its
complete runtime and locked dependencies before any separately authorized setup.
Use only existing approved language tools; do not let uv, npx, PECL or a guide's
bootstrap commands fetch a moving dependency. Review the selected analyzer's command
construction and target-execution behavior before using it on untrusted code.
For PHP, require VLD with vld.execute=0; refuse any analyzer that falls back to
OPcache target execution. For compilation, bytecode inspection and all other language
backends, use an isolated environment without unrelated credentials or network access.
Do not treat disassembly as proof that a tool cannot execute target code.
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.cVM-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.csNote: 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.swiftNote: 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 reviewed VLD extension, target execution disabled |
| JavaScript/TypeScript | Node.js in PATH |
| Python | Python 3.x in PATH |
| Ruby | Ruby with --dump=insns support |
macOS users: Homebrew installs Java and .NET as "keg-only". You must add them to your PATH:
# For Java (add to ~/.zshrc)
export PATH="/opt/homebrew/opt/openjdk@21/bin:$PATH"
# For .NET tools (add to ~/.zshrc)
export PATH="$HOME/.dotnet/tools:$PATH"See references/vm-compiled.md for detailed setup instructions and troubleshooting.
Quick Reference
| Problem | Detection | Fix |
| ---------------------- | ------------------------------- | -------------------------------------------- |
| Division on secrets | DIV, IDIV, SDIV, UDIV | Barrett reduction or multiply-by-inverse |
| Branch on secrets | JE, JNE, BEQ, BNE | Constant-time selection (cmov, bit masking) |
| Secret comparison | Early-exit memcmp | Use crypto/subtle or constant-time compare |
| Weak RNG | rand(), mt_rand, Math.random | Use crypto-secure RNG |
| Table lookup by secret | Array subscript on secret index | Bit-sliced lookups |
Interpreting Results
PASSED - No configured patterns were detected in this analysis. This is not proof of constant-time execution.
FAILED - Review candidates found; establish secret dependence and target CPU/runtime behavior before calling them vulnerabilities. Example:
[ERROR] SDIV
Function: decompose_vulnerable
Reason: SDIV has early termination optimization; execution time depends on operand valuesVerifying Results (Avoiding False Positives)
CRITICAL: Not every flagged operation is a vulnerability. The tool has no data flow analysis - it flags ALL potentially dangerous operations regardless of whether they involve secrets.
For each flagged violation, ask: Does this operation's input depend on secret data?
1. Identify inputs that the threat model actually treats as secret (for example private keys or tokens; signatures and lengths may be public).
2. Trace data flow from the flagged instruction back to inputs
3. Common false positive patterns:
// FALSE POSITIVE: Division uses public constant, not secret
int num_blocks = data_len / 16; // data_len is length, not content
// TRUE POSITIVE: Division involves secret-derived value
int32_t q = secret_coef / GAMMA2; // secret_coef from private key
4. Document your analysis for each flagged item
… (nội dung đầy đủ có trong gói tải về)
Skill liên quan
- llm-wiki – Dùng khi xây dựng hoặc duy trì một cơ sở tri thức cá nhân bền vững (second brain) trong…
- pytorch-fsdp – Huấn luyện dữ liệu song song với phân mảnh đầy đủ (fully sharded data-parallel) cho mô…
- pytorch-lightning – Vòng lặp huấn luyện gọn gàng với hỗ trợ phân tán tích hợp sẵn.
- context7-auto-research – Tự động lấy tài liệu thư viện/framework mới nhất cho Claude Code qua API Context7. Dùng…
- market-research – Dùng khi thực hiện phương pháp nghiên cứu thị trường: ước lượng quy mô thị trường theo…
- qmd – Tìm kiếm lai (hybrid) cục bộ trên ghi chú, tài liệu và bản chép lời.
- research-grants – Hỗ trợ chuẩn bị và đánh giá đề xuất nghiên cứu cho NSF, NIH, DOE, DARPA và NSTC Đài…
- research-lookup – Tổng hợp bằng chứng học thuật hiện tại cho bản thảo khoa học hoặc tóm tắt nghiên cứu khi…