Saltar al contenido
Skillpedia
Seguridad8,0 mil · #12726

crypto-protocol-diagram

Qué hace

Esta skill lee código fuente, un documento estándar o un modelo formal de un protocolo de comunicación segura y lo convierte en un diagrama de flujo de mensajes. Es para ingenieros y revisores de seguridad que necesitan entender un handshake o un intercambio de claves.

Cuándo usarla

  • ✓Cuando necesitas diagramar un handshake, un intercambio de claves u otro flujo criptográfico de varias partes.
  • ✓Cuando tienes un RFC o un artículo que describe un protocolo y quieres dibujar el orden de sus mensajes.
  • ✓Cuando tienes un modelo de ProVerif o Tamarin y quieres un diagrama legible de él.

Link de la skill

https://github.com/trailofbits/skills/blob/main/plugins/trailmark/skills/crypto-protocol-diagram/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/trailofbits/skills/blob/main/plugins/trailmark/skills/crypto-protocol-diagram/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“¿Puedes dibujar un diagrama de los pasos de mensajes en este código de intercambio de claves?”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

Encuentra quién envía qué a quién y qué paso de cifrado o firma ocurre en cada punto, y luego escribe un diagrama de secuencia de Mermaid y una versión en texto plano.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de GitHub.

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:

# 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 Par

Preguntas frecuentes

¿Qué formatos de entrada funcionan?

Funcionan el código fuente, RFCs, artículos académicos, pseudocódigo, prosa simple y archivos de modelo de ProVerif o Tamarin.

¿El diagrama muestra los pasos criptográficos además de los mensajes?

Sí. Cada paso puede incluir la operación criptográfica, como la firma o la derivación de claves.

¿Es lo mismo que un diagrama de estructura de código?

No. Muestra mensajes del protocolo, no llamadas a funciones ni la estructura de clases.

Detalles

Descripción original del autor

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.

repo: trailofbits/skills

Popularidad

Estrellas en GitHub
8,0 mil
Posición en el ranking
#12726
Licencia
CC-BY-SA-4.0
Actualizada
2/11/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas