Mamba and blockchain-based v2x trust management system

By combining the Mamba anomaly detection module and the Hyperledger Fabric blockchain module, efficient detection and dynamic management of vehicle trust in V2X systems are achieved, overcoming the shortcomings of traditional methods in terms of computational efficiency and dynamism, and improving the robustness and data trustworthiness of the system.

CN122395593APending Publication Date: 2026-07-14GUANGDONG POLYTECHNIC NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUANGDONG POLYTECHNIC NORMAL UNIV
Filing Date
2026-04-15
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

Existing V2X trust management systems struggle to efficiently detect and manage vehicle trust when facing internal attacks. Traditional methods are computationally inefficient and cannot meet the service quality requirements of large-scale vehicle networks. Centralized solutions suffer from single points of failure, and traditional trust assessment schemes are ill-suited for handling dynamically changing scenarios.

Method used

By employing an anomaly detection module based on Mamba and a blockchain module based on Hyperledger Fabric, distributed trust management is achieved by classifying the basic security message sequences sent by vehicles and calculating dynamic trust values ​​using the Beta distribution.

Benefits of technology

It significantly improves the accuracy and robustness of anomaly detection, achieves objective reliability of dynamic trust assessment, can respond to changes in node behavior in real time, and uses the immutability of blockchain to ensure data authenticity and trustworthiness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122395593A_ABST
    Figure CN122395593A_ABST
Patent Text Reader

Abstract

The application discloses a V2X trust management system based on Mamba and a block chain, which utilizes a deep neural network Mamba deployed at a base station to detect whether a basic safety message broadcast by a vehicle is abnormal in an unsupervised sequence reconstruction manner. A detection result is converted into a 'positive interaction' or 'negative interaction' record representing a vehicle behavior and stored in a block chain module jointly maintained by the base station. When it is necessary to evaluate vehicle trust, the base station inquires all interaction histories of the vehicle from the block chain module and calculates a dynamic trust value of the vehicle based on a Beta distribution expectation. The application innovatively combines a powerful abnormal detection capability of deep learning and decentralized and tamper-proof characteristics of a block chain, realizes effective identification of attacks in a vehicle network and distributed trust management, and solves a single-point failure problem of a centralized scheme.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the technical field of vehicle network security, and in particular to a V2X trust management system based on Mamba and blockchain. Background Technology

[0002] With the widespread deployment of cellular technology, V2X technology has experienced rapid development globally, leading to a surge in the number of intelligent vehicles on the road. While this trend brings convenience, it has also raised a series of critical issues that urgently need to be addressed, among which security and trust are particularly prominent. As the first line of defense, authentication protocols have been proposed to prevent external attackers from disrupting the network. However, these protocols cannot detect internal attackers with legitimate identities participating in communications, who could potentially cause traffic chaos or even fatal accidents. Therefore, as the second line of defense, implementing an effective trust management mechanism in V2X is crucial. Due to the characteristics of V2X, such as heterogeneity, high mobility, and high vehicle density, new requirements are placed on trust management schemes, such as lightweight design and high reliability.

[0003] Traditional centralized solutions require a trusted third party, which could be a centralized reputation server or a central cloud. However, these centralized solutions suffer from single points of failure and cannot meet the service quality requirements of large-scale vehicle-to-everything (V2X) networks. To adapt to the characteristics of distributed V2X, a decentralized architecture based on blockchain has been introduced, using a distributed ledger to manage vehicle trust values.

[0004] In V2X, vehicles periodically broadcast basic safety messages to their neighbors to avoid collisions and improve traffic efficiency. Determining the credibility of these basic safety messages, identifying malicious actors, and further managing trust within V2X are paramount tasks. Traditional trust management methods, such as those based on fuzzy logic and subjective logic, are widely documented in the literature. However, these methods are computationally inefficient when applied to complex models and large datasets. In recent years, there has been a surge in applications of fully connected deep neural network models to trust management to improve prediction efficiency and security. Compared to rule-based or static weight-based trust assessment schemes, introducing deep learning models can detect anomalies not previously observed in vehicle networks, resulting in better generalization and higher reliability. Specifically, rule-based schemes rely on manually designed features, making it difficult to capture complex, implicit relationships; while deep learning-based models can automatically extract high-order nonlinear features from data, thereby identifying previously unseen abnormal behavior patterns. Furthermore, static weight-based trust assessment schemes struggle to handle dynamically changing scenarios, while time-series models, such as recurrent neural networks, can handle dynamic data streams and update node trust values ​​in real time. Finally, the complexity of traditional trust management models increases dramatically with the amount of data, while deep learning models can handle massive amounts of data. Therefore, research on trust management in connected vehicles based on deep learning models shows great promise. Summary of the Invention

