Langsung ke konten
Skillpedia
Keamanan8.0k Β· #12726

crypto-protocol-diagram

Fungsinya

Skill ini membaca kode sumber, dokumen standar, atau model formal protokol komunikasi aman dan mengubahnya menjadi diagram alur pesan. Skill ini untuk insinyur dan peninjau keamanan yang perlu memahami handshake atau pertukaran kunci.

Kapan dipakai

  • βœ“Saat Anda perlu menggambar handshake, pertukaran kunci, atau alur kripto multi-pihak lainnya.
  • βœ“Saat Anda punya RFC atau makalah yang menjelaskan protokol dan ingin urutan pesannya digambar.
  • βœ“Saat Anda punya model ProVerif atau Tamarin dan menginginkan diagram yang mudah dibaca dari model itu.

Link skill

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

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/trailofbits/skills/blob/main/plugins/trailmark/skills/crypto-protocol-diagram/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œBisakah Anda menggambar diagram langkah pesan dalam kode pertukaran kunci ini?”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Skill ini menemukan siapa mengirim apa kepada siapa dan operasi enkripsi atau penandatanganan apa yang terjadi di setiap titik, lalu menulis diagram sequence Mermaid dan versi teks biasanya.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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

Pertanyaan umum

Format input apa yang bisa dipakai?

Kode sumber, RFC, makalah akademik, pseudokode, prosa biasa, dan berkas model ProVerif atau Tamarin semuanya bisa dipakai.

Apakah diagram menampilkan langkah kripto juga selain pesan?

Ya. Setiap langkah bisa mencakup operasi kripto, seperti penandatanganan atau derivasi kunci.

Apakah ini sama dengan diagram struktur kode?

Tidak. Diagram ini menunjukkan pesan protokol, bukan pemanggilan fungsi atau tata letak kelas.

Detail

Deskripsi asli dari pembuat

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

Popularitas

Bintang GitHub
8.0k
Peringkat
#12726
Lisensi
CC-BY-SA-4.0
Diperbarui
2/11/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa