Large language model driven password protocol automatic formalization modeling method and system

The automated formal modeling method for cryptographic protocols driven by large language models solves the problems of low efficiency and high professional threshold of manual model building, realizes efficient and automated symbol model generation, supports multiple specification sources, and reduces labor and time costs.

CN122433679APending Publication Date: 2026-07-21SHANDONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610556977.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-04-24
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

Existing formal verification tools for cryptographic protocols rely on manually building models, which suffers from long modeling cycles, low efficiency, high professional thresholds, and a high incidence of human error, making them difficult to apply on a large scale.

Method used

A large language model-driven approach is adopted, which automatically generates symbolic model code through preprocessing, semi-structured intermediate representation extraction, context-aware structured parameter extraction, and deterministic transformation, thereby achieving automated formal verification.

Benefits of technology

Significantly improves modeling efficiency, symbol naming consistency and semantic correctness, supports multiple standard sources, reduces labor costs, and achieves a high degree of automation in end-to-end modeling.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122433679A_ABST
    Figure CN122433679A_ABST
Patent Text Reader

Abstract

The present application belongs to the technical field of network security and artificial intelligence, and provides a large language model driven password protocol automatic formalization modeling method and system, acquires a natural language protocol specification document, and performs preprocessing; according to the priority order of a message block, a verification block and a calculation statement, a large language model extracts corresponding semi-structured intermediate representations from text blocks; all intermediate representation statements are scanned at one time by using the large language model, protocol functions and symbols are identified and stored in a knowledge base, the large language model is driven in units of intermediate representation statements to be refined one by one, and global context and local context are extracted; the completely structured intermediate representations, a protocol role set and the updated knowledge base are taken as inputs to perform deterministic one-to-one mapping with formal verification tool code, and conversion is completed. The present application can automatically generate symbol model code which can be directly input into a formal verification tool.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the interdisciplinary field of network security and artificial intelligence, specifically relating to a method and system for automatic formal modeling of cryptographic protocols driven by a large language model. Background Technology