[0005] The purpose of this invention is to overcome the shortcomings and deficiencies of existing technologies and propose a V2X trust management system based on Mamba and blockchain. Essentially, it is a distributed trust management scheme that integrates deep learning and blockchain technologies. By deploying an anomaly detection module based on Mamba and a blockchain module based on Hyperledger Fabric to the base station, the anomaly detection module classifies the basic security message sequences sent by vehicles to locate malicious behavior of abnormal nodes; the blockchain module stores the classification results, and uses Beta distribution to map the retrieved interaction history records to specific trust values, thereby achieving distributed management of trust values.

[0006] To achieve the above objectives, the technical solution provided by this invention is: a V2X trust management system based on Mamba and blockchain, comprising an anomaly detection module based on Mamba and a blockchain module based on Hyperledger Fabric deployed on a base station, as well as an on-board unit;

[0007] The vehicle-mounted unit is used to periodically generate and broadcast basic security messages. When a basic security message is generated, the sending vehicle will propagate it to all neighboring nodes, including the base station responsible for the current jurisdiction.

[0008] The base station performs the following operations: receiving basic security messages broadcast by vehicles within its coverage area and forming a basic security message sequence; inputting the basic security message sequence into a Mamba-based anomaly detection module to generate a reconstructed output sequence; using the mean absolute error between the input basic security message sequence and the reconstructed output sequence as the reconstruction error and as a loss function to minimize the reconstruction error on a preset training set; finding the optimal reconstruction error threshold on a preset validation set that can best distinguish between normal and abnormal message sequences; comparing the reconstruction error with the optimal reconstruction error threshold found on the preset validation set on a preset test set to determine whether the basic security message sequence is a normal or abnormal message sequence; generating interaction records for the corresponding vehicles based on the determination result, where normal message sequences correspond to positive interaction records and abnormal message sequences correspond to negative interaction records; storing the interaction records as transactions in a Hyperledger Fabric-based blockchain module; querying the trust value of a target vehicle by retrieving all historical interaction records of the vehicle from the blockchain module; and calculating the dynamic trust value of the vehicle using the expected value of a Beta distribution based on the number of retrieved positive and negative interaction records.

[0009] Furthermore, the basic security message includes a timestamp, sender vehicle ID, sender vehicle pseudonym, message ID, vehicle position on the x-axis and y-axis, speed, acceleration, and direction of travel.

[0010] Furthermore, the Mamba-based anomaly detection module includes a data preprocessing layer, a sequence reconstruction model, and a mean absolute error calculation and output layer. The sequence reconstruction model includes an embedding layer, a Mamba block layer, and a linear layer, which are described below:

[0011] Data preprocessing layer: For each basic security message, the timestamp, sender vehicle pseudonym, vehicle position on the x-axis, and speed field are extracted; all basic security messages are divided into different sequences according to the sender vehicle ID. ,in, It is a vehicle The first one sent Message , The sequence represents a set of integers; each sequence will be further segmented into segments of a preset length for efficient input into the sequence reconstruction model for processing; when segmenting the original sequence of each vehicle, a preset window size and sliding step size are used to obtain a preset repetition rate while ensuring the amount of training data; finally, the data preprocessing layer divides all the data into training set, validation set and test set, and normalizes the three datasets to mitigate the negative impact of the different orders of magnitude of each field on the training, validation and testing of the sequence reconstruction model;

[0012] Embedding layer: Used to map the low-dimensional original sequence to a high-dimensional vector space, satisfying the processing requirements of subsequent Mamba block layers; the input dimension of the embedding layer is... ,in It is the batch size. It refers to the window size. The dimension of the preprocessed data; the output dimension of the embedding layer is... ,in It is the output dimension after the embedding layer;

[0013] Mamba blocks are used to learn patterns in long sequences, capture complex features and structures, and output vectors for further processing by subsequent linear layers. The input to a Mamba block is the output of an embedding layer, and the data dimension is [missing information]. The output of the Mamba block layer is also ;

[0014] Linear layers: Responsible for reconstructing high-dimensional vectors into another feature space, making them usable as the expected input for the mean absolute error calculation and output layer; the input of linear layers is the output of the Mamba block layer. The output of the linear layer is , It is the output dimension after passing through the linear layer; the output of the linear layer is the output of the entire sequence reconstruction model after reconstructing the original basic security message data, including the vehicle position information on the x and y axes. This output represents the sequence reconstruction model's ability to restore the true sequence of any given original basic security message sequence from a sender without malicious intent.

[0015] Mean Absolute Error Calculation and Output Layer: L1 loss is selected as the loss function for training, validating, and testing the sequence reconstruction model. On the training set, the gradient is backpropagated and the sequence reconstruction model is trained by minimizing the mean absolute error score between the output of the sequence reconstruction model and the output of the original basic security message data after preprocessing by the data preprocessing layer. On the validation set, a threshold calculation algorithm is proposed to obtain the optimal reconstruction error threshold to maximize the accuracy of the model in correctly classifying abnormal message sequences. On the test set, the mean absolute error score obtained for each basic security message sequence in the test set is compared with the above-mentioned optimal reconstruction error threshold to determine whether the current sequence comes from an abnormal sender vehicle.

