Crypto docs

From AztecProtocol/aztec-packages · View interactive version

Crypto docs is an AI agent skill from the GitHub repository AztecProtocol/aztec-packages. Principles for writing and reviewing cryptography/protocol documentation in barretenberg — PROTOCOL.md spec files, algorithm/implementation notes, and doc-comments on prover/verifier code. Use when authoring or editing a protocol spec, a design/algorithm note, a substantial math-bearing doc-comment,

How to use this skill

Skill file

Writing crypto/protocol docs

Covers the prose, math, and structure of crypto documentation: PROTOCOL.md specs,

algorithm/implementation notes, and math-heavy doc-comments on prover/verifier code. Not the

Docusaurus developer-docs site (see docs/CLAUDE.md).

Structure and narrative

model, an invariant, or the security property — then the construction, then the implementation.

The implementation section is detail behind the concept, not a parallel restatement of it.

reference it. Repetition is the usual cause of a doc that reads as fragmented.

prose.

Bind the doc to the code

so a reader jumps from the math to the function and a rename surfaces as a stale reference.

symbol is greppable. This is what keeps a doc consistent with the code as it changes.

When the detail lives elsewhere

A note can be a sketch or summary whose full detail — the heavy algebra, the exhaustive case

analysis, the complete proof — is carried by an authoritative companion: a formalization (Lean/Coq),

a paper, or a reference implementation. Then:

intermediate claims, and why each step holds — don't reproduce derivations the companion already

carries. Point each step to where the companion proves it, and still give its mechanism (why it

holds), not just an assertion.

Present formulas when necessary, do not re-prove them.

theorem numbers, and file paths (foo_of_bar, "Thm 4.2") in running text break the mathematics.

Keep the body free of them and gather body statement → source location in a single table (an

instance of One canonical home per fact).

served in the map and in references, not the prose. In prose use conventional terms — write

"block-triangular reduction", not the source's triangularRows — and rename or explain a lifted

identifier at first use.

Conventions for a protocol spec

variable at first use.

order, each naming its method and indexing the loop explicitly.

preconditions (what is already in the transcript and is not re-sent).

that predates the implementation.

Precision and word choice

polynomial $h$), and write what is computed as an equation — not action-verb narration. Verbs that

gesture instead of naming ("walks", "contracts", "discharges") are out; precise verbs (computes,

evaluates, checks, equals) are fine.

em-dashes, or nested parentheticals; short sentences read.

chose to present it ("to keep this readable…", "for clarity…", "we now…"); that belongs in the PR

thread.

without then spelling out the obvious version. Don't restate a displayed equation, set, or table

in prose.

end-to-end).

"sharpening", effusive openers.

Present tense — describe the artifact as it is

Don't define the artifact by contrast with an approach the reader never saw ("there is no X step",

"unlike the naive Y") — state what it is, positively. The delta belongs in the PR and commit

message; the doc states the current truth. (Extends barretenberg/cpp/CLAUDE.md's comment rule to

docs.)

comments, and keep the before/after in the PR description.

Consistency

partial edit leaves contradictions.

Math and diagrams

cases); no TikZ or engine-specific packages. Prefer display math over a picture environment for

flow diagrams, and keep them simple.

Doc-comments and inline math

General comment hygiene — when to comment, no "what" comments, public-API docs, and not deleting

comments — is in the root CLAUDE.md (<writing_comments>, <preserve_todos>) and

barretenberg/cpp/CLAUDE.md; follow those. The prose rules above apply to comment text too. The

crypto-specific points:

rendered, so u⁻¹, ∏ᵢ(αᵢ + Xˢ), ⟨a, b⟩ read better inline than \f$...\f$ or $...$. (In

.md files it is the reverse — use LaTeX; see Math and diagrams.)

from comments (see PROTOCOL.md §4.1) instead of re-deriving; re-derived algebra in a comment is

what drifts.

of code defined elsewhere is documented at that definition and referenced, not re-explained here —

re-explained, it rots silently when the other code changes.

round method), not scattered line-by-line.

reconstruct; remove one only when it is wrong or the change makes it obsolete — not to shrink a

diff or tidy.

Reviewing

Two modes, applied to a draft: a qualitative lens, then a binary sweep.

Coarse to fine

Not a fixed recipe, a lens. Fixing prose inside a paragraph you later move or cut is wasted, so

review tends to go best from structure down to sentences:

(Present tense)

later, or re-explain what came earlier? Is a fact stated twice, or sitting somewhere other than the

section whose job it is? (Structure and narrative; One canonical home per fact)

something already shown (a displayed equation, an earlier line), asserts what nothing backs,

contradicts the code or another section, narrates an editorial choice, leans on an undefined term,

frames by contrast with the past, or gestures instead of naming. Several of these — *does it match

the code?, is the claim backed?* — are settled only by checking the source, not by rereading the

prose.

Mechanical checks (final sweep)

  1. No retroactive framing in a permanent file.
  2. After any algebra change, all formulas and comments agree with each other and the code.
  3. Every § cross-reference resolves.
  4. Each algorithm step names its implementing symbol; named quantities use the code's identifiers.
  5. Claims and the transcript schedule appear before the mechanism.
  6. Performance claims carry a count and a scope caveat.
  7. All math/diagrams render in a plain markdown engine (no TikZ); code comments use Unicode math,

not LaTeX markup.

  1. Prose uses conventional math terms, not source identifiers; external references (lemma names,

theorem numbers, file paths) appear only in the correspondence map.

  1. No editor's intent narrating a presentation choice ("to keep this readable…", "for clarity…");

the text carries only the content.

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.