[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.

[0003] Cryptographic protocols are a crucial infrastructure for ensuring network communication security. Their security typically requires systematic analysis and verification through formal methods. Currently, some formal verification tools have been widely used for the correctness and security analysis based on protocol symbol models, and have uncovered critical security vulnerabilities in real protocols.

[0004] However, existing formal verification tools rely almost entirely on security experts manually constructing formal models based on protocol specifications. Real-world cryptographic protocol specifications are typically published in natural language, often reaching tens or even hundreds of pages in length. Manual modeling faces the following prominent problems: The modeling process is lengthy and inefficient, requiring a significant amount of time to read through lengthy specifications. For complex protocols, the entire modeling cycle can take several weeks, severely hindering the large-scale promotion of formal analysis.

[0005] The professional threshold is extremely high. Modelers must have a strong background in cryptography, formal methods, and the specific syntax of verification tools. Experts who are competent in this work are extremely rare.

[0006] Human error is difficult to avoid. Manually building protocol models can easily introduce small but critical modeling errors due to oversight. The validity of formal verification conclusions depends entirely on the correctness of the model and security attributes.

[0007] The aforementioned bottlenecks make it difficult for formal analysis to be applied quickly and on a large scale in protocol design, standard setting, and engineering verification. Therefore, some researchers have turned to automation.

[0008] Existing attempts at automation can be broadly categorized into two types: the first type takes non-textual specifications as input, which does not conform to the protocol specifications publicly released in natural language in the real world, thus limiting its practicality; the second type takes natural language specifications as the starting point, with finite state machines as the output or focuses on message format extraction, and cannot generate symbolic formal models of cryptographic protocols. Summary of the Invention

[0009] To address the aforementioned problems, this invention proposes a method and system for automatic formal modeling of cryptographic protocols driven by a large language model. This invention takes a natural language protocol specification document as input, and through a designed semi-structured intermediate representation, a priority-based multi-step extraction method, and a context-aware structured parameter extraction method, it automatically generates symbolic model code that can be directly input into formal verification tools for formal verification.

[0010] According to some embodiments, the present invention adopts the following technical solution: A method for automatic formal modeling of cryptographic protocols driven by a large language model includes the following steps: Obtain the natural language protocol specification document and preprocess the document; The large language model is driven to extract the corresponding semi-structured intermediate representation from the text block according to the priority order of message block, validation block, and calculation statement; Based on the semi-structured intermediate representation, a large language model is used to scan all intermediate representation statements at once, identify protocol functions and symbols and store them in the knowledge base. The large language model is driven to refine each intermediate representation statement one by one, extracting global and local contexts. After each statement is refined, if new symbols or functions are introduced, the knowledge base is explicitly updated. In addition, during the refinement process, a symbol stream is maintained for each protocol party, and the source tags of each symbol are recorded, so as to achieve complete structuring of the semi-structured intermediate representation. Taking the fully structured intermediate representation, the protocol role set, and the updated knowledge base as input, the deterministic one-to-one mapping with the formal verification tool code is performed to complete the transformation.

[0011] As an optional implementation, the semi-structured intermediate representation includes three types: message blocks, verification blocks, and calculation statements. The message block is centered on a certain message operation and includes a pre-calculation process performed by the sender before sending and a post-processing verification or calculation process performed by the receiver after receiving the message. The verification block is centered around a certain verification operation, and may include a pre-calculation process. A computation statement is an independent computational action that is not semantically associated with any message or verification operation, and can appear directly as a top-level unit.

[0012] As an alternative implementation, each intermediate representation statement of the semi-structured intermediate representation includes two types of information: structured meta-information and free-format natural language description.

[0013] As an alternative implementation, the process of obtaining a natural language protocol specification document and preprocessing the document includes: cleaning the natural language protocol specification document, removing headers and footers, standardizing line breaks within paragraphs, grouping paragraphs according to the same chapter title, and ensuring that the length of each text block does not exceed the input limit of the large language model.

[0014] As an alternative implementation, the process of driving the large language model to extract the corresponding semi-structured intermediate representation from text blocks according to the priority order of message blocks, verification blocks, and calculation statements includes: extracting the representation using multiple rounds of continuous dialogue on a per-text-block basis. The first round checks whether the message operation exists, and then extracts the message operation after confirmation; the second and third rounds extract the pre-calculation process and the post-processing verification or calculation process, respectively; using the constructed ordered message sequence as context, the newly extracted message block is inserted into the correct position, and the first data is obtained after processing all text blocks; Using text blocks as units, explicit verification operations and their pre-computations are extracted through multi-turn dialogues. During integration, the ordered message sequence in the first data is used as the context to insert the verification blocks into the correct relative positions. After processing all text blocks, the second data is obtained. Extract the computational operations that are semantically independent of the message and verification operations, insert them into the appropriate positions in the ordered sequence of the second data, and finally obtain the complete semi-structured intermediate representation.

[0015] As an alternative implementation, the process of using a large language model to scan all intermediate representation statements at once, identify protocol functions and symbols and store them in the knowledge base includes: pre-organizing cross-protocol general cryptographic primitives based on modeling experience to form an initial function library; Taking the complete semi-structured intermediate representation as input, the large language model scans all intermediate representation statements at once, identifies the protocol predefined function symbols and adds them to the knowledge base, which is divided into a protocol element symbol library and a function library.

[0016] As an alternative implementation, the process of refining the large language model step by step by taking intermediate representation statements as units and extracting global and local contexts includes: providing global context, i.e., the current unified knowledge base, including protocol element symbol library and function library, and constraining symbol naming consistency during each refinement; It provides local context, i.e. hierarchical dependency information of semi-structured intermediate representation, extracts message content symbol sequence for message blocks, extracts function name, actual parameter list and calculation result symbol for calculation statements, and extracts items to be compared for verification blocks.

[0017] As an alternative implementation, in the process of refining the large language model step by step by using intermediate representation statements as units, the processing order is as follows: message block, computation statement attached to the message, verification block, computation statement attached to verification, and independent computation statement.

[0018] As an alternative implementation, the process of maintaining a symbol stream for each protocol party and recording the source markings of each symbol during the refinement process includes: after refinement, the large language module analyzes the semantics of the set of symbols marked as unknown, determines that the symbols are randomly generated, automatically inserts a calculation statement that calls the corresponding function before the first occurrence position, and updates the source to calculation; the remaining unknown symbols are remarked as constants to ensure that all symbols in the model have a clear source.

[0019] A large language model-driven automatic formal modeling system for cryptographic protocols includes: The preprocessing module is configured to acquire a natural language protocol specification document and preprocess the document. The semi-structured intermediate representation extraction module is configured to drive the large language model to extract the corresponding semi-structured intermediate representation from the text block according to the priority order of message block, validation block, and calculation statement. The structured parameter extraction module is configured to scan all intermediate representation statements at once using a large language model based on the semi-structured intermediate representation, identify protocol functions and symbols and store them in the knowledge base, drive the large language model to refine them one by one in terms of intermediate representation statements, extract global context and local context, and explicitly update the knowledge base if new symbols or functions are introduced after each statement is refined. In addition, the module maintains a symbol stream for each protocol party and records the source tags of each symbol during the refinement process, so as to achieve complete structuring of the semi-structured intermediate representation. The deterministic transformation module is configured to take the fully structured intermediate representation, the protocol role set, and the updated knowledge base as input, and perform a deterministic one-to-one mapping with the formal verification tool code to complete the transformation.

[0020] Compared with the prior art, the beneficial effects of the present invention are as follows: This invention significantly improves modeling efficiency. Through an automated framework, it reduces the time required for formal modeling of cryptographic protocols from weeks to minutes. Modeling of real-world protocols can be completed within a single run, greatly reducing the time and manpower required for formal analysis.

[0021] The semantic coverage capability of this invention is significantly superior to existing methods. Simulation results show that, across eight typical protocols with varying specifications and complexities, the average accuracy and coverage of the semi-structured intermediate statement extraction stage are both approximately 89%, while the average coverage of the structured parameter extraction stage is approximately 78%. Compared to similar technical solutions, this invention surpasses the coverage of four common protocols, with particularly outstanding advantages on complex protocols.

[0022] The symbol naming global consistency of this invention is structurally guaranteed. The unified knowledge base mechanism of this invention fundamentally solves the problem of naming drift for the same protocol element in the sentence-by-sentence processing of large language models. The symbol flow inference mechanism automatically handles the generation operation of implicit omissions in the specification, and can generate a structurally complete minimum usable model without manual intervention. Compared with the existing technology, which requires user interaction to handle the problem of unbound variables in the repair stage, it achieves a higher degree of automation.

[0023] The present invention ensures the structural correctness of message semantics. The semi-structured intermediate statement of the present invention models the message content as a symbol list rather than a nested function application. The pre-computation of message construction is represented by independent operations. The converter generates corresponding actions for the sender and receiver respectively. The message item of the receiver is always a symbol list. From the design level, the systematic message unreadable error of the existing solution is avoided, and no additional repair steps are required.

[0024] This invention is highly scalable and versatile, supporting various specification sources such as RFC documents, academic papers, industry technical standards, and modeling teaching materials. It is effective across different complexity gradients, from teaching example protocols to real-world protocols, and the block processing strategy does not impose an upper limit on the length of specification documents, thus exhibiting good scalability.

[0025] The human-machine collaboration closed loop of this invention is highly practical. Operators can complete model verification and fixed-point correction without directly editing formal code, keeping the cost of manual intervention within an acceptable range. This allows the end-to-end modeling process to maintain a high degree of automation while ensuring the correctness and usability of the final model with controllable human input.

[0026] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0027] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.