[0016] Furthermore, the loss function is calculated as follows:

[0017] The output of the linear layer and the preprocessed output of the original basic security message data are input into the loss function, and the mean absolute error score is calculated using the following formula. :

[0018] ;

[0019] In the formula, The first one obtained from the linear layer The calculated value of a basic security message. The first one obtained from the data preprocessing layer The original tag value of the basic security message. This represents the total number of basic security messages; during model training, the output dimension of the sequence reconstruction model is... The output dimension of the original basic security message data after preprocessing is: ; Extract the vehicle's position information along the x and y axes from the original basic safety messages, forming the output dimension. The original sequence and the reconstructed output sequence are input into the above formula to obtain the mean absolute error score, and the gradient is backpropagated to train the model. When validating the model, the above loss function is also used to obtain an optimal mean absolute error threshold, which is called the optimal reconstruction error threshold. When testing the model, the mean absolute error score is calculated for each sequence and then compared with the optimal reconstruction error threshold to classify normal and abnormal sending vehicles.

[0020] Furthermore, the function for finding the optimal reconstruction error threshold is defined as follows:

[0021] The core objective of the function is to find an optimal reconstruction error threshold that maximizes classification accuracy through iterative search. The function receives a list of predicted scores and a list of corresponding true labels, and finally outputs an optimal reconstruction error threshold. This optimal reconstruction error threshold will be used for the following decision rule: basic safe message sequences with scores less than or equal to the optimal reconstruction error threshold are predicted as normal categories, and basic safe message sequences with scores greater than the optimal reconstruction error threshold are predicted as abnormal categories.

[0022] The function employs an iterative search strategy of "gradually narrowing the range and improving accuracy," the specific process of which is as follows:

[0023] First, at the initial default threshold, a series of candidate thresholds are generated with a preset step size, and the classification accuracy corresponding to each candidate threshold is calculated. The calculation of classification accuracy is based on a given decision rule: for normal samples, the predicted score should not be higher than the candidate threshold; for abnormal samples, the predicted score should be higher than the candidate threshold. Then, the function selects the candidate threshold with the highest accuracy in this round as the current best result.

[0024] The next crucial step is that the function improves the search precision by an order of magnitude. This means that in the next iteration, the search will repeat the above process within a finer range, around the optimal reconstruction error threshold found in the previous round. This process is repeated in this way, and after several rounds, it can gradually approach the theoretically optimal threshold.

[0025] Furthermore, the specific details of using the blockchain module for trust management are as follows:

[0026] The blockchain module utilizes Hyperledger Fabric deployed at the base station to provide distributed trust management for V2X: First, the chaincode is initialized via the contract API, including connecting to the Hyperledger Fabric client, specifying the channel, preparing the identity identifier, and signing; next, the base station collects and processes basic security messages sent by vehicles to obtain classification results. After identifying normal and abnormal message sequences, the base station creates positive and negative interaction records and stores the corresponding transactions in the distributed ledger deployed at the base station; finally, for a given vehicle identity identifier, the trust value of the vehicle can be calculated by retrieving all records of that vehicle ID in the distributed ledger.

[0027] Once a basic security message sequence is classified as normal, the base station will create a positive interaction record, in which the vehicle identification identifier will be set to the ID of the target vehicle, the positive interaction field will be marked as true, and the negative interaction field will be marked as false. Conversely, if the basic security message sequence is classified as abnormal, the base station will create a negative interaction record. In this case, the vehicle identification identifier will still be the ID of the target vehicle, but the positive interaction field will be marked as false and the negative interaction field will be marked as true.

[0028] Ultimately, all interaction records will be stored as transactions in a distributed ledger deployed at the base station, providing support for subsequent retrieval of all interaction records of relevant vehicles and calculation of trust values.

[0029] Furthermore, the specific details of using Beta expectations to calculate the vehicle's trust value are as follows:

[0030] set up This indicates that the base station determines the probability that the message sender is legitimate based on the historical interaction records of relevant vehicles retrieved from Hyperledger Fabric; the trust value calculation mechanism is modeled using a Beta distribution: for each retrieved vehicle, let the number of its positive interaction records be... The number of negative interaction records is , assuming prior distribution Following a Beta distribution, which reflects the uncertainty of the base station's probability of determining that the retrieved vehicle is normal before obtaining any historical interaction records, each interaction record is modeled as a Bernoulli trial based on the given Beta prior distribution, thus enabling the determination of the probability of a normal vehicle. The likelihood function, according to Bayes' rule, regarding The posterior function can also be obtained; it has been verified that the statement about The posterior function still follows a Beta distribution, therefore, regarding Expectation of the Beta distribution Given by the following formula:

[0031] ;

