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.mdSalin 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
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
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
Komentar
- β¦
Skill lain dari repositori ini
audit-context-building
8.0kMembantu agent Anda mempelajari basis kode yang belum dikenal sebelum tinjauan keamanan, dengan memetakan apa yang diasumsikan, dijamin, dan bergantung pada setiap fungsi.
algorand-vulnerability-scanner
8.0kMembantu agent Anda memindai smart contract Algorand, yang ditulis dalam TEAL atau PyTeal, untuk 11 masalah keamanan umum seperti serangan rekeying dan biaya yang tidak diperiksa.
audit-prep-assistant
8.0kMembantu agent Anda menyiapkan basis kode untuk tinjauan keamanan dari luar, dengan analisis statis, cakupan tes, pembersihan kode mati, dan dokumentasi yang jelas.
cairo-vulnerability-scanner
8.0kMembantu agent Anda memindai smart contract Cairo di StarkNet untuk 6 masalah serius, termasuk overflow aritmetika, pesan lintas lapisan yang berisiko, dan replay tanda tangan.
Skill serupa
reverse-engineer-anything
422kMembantu agent Anda memeriksa aplikasi dan paket yang sudah dirilis untuk menjelaskan fitur, membandingkan versi, atau memandu pembangunan ulang dengan alat REA.
1password
394kMembantu agent Anda mengatur CLI 1Password, masuk, serta membaca atau menyisipkan rahasia tanpa menampilkan nilainya di chat.
healthcheck
394kMembantu agent Anda mengaudit komputer atau server OpenClaw dari risiko keamanan seperti SSH, firewall, pembaruan, dan cadangan, lalu menyarankan perbaikan aman.