[0028] Figure 1 This is an overall flowchart of an automated modeling framework for one embodiment. Detailed Implementation

[0029] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0030] It should be noted that the following detailed description is illustrative and intended to provide further explanation of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0031] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of exemplary embodiments according to the invention. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.

[0032] Where there is no conflict, the embodiments and features described in this application may be combined with each other.

[0033] Example 1 A method for automatic formal modeling of cryptographic protocols driven by a large language model includes the following steps: Obtain the natural language protocol specification document and preprocess the document; The Large Language Model (LLM) is driven to extract the corresponding semi-structured intermediate representations from text blocks according to the priority order of message blocks, validation blocks, and computation statements. Based on the semi-structured intermediate representation, a large language model is used to scan all intermediate representation statements at once, identify protocol functions and symbols and store them in the knowledge base. The large language model is driven to refine each intermediate representation statement one by one, extracting global and local contexts. After each statement is refined, if new symbols or functions are introduced, the knowledge base is explicitly updated. In addition, during the refinement process, a symbol stream is maintained for each protocol party, and the source tags of each symbol are recorded, so as to achieve complete structuring of the semi-structured intermediate representation. Taking the fully structured intermediate representation, the protocol role set, and the updated knowledge base as input, the deterministic one-to-one mapping with the formal verification tool code is performed to complete the transformation.