[0032] In the formula, , , The expectation is only related to the number of positive and negative interaction records of the retrieved vehicle. Therefore, the expectation of the Beta distribution can be used to calculate the dynamic trust value of the retrieved vehicle.

[0033] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0034] 1. Significantly improved detection accuracy and efficiency. The anomaly detection module based on Mamba (including an unsupervised sequence reconstruction model) is used for anomaly detection, which can efficiently capture long-term dependencies and complex spatiotemporal patterns in vehicle behavior sequences. It has a stronger ability to identify various simple and advanced attacks (such as location spoofing, message replay, Sybil attacks, etc.), significantly improving the accuracy and robustness of anomaly detection.

[0035] 2. Dynamic trust assessment is more objective and reliable. The system writes the detection results (positive / negative interaction records) as transactions into a blockchain based on Hyperledger Fabric, using an immutable distributed ledger to ensure data authenticity and trustworthiness. The dynamic trust calculation method based on the expected value of the Beta distribution can quantify trustworthiness in real time and objectively based on the number of normal and abnormal message sequences in the vehicle's historical interactions, effectively responding to dynamic changes in node behavior. Attached Figure Description

[0036] Figure 1 This is a schematic diagram illustrating the application of the system of the present invention.

[0037] Figure 2 This is a framework diagram of an anomaly detection module based on Mamba.

[0038] Figure 3 This is a data flow diagram based on Hyperledger Fabric.

[0039] Figure 4 This is a performance graph of the model for anomaly detection in a simple attack scenario.

[0040] Figure 5 This is a performance graph of the model for anomaly detection in advanced attack scenarios.

[0041] Figure 6 This is a graph showing the changes in a vehicle's trust value under a specific attack scenario.

[0042] Figure 7 This is a graph showing the changes in trust values ​​for normal vehicles.

[0043] Figure 8 This is a performance graph for the Hyperledger Fabric blockchain module. Detailed Implementation

[0044] The present invention will be further described in detail below with reference to the embodiments and accompanying drawings, but the embodiments of the present invention are not limited thereto.

[0045] This embodiment discloses a V2X trust management system based on Mamba and blockchain, such as... Figure 1 As shown, it includes an onboard unit and a base station. The framework of the Mamba-based anomaly detection module deployed on the base station is as follows: Figure 2 As shown, the model includes a data preprocessing layer, an embedding layer, a Mamba block layer, a linear layer, and a mean absolute error (MAE) calculation and output layer; the embedding layer, Mamba block layer, and linear layer constitute the sequence reconstruction model. Furthermore, detailed descriptions of the MAE loss function, the algorithm for calculating the optimal reconstruction error threshold, the trust management of the Hyperledger Fabric-based blockchain module, and the method for calculating the vehicle trust value based on Beta expectations are provided below.

[0046] The on-board unit is used to periodically generate and broadcast basic security messages. These messages include a timestamp, the sender vehicle's ID, the sender vehicle's pseudonym, a message ID, the vehicle's position on the x and y axes, speed, acceleration, and direction of travel. Once generated, the sender vehicle propagates the basic security message to all neighboring nodes, including the base station responsible for its current jurisdiction.

[0047] The base station performs the following operations: receiving basic security messages broadcast by vehicles within its coverage area and forming a basic security message sequence; inputting the basic security message sequence into a Mamba-based anomaly detection module to generate a reconstructed output sequence; using the mean absolute error between the input basic security message sequence and the reconstructed output sequence as the reconstruction error and as a loss function to minimize the reconstruction error on a preset training set; finding the optimal reconstruction error threshold on a preset validation set that can best distinguish between normal and abnormal message sequences; comparing the reconstruction error with the optimal reconstruction error threshold found on the preset validation set on a preset test set to determine whether the basic security message sequence is a normal or abnormal message sequence; generating interaction records for the corresponding vehicles based on the determination result, where normal message sequences correspond to positive interaction records and abnormal message sequences correspond to negative interaction records; storing the interaction records as transactions in a Hyperledger Fabric-based blockchain module; querying the trust value of a target vehicle by retrieving all historical interaction records of the vehicle from the blockchain module; and calculating the dynamic trust value of the vehicle using the expected value of a Beta distribution based on the number of retrieved positive and negative interaction records.

[0048] The sequence reconstruction model considers 18 attack types as shown in Table 1.

[0049] Table 1

[0050]

[0051] The layers of the Mamba-based anomaly detection module are described below:

