arXiv:2609.06226cs.CRSep 2026

Manuscript Offprint

arXiv:2609.06226

Scratchy: Visual-Scratchpad Multimodal Reasoning for Cryptographic Proof Generation in EasyCrypt

Yupeng Ren, Zhaoxuan Li, Rui Zhang

Abstract

Large language models (LLMs) have recently made substantial progress in formal proof generation, yet presenting distinctive challenges in cryptographic area. Computational security arguments posit that a valid proof must coordinate probability, adversarial games, invariants, assumptions and bounds, which can be provided by a machine-checked framework named EasyCrypt. Although all objects may appear in available context, LLMs still struggle because proof-theoretic dependencies are typically implicit in a linear representation and distributed across multiple programs. So, this paper presents Scratchy, a visual-scratchpad approach that exposes these dependencies for multimodal generation. Given the natural-language security description, with formal context and target propositions, the proof objects can be normalized into a typed proof-relation graph. Then a structure-preserving visual compiler transforms the graph into the formula-rich visual proof state that guides a multimodal model in generating the EasyCrypt proof. Also, the Scratchy-eval, a 114-task dataset derived from reliable official EasyCrypt files, has been introduced. It contains 64 security-form proof generations and 50 multiple-choice knowledge tests. After a series of evaluations, covering semantic grounding, relational invariants, and game reductions, classical LLMs like GPT-5.6-Sol and Claude-Opus-5 have gained a clear advantage from Scratchy's structured visual proof states. This contrast suggests that explicit proof structure can make the improvement and multimodal proof-state representation as a promising direction for computer-aided cryptography.

1 Introduction

With the rapid development of Large Language Models (LLMs), formal proof generation has become an important task for machine reasoning. Recently, researchers have expanded formal supervision through synthetic natural language, including

Figure

Figure 1: Results of the API-based EasyCrypt proof-generation Observation across six representation conditions. The professional multimodal graph achieves the highest compile pass rate (62.5%, 25/40), outperforming all baselines.

Lean corpora, self-play that alternates conjecturing and proving, and verifier-guided repair of generated proofs (Ying et al., 2024; Dong and Ma, 2025; Ospanov et al., 2025). These advances show that formal libraries and prover feedback can effectively support proof generation. However, the dominant setting remains mathematical theorem proving, and the interface between the model and the prover is still primarily composed of serialized theorem statements, proof code, candidate premises, and diagnostic messages.

Cryptographic proofs have a different structure. A computational security argument must coordinate probabilistic programs, games, adversarial capabilities, invariants, security assumptions, and concrete advantage bounds. Correctness depends not only on whether these objects are available, but also on the direction and order required by the security reduction. Foundational work on machine-checked cryptography developed CertiCrypt for code-based game proofs and subsequently introduced EasyCrypt to elaborate machine-checkable security proofs from game sketches (Barthe et al., 2009, 2011). These systems established that program transformations, relational judgments, and

Table 1: Notation expolited in the Scratchy pipeline and the motivating Observation.

