A method and system for predicting and analyzing round states in a block cipher based on neural networks.
By adding state reading and neural prediction steps outside the block cipher, and utilizing LSTM and multi-output neural networks, the problems of reusability and evaluation uniformity in block cipher round state analysis are solved, enabling flexible and accurate prediction of local bits and the overall state.
Patent Information
- Application Number
- CN202611427494.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-15
- Publication Date
- 2026-11-17
AI Technical Summary
Existing technologies in block cipher round state analysis have difficulty reusing experimental procedures across different rounds, and bit-by-bit accuracy cannot reflect the prediction of the entire state, lacking a unified evaluation standard.
Outside of the block cipher, state reading, sample generation, and neural prediction steps are added. LSTM is used to process the input bit sequence, a multi-output neural network is used to predict the round state, and the BCEWithLogitsLoss and AdamW optimizers are combined to evaluate bit-by-bit and complete states in a balanced manner.
It achieves local bit and global state prediction under different rounds, maintains a fixed correspondence in the output results, has reliable sources of supervision data, preserves local and global levels in the statistical results, adapts to different state representation methods, and improves the flexibility and accuracy of round state analysis.
Smart Images

Figure CN123116304A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the problem of neural network modeling in information security and symmetric cryptanalysis, analyzing the internal states generated when a block cipher reaches a specified round. Given an input block, a neural model is used to predict each bit of the round state, and then the predicted values are compared bit by bit with the actual state generated by the cryptographic program to measure the predictability of the round state under the current experimental conditions. Background Technology
[0002] Block cipher computation is typically accomplished through several rounds of continuous transformations. (Fixed) Then, the same input group After round 1, round 2, and subsequent rounds, a set of intermediate states will be generated in sequence. Nonlinear substitution, shifting, XOR, and hybrid operations constantly change the state between rounds. Therefore, the input-related information retained in different rounds is not the same, and the difficulty for the neural model to learn the state of each round also changes accordingly.
[0003] From a program implementation perspective, round-state analysis first encounters interface differences. Some ciphers store the state as integers, some implementations use byte arrays or bit vectors, and some encapsulate the round function within a class. If the state reading, sample generation, and model input code are rewritten for each algorithm change, the experimental workflow becomes difficult to reuse. Furthermore, bit-by-bit accuracy only reflects the average prediction performance at each position; to determine whether the entire state can be predicted correctly simultaneously, a separate complete state metric is needed.
[0004] Based on these issues, this application separates the state extraction, sample generation, and prediction evaluation processes. The cryptographic implementation is only responsible for returning the true state after a given number of rounds; subsequent modules uniformly receive the encoded state vector. The prediction results are analyzed both bit-by-bit and as a complete vector. Bit target state, using As a complete hit benchmark that is uniformly random and independent of the true state, the results of different target wheels can be compared under the same evaluation criteria. Summary of the Invention
[0005] This application presents a round state prediction process that can be directly implemented into a program. This process does not change the round function of the block cipher itself, but adds state reading, sample organization, neural prediction, and result statistics steps outside the algorithm. The model is trained after the input blocks are paired one-to-one with the actual states of the specified rounds; during testing, both the correctness of each bit prediction and the accuracy of the complete state prediction are checked.
[0006] During implementation, a specified round status return interface is first established for the password to be analyzed. The caller provides the input grouping. and target number of rounds The interface execution reached the first... Return to internal state after wheel rotation If the analysis object only covers the state. Part of the data is extracted according to a pre-fixed bit order. Bit target vector The resulting supervisory labels are derived directly from the execution results of the cryptographic program.
[0007] A supervised sample is written as .in It is the input group. It was obtained under the same key, the same target round, and the same encoding rules. Bit reality state. Model reception. Then, at the same time, give The probability that each target position is 1; after thresholding, the predicted state is formed according to the original bit order. .
[0008] The test results were statistically analyzed in two levels. First, the calculation... Observe the average accuracy of each state bit; then calculate Only all samples of the same type A complete hit is recorded only if all target bits are correct simultaneously. Bit state, in As a complete hit benchmark for uniform random guessing, and based on this, we obtain After training and testing are completed for multiple target rounds, the data is saved according to the round number. , and When a single round number summary is needed, it is then determined from these results. .
[0009] One specific implementation uses an LSTM to process the input bit sequence, followed by two fully connected prediction heads. The input blocks are first split into 0 / 1 sequences according to a fixed high / low bit order. The LSTM only takes the output of the last time step as the feature of that block, and then maps it to... The training phase uses BCEWithLogitsLoss and AdamW; during testing, Sigmoid is executed with a threshold of 0.5 for each bit. Parameters such as network layers, hidden dimension, Dropout, learning rate, and batch size are given in the examples. Beneficial effects
[0010] With the above structure, the method has the following characteristics in terms of engineering implementation and result interpretation.
[0011] The model output position maintains a fixed correspondence with the target wheel state position. A single forward computation yields a predictive state that can be checked bit by bit, rather than a single-category conclusion; for any test input, it is possible to directly pinpoint which state bits are correctly predicted and which positions are incorrect.
[0012] The source of the monitoring data is traceable. Sample inputs are taken from selected input groups, and labels are actually obtained by the execution of cryptographic programs under the same key and the same target round. If an anomaly is found in a sample, the corresponding input can be re-executed to verify the state value, without relying on additional manual annotation.
[0013] The statistical results retain both local and global levels. Bit-by-bit accuracy is used to observe the average prediction performance at a single location, while the complete state matching rate requires the entire state to be correct simultaneously; furthermore... As The random complete hit reference of bit state can distinguish between two different cases: "most positions are easy to predict" and "complete state can be hit".
[0014] Multiple rounds of experiments preserve the bit accuracy, complete state matching rate, and state prediction advantages of each round, without forcibly compressing all results into a single value. When necessary, the predictable round number boundary is then derived from the existing results. The round state interface is located between the cryptographic code and the prediction process. When changing to integers, byte arrays, or other state representations, the main adjustment is to the interface layer; the training and evaluation parts can continue to use the same approach. Attached Figure Description
[0015] Figure 1 This is a flowchart of the overall process for predicting and analyzing the round state of the block cipher in this invention.
[0016] Figure 2 A schematic diagram illustrating the extraction of target round states and the invocation of unified round states in block ciphers.
[0017] Figure 3 A schematic diagram illustrating the construction of round state prediction samples and the training of a multi-output neural model.
[0018] Figure 4 This diagram illustrates the bit-by-bit evaluation and complete state evaluation of the predicted state.
[0019] Figure 5 This is a schematic diagram of the predictability sequence of wheel states for multiple target wheels.
[0020] Figure 6 This is a schematic diagram of the system modules and data flow structure of the present invention. Detailed Implementation
[0021] The following combination Figures 1 to 6This document describes the implementation process of this application. Each part unfolds according to the actual execution order of the program: first, the target round state is obtained from the cryptographic implementation; then, supervised samples are organized and the model is trained; subsequently, single-round evaluation and multi-round result summarization are completed. The parameters and test data listed in the embodiments are used to illustrate the specific implementation of this process.
[0022] 1. Target wheel state definition and unified invocation
[0023] like Figure 1 and Figure 2 As shown, the task begins by providing the block cipher implementation to be analyzed and the key. Target number of rounds And the method for selecting the target state. The interface layer is responsible for handling the input format of the original algorithm, round function calls, and state reading, so that the upper layer only needs to pass in unified parameters to obtain the corresponding round state.
[0024]
[0025] in, express Bit input blocks, Indicates the key used. Indicates the target round number. Indicate execution The state after the wheel. If Equal to the number of complete rounds of the algorithm ,but This is the complete output state; if Less than ,but This corresponds to the intermediate wheel state.
[0026] The unified round state invocation relationship can be recorded as follows:
[0027]
[0028] in, Group the input. For the key, For the target number of rounds, This corresponds to the round state. For a block cipher consisting of multiple round functions iterated sequentially, the following steps are performed: The state mapping after the round can be further formalized as follows:
[0029]
[0030] Once the interface adaptation is complete, the upper-layer program no longer needs to know what data type the original password used internally. A single call only needs to consider the input group. Key Target number of rounds and return status The subsequent dataset generation and neural network components all use the uniformly encoded state, so when replacing the specific cryptographic implementation, it is not necessary to rewrite the training and evaluation code simultaneously.
[0031] 2. Construction of Round State Prediction Samples
[0032] Figure 3 One sample is grouped by the input and corresponding target wheel The real state Composition, denoted as When generating samples, the specified round call is first executed to obtain the state, and then the samples are selected and encoded according to the predetermined positions. Bit target vector. The input and label ends are written to the dataset using a fixed bit order.
[0033] For input groups The system uses a round-robin state call. Get the first Wheel state And select a strategy based on the target state. Obtained from the complete round output state or a specified intermediate state Bit target vector ,Right now:
[0034]
[0035] A target wheel A corresponding sample set consists of multiple The data is structured as follows: When the input space is small, candidate inputs can be enumerated first, and then the training, validation, and test data can be divided; when the space is large, non-repeating inputs are randomly generated. The input groups used for the three data subsets do not overlap to avoid the same plaintext entering the training and testing phases simultaneously.
[0036]
[0037] 3. Prediction of multi-output neuron states
[0038]
[0039] in, Indicates the first The probability estimate of each target state bit being 1, the model The dimensional output vector is represented as:
[0040]
[0041] in, ∈[0,1]. Let the target state be the [0,1]. The actual value is The model training objective then uses bit-by-bit binary cross-entropy:
[0042]
[0043] After training, the system binarizes each output probability according to a uniform threshold to obtain the predicted value for each target bit:
[0044]
[0045] From all The binary prediction results are combined in the order of the target state bits to obtain the predicted state vector:
[0046]
[0047] Specifically regarding the LSTM implementation Bit input blocks are expanded from most significant bit to least significant bit to length. The 0 / 1 sequence has only one scalar at each time step, therefore the shape of a single sample is ( 1). LSTM processes batch data in batch_first mode, and only takes the last time step as the grouping feature. If the hidden dimension is... Prediction first uses Linear ( , Perform a linear mapping, then ReLU, and finally Linear( , ) give The logits; the The output is fixed and corresponds to the target state. 1 bit.
[0048] During training, instead of adding a separate Sigmoid function at the end of the network, we use... Dimension logits and The true bit state is directly fed into BCEWithLogitsLoss. After backpropagation of each batch, gradient norm clipping is performed first, and then the parameters are updated by AdamW. After each epoch, bit_acc and full_acc are calculated on the validation set; when saving the model, bit_acc is compared first, and if they are the same, full_acc is compared. During the testing phase, only the saved parameters are loaded, and test samples are not used in training or model selection.
[0049] In this embodiment, the network size is fixed at two unidirectional LSTM layers with a hidden dimension of 128, Dropout set to 0.1, and the prediction head uses Linear(128,128)-ReLU-Linear(128,16). According to this configuration, the trainable parameters are 217744; the settings for learning rate, weight decay, batch size, and number of training epochs are listed in Table 1.
[0050] 4. Bit-by-bit prediction and complete state evaluation
[0051] During the test, for the first Each sample undergoes two statistical analyses simultaneously: first, a bit-by-bit comparison between the predicted and actual states to accumulate the number of correctly correct bits; second, a direct comparison of the complete vector, only comparing the entire vector. A full hit is only added when all target bits are identical. Let the number of test samples be... The complete state matching accuracy for that round is calculated by dividing the number of complete hits by the number of samples.
[0052]
[0053] Where 1[·] is an indicator function. For Bit target state, when the prediction vector is in all When the predicted values are uniformly randomized across 3 possible states, and this randomized prediction is independent of the actual target state, the theoretical probability of a complete hit is:
[0054]
[0055] Therefore, the system uses the complete state random hit benchmark as a reference and defines the state prediction advantage as:
[0056]
[0057] Here, the state prediction advantage is used to represent... Compared to The absolute probability difference. When the value is positive, it indicates that the hit rate of the complete state is higher than the level of uniform random guessing for states of the same length; if it is further used to determine the number of rounds, it also needs to be combined with a pre-defined threshold. Given the current experimental conditions, the first point cannot be explained in isolation from sample size and network configuration. The result of the round.
[0058] 5. Multi-round state predictability outcome organization
[0059] Multi-round experiments do not involve training by mixing labels from different rounds together, but rather by training each target round in the set of rounds. Each task is treated as a separate task. For a given round, labels are regenerated, the corresponding model is trained, and calculations are performed. , and After all rounds are completed, the results are organized according to the round number. This preserves the original test results for each round, making it easy to check each round.
[0060]
[0061] The target wheel set can be represented as:
[0062]
[0063] After retaining the round-by-round results, the local bit prediction performance and the overall state hit rate can be directly compared across different rounds. Only when a round-by-round summary metric is truly needed should a separate prediction advantage threshold be assigned. Then, find the maximum number of rounds that still reach the threshold from the completed target rounds.
[0064] The predictable rounds boundary can be defined as:
[0065]
[0066] Defined predictable round number boundary Depending on the current data partitioning, model structure, and threshold settings, it is an induction of the results from multiple rounds under the conditions of this experiment, rather than a fixed constant of the cryptographic algorithm itself. If the set If the value is empty, this boundary condition will not be generated in this analysis; when the program interface must return a value, a return value can be agreed upon. .
[0067] 6. Sample space and state dimension adaptation
[0068] For block ciphers with an input space size not exceeding a preset threshold, the system can enumerate input blocks and divide the data into subsets; for block ciphers with a large input space, the system uses random unique sampling. Regardless of the sampling method used, each input block is only associated with the actual round state obtained under the same key and the same target round number, and the input blocks in the training set, validation set, and test set do not overlap.
[0069] Target state length Depending on the object of this analysis, either the complete intermediate wheel state can be selected, or only a few pre-specified positions can be selected. After the target length changes, the number of outputs in the final layer of the model, the length of the supervision label, and the random complete hit benchmark all change accordingly. With synchronized adjustments, other training and evaluation steps do not need to be redefined.
[0070] 7. System Implementation Method
[0071] Figure 6The software processing is divided into two paths: the actual state and the predicted state. On the left, the code to be analyzed executes and saves the actual state for a specified round. On the right, the same input is fed into a neural network to generate the predicted state. The results from both paths are then combined in the complete state evaluation module. Interface adaptation, sample preparation, model training, evaluation, multi-round aggregation, and result saving are each completed by their respective modules.
[0072] The round-state interface module adapts the original cryptographic code to a unified calling method; the target state generation module extracts and encodes the real state in a specified round; the sample organization module organizes the input and labels into the format required for training, validation, and testing. The neural prediction module outputs the logits of each state bit, which are then used to form a prediction vector during testing by applying a sigmoid function and a 0.5 threshold. The evaluation module calculates based on this. , , and The multi-round result organization module saves various indicators according to round number; the model configuration and recording module saves training parameters and data partitioning; and the result output module provides the result sequence and optional parameters. .
[0073] When a task contains multiple target rounds, the program executes round by round, rather than training a single model that predicts all rounds simultaneously. The input grouping rules can remain consistent, but the label for each target round must be regenerated cryptographically, and the model parameters and test results for that round must be saved separately, allowing each round to be recalculated independently.
[0074] 8. Specific Implementation Examples and Experimental Results
[0075] Example 1: Block Cipher and Target State Generation. The experiment used the Toy-SIMON16 / 32 16-bit reduced block cipher, whose internal state consists of two 8-bit words. and Composition: Master key length 32 bits, fixed key is... . No. Wheel press Calculate the round function, then press Update two 8-bit words; This indicates an 8-bit circular left shift. For the first Round-by-round keys, obtained by expanding the master key to obtain each round key. This implementation does not have additional tail whitening, therefore execution proceeds to the next step. The 16-bit internal state obtained after the round can be directly used as the... Round of supervision targets ,Right now .
[0076] plain text Take a 16-bit integer between 0 and 65535. The data generation program sends each plaintext to a specified round function and retrieves the... After each 16-bit state iteration, the data is expanded into a float32 0 / 1 vector from MSB to LSB; the network input uses the same bit order. The complete plaintext space is first shuffled with a random seed of 0, and then divided into non-overlapping candidate regions. This experiment used 2048 training samples, 512 validation samples, and 4096 test samples.
[0077] Example 2: Specific Neural Network Structure. This example uses a two-layer unidirectional LSTM as the sequence feature extractor, with input_size=1, hidden_size=128, num_layers=2, dropout=0.1, batch_first=True, and bidirectional=False. For a batch input of shape (B,16,1), the LSTM output shape is (B,16,128), and the (B,128) feature is obtained by taking the last time step. The prediction head consists of a first fully connected layer (Linear(128,128)), a ReLU activation layer, and a second fully connected layer (Linear(128,16)), outputting 16 logits. The total trainable parameters of the model are 217744, where the two LSTM layers are responsible for sequence feature extraction, and the prediction head is responsible for mapping the features of the last time step to 16 target state bits. The forward propagation does not include a sigmoid function inside the model, so that BCEWithLogitsLoss can be used directly during training; during testing, a sigmoid function is applied to logits and a 16-bit prediction state is generated with a threshold of 0.5.
[0078] The network and training parameters used in this embodiment are shown in Table 1.
[0079] Table 1. Network structure and training parameters of the Toy-SIMON16 / 32 example
[0080] Parameters Detailed settings Experimental Algorithm Toy-SIMON16 / 32 (16-bit block size, 32-bit key) Fixed key 0x19181110 Target number of rounds Establish independent prediction models respectively Target state dimension Input encoding 16 bits, MSB→LSB, single sample shape (16,1) LSTM structure 2-layer, unidirectional, hidden_size=128, dropout=0.1 Predicting Head Linear(128,128) → ReLU → Linear(128,16) Number of trainable parameters 217744 Number of training / validation / test samples The plaintext of 2048 / 512 / 4096 does not overlap. loss function BCEWithLogitsLoss (bit-by-bit) Optimizer AdamW Learning rate / weight decay 0.003 / Batch size / Number of training epochs 256 / 60 epoch Gradient clipping Maximum norm 1.0 Predicted threshold If the Sigmoid probability is ≥0.5, it is judged as 1; otherwise, it is judged as 0. Random Seed 0
[0081] Example 3: Training Process. For each target round... The models were trained separately, with the same set of plaintext partitions shared across the three tasks, but the supervision labels were generated separately from the states of each round. The optimizer used was AdamW, with an initial learning rate of 0.003 and weight_decay. The batch size is 256, and the training lasts for 60 epochs. Each batch sequentially performs forward computation, loss calculation, backpropagation, gradient pruning, and parameter updates, with the maximum norm of the pruning set to 1.0. After each epoch, bit_acc and full_acc are calculated on the validation set. Models are first selected based on bit_acc; if they are the same, then full_acc is compared. The test set is used only for final evaluation.
[0082] Example 4: Test Results. Following the configuration in Table 1, the first, second, and third rounds of model training were completed, and tests were performed using 4096 plaintexts that were not involved in training or model selection. The benchmark for random full hits of 16-bit states was... (Approximately 0.001526%). Table 2 lists the data from the three rounds of testing, and the calculation method for the evaluation metric is given below.
[0083] Bit Accuracy (Bit Prediction Precision) is calculated on a sample-by-sample, bit-by-bit basis. Let the number of test samples be... The target state length is The predicted bits of each sample are compared with the true bits one by one, and the total number of correct bits is obtained by accumulating the results. This metric reflects the average proportion of correctly predicted individual state positions, without requiring all target positions in the same sample to be correctly predicted simultaneously.
[0084]
[0085] in, This represents the total number of correctly predicted bits accumulated across all test samples and all target bit positions.
[0086] (Perfect Match Rate) is calculated based on the complete vector. For a given test sample, only the complete vector is considered. A complete hit is counted only if each predicted bit matches the actual state. The final score is calculated by dividing the number of complete hits by the total number of test samples. This metric is more stringent than bit-by-bit accuracy and directly reflects whether the entire round's state was predicted correctly on the first attempt.
[0087] (State prediction advantage) is used to represent the magnitude by which the accuracy of a complete state match exceeds the random complete hit benchmark. In this embodiment, it is based on... Calculation. Table 2 lists both the total number of hits and... ,in It is obtained by dividing the total number of hits by 4096, so each ratio corresponds to the actual number of hits in the test set.
[0088] Table 2. Actual test results of Toy-SIMON 16 / 32 from round 1 to round 3.
[0089] Target Wheel Random benchmark 1 98.2407% 9.366211% 0.001526% 9.364685% 2 92.8907% 3.073242% 0.001526% 3.071716% 3 79.0905% 0.382414% 0.001526% 0.380888%
[0090] As shown in Table 2, under the given data scale, network structure, and training parameters in this embodiment, the bit prediction accuracy is 98.2407% in the first round, 92.8907% in the second round, and 79.0905% in the third round. This result provides specific predictability quantification values for the same block cipher under different target rounds and verifies the prediction accuracy from real round state generation and LSTM multi-output prediction. , and The complete execution flow of the calculation. The above values only correspond to the parameter configurations listed in this embodiment and are used to illustrate the executability and evaluation process of this method. They are not intended to make inferences beyond the experimental conditions regarding other rounds, other keys, or other block ciphers.
[0091] Example 5: Interface Adaptation for Other Block Ciphers. For 64-bit block ciphers such as TEA-64 / 128 and HIGHT-64 / 128, the changes are mainly concentrated in the interface layer and input / output dimensions. If the algorithm receives input as a byte sequence, the 64-bit plaintext is first converted into 8 bytes according to the agreed byte order, and then the target round number is mapped to the cycles or rounds parameter of the original implementation. When the output is bytes, tuple / list, or integer, the interface is uniformly converted to a 64-bit state and expanded from MSB to LSB. After synchronously changing the LSTM input length and prediction head output dimension to 64, the remaining sample organization, training, threshold determination, and... / The calculation process remains unchanged, but the random hit of the baseline in the complete state is changed to... .
[0092] The above embodiments illustrate the complete execution method from code interface to test results: the cryptographic program generates the actual round states, the neural network provides predicted states based on input grouping, and the evaluation module statistically analyzes bit correctness and complete state hits. For multi-round tasks, the same generation, training, and testing process is repeated for selected rounds, and the results are saved by round number.
Claims
1. A neural network based round state prediction analysis method for a block cipher, characterized by, Includes the following steps: Step S1: Obtain the block cipher and key to be analyzed and target number of rounds The block cipher is converted into a cipher that can be used to convert input blocks. Output the first Wheel state Round state call format and the first Wheel state coding is Bit target state vector ; Step S2: Grouping multiple inputs Call each Obtain the corresponding target state Grouped by each input and its corresponding Bit target state Constitute a supervisory sample This forms a target wheel state prediction sample set; Step S3: Train the multi-output neural prediction model This allows the model to receive a single input group. and output Probability estimation of each bit corresponding to the target state bit Using the The bit target state vector is used as a bit-by-bit monitoring signal to optimize the model parameters; Step S4: For the... The predicted state vector is obtained by performing threshold determination based on probability estimates. The bit prediction accuracy is obtained by comparing the predicted state vector with the true target state vector bit by bit and by comparing the complete vector. Matching accuracy with complete state and according to Random hit benchmark of bit integrity state Advantages of computational state prediction ; Step S5: For the selected multiple target rounds, execute steps S2 to S4 respectively, and assign the corresponding rounds to each round. , and Organize and output a sequence of predictability results for round states based on the number of rounds.
2. The method according to claim 1, characterized in that, In step S1, for block cipher implementations in integer, byte sequence, bit vector, or class method form, they are converted into a unified round state call interface through input encoding, round function calls, and state decoding. ;when When equal to the number of complete rounds of the algorithm, For the complete round output state, when When less than the number of complete rounds of the algorithm, This corresponds to the intermediate wheel state.
3. The method according to claim 1, characterized in that, Target state vector From the complete number Wheel state, complete wheel output state, or from the first wheel The target state vector is composed of specified bit subvectors selected from each round state, and the number of bits in the target state vector is... It also serves as the output dimension of the neural prediction model and a calculation parameter for the baseline of random hits in the complete state.
4. The method according to claim 1, characterized in that, In step S2, the supervised sample is represented as ,in Group the input. For the input group corresponding to Bit target state vector; the training set, validation set, and test set are each composed of unique input groups.
5. The method according to claim 1, characterized in that, In step S3, the number of output nodes of the multi-output neural prediction model is: Each output node corresponds to a specific bit in the target state; the model input consists of input groups. The bits are encoded in a fixed bit order. The training target uses bit-by-bit binary cross-entropy to enable the model to learn the mapping relationship from the input group to the target round state bit vector.
6. The method according to claim 1, characterized in that, In one implementation, the multi-output neural prediction model includes an LSTM sequence feature extraction layer and a fully connected prediction head; the input packets are organized in bit order into lengths. For a sequence with feature dimension of 1, the output of the last time step of the LSTM passes sequentially through the first fully connected layer, the ReLU activation layer, and the second fully connected layer. The output of the second fully connected layer is... 1 logits, and converted by the Sigmoid function to the _logits_. A probability estimate.
7. The method according to claim 1, characterized in that, The model training employs the AdamW optimizer and bit-by-bit binary cross-entropy loss, with gradient norm pruning. The model state is selected based on the bit prediction accuracy of the validation set. When the bit prediction accuracy of the validation set is the same, the full state matching accuracy is used as a secondary selection metric. During the testing phase, a Sigmoid transformation is performed on each output logit, and the predicted bits are obtained with a decision threshold of 0.
5.
8. The method according to claim 1, characterized in that, In step S4, complete state matching only occurs within the same sample. A complete hit is defined as when all predicted bits match the corresponding actual bits. Complete state matching accuracy The proportion of samples that completely hit the target in the test set; the predicted vector in all... Under the condition that the bit values are uniformly random in space and independent of the real target state, the baseline for random hits in the complete state is: State prediction advantage is defined as .
9. The method according to claim 1, characterized in that, The round state predictability result sequence includes at least the bit prediction accuracy, complete state matching accuracy, and state prediction advantage corresponding to different target round numbers, which are used to simultaneously characterize local bit prediction capability and complete round state prediction capability.
10. The method according to claim 1, characterized in that, When it is necessary to further summarize the sequence of predictability results of the wheel states into a wheel count index, based on the state prediction advantage and a preset threshold... Determine the predictable round number boundary ,in If no target wheel meets the conditions, the predictable wheel number boundary is determined to be non-existent, or, when numerical encoding is required, it is recorded as... ; For block ciphers with an input space size not exceeding a preset threshold, samples can be constructed from the complete input space. For block ciphers with an input space size exceeding the preset threshold, samples are constructed using random unique sampling.
11. A block cipher round state prediction and analysis system based on neural networks, characterized in that, Includes the following modules: Module M1: Round State Interface Module, used to receive the block cipher to be analyzed, the key and the target round number, and generate a unified call interface that can output the specified round state; Module M2: Target state generation module, used to perform block cipher operations on the input block for a specified number of rounds, extract the complete round state, the complete round output state, or a specified bit subvector and encode it into the target state vector; Module M3: Prediction Sample Organization Module, used to organize a single input group and its corresponding target state vector into supervised samples, and to divide them into training set, validation set and test set; Module M4: Multi-output neural prediction module, used to train the neural prediction model and output probability estimates that correspond one-to-one with each bit of the target state, and generate a predicted state vector after threshold determination; in one embodiment, the neural prediction model is composed of an LSTM sequence feature extraction layer, a first fully connected layer, a ReLU activation layer and a second fully connected layer. Module M5: Complete State Evaluation Module, used to compare the predicted state vector with the real target state vector bit by bit and the complete vector, and calculate the bit prediction accuracy, complete state matching accuracy, complete state random hit benchmark, and state prediction advantages. Module M6: Multi-round result organization module, used to summarize the prediction indicators under multiple target rounds and form a sequence of round state predictability results, and further provide the predictable round number boundary when a threshold is set; Module M7: Model configuration and recording module, used to set LSTM hidden dimension, number of network layers, Dropout ratio, network orientation, learning rate, weight decay, batch size, number of training epochs and gradient clipping threshold, and record the data partitioning, model parameters and prediction metrics corresponding to each target epoch; Module M8: Result output module, used to output the bit prediction results, complete state prediction results, state prediction advantages, sequence of round state predictability results, and optional predictable round number boundaries for each target round.