[0052] Data preprocessing layer: For each basic security message, the timestamp, sender vehicle pseudonym, vehicle position on the x and y axes, and speed field are extracted. All basic security messages are then divided into different sequences according to the sender vehicle ID. ,in, It is a vehicle The first one sent Message , This represents a set of integers. Each sequence will be further segmented into segments of a preset length to efficiently input the sequence reconstruction model for processing. Determining the window size and sliding step is crucial when segmenting the original sequence for each vehicle. A larger window can contain more data points, resulting in more accurate classification results, but excessively long sequences can lead to decreased processing performance. Similarly, while a large sliding step can reduce data repetition, it reduces the number of training samples. This study chooses a window size of 50 and a sliding step of 10 to achieve an acceptable repetition rate while ensuring sufficient training data. Finally, the data preprocessing layer divides all data into training, validation, and test sets, and normalizes the three datasets to mitigate the negative impact of different orders of magnitude in each field on model training. The specific normalization formula is given below:

[0053] ;

[0054] in, It is the original message sequence. It is the normalized message sequence. It is the mean of the training sequences. This is the standard deviation of the training sequence. Here, the mean and standard deviation of the training set are used to normalize the data in the training, validation, and test sets, respectively, to simulate the situation in real-world scenarios where only the statistics of the training set are available, and the validation and test sets need to be aligned according to the mean and standard deviation of the training set.

[0055] Embedding layer: Maps the low-dimensional original sequence to a high-dimensional vector space, satisfying the processing requirements of subsequent Mamba block layers. ,in It is the batch size. It refers to the window size. This refers to the dimensions of the preprocessed data. Here, we select... It is 512. The 50 selected above. The selected BSM dimension is 6. The output dimension of the embedding layer is... ,in This is the output dimension after the embedding layer. Here, we select... It is 512. The 50 selected above. It is 256.

[0056] Mamba block layers: These layers learn patterns in long sequences, capture complex features and structures, and output vectors for further processing by subsequent linear layers. The input to a Mamba block layer is the output of an embedding layer, and the data dimension is [missing information]. ,in It is 512. The 50 selected above. It's 256. The output of the Mamba block layer is also... ,in It is 512. The 50 selected above. It is 256. Parameters related to the Mamba block layer include: d_model, d_state, d_conv, and expand. Specifically, d_model is set to 256, d_state to 128, d_conv to 4, and expand to 2.

[0057] Linear layers: Responsible for reconstructing high-dimensional vectors into another feature space, making them usable as the expected input for the mean absolute error calculation and output layer. The input to the linear layer is the output of the Mamba block layer. ,in It is 512. The 50 selected above. It is 256. The output of the linear layer is... ,in It is 512. The 50 selected above. This is output dimension 2. The output of the linear layer is the result of the entire sequence reconstruction model reconstructing the original basic security message data, including the vehicle's position information on the x and y axes. This output represents how the sequence reconstruction model can reconstruct the true sequence from a sender without malicious intent for any given original basic security message sequence.

[0058] Mean Absolute Error Calculation and Output Layer: L1 loss is selected as the loss function for training, validating, and testing the sequence reconstruction model. On the training set, the gradient is backpropagated and the sequence reconstruction model is trained by minimizing the mean absolute error score between the output of the sequence reconstruction model and the output of the original basic security message data after preprocessing by the data preprocessing layer. On the validation set, a threshold calculation algorithm is proposed to obtain the optimal reconstruction error threshold to maximize the model's accuracy in correctly classifying abnormal behavior. On the test set, the mean absolute error score obtained for each basic security message sequence in the test set is compared with the aforementioned optimal reconstruction error threshold to determine whether the current sequence originates from an abnormal sending vehicle.

[0059] Specifically, the loss function is calculated as follows:

[0060] The output of the linear layer and the preprocessed output of the original basic security message data are input into the loss function, and the mean absolute error score is calculated using the following formula. :

[0061] ;

[0062] In the formula, The first one obtained from the linear layer The calculated value of a basic security message. The first one obtained from the data preprocessing layer The original tag value of the basic security message. This represents the total number of basic security messages; during model training, the output dimension of the sequence reconstruction model is... The output dimension of the original basic security message data after preprocessing is: ; Extract the vehicle's position information along the x and y axes from the original basic safety messages, forming the output dimension. The original sequence and the reconstructed output sequence are input into the above formula to obtain the mean absolute error score, and the gradient is backpropagated to train the model. When validating the model, the mean absolute error loss function is also used to obtain an optimal mean absolute error threshold, called the optimal reconstruction error threshold. When testing the model, the mean absolute error score is calculated for each sequence and then compared with the optimal reconstruction error threshold to classify normal and abnormal sending vehicles.

[0063] The algorithm for the function of the optimal reconstruction error threshold is given below:

[0064] The core objective of the function is to find an optimal reconstruction error threshold that maximizes classification accuracy through iterative search. The function receives a list of predicted scores and a corresponding list of true labels, and ultimately outputs an optimal reconstruction error threshold. This optimal reconstruction error threshold is used in a simple decision rule: basic safe message sequences with scores less than or equal to the optimal reconstruction error threshold are predicted as normal, while basic safe message sequences with scores greater than the threshold are predicted as anomalous.