[0034] The following is a detailed description.

[0035] In this embodiment, a semi-structured intermediate representation is pre-designed, referred to as FormalIR in this embodiment. This step is part of the preparatory work before the framework runs. FormalIR runs through the entire modeling process and is the cornerstone for the smooth progress of the two-stage extraction.

[0036] In this embodiment, a dedicated semi-structured intermediate representation, FormalIR, is designed by systematically summarizing a large number of formal models of real cryptographic protocols. FormalIR represents the protocol as an ordered sequence of units, each unit belonging to one of the following three categories: (1) Message block (msg_block): It is based on a certain message operation (msg_stmt), and includes the pre-calculation process (msg_pre, which consists of one or more calculation operations cal_stmt) executed by the sender before sending, and the post-processing verification or calculation process (msg_post, which consists of calculation operation cal_stmt and / or verification operation val_stmt) executed by the receiver after receiving the message.

[0037] (2) Verification block (val_block): It is based on a certain verification operation (val_stmt) and includes possible pre-calculation processes (val_pre, which consists of one or more cal_stmt).

[0038] (3) Independent computation operation (cal_stmt): Independent computation action that is not directly associated with any message or verification operation in semantics, and can be directly used as the top-level unit.

[0039] Each intermediate IR statement contains two types of information: structured metadata (operation type enumeration value, executor, sender / receiver) and a free-format natural language description (desc).

[0040] This semi-structured design divides the end-to-end modeling process into two stages: the first stage focuses on extracting core operational semantics from the verbose specification (outputting FormalIR), and the second stage refines the structured symbol parameters based on this (outputting FormalIR*), which is finally mapped to ProVerif code by the converter. FormalIR also acts as a filter, naturally shielding content in the specification that is irrelevant to the symbol model (compatibility specifications, implementation suggestions, etc.) during the extraction process.

[0041] The next step is the modeling process, which involves priority-based multi-step IR extraction. In this embodiment, this is implemented using the PriorIR extractor.

[0042] The input for this step is a natural language protocol specification document, and the output is a semi-structured FormalIR.

[0043] Specifically, it includes: (1) Standardize document preprocessing and segmentation: Clean up RFC and other formatted documents (remove headers and footers, standardize line breaks within paragraphs), group paragraphs according to the same chapter title, and ensure that the length of each text block does not exceed the LLM input limit.

[0044] (2) Priority-based three-step extraction process: The PriorIR extractor utilizes the natural laws of cryptographic protocol interaction to drive the LLM to extract and refine the FormalIR from the text block in three steps according to the priority order of message, verification, and computation: like Figure 1 As shown, message block extraction is performed on a multi-turn continuous dialogue basis, with each text block as a unit. The first turn uses a two-step prompting strategy (first check if the message exists, then confirm before extraction) to prevent false positives; the second and third turns extract `msg_pre` and `msg_post` respectively; finally, using the constructed ordered message sequence as context, the newly extracted message block is inserted into the correct position. The entire output format is constrained to JSON, and a thought chain reasoning approach is introduced to improve accuracy. PartialIR1 is obtained after processing all text blocks.

[0045] Validation block extraction: Explicit validation operations and their pre-computed functions are extracted from multiple rounds of dialogue, using text blocks as units. During integration, the ordered message sequence in PartialIR1 is used as the context to insert validation blocks into their correct relative positions, avoiding global reordering and reducing complexity. PartialIR2 is obtained after processing all text blocks.

