crypto-protocol-diagram
Extracts protocol message flow from source code, RFCs, academic papers, pseudocode, informal prose, ProVerif (.pv), or Tamarin (.spthy) models and generates…
Skill by trailofbits
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/trailofbits-crypto-protocol-diagram
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: research, finance
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
- Runs as
- Python package
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/crypto-protocol-diagram
What's inside
- Skill name
crypto-protocol-diagram- Description
- Extracts protocol message flow from source code, RFCs, academic papers, pseudocode, informal prose, ProVerif (.pv), or Tamarin (.spthy) models and generates Mermaid sequenceDiagrams with cryptographic annotations. Use when diagramming a crypto protocol, visualizing a handshake or key exchange flow, extracting message flow from a spec or RFC, diagramming a ProVerif or Tamarin model, or drawing sequence diagrams for TLS, Noise, Signal, X3DH, Double Ratchet, FROST, DH, or ECDH protocols.
- License
- CC-BY-SA-4.0
- Instructions
- 437 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Files (11)
- SKILL.md
- openai.yaml · agents/
- trail-of-bits-mark.svg · assets/
- expected-output.md · examples/simple-handshake/
- protocol.py · examples/simple-handshake/
- expected-output.md · examples/simple-proverif/
- model.pv · examples/simple-proverif/
- ascii-sequence-diagram.md · references/
- mermaid-sequence-syntax.md · references/
- protocol-patterns.md · references/
- spec-parsing-patterns.md · references/
SKILL.md (first lines)
# Crypto Protocol Diagram
Produces a Mermaid `sequenceDiagram` (written to file) and an ASCII sequence
diagram (printed inline) from either:
- **Source code** implementing a cryptographic protocol, or
- **A specification** — RFC, academic paper, pseudocode, informal prose,
ProVerif (`.pv`), or Tamarin (`.spthy`) model.
**Tools used:** Read, Write, Grep, Glob, Bash, WebFetch (for URL specs).
Unlike the `diagramming-code` skill (which visualizes code structure), this skill
extracts **protocol semantics**: who sends what to whom, what cryptographic
transformations occur at each step, and what protocol phases exist.
For call graphs, class hierarchies, or module dependency maps, use the
`diagramming-code` skill instead.
## When to Use
- User asks to diagram, visualize, or extract a cryptographic protocol
- Input is source code implementing a handshake, key exchange, or multi-party protocol
- Input is an RFC, academic paper, pseudocode, or formal model (ProVerif/Tamarin)
- User names a specific protocol (TLS, Noise, Signal, X3DH, FROST)
## When NOT to Use
- User wants a call graph, class hierarchy, or module dependency map — use `diagramming-code`
- User wants to formally verify a protocol — use `mermaid-to-proverif` (after generating the diagram)
- Input has no cryptographic protocol semantics (no parties, no message exchange)
## Rationalizations to Reject
| Rationalization | Why It's Wrong | Required Action |
|-----------------|----------------|-----------------|
| "The protocol is simple, I can diagram from memory" | Memory-based diagrams miss steps and invert arrows | Read the source or spec systematically |
| "I'll skip the spec path since code exists" | Code may diverge from the spec — both paths catch different bugs | When both exist, run spec workflow first, then annotate code divergences |
| "Crypto annotations are optional decoration" | Without crypto annotations, the diagram is just a message flow — useless for security review | Annotate every cryptographic operation |
| "The abort path is obvious, no need for alt blocks" | Implicit abort handling hides missing error checks | Show every abort/error path with `alt` blocks |
| "I don't need to check the examples first" | The examples define the expected output quality bar | Study the relevant example before working on unfamiliar input |
| "ProVerif/Tamarin models are code, not specs" | Formal models are specifications — they describe intended behavior, not implementation | Use the spec workflow (S1–S5) for `.pv` and `.spthy` files |
---
## Workflow
```
Protocol Diagram Progress:
- [ ] Step 0: Determine input type (code / spec / both)
- [ ] Step 1 (code) or S1–S5 (spec): Extract protocol structure
- [ ] Step 6: Generate sequenceDiagram
- [ ] Step 7: Verify and deliver
```
---
### Step 0: Determine Input Type
Before doing anything else, classify the input:
| Signal | Input type |
|--------|-----------|
| Source file extensions (`.py`, `.rs`, `.go`, `.ts`, `.js`, `.cpp`, `.c`) | **Code** |
| Function/class definitions, import statements | **Code** |
| RFC-style section headers (`§`, `Section X.Y`, `MUST`/`SHALL` keywords) | **Spec** |
| `Algorithm`/`Protocol`/`Figure` labels, mathematical notation | **Spec** |
| ProVerif file (`.pv`) with `process`, `let`, `in`/`out` | **Spec** |
| Tamarin file (`.spthy`) with `rule`, `--[...]->` | **Spec** |
| Plain prose or numbered steps describing a protocol | **Spec** |
| Both source files and a spec document | **Both** (annotate divergences with `⚠️`) |
- **Code only** → skip to Step 1 below
- **Spec only** → skip to Spec Workflow (S1–S5) below
- **Both** → run Spec Workflow first, then use the code-reading steps to verify
the implementation against the spec diagram and annotate any divergences with `⚠️`
- **Ambiguous** → ask the user: "Is this a source code file, a specification
document, or both?"
---
### Step 1: Locate Protocol Entry Points
Grep for function names, type names, and comments that reveal the protocol:
```bash
# Find handshake, session, round, phase entry points
rg -l "handshake|session_init|round[_0-9]|setup|keygen|send_msg|recv_msg" {targetDir}
# Find crypto primitives in use
rg "sign|verify|encrypt|decrypt|dh|ecdh|kdf|hkdf|hmac|hash|commit|reveal|share" \
{targetDir} --type-add 'src:*.{py,rs,go,ts,js,cpp,c}' -t src -l
```
Start reading from the highest-level orchestration function — the one that calls
into handshake phases or the main protocol loop.
### Step 2: Identify Parties and Roles
Extract participant names from:
- Struct/class names: `Client`, `Server`, `Initiator`, `Responder`, `Prover`,
`Verifier`, `Dealer`, `Party`, `Coordinator`
- Function parameter names that carry state for a role
- Comments declaring the protocol role
- Test fixtures that set up two-party or N-party scenarios
Map these to Mermaid `participant` declarations. Use short, readable aliases:
```
participant I as Initiator
participant R as Responder
```
### Step 3: Trace Message Flow
Follow state transitions and network sends/receives. Look for patterns like:
| Pattern | Meaning |
|---------|---------|From trailofbits/skills, CC-BY-SA-4.0.
More from trailofbits/skills
- 0.767score
slicing-code-context
trailofbits
Selects bounded, graph-informed source slices with Trailmark and delegates focused code analysis or patch-proposal work to a smaller subagent.
SkillAFreshness: A★ 7.8KClaude Code +9 - 0.767score
diagramming-code
trailofbits
Generates Mermaid diagrams from Trailmark code graphs.
SkillAFreshness: A★ 7.8KClaude Code +9 - 0.767score
semgrep
trailofbits
Runs a Semgrep security scan over a codebase: detects languages, selects rulesets, presents the plan for explicit approval, then runs every approved ruleset…
SkillAFreshness: A★ 7.8KClaude Code +9 - 0.767score
mermaid-to-proverif
trailofbits
Translates Mermaid sequenceDiagrams describing cryptographic protocols into ProVerif formal verification models (.pv files).
SkillAFreshness: A★ 7.8KClaude Code +9 - 0.767score
github-triage
trailofbits
Triages a repository's open GitHub issues and pull requests via the gh CLI.
SkillAFreshness: A★ 7.8KClaude Code +9 - 0.767score
firebase-apk-scanner
trailofbits
Scans Android APKs for Firebase security misconfigurations including open databases, storage buckets, authentication issues, and exposed cloud functions.
SkillAFreshness: A★ 7.8KClaude Code +9 - 0.767score
dimensional-analysis
trailofbits
Audits code for unit and decimal-scaling bugs and annotates it with dimensional comments recording the units of each value.
SkillAFreshness: A★ 7.8KClaude Code - 0.767score
let-fate-decide
trailofbits
Draws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated.
SkillAFreshness: A★ 7.8KClaude Code +9 - 0.767score
codeql
trailofbits
Scans a codebase for security vulnerabilities using CodeQL's interprocedural data flow and taint tracking analysis.
SkillAFreshness: A★ 7.8KClaude Code +9 - 0.767score
interpreting-culture-index
trailofbits
Interprets Culture Index (CI) surveys, behavioral profiles, and personality assessment data.
SkillAFreshness: A★ 7.8KClaude Code +9 - 0.767score
entry-point-analyzer
trailofbits
Analyzes smart contract codebases to identify state-changing entry points for security auditing.
SkillAFreshness: A★ 7.8KClaude Code +9 - 0.767score
trailmark
trailofbits
Builds and queries multi-language source and binary code graphs for security analysis.
SkillAFreshness: A★ 7.8KClaude Code +9
Compare and alternatives
Featured in
Signals
- Stars
- 7,783
- Forks
- 671
- Open issues
- 30
- Last commit (this folder)
- Sep 16, 2026 (1 month ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- CC-BY-SA-4.0
- Repository
- github.com/trailofbits/skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from trailofbits
- 0.767score
github-triage
trailofbits
Triages a repository's open GitHub issues and pull requests via the gh CLI.
SkillAFreshness: A★ 7.8KClaude Code +9 - 0.767score
entry-point-analyzer
trailofbits
Analyzes smart contract codebases to identify state-changing entry points for security auditing.
SkillAFreshness: A★ 7.8KClaude Code +9 - 0.767score
interpreting-culture-index
trailofbits
Interprets Culture Index (CI) surveys, behavioral profiles, and personality assessment data.
SkillAFreshness: A★ 7.8KClaude Code +9 - 0.767score
firebase-apk-scanner
trailofbits
Scans Android APKs for Firebase security misconfigurations including open databases, storage buckets, authentication issues, and exposed cloud functions.
SkillAFreshness: A★ 7.8KClaude Code +9 - 0.767score
dimensional-analysis
trailofbits
Audits code for unit and decimal-scaling bugs and annotates it with dimensional comments recording the units of each value.
SkillAFreshness: A★ 7.8KClaude Code - 0.767score
let-fate-decide
trailofbits
Draws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated.
SkillAFreshness: A★ 7.8KClaude Code +9
Cite this page
crypto-protocol-diagram skill. Agent Mart. https://agentmart.dev/skills/trailofbits-crypto-protocol-diagram (last updated 2026-10-24)