[0065] The function employs an iterative search strategy of "gradually narrowing the range and improving accuracy." It first generates a series of candidate thresholds near an initial threshold (default 1) with a step size of 0.1, and calculates the classification accuracy for each candidate threshold. The accuracy calculation is based on a given decision rule: for normal samples, the predicted score should not exceed the candidate threshold; for outlier samples, the predicted score should exceed the candidate threshold. Subsequently, the function selects the candidate threshold with the highest accuracy in this round as the current best result.

[0066] The next crucial step is that the function increases the search precision by an order of magnitude, for example, from 0.1 to 0.01. This means that in the next iteration, the search will repeat the process within a finer range, focusing on the optimal reconstruction error threshold found in the previous iteration. This process is repeated several times, gradually approaching the theoretically optimal threshold. This method is similar to using a magnifying glass to observe objects step by step: first, roughly locate the general bright area, then gradually narrow the range and use a higher magnification lens for precise localization.

[0067] Specifically, the trust management based on the Hyperledger Fabric blockchain module is described in detail below:

[0068] The blockchain module utilizes Hyperledger Fabric deployed at the base station to provide distributed trust management for V2X. First, the chaincode is initialized via the contract API, including connecting to the Hyperledger Fabric client, specifying the channel, preparing the identity identifier, and signing. Next, the base station collects and processes basic security messages sent by vehicles to obtain classification results. After identifying normal and abnormal message sequences, the base station creates positive and negative interaction records and stores the corresponding transactions in the distributed ledger deployed at the base station. Finally, for a given vehicle identity identifier, the trust value of the vehicle can be calculated by retrieving all records for that vehicle ID in the distributed ledger.

[0069] Figure 3 This is a data flow diagram based on Hyperledger Fabric. The definition of the chaincode structure in Hyperledger Fabric is shown in Table 2.

[0070] Table 2

[0071]

[0072] Once a basic security message is classified as normal, the base station creates a positive interaction record. In this record, the vehicle identity identifier is set to the target vehicle's identity information, the positive interaction field is marked as true, and the negative interaction field is marked as false. Conversely, if a basic security message is classified as abnormal, the base station creates a negative interaction record. In this case, the vehicle identity identifier remains the target vehicle's identity, but the positive interaction field is marked as false, and the negative interaction field is marked as true. Ultimately, these transactions are stored in a distributed ledger deployed at the base station, providing support for subsequent retrieval of all interaction records related to the vehicle and calculation of trust values.

[0073] Specifically, the details of using Beta expectations to calculate a vehicle's trust value are as follows:

[0074] set up This indicates the probability that the base station determines the message sender's legitimacy based on historical interaction records of relevant vehicles retrieved from Hyperledger Fabric. The trust value calculation mechanism uses a Beta distribution for modeling. For each retrieved vehicle, let the number of positive interaction records be... The number of negative interaction records is Assuming prior distribution It follows a Beta distribution, which reflects the uncertainty of the probability that the base station judges the retrieved vehicle to be normal before obtaining any historical interaction records, and is given by the following formula:

[0075] ;

[0076] in, It is the gamma function. , , and if ,but ,if ,but . and This determines the shape of the probability density function of the prior. Based on the given Beta prior distribution, each interaction record is modeled as a Bernoulli trial. Thus, we can obtain information about... likelihood function It is given by the following formula:

[0077] ;

[0078] in, It is the probability of Bernoulli's experiment succeeding. This is a specific classification result of Bernoulli's experiment. According to Bayes' theorem, regarding... The posterior function can also be obtained, given by the following formula:

[0079] ;

[0080] Therefore, the statement about The posterior function still follows a Beta distribution. Therefore, the Beta distribution is the conjugate prior distribution of the Bernoulli distribution. Furthermore, because of the... Expectation of the Beta distribution Given by the following formula:

[0081] ;

[0082] in, , , This expectation depends only on the number of positive and negative interactions with the retrieved vehicle. Therefore, the expectation of a Beta distribution is used to calculate the dynamic trust value of the retrieved vehicle.

[0083] The system of this invention was used to perform performance testing on anomaly detection using the VeReMi extended dataset, and the performance of the blockchain module based on Hyperledger Fabric was evaluated. Table 3 shows the experimental parameter values ​​for testing on the training set.

[0084] Table 3

[0085]

[0086] Figure 4 and Figure 5 The graphs show the performance of the model's anomaly detection under simple and advanced attack scenarios, respectively. Performance metrics include precision, accuracy, recall, and F1 score. As the proportion of anomalous vehicle senders in the total test set increases from 5% to 50% in increments of 5%, precision, accuracy, recall, and F1 score show relatively consistent trends under both simple and advanced attack scenarios. Figure 6 This describes how the trust value of a specific abnormal vehicle changes as basic security messages accumulate. Figure 7 This describes how the trust value of a normal vehicle changes as basic security messages accumulate. Figure 8 To retrieve the latency changes of all records from Hyperledger Fabric as the length of the historical records of positive and negative interactions changes.