(a) Scratchy proof objects and verification
SymbolMeaning
X,x\mathcal{X}, xSecurity setting and task.
C,Γ\mathcal{C}, \GammaLocal context and environment.
ϕ\phiTarget obligation.
qqStructured Natural-Language Proof Sketch.
G=(V,E,τ,λ)\mathcal{G} = (\mathcal{V}, \mathcal{E}, \tau, \lambda)Typed relation graph.
V,E\mathcal{V}, \mathcal{E}Graph nodes and edges.
τ,λ\tau, \lambdaType and label maps.
R\mathcal{R}Visual compiler.
IG=R(G)I_{\mathcal{G}} = \mathcal{R}(\mathcal{G})Visual proof state.
Gi,GL,GRG_i, G_L, G_RHybrid and paired games.
viL,viRv_i^L, v_i^RAligned state values.
rir_iTransition cue.
Δij\Delta_{ij}Game distance.
ϵi\epsilon_iGame-hop bound.
π,π^\pi, \widehat{\pi}Proof fragments.
pθ,θp_\theta, \thetaGenerator and parameters.
S[π^]S[\widehat{\pi}]Reconstructed source.
VEC\mathbf{V}_{\mathrm{EC}}EasyCrypt verifier.
⊤,⊥\top, \botVerification outcomes.
Pr⁡[Gi⇒1],I\Pr[G_i \Rightarrow 1], \mathcal{I}Probability and invariant.
(b) Observation metrics and routing
SymbolMeaning
T,T,t\mathcal{T}, T, tTask set, size, and index.
M,M,m\mathcal{M}, M, mModel set, size, and index.
MAPI\mathcal{M}_{\mathrm{API}}Hosted-model pool.
K,K,c\mathcal{K}, K, cCondition set, size, and index.
cNR,cTH,cCRc_{\mathrm{NR}}, c_{\mathrm{TH}}, c_{\mathrm{CR}}Text conditions.
cGD,cSG,cPGc_{\mathrm{GD}}, c_{\mathrm{SG}}, c_{\mathrm{PG}}Graph conditions.
Ktext\mathcal{K}_{\mathrm{text}}Text-condition set.
Kvctl\mathcal{K}_{\mathrm{vctl}}Visual-control set.
ymtcy_{mtc}Compile outcome.
Smc=∑tymtcS_{mc} = \sum_t y_{mtc}Compile count.
p^c\widehat{p}_cPooled pass rate.
[Lc,Uc][L_c, U_c]Wilson interval.
ctextm,cvctlmc_{\mathrm{text}}^{m}, c_{\mathrm{vctl}}^{m}Best text/visual controls.
δtextm,δvctlm\delta_{\mathrm{text}}^{m}, \delta_{\mathrm{vctl}}^{m}Professional-condition gains.
zmtz_{mt}Outcome class.
ℓ\ellLanguage-layer index.
Hℓ(c),ΔHℓH_{\ell}^{(c)}, \Delta H_{\ell}Routing entropy/change.
Uℓ(c),ΔUℓU_{\ell}^{(c)}, \Delta U_{\ell}Expert utilization/change.
DJSD_{\mathrm{JS}}Routing divergence.
Nimg,AvisN_{\mathrm{img}}, A_{\mathrm{vis}}Image tokens/activation.

concrete security bounds can be rigorously checked within a formal framework. Researchers further proposed EasyCrypt proof workflow and demonstrated representative applications to cryptographic standards and post-quantum constructions (Barthe et al., 2012; Almeida et al., 2019; Barbosa et al., 2021).

Despite the relational of cryptographic proofs, recent proving pipelines still use textual or symbolic sequences as their primary interface. They construct natural-language with formal corpora to improve training, search, and feedback (Ying et al., 2024; Dong and Ma, 2025; Wang et al., 2025; Ospanov et al., 2025). However, these works do not present the distributed relationships within a proof to the generator as a unified visual state. A linear interface preserves symbolic content, but it does not naturally expose object types. Consequently, the relationships between the direction of a game hop and multiple dependency paths running from local obligations to the security goal cannot be simultaneously represented.

Multimodal images provide a representation channel that remains underexplored. Researchers have begun to treat images as intermediate reasoning states. Visual Sketchpad allows a model to draw visual marks, GraphVis preserves graph structure through the visual modality, and MIRA evaluates problems that require intermediate visual cues (Hu et al., 2024; Deng et al., 2024; Zhou et al., 2026). In an adjacent formalization setting, LeanEuclid studies diagram-dependent Euclidean geometry with GPT-4V, but targets mathematical autoformalization rather than machine-checked cryptographic security proofs (Murphy et al., 2024). Thus, whether task-specific images can improve machine-checkable security-proof generation, and which visual proof state is most effective, are still worth diving into.

A preliminary observation indicates that task-specific, structured proof diagrams can improve EasyCrypt proof generation across multimodal models, whereas generic or structurally corrupted diagrams provide weaker benefits. This finding suggests that the gain depends not only on the visual modality itself but also on the faithful organization of proof objects and their relations, motivating the design of Scratchy.

To sum up, this paper proposes Scratchy. While the security attributes are received, within local formal context, target obligation, and proof guidance, the distributed objects can be normalized into a typed proof-relation graph. Its nodes distinguish threat models, program facts, proof obligations, rules, and security goals. At the same time, the constraint, transformation, and discharge relations are supported by directed edges encoding. The graph specifies the semantic structure that a visual representation must preserve, turning the search for an effective image into a constrained proof-state design problem.

As shown in Section. 4, a structure-preserving visual compiler renders the relation graph as a formula-rich visual scratchpad. Guided by different states, the multimodal model performs program unfolding, state alignment, rule application, and goal discharge to generate an EasyCrypt proof fragment. The fragment then enters an EasyCrypt verification loop for parsing and type checking, obligation discharge, and target closure.

For systematic evaluation, this paper further introduces Scratchy-eval. The benchmark derives 114 tasks from 26 source groups and 37 pinned official EasyCrypt files. It contains 64 free-form proof generation tasks and 50 multiple-choice tasks on semantic recognition. The tasks are evaluated under six paired representation conditions. Compilation under EasyCrypt is the primary criterion for generation.

The main contributions of this work are as follows: