Blockchain-based data storage method, device, equipment and readable storage medium
By using gradient descent algorithm to update model parameters in the blockchain network and adding Laplace noise to the model, the security problem when uploading model parameters is solved, and the privacy guarantee of the differential privacy mechanism and the improvement of system security is achieved.
Patent Information
- Application Number
- CN202111494285.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-08
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2041-12-08
AI Technical Summary
In the prior art, model parameters are easily subject to single point of failure and malicious attacks when uploading to the central server, resulting in low security in data proof transmission.
By obtaining the initial training model and loss function broadcasted by the platform blockchain node, the model parameters are updated based on the gradient descent algorithm, and Laplace noise is added to the local training model to generate a local model. Send the local model to the designated blockchain node, and aggregate it with the local models of other blockchain nodes, generate an proof-keeping model and upload it to the platform blockchain node.
Effectively provide privacy guarantees that meet the differential privacy mechanism, reduce differential attacks against updates, improve system security, and avoid single point of failure and malicious attacks.
Smart Images

Figure CN114417394B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a blockchain-based data storage method, device, equipment and readable storage medium. Background Art
[0002] Cross-border e-commerce companies will upload local financing data to the blockchain network for data storage after training with local models. Therefore, the blockchain network stores data storage of local financing data of multiple e-commerce companies. When financial institutions need to trace the source of target data storage, they trace the target storage by calling the storage model, that is, querying the blockchain node that uploaded the target storage.
[0003] In the related technology, the traditional data notarization method is that each e-commerce company calculates the model parameters locally using its own data, and uploads the learned model parameters to the central server to generate a notarization model. The central server performs weighted averaging on all received model parameters and distributes the generated notarization model to all clients after each iteration.
[0004] In the process of implementing this application, the applicant found that the related technology has at least the following problems:
[0005] Due to the sensitivity of model parameters, they are prone to single point failures and malicious attacks when uploading them to the central server, causing malicious attack nodes to directly infer the source data of the data provider through the model parameters of the locally trained model uploaded locally, resulting in low security of data storage and transmission. Summary of the invention
[0006] In view of this, the present application provides a blockchain-based data storage method, device, equipment and readable storage medium, the main purpose of which is to solve the problem that malicious attack nodes currently directly infer the source data of the data provider through the model parameters of the local training model uploaded locally, resulting in low security of data storage transmission.
[0007] According to the first aspect of the present application, a data storage method based on blockchain is provided, the method comprising:
[0008] Obtaining an initial training model and a loss function, wherein the initial training model and the loss function are obtained by the target blockchain node identifying the network parameters broadcast by the platform blockchain node;
[0009] Based on the gradient descent algorithm, the loss function is used to perform gradient operation on multiple local training data, and the model parameters of the initial training model are updated using the operation results to obtain a local training model;
[0010] Adding Laplace noise to the local training model to obtain a local model, and sending the local model to a designated blockchain node, where the designated blockchain node is a blockchain node selected by the target blockchain node to participate in this model update;
[0011] Receive the specified local model sent by other blockchain nodes, perform model aggregation on the specified local model and the local training model, obtain the evidence model and upload the evidence model to the platform blockchain node, the other blockchain nodes are the blockchain nodes participating in this model training except the target blockchain node.
[0012] Optionally, it is characterized in that the obtaining of the initial training model and the loss function comprises:
[0013] In response to receiving the data transmission instruction broadcast by the platform blockchain, calling the data receiving interface, receiving the network parameters broadcast by the platform blockchain, performing data identification on the network parameters, and obtaining the first hash value and the second hash value of the initial training model and the loss function;
[0014] Based on the hash mapping algorithm, the first original value and the second original value corresponding to the first hash value and the second hash value are queried respectively, the first original value is used as the initial training model, and the second original value is used as the loss function.
[0015] Optionally, the gradient descent algorithm is based on the loss function to perform gradient operation on multiple local training data, and the model parameters of the initial training model are updated using the operation results to obtain the local training model, including:
[0016] Read the multiple local training data, input the multiple local training data into the initial training model, calculate the product of each local training data in the multiple local training data and the loss function based on the gradient descent algorithm, use the product as the sample loss, and obtain multiple sample losses of the multiple local training data;
[0017] Calculate the average value of the multiple sample losses. When the average value of the multiple sample losses is less than a preset loss threshold, use the average value to update the model parameters of the initial training model in the reverse direction of the gradient operation to obtain a local training model.
[0018] Optionally, it is characterized in that sending the local model to a designated blockchain node comprises:
[0019] Reading a distributed hash table, and numbering data retrieval information stored in the distributed hash table;
[0020] Extracting target data retrieval information corresponding to a target number in the distributed hash table, taking a blockchain node corresponding to the target data retrieval information as the designated blockchain node, and taking an arbitrary value for the target number;
[0021] The local model is sent to the designated blockchain node.
[0022] Optionally, it is characterized in that the receiving of the designated local model sent by other blockchain nodes except the target blockchain node among the blockchain nodes participating in the current model training, performing aggregation operation on the designated local model and the local training model to generate a stored model, and uploading the stored model to the platform blockchain node includes:
[0023] Receiving the designated local model sent by the other blockchain nodes, and querying the target data volume corresponding to the designated local model as the model weight according to the designated local model;
[0024] Calculate the product of the model weight and the specified local model, aggregate the product with the local training model to obtain the evidence model, and upload the evidence model to the platform blockchain node.
[0025] Optionally, the method further comprises:
[0026] Inputting the multiple local training data into the evidence model to obtain multiple sample classification results, calculating the ratio of the number of correctly classified samples in the multiple sample classification results to the total number of the local training data, and using the ratio as the model accuracy of the evidence model;
[0027] The accuracy of the model is continuously detected. When the accuracy of the model reaches a preset accuracy threshold, the model training of the evidence model is completed and the evidence model is uploaded to the blockchain network.
[0028] According to the second aspect of the present application, a data storage device based on blockchain is provided, the device comprising:
[0029] An acquisition module, used to acquire an initial training model and a loss function, wherein the initial training model and the loss function are obtained by the target blockchain node identifying the network parameters broadcast by the platform blockchain node;
[0030] A calculation module, used for performing gradient calculation on multiple local training data using the loss function based on a gradient descent algorithm, and updating the model parameters of the initial training model using the calculation result to obtain a local training model;
[0031] A transmission module, used to add Laplace noise to the local training model to obtain a local model, and send the local model to a designated blockchain node, where the designated blockchain node is a blockchain node selected by the target blockchain node to participate in this model update;
[0032] The aggregation module is used to receive the specified local model sent by other blockchain nodes, perform model aggregation on the specified local model and the local training model, obtain the evidence model and upload the evidence model to the platform blockchain node. The other blockchain nodes are the blockchain nodes participating in this model training except the target blockchain node.
[0033] Optionally, the acquisition module is used to call the data receiving interface in response to receiving the data transmission instruction broadcast by the platform blockchain, receive the network parameters broadcast by the platform blockchain, perform data identification on the network parameters, and obtain the first hash value and the second hash value of the initial training model and the loss function; based on the hash mapping algorithm, query the first original value and the second original value corresponding to the first hash value and the second hash value respectively, use the first original value as the initial training model, and use the second original value as the loss function.
[0034] Optionally, the operation module is used to read the multiple local training data, input the multiple local training data into the initial training model, calculate the product of each local training data in the multiple local training data and the loss function based on the gradient descent algorithm, use the product as the sample loss, and obtain multiple sample losses of the multiple local training data; calculate the average value of the multiple sample losses, and when the average value of the multiple sample losses is less than a preset loss threshold, use the average value to update the model parameters of the initial training model in the reverse direction of the gradient operation to obtain a local training model.
[0035] Optionally, the transmission module is used to read a distributed hash table and number the data retrieval information stored in the distributed hash table; extract the target data retrieval information corresponding to the target number in the distributed hash table, and use the blockchain node corresponding to the target data retrieval information as the designated blockchain node, and the value of the target number can be any numerical value; and send the local model to the designated blockchain node.
[0036] Optionally, the aggregation module is used to receive the designated local model sent by the other blockchain nodes, query the target data volume corresponding to the designated local model as the model weight based on the designated local model; calculate the product of the model weight and the designated local model, aggregate the product with the local training model to obtain the evidence model, and upload the evidence model to the platform blockchain node.
[0037] Optionally, the device further comprises:
[0038] A calculation module, used to input the multiple local training data into the evidence storage model to obtain multiple sample classification results, calculate the ratio of the number of correctly classified samples in the multiple sample classification results to the total number of the local training data, and use the ratio as the model accuracy of the evidence storage model;
[0039] The detection module is used to continuously detect the accuracy of the model. When the accuracy of the model reaches a preset accuracy threshold, the model training of the evidence model is completed and the evidence model is uploaded to the blockchain network.
[0040] According to the third aspect of the present application, a computer device is provided, comprising a storage device, a processor, and a computer program stored on the storage device and executable on the processor, wherein when the processor executes the program, the steps of any one of the methods described in the first aspect are implemented.
[0041] According to a fourth aspect of the present application, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the steps of any one of the methods described in the first aspect are implemented.
[0042] By means of the above technical scheme, the present application provides a data storage method, device, equipment and readable storage medium based on blockchain. The present application first obtains the initial training model and loss function broadcast by the platform blockchain node. Subsequently, based on the gradient descent algorithm, the loss function is used to perform gradient calculation on multiple local training data, and the model parameters of the initial training model are updated using the calculation results to obtain the local training model. Next, Laplace noise is added to the local training model to obtain a local model, and the local model is sent to the designated blockchain node selected by the target blockchain node to participate in this model update. Finally, the designated local model sent by other blockchain nodes other than the target blockchain node in the blockchain nodes participating in this model training is received, and the designated local model is aggregated with the local training model to generate a storage model, and the storage model is uploaded to the platform blockchain node. Each blockchain node uses local training data for model training, and adds Laplace noise to the trained local training model to obtain a local model, effectively providing privacy guarantees that meet the differential privacy mechanism, and adopts the method of randomly selecting blockchain nodes for model update to collaboratively train the storage model, reduce differential attacks on updates, and improve system security.
[0043] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0045] Figure 1 A schematic diagram of a data storage method based on blockchain provided in an embodiment of the present application is shown;
[0046] Figure 2 A schematic diagram of a data storage method based on blockchain provided in an embodiment of the present application is shown;
[0047] Figure 3A A schematic diagram of the structure of a data evidence storage device based on blockchain provided in an embodiment of the present application is shown;
[0048] Figure 3B A schematic diagram of the structure of a data evidence storage device based on blockchain provided in an embodiment of the present application is shown;
[0049] Figure 4 A schematic diagram of the device structure of a computer device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0050] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0051] The present application embodiment provides a data storage method based on blockchain, such as Figure 1 As shown, the method includes:
[0052] 101. Obtain an initial training model and a loss function. The initial training model and the loss function are obtained by the blockchain node identifying the network parameters broadcast by the platform blockchain node.
[0053] 102. Based on the gradient descent algorithm, a loss function is used to perform gradient operations on multiple local training data, and the operation results are used to update the model parameters of the initial training model to obtain a local training model.
[0054] 103. Add Laplace noise to the local training model to obtain a local model, and send the local model to a designated blockchain node. The designated blockchain node is a blockchain node selected by the blockchain node to participate in this model update.
[0055] 104. Receive the specified local model sent by other blockchain nodes, perform aggregation operation on the specified local model and the local training model, and generate a proof model. Other blockchain nodes are blockchain nodes other than the blockchain node in the blockchain network.
[0056] The method provided in the embodiment of the present application first obtains the initial training model and loss function broadcast by the platform blockchain node. Subsequently, based on the gradient descent algorithm, the loss function is used to perform gradient operations on multiple local training data, and the model parameters of the initial training model are updated using the operation results to obtain a local training model. Next, Laplace noise is added to the local training model to obtain a local model, and the local model is sent to the designated blockchain node selected by the target blockchain node to participate in this model update. Finally, the designated local model sent by other blockchain nodes other than the target blockchain node in the blockchain nodes participating in this model training is received, and the designated local model is aggregated with the local training model to generate a certificate model, and the certificate model is uploaded to the platform blockchain node. Each blockchain node uses local training data for model training, and adds Laplace noise to the trained local training model to obtain a local model, effectively providing privacy guarantees that meet the differential privacy mechanism, and adopts a method of randomly selecting blockchain nodes for model update to collaboratively train the certificate model, reduce differential attacks on updates, and improve system security.
[0057] The present application embodiment provides a data storage method based on blockchain, such as Figure 2 As shown, the method includes:
[0058] 201. Obtain an initial training model and loss function.
[0059] Cross-border e-commerce will upload local financing data to the blockchain network for data storage after training the local model. Therefore, the blockchain network stores data storage of local financing data of multiple e-commerce companies. When financial institutions need to trace the source of target data storage, financial institutions trace the target storage by calling the storage model, that is, querying the blockchain node that uploaded the target storage. At present, the traditional data storage method is that each e-commerce company calculates the model parameters locally using its own data, and uploads the learned model parameters to the central server to generate a storage model. The central server performs weighted average on all received model parameters and distributes the generated storage model to all clients after each iteration. However, the applicant recognizes that due to the sensitivity of the model parameters, it is easy to encounter threats such as single point failures and malicious attacks when uploading the model parameters to the central server, resulting in malicious attack nodes directly inferring the source data of the data provider through the model parameters of the locally uploaded local training model, resulting in low security of data storage transmission.
[0060] Therefore, the present application provides a data storage method, device, equipment and readable storage medium based on blockchain. The present application first obtains the initial training model and loss function broadcast by the platform blockchain node. Subsequently, based on the gradient descent algorithm, the loss function is used to perform gradient calculations on multiple local training data, and the model parameters of the initial training model are updated using the calculation results to obtain a local training model. Next, Laplace noise is added to the local training model to obtain a local model, and the local model is sent to the designated blockchain node selected by the target blockchain node to participate in this model update. Finally, the designated local model sent by other blockchain nodes other than the target blockchain node in the blockchain nodes participating in this model training is received, and the designated local model is aggregated with the local training model to generate a storage model, and the storage model is uploaded to the platform blockchain node. Each blockchain node uses local training data for model training, and adds Laplace noise to the trained local training model to obtain a local model, effectively providing privacy guarantees that meet the differential privacy mechanism, and adopts a method of randomly selecting blockchain nodes for model update to collaboratively train the storage model, reduce differential attacks on updates, and improve system security.
[0061] Among them, the platform blockchain node is the publisher of the model building task. It is necessary to determine the pre-trained initial training model in advance, and use the initialized initial training model and initial training parameters as network parameters, and broadcast them to the target blockchain nodes participating in the model training this time, so that the target blockchain nodes can use local data to perform model training based on the received network parameters. In the actual application process, the platform can set the screening number, and select a preset screening number of blockchain nodes in the distributed hash table as the target blockchain nodes participating in this model training, for example, 30, 50, etc. In fact, the screening number can use the system default number or can be set by relevant staff based on the actual application scenario, and can be set in the form of numbers or proportions. This application does not specifically limit the setting size and setting method of the screening number.
[0062] In an embodiment of the present application, after receiving the network parameters broadcast by the platform blockchain node, the target blockchain node needs to perform data identification on the network parameters, and then obtain an initial training model and a loss function, wherein the initial training model and the loss function can be preset by relevant staff according to the actual application scenario. This application does not specifically limit the content of the initial training model and the loss function.
[0063] Specifically, in response to receiving the data transmission instruction broadcast by the platform blockchain, the data receiving interface is called to receive the network parameters broadcast by the platform blockchain, and the network parameters are identified to obtain the first hash value and the second hash value of the initial training model and the loss function. Subsequently, based on the hash mapping algorithm, the first original value and the second original value corresponding to the first hash value and the second hash value are queried respectively, and the first original value is used as the initial training model, and the second original value is used as the loss function.
[0064] 202. Based on the gradient descent algorithm, a loss function is used to perform gradient operations on multiple local training data, and the operation results are used to update the model parameters of the initial training model to obtain a local training model.
[0065] In an embodiment of the present application, the target blockchain node inputs local training data into the initial training model for model training. It should be noted that the training process is to calculate the loss of each local training data based on the gradient descent algorithm to obtain the optimal model parameters, and obtain the local training model when the model parameters reach the optimal value.
[0066] Specifically, multiple local training data are read from a local database, the multiple local training data are input into an initial training model, and the product of each local training data and a loss function in the multiple local training data is calculated based on a gradient descent algorithm, and the product is used as a sample loss to obtain multiple sample losses of the multiple local training data. Subsequently, the average value of the multiple sample losses is calculated, and when the average value of the multiple sample losses is less than a preset loss threshold, the average value is used to update the model parameters of the initial training model in the reverse direction of the gradient operation to obtain a local training model. The specific process of calculating the average value of the sample losses can be implemented based on the following formula 1:
[0067] Formula 1:
[0068] Among them, F i (w) is the loss function; D i It is the local training data of the target blockchain node.
[0069] Through the above steps, the target blockchain node uses local training data to optimize in the opposite direction of the loss function gradient to approach the optimal solution, obtains the model parameter w when the average value of the sample loss is minimized, and uses the model parameter w to update the model parameter of the initial training model to obtain the local training model.
[0070] 203. Add Laplace noise to the local training model to obtain a local model, and send the local model to the designated blockchain node.
[0071] In an embodiment of the present application, considering that the learned model may contain sensitive information, in order to protect the original data from being inferred by malicious participants, the method uses the Laplace mechanism to add noise to the local training model to obtain a local model, and sends the local model to the designated blockchain node.
[0072] It should be noted that the designated blockchain node is a blockchain node randomly selected by the target blockchain node based on the distributed hash table. Specifically, the distributed hash table is read, and the data retrieval information stored in the distributed hash table is numbered. Subsequently, the target data retrieval information corresponding to the target number is extracted from the distributed hash table, and the blockchain node corresponding to the target data retrieval information is used as the designated blockchain node, wherein the value of the target number is any value, and this application does not specifically limit the value method of the target number. Finally, the local model is sent to the designated blockchain node.
[0073] By adding Laplace noise to the local training model, the generated evidence model is provided with privacy guarantees that meet the differential privacy mechanism, and a random partial update mechanism is adopted to replace the traditional centralized update. An update node selection log is generated in the target blockchain node to record the selected designated blockchain node, so that the training logs of each target blockchain node during the training process can be traced, effectively preventing malicious e-commerce platforms from intentionally destroying the model optimization process, reducing the risk of privacy leakage, and improving system security.
[0074] 204. Receive the designated local model sent by other blockchain nodes, perform aggregation operation on the designated local model and the local training model, and generate a proof model.
[0075] In the embodiment of the present application, there are multiple target blockchain nodes participating in this model training. After generating a local model, each target blockchain node will use a distributed hash table to select a designated blockchain node for model update iteration, and the selected blockchain node will receive the local model sent by the target blockchain node. Therefore, the target blockchain node will receive the designated local model sent by other blockchain nodes, and the evidence model can be obtained by model aggregation of all the received designated local models.
[0076] Specifically, a designated local model sent by other blockchain nodes is received, and a target data volume corresponding to the designated local model is queried according to the designated local model as a model weight. Subsequently, the product of the model weight and the designated local model is calculated, and the product is aggregated with the local training model to obtain a stored model, and the stored model is uploaded to the platform blockchain node.
[0077] In the actual application process, after generating the evidence model, the target blockchain node will use the local training data to calculate the model accuracy of the evidence model. If the model accuracy does not meet the preset accuracy threshold, the target blockchain node will continue to update and iterate the evidence model as a local training model until the model accuracy of the evidence model reaches the preset accuracy threshold after multiple updates and iterations, and then stop updating to obtain the final evidence model. Specifically, multiple local training data are input into the evidence model to obtain multiple sample classification results, and the ratio of the number of correctly classified samples in the multiple sample classification results to the total number of local training data is calculated, and the ratio is used as the model accuracy of the evidence model. Subsequently, the model accuracy is continuously tested, and when the model accuracy reaches the preset accuracy threshold, the model training of the evidence model is completed, and the evidence model is uploaded to the platform blockchain node.
[0078] Through the above steps, a training model combining blockchain network and federated learning is introduced. The blockchain nodes share local training models and jointly train the models in an iterative manner. Traditional central nodes are no longer needed, which can effectively reduce the risk of privacy leakage.
[0079] The method provided in the embodiment of the present application first obtains the initial training model and loss function broadcast by the platform blockchain node. Subsequently, based on the gradient descent algorithm, the loss function is used to perform gradient operations on multiple local training data, and the model parameters of the initial training model are updated using the operation results to obtain a local training model. Next, Laplace noise is added to the local training model to obtain a local model, and the local model is sent to the designated blockchain node selected by the target blockchain node to participate in this model update. Finally, the designated local model sent by other blockchain nodes other than the target blockchain node in the blockchain nodes participating in this model training is received, and the designated local model is aggregated with the local training model to generate a certificate model, and the certificate model is uploaded to the platform blockchain node. Each blockchain node uses local training data for model training, and adds Laplace noise to the trained local training model to obtain a local model, effectively providing privacy guarantees that meet the differential privacy mechanism, and adopts a method of randomly selecting blockchain nodes for model update to collaboratively train the certificate model, reduce differential attacks on updates, and improve system security.
[0080] Further, as Figure 1 The specific implementation of the method, the embodiment of the present application provides a data storage device based on blockchain, such as Figure 3A As shown, the device includes: an acquisition module 301, a calculation module 302, a transmission module 303, and an aggregation module 304.
[0081] The acquisition module 301 is used to acquire an initial training model and a loss function, wherein the initial training model and the loss function are obtained by the target blockchain node identifying the network parameters broadcast by the platform blockchain node;
[0082] The operation module 302 is used to perform gradient operation on multiple local training data using the loss function based on the gradient descent algorithm, and update the model parameters of the initial training model using the operation result to obtain the local training model;
[0083] The transmission module 303 is used to add Laplace noise to the local training model to obtain a local model, and send the local model to a designated blockchain node, where the designated blockchain node is a blockchain node selected by the target blockchain node to participate in this model update;
[0084] The aggregation module 304 is used to receive the specified local model sent by other blockchain nodes, perform model aggregation on the specified local model and the local training model, obtain the evidence model and upload the evidence model to the platform blockchain node. The other blockchain nodes are the blockchain nodes participating in this model training except the target blockchain node.
[0085] In a specific application scenario, the acquisition module 301 is used to respond to the data transmission instruction received from the platform blockchain broadcast, call the data receiving interface, receive the network parameters broadcast by the platform blockchain, perform data identification on the network parameters, and obtain the first hash value and the second hash value of the initial training model and the loss function; based on the hash mapping algorithm, query the first original value and the second original value corresponding to the first hash value and the second hash value respectively, use the first original value as the initial training model, and use the second original value as the loss function.
[0086] In a specific application scenario, the operation module 302 is used to read the multiple local training data, input the multiple local training data into the initial training model, calculate the product of each local training data in the multiple local training data and the loss function based on the gradient descent algorithm, use the product as the sample loss, and obtain multiple sample losses of the multiple local training data; calculate the average value of the multiple sample losses, and when the average value of the multiple sample losses is less than a preset loss threshold, use the average value to update the model parameters of the initial training model in the opposite direction of the gradient operation to obtain a local training model.
[0087] In a specific application scenario, the transmission module 303 is used to read a distributed hash table and number the data retrieval information stored in the distributed hash table; extract the target data retrieval information corresponding to the target number in the distributed hash table, and use the blockchain node corresponding to the target data retrieval information as the designated blockchain node, and the value of the target number can be any numerical value; and send the local model to the designated blockchain node.
[0088] In a specific application scenario, the aggregation module 304 is used to receive the designated local model sent by the other blockchain nodes, query the target data volume corresponding to the designated local model as the model weight based on the designated local model; calculate the product of the model weight and the designated local model, aggregate the product with the local training model to obtain the evidence model, and upload the evidence model to the platform blockchain node.
[0089] In specific application scenarios, such as Figure 3B As shown, the device further includes: a calculation module 305 and a detection module 306.
[0090] The calculation module 305 is used to input the multiple local training data into the evidence model to obtain multiple sample classification results, calculate the ratio of the number of correctly classified samples in the multiple sample classification results to the total number of the local training data, and use the ratio as the model accuracy of the evidence model;
[0091] The detection module 306 is used to continuously detect the accuracy of the model. When the accuracy of the model reaches a preset accuracy threshold, the model training of the evidence model is completed and the evidence model is uploaded to the blockchain network.
[0092] The device provided in the embodiment of the present application first obtains the initial training model and loss function broadcast by the platform blockchain node. Subsequently, based on the gradient descent algorithm, the loss function is used to perform gradient operations on multiple local training data, and the model parameters of the initial training model are updated using the operation results to obtain a local training model. Next, Laplace noise is added to the local training model to obtain a local model, and the local model is sent to the designated blockchain node selected by the target blockchain node to participate in this model update. Finally, the designated local model sent by other blockchain nodes other than the target blockchain node in the blockchain nodes participating in this model training is received, and the designated local model is aggregated with the local training model to generate a certificate model, and the certificate model is uploaded to the platform blockchain node. Each blockchain node uses local training data for model training, and adds Laplace noise to the trained local training model to obtain a local model, effectively providing privacy guarantees that meet the differential privacy mechanism, and adopts a method of randomly selecting blockchain nodes for model update to collaboratively train the certificate model, reduce differential attacks on updates, and improve system security.
[0093] It should be noted that for other corresponding descriptions of the functional units involved in the blockchain-based data storage device provided in the embodiment of the present application, please refer to Figure 1 and Figure 2 The corresponding description in will not be repeated here.
[0094] In an exemplary embodiment, see Figure 4 , and also provides a device, which includes a bus, a processor, a memory and a communication interface, and may also include an input and output interface and a display device, wherein each functional unit can communicate with each other through the bus. The memory stores a computer program, and the processor is used to execute the program stored in the memory and execute the blockchain-based data storage method in the above embodiment.
[0095] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the blockchain-based data storage method.
[0096] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by hardware, or by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each implementation scenario of the present application.
[0097] Those skilled in the art will appreciate that the accompanying drawings are merely schematic diagrams of a preferred implementation scenario, and the modules or processes in the accompanying drawings are not necessarily required for implementing the present application.
[0098] Those skilled in the art will appreciate that the modules in the device in the implementation scenario can be distributed in the device in the implementation scenario according to the implementation scenario description, or can be changed accordingly and located in one or more devices different from the implementation scenario. The modules in the above implementation scenario can be combined into one module, or can be further split into multiple sub-modules.
[0099] The above application serial numbers are for description only and do not represent the advantages or disadvantages of the implementation scenarios.
[0100] The above disclosure only discloses several specific implementation scenarios of the present application. However, the present application is not limited thereto, and any changes that can be conceived by technicians in this field should fall within the scope of protection of the present application.
Claims
1. A data storage method based on blockchain, characterized in that: The method is applied to the target blockchain node participating in the model training, and the method includes: Obtaining an initial training model and a loss function, wherein the initial training model and the loss function are obtained by the target blockchain node identifying the network parameters broadcast by the platform blockchain node; Based on the gradient descent algorithm, the loss function is used to perform gradient operation on multiple local training data, and the model parameters of the initial training model are updated using the operation results to obtain a local training model; Add Laplace noise to the local training model to obtain a local model, read a distributed hash table, number the data retrieval information stored in the distributed hash table, extract the target data retrieval information corresponding to the target number in the distributed hash table, use the blockchain node corresponding to the target data retrieval information as the designated blockchain node, send the local model to the designated blockchain node, the designated blockchain node is the blockchain node selected by the target blockchain node to participate in this model update, and the value of the target number is an arbitrary value; Receive the specified local model sent by other blockchain nodes, perform model aggregation on the specified local model and the local training model, obtain the evidence model and upload the evidence model to the platform blockchain node, the other blockchain nodes are the blockchain nodes participating in this model training except the target blockchain node.
2. The method according to claim 1, characterized in that The obtaining of the initial training model and loss function includes: In response to receiving the data transmission instruction broadcast by the platform blockchain, calling the data receiving interface, receiving the network parameters broadcast by the platform blockchain, performing data identification on the network parameters, and obtaining the first hash value and the second hash value of the initial training model and the loss function; Based on the hash mapping algorithm, the first original value and the second original value corresponding to the first hash value and the second hash value are queried respectively, the first original value is used as the initial training model, and the second original value is used as the loss function.
3. The method according to claim 1, characterized in that The method of performing gradient operation on multiple local training data using the loss function based on the gradient descent algorithm and updating the model parameters of the initial training model using the operation results to obtain the local training model includes: Read the multiple local training data, input the multiple local training data into the initial training model, calculate the product of each local training data in the multiple local training data and the loss function based on the gradient descent algorithm, use the product as the sample loss, and obtain multiple sample losses of the multiple local training data; Calculate the average value of the multiple sample losses. When the average value of the multiple sample losses is less than a preset loss threshold, use the average value to update the model parameters of the initial training model in the reverse direction of the gradient operation to obtain a local training model.
4. The method according to claim 1, characterized in that The receiving of the designated local model sent by other blockchain nodes except the target blockchain node among the blockchain nodes participating in the model training, performing aggregation operation on the designated local model and the local training model to generate a stored model, and uploading the stored model to the platform blockchain node includes: Receiving the designated local model sent by the other blockchain nodes, and querying the target data volume corresponding to the designated local model as the model weight according to the designated local model; Calculate the product of the model weight and the specified local model, aggregate the product with the local training model to obtain the evidence model, and upload the evidence model to the platform blockchain node.
5. The method according to claim 1, characterized in that The method further comprises: Inputting the multiple local training data into the evidence model to obtain multiple sample classification results, calculating the ratio of the number of correctly classified samples in the multiple sample classification results to the total number of the local training data, and using the ratio as the model accuracy of the evidence model; The accuracy of the model is continuously detected. When the accuracy of the model reaches a preset accuracy threshold, the model training of the evidence model is completed and the evidence model is uploaded to the blockchain network.
6. A data evidence storage device based on blockchain, characterized in that: The device is applied to the target blockchain node participating in the model training, and the device includes: An acquisition module, used to acquire an initial training model and a loss function, wherein the initial training model and the loss function are obtained by the target blockchain node identifying the network parameters broadcast by the platform blockchain node; A calculation module, used for performing gradient calculation on multiple local training data using the loss function based on a gradient descent algorithm, and updating the model parameters of the initial training model using the calculation result to obtain a local training model; A transmission module is used to add Laplace noise to the local training model to obtain a local model, read a distributed hash table, number the data retrieval information stored in the distributed hash table, extract the target data retrieval information corresponding to the target number in the distributed hash table, use the blockchain node corresponding to the target data retrieval information as the designated blockchain node, and send the local model to the designated blockchain node. The designated blockchain node is the blockchain node selected by the target blockchain node to participate in this model update. The value of the target number can be any value. The aggregation module is used to receive the specified local model sent by other blockchain nodes, perform model aggregation on the specified local model and the local training model, obtain the evidence model and upload the evidence model to the platform blockchain node. The other blockchain nodes are the blockchain nodes participating in this model training except the target blockchain node.
7. The device according to claim 6, characterized in that The acquisition module is used to call the data receiving interface in response to receiving the data transmission instruction broadcast by the platform blockchain, receive the network parameters broadcast by the platform blockchain, perform data identification on the network parameters, and obtain the first hash value and the second hash value of the initial training model and the loss function; Based on the hash mapping algorithm, the first original value and the second original value corresponding to the first hash value and the second hash value are queried respectively, the first original value is used as the initial training model, and the second original value is used as the loss function.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Federated learning system and method based on block chain
CN111212110A
Multi-dimensional multi-subset differential attack resistant data aggregation method for smart power grid
CN112637227A