[0087] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.

Claims

1. A V2X trust management system based on Mamba and blockchain, characterized in that, It includes a Mamba-based anomaly detection module and a Hyperledger Fabric-based blockchain module deployed on base stations, as well as an onboard unit; The vehicle-mounted unit is used to periodically generate and broadcast basic security messages. When a basic security message is generated, the sending vehicle will propagate it to all neighboring nodes, including the base station responsible for the current jurisdiction. The base station performs the following operations: receives basic security messages broadcast by vehicles within its coverage area and forms a basic security message sequence; inputs the basic security message sequence into a Mamba-based anomaly detection module to generate a reconstructed output sequence; the average absolute error between the input basic security message sequence and the reconstructed output sequence is called the reconstruction error and used as a loss function to minimize the reconstruction error on a preset training set; and finds the optimal reconstruction error threshold on a preset validation set that can best distinguish between normal message sequences and abnormal message sequences. The reconstruction error is compared with the optimal reconstruction error threshold found on the preset verification set on the preset test set to determine whether the basic security message sequence is a normal message sequence or an abnormal message sequence. Based on the judgment result, the corresponding vehicle's interaction record is generated, where normal message sequences correspond to positive interaction records and abnormal message sequences correspond to negative interaction records; the interaction records are written as transactions into the blockchain module based on Hyperledger Fabric for storage; For a trust value query of a target vehicle, all historical interaction records of the vehicle are retrieved from the blockchain module; based on the number of positive and negative interaction records retrieved, the dynamic trust value of the vehicle is calculated using the expected value of the Beta distribution.

2. The V2X trust management system based on Mamba and blockchain according to claim 1, characterized in that, The basic security message includes a timestamp, sender vehicle ID, sender vehicle pseudonym, message ID, vehicle position on the x and y axes, speed, acceleration, and direction of travel.

3. The V2X trust management system based on Mamba and blockchain according to claim 2, characterized in that, The Mamba-based anomaly detection module comprises a data preprocessing layer, a sequence reconstruction model, and a mean absolute error calculation and output layer. The sequence reconstruction model includes an embedding layer, a Mamba block layer, and a linear layer, which are described below: Data preprocessing layer: For each basic security message, the timestamp, sender vehicle pseudonym, vehicle position on the x-axis, and speed field are extracted; all basic security messages are divided into different sequences according to the sender vehicle ID. ,in, It is a vehicle The first one sent Message , The sequence represents a set of integers; each sequence will be further segmented into segments of a preset length for efficient input into the sequence reconstruction model for processing; when segmenting the original sequence of each vehicle, a preset window size and sliding step size are used to obtain a preset repetition rate while ensuring the amount of training data; finally, the data preprocessing layer divides all the data into training set, validation set and test set, and normalizes the three datasets to mitigate the negative impact of the different orders of magnitude of each field on the training, validation and testing of the sequence reconstruction model; Embedding layer: Used to map the low-dimensional original sequence to a high-dimensional vector space, satisfying the processing requirements of subsequent Mamba block layers; the input dimension of the embedding layer is... ,in It is the batch size. It refers to the window size. The dimension of the preprocessed data; the output dimension of the embedding layer is... ,in It is the output dimension after the embedding layer; Mamba blocks are used to learn patterns in long sequences, capture complex features and structures, and output vectors for further processing by subsequent linear layers. The input to a Mamba block is the output of an embedding layer, and the data dimension is [missing information]. The output of the Mamba block layer is also ; Linear layers: Responsible for reconstructing high-dimensional vectors into another feature space, making them usable as the expected input for the mean absolute error calculation and output layer; the input of linear layers is the output of the Mamba block layer. The output of the linear layer is , It is the output dimension after passing through the linear layer; the output of the linear layer is the output of the entire sequence reconstruction model after reconstructing the original basic security message data, including the vehicle position information on the x and y axes. This output represents the sequence reconstruction model's ability to restore the true sequence of any given original basic security message sequence from a sender without malicious intent. Mean Absolute Error Calculation and Output Layer: L1 loss is selected as the loss function for training, validating, and testing the sequence reconstruction model. On the training set, the gradient is backpropagated and the sequence reconstruction model is trained by minimizing the mean absolute error score between the output of the sequence reconstruction model and the output of the original basic security message data after preprocessing by the data preprocessing layer. On the validation set, a threshold calculation algorithm is proposed to obtain the optimal reconstruction error threshold to maximize the accuracy of the model in correctly classifying abnormal message sequences. On the test set, the mean absolute error score obtained for each basic security message sequence in the test set is compared with the above-mentioned optimal reconstruction error threshold to determine whether the current sequence comes from an abnormal sender vehicle.

