Constant time check

From bronlabs/bron-crypto · View interactive version

Constant time check is an AI agent skill from the GitHub repository bronlabs/bron-crypto. Audit code for timing side-channels — variable-time operations on secret values. Use when the user asks to check constant-time, timing, or side-channel safety of a file, function, or diff in this repo.

How to use this skill

Skill file

You are checking whether code introduces timing leaks on secret data. Be specific, cite file:line, and don't fix — report.

Library context (read once)

What counts as "secret"

Anything that, if leaked bit-by-bit, breaks the protocol. In this repo:

If you're unsure whether a value is secret, say so in the finding rather than silently exclude it.

Steps

  1. Identify the target (file / package / diff). Determine audit scope: is it reachable from pkg/mpc/signatures/** or transitively depended on by it? In-scope code gets the higher bar.
  2. List the secret values in the function. For each one, check the patterns below.
  3. Output findings as a flat list with severity.

Patterns to flag (with the right replacement)

Branching on secrets

Variable-time big-integer arithmetic on secrets

Equality on byte buffers

Table / array lookup by a secret index

Conditional negate / select / swap implemented as `if`

Secret-dependent allocation or length

Logging / formatting / Stringer on secrets

Hash / KDF inputs whose *length* is secret

Loops over public-and-secret zipped data

Calls into variable-time primitives

What is acceptable

Output format

Output as GitHub-flavoured markdown. Use headers, bold severity tags, and code spans for paths and replacements so the terminal renders a clear visual hierarchy. Don't wrap the whole report in a fenced code block. Template:

## Constant-time check — <target>

**Scope:** in-scope — _or_ — experimental
**Secrets identified:** `secret1`, `secret2`, …

### Findings

- **[critical]** `file.go:42` — short description
  - _Replace with:_ `ct.Foo`
- **[major]** `file.go:99` — short description
  - _Replace with:_ `numct.Bar`
- **[minor]** `file.go:120` — short description
  - _Replace with:_ ...
- **[question]** `file.go:150` — value may be secret; needs caller-side confirmation

_(If none: "No findings.")_

### Summary

**Counts:** N critical, N major, N minor, N question.

Severity tags must be one of [critical], [major], [minor], [question] and always bolded. Order findings by severity (critical first), then by file path.

Don'ts

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.