crypto protocol diagram

AI Community

Skill notes

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

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

Step 1: Locate Protocol Entry Points

Grep for function names, type names, and comments that reveal the protocol: Start reading from the highest-level orchestration function — the one that calls into handshake phases or the main protocol loop.

Fluxly profile Runtime and permissions are inferred by Fluxly static checks, not author declarations or runtime test results.
Domain
AI
Author-declared agents
No explicit declaration found; this is not inferred or tested compatibility
Static check
88 / 100 · heuristic scan, not runtime safety proof
Runtime evidence
Not run; no isolated runtime test evidence is currently recorded
Author / version / license
@trailofbits · no license declared
Token usage
Moderate
Setup complexity
Guided setup
External API key
Not required
Operating systems
Unspecified (assume cross-platform)
Runtime requirements
No explicit requirements detected
Detected file/system behavior
  • Read-only
  • Write / modify
Network behavior
External requests
Install commands
None (reference only)

Heads up: Tool permissions are not declared; actual access depends on the runtime.

01
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

02
Step 1: Locate Protocol Entry Points

Grep for function names, type names, and comments that reveal the protocol: Start reading from the highest-level orchestration function — the one that calls into handshake phases or the main protocol loop.

03
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

04
Step 3: Trace Message Flow

Follow state transitions and network sends/receives. Look for patterns like: Pattern · Meaning `send(msg)` / `recv()` · Direct message exchange `serialize` + `transmit` · Structured message sent Return value passed to other party's function · Logical message (in-process)

05
Step 4: Annotate Cryptographic Operations

At each protocol step, identify and label: Operation · Diagram annotation Key generation · `Note over A: keygen(params) → pk, sk` DH / ECDH · `Note over A,B: DH(sk_A, pk_B)` KDF / HKDF · `Note over A: HKDF(ikm, salt, info)`

06
Step 5: Identify Protocol Phases

Group message steps into named phases using `rect` or `Note` blocks: Common phases to detect: Setup / Key Generation: party key creation, trusted setup, parameter gen Handshake / Init: ephemeral key exchange, nonce exchange, version negotiation Authentication: identity proof, certificate exchange, signature verification

07
Step 6: Generate sequenceDiagram

Produce Mermaid syntax following the rules in references/mermaid-sequence-syntax.md. Completeness over brevity. Show every distinct message type. Omit repeated loop iterations (use `loop` blocks instead), but never omit a distinct protocol step.

08
Step 7: Verify and Deliver

Before delivering: [ ] Every participant declared actually sends or receives at least one message [ ] Arrows point in the correct direction (sender → receiver) [ ] Cryptographic operations are on the correct party (the one computing them) [ ] If protocol phases are used, no arrows appear outside a phase block

Discussion

Powered by GitHub Discussions. Sign in with GitHub to comment, react, or subscribe.