4. The V2X trust management system based on Mamba and blockchain according to claim 3, characterized in that, The loss function is calculated as follows: The output of the linear layer and the preprocessed output of the original basic security message data are input into the loss function, and the mean absolute error score is calculated using the following formula. : ; In the formula, The first one obtained from the linear layer The calculated value of a basic security message. The first one obtained from the data preprocessing layer The original tag value of the basic security message. This represents the total number of basic security messages; during model training, the output dimension of the sequence reconstruction model is... The output dimension of the original basic security message data after preprocessing is: ; Extract the vehicle's position information along the x and y axes from the original basic safety messages, forming the output dimension. The original sequence and the reconstructed output sequence are input into the above formula to obtain the mean absolute error score, and the gradient is backpropagated to train the model. When validating the model, the above loss function is also used to obtain an optimal mean absolute error threshold, which is called the optimal reconstruction error threshold. When testing the model, the mean absolute error score is calculated for each sequence and then compared with the optimal reconstruction error threshold to classify normal and abnormal sending vehicles.

5. The V2X trust management system based on Mamba and blockchain according to claim 4, characterized in that, The function for finding the optimal reconstruction error threshold is defined as follows: The core objective of the function is to find an optimal reconstruction error threshold that maximizes classification accuracy through iterative search. The function receives a list of predicted scores and a list of corresponding true labels, and finally outputs an optimal reconstruction error threshold. This optimal reconstruction error threshold will be used for the following decision rule: basic safe message sequences with scores less than or equal to the optimal reconstruction error threshold are predicted as normal categories, and basic safe message sequences with scores greater than the optimal reconstruction error threshold are predicted as abnormal categories. The function employs an iterative search strategy of "gradually narrowing the range and improving accuracy," the specific process of which is as follows: First, at the initial default threshold, a series of candidate thresholds are generated with a preset step size, and the classification accuracy corresponding to each candidate threshold is calculated. The calculation of classification accuracy is based on a given decision rule: for normal samples, the predicted score should not be higher than the candidate threshold; for abnormal samples, the predicted score should be higher than the candidate threshold. Then, the function selects the candidate threshold with the highest accuracy in this round as the current best result. The next crucial step is that the function improves the search precision by an order of magnitude. This means that in the next iteration, the search will repeat the above process within a finer range, around the optimal reconstruction error threshold found in the previous round. This process is repeated in this way, and after several rounds, it can gradually approach the theoretically optimal threshold.

6. The V2X trust management system based on Mamba and blockchain according to claim 5, characterized in that, The specific details of using the blockchain module for trust management are as follows: The blockchain module utilizes Hyperledger Fabric deployed at the base station to provide distributed trust management for V2X: First, the chaincode is initialized via the contract API, including connecting to the Hyperledger Fabric client, specifying the channel, preparing the identity identifier, and signing; next, the base station collects and processes basic security messages sent by vehicles to obtain classification results. After identifying normal and abnormal message sequences, the base station creates positive and negative interaction records and stores the corresponding transactions in the distributed ledger deployed at the base station; finally, for a given vehicle identity identifier, the trust value of the vehicle can be calculated by retrieving all records of that vehicle ID in the distributed ledger. Once a basic security message sequence is classified as normal, the base station will create a positive interaction record, in which the vehicle identification identifier will be set to the ID of the target vehicle, the positive interaction field will be marked as true, and the negative interaction field will be marked as false. Conversely, if the basic security message sequence is classified as abnormal, the base station will create a negative interaction record. In this case, the vehicle identification identifier will still be the ID of the target vehicle, but the positive interaction field will be marked as false and the negative interaction field will be marked as true. Ultimately, all interaction records will be stored as transactions in a distributed ledger deployed at the base station, providing support for subsequent retrieval of all interaction records of relevant vehicles and calculation of trust values.

7. The V2X trust management system based on Mamba and blockchain according to claim 6, characterized in that, The following is a detailed explanation of how to calculate a vehicle's trust value using Beta expectations: set up This indicates that the base station determines the probability that the message sender is legitimate based on the historical interaction records of relevant vehicles retrieved from Hyperledger Fabric; the trust value calculation mechanism is modeled using a Beta distribution: for each retrieved vehicle, let the number of its positive interaction records be... The number of negative interaction records is , assuming prior distribution Following a Beta distribution, which reflects the uncertainty of the base station's probability of determining that the retrieved vehicle is normal before obtaining any historical interaction records, each interaction record is modeled as a Bernoulli trial based on the given Beta prior distribution, thus enabling the determination of the probability of a normal vehicle. The likelihood function, according to Bayes' rule, regarding The posterior function can also be obtained; it has been verified that the statement about The posterior function still follows a Beta distribution, therefore, regarding Expectation of the Beta distribution Given by the following formula: ; In the formula, , , ; The expectation is only related to the number of positive and negative interaction records of the retrieved vehicle. Therefore, the expectation of the Beta distribution can be used to calculate the dynamic trust value of the retrieved vehicle.