[0046] Computation statement extraction: Extract the computation operations that are semantically independent of the message and verification operations, insert them into the appropriate positions in the ordered sequence of PartialIR2, and finally obtain the complete FormalIR.

[0047] Next, the CAPE extractor is used to extract context-aware structured parameters.

[0048] This step corresponds to the second stage of modeling. The input is the FormalIR produced in the first stage, and the output is formal model code that conforms to the syntax specifications of the formal verification tool ProVerif. Specifically, it includes: (1) Construction of a unified knowledge base: Based on modeling experience, a general cryptographic primitive across protocols (such as modular exponentiation exp, hash, asymmetric encryption enc_pk, etc.) is pre-organized to form an initial function library; taking the complete FormalIR as input, the LLM scans all IR statements at once, identifies protocol-specific function symbols and adds them to the knowledge base. The knowledge base is divided into two sub-libraries: the protocol element symbol library (ST) and the function library (FT), which are continuously updated in the subsequent refinement process and always kept open.

[0049] (2) Context-aware structured parameter extraction: The LLM is refined step by step, driven by IR statements, and each refinement provides two types of context: (a) Global context—the current unified knowledge base (ST and FT) constrains symbol naming consistency; (b) Local context—FormalIR level dependency information (such as computation operations within a message block providing the refined message statements to which they depend, and verification operations additionally providing the dependent message statements and their pre-computations).

[0050] The structured parameters to be extracted for each type of statement are as follows: message statements extract the sequence of message content symbols; calculation statements extract the function name, argument list (supporting nested function applications), and calculation result symbols; verification statements extract the two items to be compared. After each statement is refined, the knowledge base is explicitly updated if new symbols or functions are introduced. The overall processing order is: message statement → calculation statement attached to the message → verification statement → calculation statement attached to verification → independent calculation statement.

[0051] (3) Symbol stream inference (post-processing): During the refinement process, maintain the symbol stream for each protocol party and record the source markers of each symbol (calculated / received / unknown).

[0052] After refinement, the semantics of the set of symbols marked as unknown are analyzed by the LLM: if a symbol is determined to be randomly generated, a calculation statement calling the gen function is automatically inserted before its first occurrence, and the source is updated to calculated; the remaining unknown symbols are remarked as constant (public constants known before protocol execution) to ensure that all symbols in the model have a clear source and to guarantee compilability.

[0053] (4) Deterministic Transformer: Taking the fully structured FormalIR*, protocol role set R, symbol library ST, and function library FT as input, it performs a deterministic one-to-one mapping—the declaration part maps the identifiers in ST to the functions and destructors in FT to ProVerif's free name declaration statements and constructor (i.e., function symbol) declaration statements; the process part divides IR* statements according to the protocol side, message statements generate sender output (out) actions and receiver input (in) actions respectively, computation statements are mapped to let local definition statements or new fresh name generation statements, and verification statements are mapped to conditional check statements. The entire transformation process does not require calling LLM, ensuring syntactic correctness and stability.

[0054] In some embodiments, a visual interactive modeling system can also be established as a post-processing step in the automated workflow to support lightweight manual refinement of the automatically extracted results. The system adopts a front-end / back-end separation architecture, with the interface divided into four functional areas: Navigation bar: Provides protocol selection (built-in examples or uploaded framework output) and model export (can be directly imported into ProVerif).

[0055] Central Interactive Diagram: Displays the complete execution flow of the protocol in the form of a sequence diagram. Message operations are represented by lines with arrows, and calculation / generation / verification operations are displayed as differentiated nodes. It supports the selection, addition (insertion at a specified position by clicking the "+" button), and deletion of operation nodes.

[0056] Operation editing area: Activated in real time after selecting a node, displaying the text description of the operation, the current knowledge base status of the executor, and the function call stack; supports structured parameter editing for four types of operations (message, calculation, random number generation, and verification), and the modification results are synchronized to the interactive graph in real time.

[0057] Specification Text Area: Displays the original protocol specifications, establishes an index association with the interaction graph nodes, and automatically jumps to and highlights the corresponding specification text when an operation is selected, providing semantic reference for manual correction.

