mermaid-to-proverif
What it does
This skill converts a Mermaid sequence diagram of a cryptographic protocol into a ProVerif model file. It is for security engineers who want to check a protocol design with formal verification.
When to use it
- βWhen you have a Mermaid diagram of a crypto protocol and want to verify it formally.
- βWhen you need to check properties such as secrecy, authentication, or forward secrecy.
- βWhen you want to check a protocol design for replay attacks.
Skill link
https://github.com/trailofbits/skills/blob/main/plugins/trailmark/skills/mermaid-to-proverif/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βTurn this protocol diagram into a ProVerif model so I can check that the keys stay secret.β
5 new skills a week. 1 minute to read.
How it works
It reads the diagram's messages and cryptographic steps, then writes a .pv model file that the ProVerif tool can check. It also adds reachability checks as a sanity test.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Mermaid to ProVerif
Reads a Mermaid sequenceDiagram describing a cryptographic protocol and
produces a ProVerif model (.pv file) that can be passed directly to the
ProVerif verifier.
Tools used: Read, Write, Grep, Glob.
The typical input is the output of the crypto-protocol-diagram skill β a
Mermaid sequenceDiagram annotated with cryptographic operations (Sign,
Verify, DH, HKDF, Enc, Dec, etc.) and message arrows.
When to Use
- User asks to formally verify a cryptographic protocol described as a Mermaid sequenceDiagram
- User wants to generate a ProVerif model (.pv file) from a protocol diagram
- User wants to prove secrecy, authentication, or forward secrecy properties
- Input is the output of the
crypto-protocol-diagramskill
When NOT to Use
- No Mermaid sequenceDiagram exists yet β use
crypto-protocol-diagramfirst to generate one - User wants to verify properties of non-cryptographic systems (state machines, access control)
- User wants to run ProVerif on an existing .pv file β just run
proverif model.pvdirectly
Rationalizations to Reject
| Rationalization | Why It's Wrong | Required Action |
|---|---|---|
| "Reachability queries are just busywork" | If events aren't reachable, all other query results are meaningless | Always add reachability queries first as a sanity check |
| "Public channels are fine for all messages" | Private channels for internal state prevent false attacks | Use private channels for intra-process state threading |
| "I'll skip the forward secrecy test" | Ephemeral keys demand forward secrecy verification | Add the ForwardSecrecyTest process whenever the diagram shows ephemeral keys |
| "Unused declarations are harmless" | ProVerif may report spurious results from orphan declarations | Clean up all unused types, functions, and events |
| "The model compiles, so it's correct" | A compiling model can have dead receives, type mismatches, or impossible guards that make queries vacuously true | Validate reachability before trusting any security query |
| "I don't need to check the example first" | The example defines the expected output quality bar | Study examples/simple-handshake/ before working on unfamiliar protocols |
Workflow
ProVerif Model Progress:
- [ ] Step 1: Parse participants and channels
- [ ] Step 2: Inventory cryptographic operations
- [ ] Step 3: Declare types, functions, and equations
- [ ] Step 4: Identify and declare events
- [ ] Step 5: Formulate security queries
- [ ] Step 6: Write participant processes
- [ ] Step 7: Write main process and finalize
- [ ] Step 8: Verify and deliver
Step 1: Parse Participants and Channels
From the Mermaid diagram:
- Extract every
participantoractordeclaration. Each becomes a ProVerif process. - Count message arrows (
->>,-->>,-x,--x). Each distinctA ->> B: labelcreates a communication step on a channel. - Decide channel model:
- Public channel for any message sent over the network before a secure channel is established (e.g., ClientHello, ephemeral keys, ciphertext to be decrypted by the peer).
- Private channel only for internal state threading within a single party process (not for cross-party messages).
- Default: declare one shared public channel
cfor all cross-party messages. Add per-flow channels only when two distinct parallel sessions must be independent.
free c: channel.
Step 2: Inventory Cryptographic Operations
Walk through every Note over annotation and message label. Build a list of
all distinct operations used. Map each to a ProVerif declaration category:
| Mermaid annotation | ProVerif category |
|---|---|
keygen() β sk, pk |
New name (new sk), public key derived via function |
DH(sk_A, pk_B) |
DH function or exp with group |
Sign(sk, msg) β Ο |
Signature function |
Verify(pk, msg, Ο) |
Equation or destructor |
Enc(key, msg) β ct |
Symmetric or asymmetric encryption function |
Dec(key, ct) β msg |
Destructor (equation) |
HKDF(ikm, info) β k |
PRF/KDF function |
HMAC(key, msg) β tag |
MAC function |
H(msg) β digest |
Hash function |
Commit(v, r) β C |
Commitment function |
Open(C, v, r) |
Commitment equation |
Consult references/crypto-to-proverif-mapping.md for exact ProVerif syntax for e
FAQ
Do I need the diagram skill first?
Usually yes. The crypto protocol diagram skill creates the Mermaid diagram that this skill reads.
Does the skill run ProVerif for me?
No. It writes the model file, which you then run with ProVerif yourself.
Which properties can it check?
It is set up for secrecy, authentication, and forward secrecy, along with replay attack checks.
Details
Original description by the author
Translates Mermaid sequenceDiagrams describing cryptographic protocols into ProVerif formal verification models (.pv files). Use when generating a ProVerif model, formally verifying a protocol, converting a Mermaid diagram to ProVerif, verifying protocol security properties (secrecy, authentication, forward secrecy), checking for replay attacks, or producing a .pv file from a sequence diagram.
repo: trailofbits/skills
Popularity
- GitHub stars
- 8.0k
- Ranking position
- #12730
- License
- CC-BY-SA-4.0
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
audit-context-building
8.0kHelps your agent learn an unfamiliar codebase before a security review, mapping what each function assumes, guarantees and depends on.
algorand-vulnerability-scanner
8.0kHelps your agent scan Algorand smart contracts, written in TEAL or PyTeal, for 11 common security problems such as rekeying attacks and unchecked fees.
audit-prep-assistant
8.0kHelps your agent get a codebase ready for an outside security review, with static analysis, test coverage, dead-code cleanup and clear documentation.
cairo-vulnerability-scanner
8.0kHelps your agent scan Cairo smart contracts on StarkNet for 6 serious problems, including arithmetic overflow, risky cross-layer messages and signature replay.
Similar skills
reverse-engineer-anything
422kHelps your agent look inside shipped apps and packages to explain features, compare versions, or guide a rebuild, using the REA tool.
1password
394kHelps your agent set up the 1Password CLI, sign in, and read or inject secrets without printing their values into chat.
healthcheck
394kHelps your agent audit the computer or server that runs OpenClaw for security risks, such as SSH, firewall, updates, and backups, then suggest safe fixes.