[0058] The system supports two usage modes: manual modeling starting from scratch (the system maintains the knowledge base status in real time for reference), and manual post-processing correction based on automated extraction results (importing FormalIR* automatically renders interactive diagrams, and users only need to make point-to-point corrections to a few questionable operations).

[0059] In summary, the solution provided in this embodiment bridges the structural expression differences between natural language protocol specifications and strict symbolic formal models, enabling LLM to reliably complete cross-paradigm semantic transformations, rather than the performance degradation caused by end-to-end direct generation.

[0060] This embodiment can reliably identify and reconstruct the implicit execution order of each operation from protocol specification documents that lack a standardized document structure and have scattered content.

[0061] This embodiment can ensure global consistency of symbol naming across operations in the generated formal model under the LLM statement-by-statement processing mode, preventing compilation errors and semantic conflicts caused by name drift.

[0062] Example 2 A large language model-driven automatic formal modeling system for cryptographic protocols includes: The preprocessing module is configured to acquire a natural language protocol specification document and preprocess the document. The semi-structured intermediate representation extraction module is configured to drive the large language model to extract the corresponding semi-structured intermediate representation from the text block according to the priority order of message block, validation block, and calculation statement. The structured parameter extraction module is configured to scan all intermediate representation statements at once using a large language model based on the semi-structured intermediate representation, identify protocol functions and symbols and store them in the knowledge base, drive the large language model to refine them one by one in terms of intermediate representation statements, extract global context and local context, and explicitly update the knowledge base if new symbols or functions are introduced after each statement is refined. In addition, the module maintains a symbol stream for each protocol party and records the source tags of each symbol during the refinement process, so as to achieve complete structuring of the semi-structured intermediate representation. The deterministic transformation module is configured to take the fully structured intermediate representation, the protocol role set, and the updated knowledge base as input, and perform a deterministic one-to-one mapping with the formal verification tool code to complete the transformation.

[0063] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of one or more computer-usable storage media (including, but not limited to, disk storage, etc.) containing computer-usable program code. CD - ROM It takes the form of a computer program product implemented on (such as optical memory, etc.).

[0064] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0065] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0066] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0067] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made by those skilled in the art without creative effort within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for automatic formal modeling of cryptographic protocols driven by a large language model, characterized in that, Includes the following steps: Obtain the natural language protocol specification document and preprocess the document; The large language model is driven to extract the corresponding semi-structured intermediate representation from the text block according to the priority order of message block, validation block, and calculation statement; Based on the semi-structured intermediate representation, a large language model is used to scan all intermediate representation statements at once, identify protocol functions and symbols and store them in the knowledge base. The large language model is driven to refine each intermediate representation statement one by one, extracting global and local contexts. After each statement is refined, if new symbols or functions are introduced, the knowledge base is explicitly updated. In addition, during the refinement process, a symbol stream is maintained for each protocol party, and the source tags of each symbol are recorded, so as to achieve complete structuring of the semi-structured intermediate representation. Taking the fully structured intermediate representation, the protocol role set, and the updated knowledge base as input, the deterministic one-to-one mapping with the formal verification tool code is performed to complete the transformation.

2. The method for automatic formal modeling of cryptographic protocols driven by a large language model as described in claim 1, characterized in that, The semi-structured intermediate representation includes three types: message blocks, verification blocks, and calculation statements. Among them, the message block takes a certain message operation as its core and includes a pre-calculation process performed by the sender before sending and a post-processing verification or calculation process performed by the receiver after receiving the message. The verification block is centered around a certain verification operation, and may include a pre-calculation process. A computation statement is an independent computational action that is not semantically associated with any message or verification operation, and can appear directly as a top-level unit.

3. The method for automatic formal modeling of cryptographic protocols driven by a large language model as described in claim 1, characterized in that, Each intermediate representation statement in the semi-structured intermediate representation includes two types of information: structured meta-information and free-format natural language description.

4. The method for automatic formal modeling of cryptographic protocols driven by a large language model as described in claim 1, characterized in that, The process of obtaining the natural language protocol specification document and preprocessing the document includes: cleaning the natural language protocol specification document, removing headers and footers, standardizing line breaks within paragraphs, grouping paragraphs by the same chapter title, and ensuring that the length of each text block does not exceed the input limit of the large language model.

5. The method for automatic formal modeling of cryptographic protocols driven by a large language model as described in claim 1, characterized in that, The process of extracting the corresponding semi-structured intermediate representation from text blocks by driving the large language model according to the priority order of message blocks, validation blocks, and computation statements includes: extracting the representation from each text block using multiple rounds of continuous dialogue. The first round checks whether the message operation exists, and then extracts the message operation after confirmation; the second and third rounds extract the pre-calculation process and the post-processing verification or calculation process, respectively; using the constructed ordered message sequence as context, the newly extracted message block is inserted into the correct position, and the first data is obtained after processing all text blocks; Using text blocks as units, explicit verification operations and their pre-computations are extracted through multi-turn dialogues. During integration, the ordered message sequence in the first data is used as the context to insert the verification blocks into the correct relative positions. After processing all text blocks, the second data is obtained. Extract the computational operations that are semantically independent of the message and verification operations, insert them into the appropriate positions in the ordered sequence of the second data, and finally obtain the complete semi-structured intermediate representation.

6. The method for automatic formal modeling of cryptographic protocols driven by a large language model as described in claim 1, characterized in that, The process of using a large language model to scan all intermediate representation statements at once, identify protocol functions and symbols, and store them in the knowledge base includes: pre-organizing cross-protocol general cryptographic primitives based on modeling experience to form an initial function library; Taking the complete semi-structured intermediate representation as input, the large language model scans all intermediate representation statements at once, identifies the protocol predefined function symbols and adds them to the knowledge base, which is divided into a protocol element symbol library and a function library.

7. The method for automatic formal modeling of cryptographic protocols driven by a large language model as described in claim 1, characterized in that, The process of refining the large language model step by step by taking intermediate representation statements as the unit and extracting global and local contexts includes: providing global context, i.e., the current unified knowledge base, including protocol element symbol library and function library, and constraining symbol naming consistency during each refinement; It provides local context, i.e. hierarchical dependency information of semi-structured intermediate representation, extracts message content symbol sequence for message blocks, extracts function name, actual parameter list and calculation result symbol for calculation statements, and extracts items to be compared for verification blocks.

8. The method for automatic formal modeling of cryptographic protocols driven by a large language model as described in claim 1, characterized in that, In the process of refining the large language model step by step by using intermediate representation statements as units, the processing order is as follows: message block, computation statement attached to the message, validation block, computation statement attached to validation, and independent computation statement.

9. The method for automatic formal modeling of cryptographic protocols driven by a large language model as described in claim 1, characterized in that, The process of refining the symbol stream for each protocol party and recording the source markings of each symbol includes: after refining, the large language module analyzes the semantics of the set of symbols marked as unknown, determines that the symbols are randomly generated, automatically inserts the calculation statement that calls the corresponding function before the first occurrence position, and updates the source to calculation; the remaining unknown symbols are remarked as constants to ensure that all symbols in the model have a clear source.

10. A large language model-driven automatic formal modeling system for cryptographic protocols, characterized in that, include: The preprocessing module is configured to acquire a natural language protocol specification document and preprocess the document. The semi-structured intermediate representation extraction module is configured to drive the large language model to extract the corresponding semi-structured intermediate representation from the text block according to the priority order of message block, validation block, and calculation statement. The structured parameter extraction module is configured to scan all intermediate representation statements at once using a large language model based on the semi-structured intermediate representation, identify protocol functions and symbols and store them in the knowledge base, drive the large language model to refine them one by one in terms of intermediate representation statements, extract global context and local context, and explicitly update the knowledge base if new symbols or functions are introduced after each statement is refined. In addition, the module maintains a symbol stream for each protocol party and records the source tags of each symbol during the refinement process, so as to achieve complete structuring of the semi-structured intermediate representation. The deterministic transformation module is configured to take the fully structured intermediate representation, the protocol role set, and the updated knowledge base as input, and perform a deterministic one-to-one mapping with the formal verification tool code to complete the transformation.