LocalStorage anti-loss method and system based on proxy mode

By introducing a proxy server into the browser and using technologies such as encryption processing and deep learning algorithms to back up and synchronize data in LocalStorage in real time, the problem of data loss is solved, data reliability and system performance are improved, and costs are reduced.

CN118473832BActive Publication Date: 2024-09-24冠骋信息技术(苏州)有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410931843.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-12
Publication Date
2024-09-24
Estimated Expiration
2044-07-12

AI Technical Summary

Technical Problem

Existing technologies cannot completely solve the problem of LocalStorage data loss, and there are problems with high system overhead and maintenance costs.

Method used

Using a proxy mode-based approach, the proxy server is introduced in the browser to intercept and enhance the read and write operations of LocalStorage, achieving real-time backup, multi-level caching and asynchronous synchronization of data, and utilizing encryption processing, deep learning algorithms, and federated learning technology. , blockchain and multi-party secure computing protocols and other technologies to ensure the security and reliability of data.

Benefits of technology

Effectively prevents LocalStorage data loss, improves data reliability and availability, reduces system overhead and maintenance costs, ensures data confidentiality and privacy, and improves system throughput and response speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118473832B
    Figure CN118473832B
Patent Text Reader

Abstract

The present invention provides a LocalStorage anti-loss method and system based on a proxy mode, which relates to the field of data processing technology, including: when a data storage operation is performed in a browser, the data to be stored is sent to a proxy server, the data is encrypted, the encrypted data is forwarded to a target server and a unique identifier corresponding to the data is generated, and the encrypted data is sent to the proxy server; a target verification code corresponding to the data is generated and stored in a local storage; when a data reading operation is performed in the browser, the unique identifier and the target verification code of the data to be read are read from the local storage, the proxy server verifies the target verification code, and if the verification is successful, the target encrypted data corresponding to the unique identifier of the data to be read is queried and sent to the proxy server, the proxy server decrypts the target encrypted data, and the decrypted data is sent to the browser and stored in the local storage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to data processing technology, and in particular to a LocalStorage anti-loss method and system based on an agent mode. Background Art

[0002] With the widespread use of Web applications, storing data on the client has become a common requirement. LocalStorage, as a local storage technology provided by HTML5 (Hyper Text Markup Language), can persistently store key-value data in the user's browser. However, LocalStorage has the problem of easy data loss. For example, when the user manually clears the browser cache or uses a third-party cleaning tool, the data in LocalStorage may be deleted, resulting in data loss. When the operating system or browser has an exception or crashes, the data in LocalStorage may be damaged or lost. Or some browsers may clear the data in LocalStorage after a version update, causing data loss.

[0003] In the prior art, in order to solve the problem of LocalStorage data loss, the data in LocalStorage is usually backed up to the server at a regular interval so that it can be restored when the data is lost. Or the data is stored in LocalStorage and other storage media (such as IndexedDB, Cookie) at the same time to improve the reliability of the data.

[0004] However, the above methods all have certain limitations and cannot completely solve the problem of LocalStorage data loss. Therefore, a new technical solution is needed that can effectively prevent LocalStorage data loss, improve data reliability and availability, and reduce system overhead and maintenance costs. Therefore, the present invention proposes a LocalStorage anti-loss method and system based on a proxy mode, which intercepts and enhances the read and write operations of LocalStorage by introducing a proxy layer, realizes real-time backup, multi-level caching and asynchronous synchronization of data, effectively solves the problem of easy loss of LocalStorage data, and improves the data reliability and user experience of Web applications. Summary of the invention

[0005] The embodiments of the present invention provide a method and a system, which can solve the problems in the prior art.

[0006] According to a first aspect of the embodiments of the present invention,

[0007] Provides a LocalStorage anti-loss method based on proxy mode, including:

[0008] When performing a data storage operation in the browser, the data to be stored is sent to the proxy server. After receiving the data to be stored, the proxy server encrypts the data to obtain the encrypted data, forwards the encrypted data to the target server and generates a unique identifier corresponding to the data, and sends the unique identifier to the proxy server.

[0009] After receiving the unique identifier, the proxy server generates a target verification code corresponding to the unique identifier, sends the unique identifier and the target verification code to the browser, and stores the unique identifier, the target verification code and the data to be stored in the local storage;

[0010] When performing a data reading operation in the browser, the unique identifier and target verification code of the data to be read are read from the local storage and sent to the proxy server. The proxy server verifies the target verification code. If the verification is successful, the unique identifier of the data to be read is forwarded to the target server. The target server queries the target encrypted data corresponding to the unique identifier of the data to be read from the database and sends it to the proxy server. The proxy server decrypts the target encrypted data, sends the decrypted data to the browser, and stores it in the local storage.

[0011] In an optional embodiment,

[0012] After receiving the data to be stored, the proxy server encrypts it, and the encrypted data includes:

[0013] After receiving the data to be stored, the proxy server uses a deep learning algorithm to extract features of the data to be stored and obtains a feature vector of the data to be stored;

[0014] An initial encryption algorithm model is trained according to the feature vector of the data to be stored, and multiple initial encryption algorithm models are aggregated using federated learning technology to obtain the final target encryption algorithm selection model;

[0015] The feature vector of the data to be stored is input into the trained target encryption algorithm selection model, the optimal encryption algorithm is dynamically selected, the data to be stored is encrypted, and the encrypted data is obtained.

[0016] In an optional embodiment,

[0017] Each proxy server trains an initial encryption algorithm model based on the feature vector of the data to be stored. Using federated learning technology, multiple initial encryption algorithm models are aggregated to obtain the final target encryption algorithm selection model, including:

[0018] Send the feature vector of the data to be stored to the federated learning coordinator;

[0019] The federated learning coordinator receives feature vectors of data to be stored from multiple proxy servers, aggregates the received feature vectors of the data to be stored to form a global feature vector set, and sends the global feature vector set to the proxy servers participating in the federated learning;

[0020] The proxy server trains the encryption algorithm to select the model based on the received global feature vector set, obtains the local model parameters, and sends the local model parameters to the federated learning coordinator;

[0021] The federated learning coordinator securely aggregates the received local model parameters to obtain the final target encryption algorithm selection model.

[0022] In an optional embodiment,

[0023] Forwarding the encrypted data to the target server and generating a unique identifier corresponding thereto includes:

[0024] The proxy server forwards the encrypted data to the target server, and adds the encrypted data as a new block to the blockchain maintained by the proxy server and the target server. Through the consensus algorithm, a consensus is reached on the newly added block, and the new block is added to the end of the blockchain, and the block hash value of the new block is used as the first identifier;

[0025] Based on the first identifier, according to the sensitivity of the data and the user's access rights, dynamically generate encryption parameters and keys corresponding to the first identifier, and encrypt the first identifier using homomorphic encryption technology according to the generated encryption parameters and keys to obtain a homomorphically encrypted second identifier;

[0026] Based on the second identifier after homomorphic encryption, a multi-party secure computing protocol is introduced to calculate the encryption parameters of the proxy server and the encryption parameters of the target server respectively. The encryption parameters of the proxy server and the encryption parameters of the target server are combined to generate a complete unique identifier.

[0027] In an optional embodiment,

[0028] Dynamically generating encryption parameters and keys corresponding to the first identifier according to the sensitivity of the data and the access rights of the user includes:

[0029] Define a set of attributes, including data sensitivity attributes and user access rights attributes. Classify data sensitivity attributes according to the confidentiality and importance of the data, and classify user access rights attributes according to user identity, role, and security level.

[0030] According to the attribute values ​​in the attribute set, an access structure corresponding to the attribute values ​​is dynamically generated, and according to the sensitivity attribute of the first identifier, different homomorphic encryption algorithms and key lengths are used to encrypt the first identifier to obtain a homomorphically encrypted second identifier;

[0031] A hierarchical deterministic key derivation mechanism is adopted to dynamically derive a first encryption key corresponding to the second identifier according to an attribute value of the second identifier and a master key, and the second identifier, the access structure and the encryption key derivation parameters are stored in association with each other;

[0032] When a data access request is received, it is determined whether the requirements of the access structure are met based on the user attributes in the data access request. If the user attributes meet the requirements of the access structure, a new encryption key is re-derived based on the derivation parameters of the encryption key, and the first identifier is re-encrypted using the new encryption key to achieve adaptive encryption protection.

[0033] In an optional embodiment,

[0034] After receiving the unique identifier, the proxy server generates a target verification code corresponding to the unique identifier, including:

[0035] Obtaining the user's biometric information, combining it with the unique identifier, and performing hash calculation on the combined data using a secure hash function to obtain a hash value;

[0036] Get the current timestamp, concatenate the current timestamp with the hash value to generate the data to be signed, and use the threshold key splitting technology to split the private key of the proxy server into multiple subkeys, and store them in multiple key escrow servers. Perform threshold signing on the data to be signed through multiple key escrow servers to generate partial signature values.

[0037] Combine partial signature values ​​generated by multiple key escrow servers and use the threshold signature recovery algorithm to obtain the complete digital signature value;

[0038] Use the pre-shared key, combined with the hash value and timestamp, generate a message authentication code through the hash message authentication code algorithm, combine the generated message authentication code, the complete digital signature value and the timestamp to generate the target check code.

[0039] In an optional embodiment,

[0040] Combining the partial signature values ​​generated by multiple key escrow servers and using the threshold signature recovery algorithm, the complete digital signature value is obtained, including:

[0041] Each key trustee server generates a ciphertext proof using a zero-knowledge proof protocol while generating a partial signature value. The key trustee server sends the generated partial signature value and the corresponding ciphertext proof to the designated reconstruction server through a secure channel.

[0042] After the reconstruction server receives partial signature values ​​and ciphertext proofs from multiple key trustee servers, it uses a multi-party computing protocol to jointly verify the received ciphertext proofs;

[0043] For the partial signature values ​​that have passed verification, the coefficients of the corresponding Lagrange interpolation polynomials are calculated. Based on the coefficients of the Lagrange interpolation polynomials of each partial signature value, the pre-built threshold signature recovery function is used to merge the partial signature values ​​into a complete digital signature value, and a reconstruction proof is generated using the zero-knowledge proof protocol.

[0044] The restored complete digital signature value and reconstruction proof are returned to the requester through a secure channel. After the requester receives the complete digital signature value and reconstruction proof returned by the reconstruction server, it uses a zero-knowledge proof verification algorithm to verify the reconstruction proof.

[0045] According to a second aspect of the embodiments of the present invention,

[0046] Provides a LocalStorage anti-loss system based on proxy mode, including:

[0047] The first unit is used for sending the data to be stored to the proxy server when performing the data storage operation in the browser. After receiving the data to be stored, the proxy server encrypts the data to obtain the encrypted data, forwards the encrypted data to the target server and generates a unique identifier corresponding to the data, and sends the unique identifier to the proxy server;

[0048] The second unit is used for the proxy server to generate a target verification code corresponding to the unique identifier after receiving the unique identifier, send the unique identifier and the target verification code to the browser, and store the unique identifier, the target verification code and the data to be stored in the local storage;

[0049] The third unit is used to read the unique identifier and target verification code of the data to be read from the local storage when performing a data reading operation in the browser, and send them to the proxy server. The proxy server verifies the target verification code. If the verification is successful, the unique identifier of the data to be read is forwarded to the target server. The target server queries the target encrypted data corresponding to the unique identifier of the data to be read from the database and sends it to the proxy server. The proxy server decrypts the target encrypted data, sends the decrypted data to the browser, and stores it in the local storage.

[0050] According to a third aspect of the embodiments of the present invention,

[0051] An electronic device is provided, comprising:

[0052] processor;

[0053] a memory for storing processor-executable instructions;

[0054] The processor is configured to call the instructions stored in the memory to execute the aforementioned method.

[0055] A fourth aspect of the embodiments of the present invention is:

[0056] A computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the aforementioned method is implemented.

[0057] In this embodiment, by encrypting the data to be stored in the proxy server, the target server only stores the encrypted data, and the entire data transmission and storage process is in an encrypted state, which prevents the data from being stolen or peeped during the transmission or storage process, and protects the confidentiality and privacy of the data throughout the process. By associating the unique identifier and the target check code with the data to be stored and storing them locally in the browser, even if the local storage is attacked or tampered with, the proxy server can determine whether the data has been modified by verifying the target check code when reading, thereby ensuring the integrity of the locally stored data. With the help of the browser local storage mechanism, some commonly used data can be directly read from the local copy without having to read from the server every time, which alleviates the reading pressure on the server to a certain extent and improves the throughput and response speed of the overall system. While ensuring data security, it also takes into account the system's high availability, high throughput, good privacy, and future scalability and other requirements. It is a distributed security storage solution with good comprehensive performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] Figure 1 It is a flowchart of a LocalStorage anti-loss method based on a proxy mode according to an embodiment of the present invention;

[0059] Figure 2 It is a structural diagram of a LocalStorage anti-loss system based on a proxy mode according to an embodiment of the present invention. DETAILED DESCRIPTION

[0060] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0061] The technical solution of the present invention is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0062] Figure 1 FIG. 1 is a flow chart of a LocalStorage anti-loss method based on a proxy mode according to an embodiment of the present invention. Figure 1 As shown, the method includes:

[0063] S101. When performing a data storage operation in a browser, the data to be stored is sent to a proxy server. After receiving the data to be stored, the proxy server encrypts the data to obtain the encrypted data, forwards the encrypted data to a target server and generates a unique identifier corresponding thereto, and sends the unique identifier to the proxy server.

[0064] In an optional embodiment,

[0065] After receiving the data to be stored, the proxy server encrypts it, and the encrypted data includes:

[0066] After receiving the data to be stored, the proxy server uses a deep learning algorithm to extract features of the data to be stored and obtains a feature vector of the data to be stored;

[0067] An initial encryption algorithm model is trained according to the feature vector of the data to be stored, and multiple initial encryption algorithm models are aggregated using federated learning technology to obtain the final target encryption algorithm selection model;

[0068] The feature vector of the data to be stored is input into the trained target encryption algorithm selection model, the optimal encryption algorithm is dynamically selected, the data to be stored is encrypted, and the encrypted data is obtained.

[0069] Exemplarily, the data to be stored is first preprocessed, such as removing noise and standardizing, and a deep learning algorithm (such as a convolutional neural network, a recursive neural network, etc.) is used to extract features from the preprocessed data. The data features are automatically extracted through the model, and the features are encoded to obtain a feature vector representation of the data to be stored.

[0070] Design a network structure for the encryption algorithm selection model, such as a multi-layer perceptron (MLP), where the input of the encryption algorithm selection model is the feature vector of the data to be stored, and the output is the probability scores of different encryption algorithms. Select a suitable loss function, such as cross entropy loss, and use an optimization algorithm (such as SGD) to minimize the loss. Train the initial encryption algorithm model locally on each proxy server using the feature vector of the local data.

[0071] A secure communication channel is established between each proxy server, the participant cluster is determined, and the federated learning technology is used to aggregate multiple initial encryption algorithm models to obtain the final target encryption algorithm selection model. Among them, privacy protection mechanisms such as differential privacy and encryption technology can be used to avoid privacy leakage during parameter transmission.

[0072] The data to be stored is input into the feature extraction module to obtain its feature vector representation, and the feature vector is input into the trained target encryption algorithm selection model. The probability scores of various encryption algorithms are output according to the feature vector, and the encryption algorithm with the highest probability score is selected to encrypt the original data to obtain the encrypted data.

[0073] Store the encrypted data in a secure storage medium, collect new data samples regularly, update the feature vector representation of the data to be stored, and use the updated feature vector to repeat iterations to retrain and update the encryption algorithm selection model.

[0074] In an optional embodiment,

[0075] Each proxy server trains an initial encryption algorithm model based on the feature vector of the data to be stored. Using federated learning technology, multiple initial encryption algorithm models are aggregated to obtain the final target encryption algorithm selection model, including:

[0076] Send the feature vector of the data to be stored to the federated learning coordinator;

[0077] The federated learning coordinator receives feature vectors of data to be stored from multiple proxy servers, aggregates the received feature vectors of the data to be stored to form a global feature vector set, and sends the global feature vector set to the proxy servers participating in the federated learning;

[0078] The proxy server trains the encryption algorithm to select the model based on the received global feature vector set, obtains the local model parameters, and sends the local model parameters to the federated learning coordinator;

[0079] The federated learning coordinator securely aggregates the received local model parameters to obtain the final target encryption algorithm selection model.

[0080] Exemplarily, a federated learning coordinator is set up, and each proxy server sends the feature vector of the local data to be stored to the federated learning coordinator, and adopts a secure transmission protocol (such as TLS / SSL) and data encryption technology during the communication process to prevent the feature vector from being stolen. The federated learning coordinator receives feature vectors from all proxy servers, and preprocesses the received feature vectors, such as deduplication and normalization, and aggregates the preprocessed feature vectors into a global feature vector set.

[0081] The federated learning coordinator distributes the constructed global feature vector set to all proxy servers participating in the federated learning. Optionally, a secure communication protocol and data encryption technology are used during the distribution process to prevent the global feature vector set from being stolen.

[0082] After each proxy server receives the global feature vector set, it first trains the encryption algorithm selection model through the stochastic gradient descent optimization algorithm based on the feature vectors of the local data and the global feature vector set. Privacy protection technologies such as differential privacy and homomorphic encryption are used in the training process to prevent the leakage of model parameters. Through iterative training, a privacy-protected local encryption algorithm selection model is obtained.

[0083] Each proxy server uploads the trained local model parameters to the federated learning coordinator. During the upload process, secure communication protocols and data encryption technology are used to prevent the model parameters from being stolen.

[0084] The federated learning coordinator receives the local model parameters uploaded by all proxy servers, aggregates them by weighted averaging or majority voting, and updates the global model parameters as the final target encryption algorithm selection model.

[0085] The federated learning coordinator can distribute the obtained target encryption algorithm selection model to all participants. After each proxy server receives the model, it can replace the local encryption algorithm selection model for subsequent encryption operations.

[0086] In this embodiment, by dynamically selecting the optimal encryption algorithm to encrypt the data, various cryptanalysis attacks can be effectively prevented, greatly improving the security of stored data. Compared with the use of a fixed encryption algorithm, this solution can be flexibly adjusted according to the characteristics of the data, and the cracking difficulty is higher. By adopting federated learning technology, each proxy server does not need to share the original data, but trains the model locally and uploads the parameters for aggregation, thereby effectively protecting data privacy. At the same time, the privacy protection capability is further enhanced through technologies such as differential privacy. Using deep learning algorithms to extract features from data, there is no need for manual participation in tedious feature engineering, and implicit feature patterns in the data can be automatically discovered, improving the quality and efficiency of feature representation. By automatically learning data features through the model, the encryption strategy can be adjusted in time according to new data, with good adaptability and robustness, ensuring long-term data storage security.

[0087] In an optional embodiment,

[0088] Forwarding the encrypted data to the target server and generating a unique identifier corresponding thereto includes:

[0089] The proxy server forwards the encrypted data to the target server, and adds the encrypted data as a new block to the blockchain maintained by the proxy server and the target server. Through the consensus algorithm, a consensus is reached on the newly added block, and the new block is added to the end of the blockchain, and the block hash value of the new block is used as the first identifier;

[0090] Based on the first identifier, according to the sensitivity of the data and the user's access rights, dynamically generate encryption parameters and keys corresponding to the first identifier, and encrypt the first identifier using homomorphic encryption technology according to the generated encryption parameters and keys to obtain a homomorphically encrypted second identifier;

[0091] Based on the second identifier after homomorphic encryption, a multi-party secure computing protocol is introduced to calculate the encryption parameters of the proxy server and the encryption parameters of the target server respectively. The encryption parameters of the proxy server and the encryption parameters of the target server are combined to generate a complete unique identifier.

[0092] Exemplarily, while the proxy server forwards the encrypted data to the target server, it uses blockchain technology to add the encrypted data as a new block to the blockchain maintained by the proxy server and the target server. In the blockchain, each block contains the hash value of the previous block, forming a chain structure. The hash value of the block is obtained by hashing the data in the block, which is unique and irreversible. Therefore, the hash value of the block can be used as a unique identifier of the encrypted data to establish a mapping relationship between data and blocks.

[0093] Specifically, the proxy server packages the encrypted data into a new block and broadcasts the new block to all nodes participating in the blockchain maintenance (proxy server and target server). All nodes execute consensus algorithms, such as proof of work PoW or proof of stake PoS, to verify the new block. Once a consensus is reached, the new block is confirmed and added to the end of the blockchain. Further, the block hash value of the new block is calculated. Optionally, the sensitivity of the encrypted data is evaluated, the corresponding access permission level is determined, and encryption parameters and keys are generated for the proxy server and the target server respectively according to the data sensitivity and access permission, wherein the encryption parameters may include random number seeds, elliptic curve parameters, etc., and the keys may include symmetric keys, private keys, public keys, etc. Finally, the block hash value of the new block is used as the first identifier.

[0094] The encryption parameters and keys of the proxy server and the target server are used to encrypt the first identifier using homomorphic encryption technology to obtain a homomorphically encrypted second identifier, such as an integer-based homomorphic encryption Paillier encryption system or a theoretical lattice-based homomorphic encryption RLWE (Ring Learning Weighted Error) system.

[0095] Select a suitable secure multi-party computing (SMC) protocol, such as the GMW protocol based on encryption sharing. The proxy server uses the SMC protocol to calculate its own encryption parameter share. At the same time, the target server uses the SMC protocol to calculate its own encryption parameter share. The two parties exchange and combine their respective shares to reconstruct a complete unique identifier.

[0096] The encrypted data, the second identifier and the unique identifier are stored in a secure storage system. When the data needs to be accessed later, the unique identifier is used to authenticate and control access to the data. If the data content needs to be read, the second identifier is first decrypted with the unique identifier to obtain the first identifier, and the corresponding block is searched according to the first identifier, and the original data is decrypted to obtain it.

[0097] In this embodiment, by storing the encrypted data in a blockchain jointly maintained by the proxy server and the target server, the data is protected from tampering. At the same time, each block contains the hash value of the previous block, forming a data storage audit link that cannot be forged, ensuring the traceability of the data source. By introducing a multi-party secure computing protocol, the proxy server and the target server are required to each calculate a portion of the encryption parameter share and work together to calculate a complete unique identifier. This collaborative encryption avoids the security risks caused by any single party controlling all the keys alone, and improves the robustness of key management. This embodiment fully combines and utilizes a variety of existing cutting-edge cryptographic technologies to provide all-round security protection for data storage, and achieves multiple technical effects such as data integrity, privacy, access controllability, and fault tolerance. It is an innovative, efficient and reliable data security storage solution.

[0098] In an optional embodiment,

[0099] Dynamically generating encryption parameters and keys corresponding to the first identifier according to the sensitivity of the data and the access rights of the user includes:

[0100] Define a set of attributes, including data sensitivity attributes and user access rights attributes. Classify data sensitivity attributes according to the confidentiality and importance of the data, and classify user access rights attributes according to user identity, role, and security level.

[0101] According to the attribute values ​​in the attribute set, an access structure corresponding to the attribute values ​​is dynamically generated, and according to the sensitivity attribute of the first identifier, different homomorphic encryption algorithms and key lengths are used to encrypt the first identifier to obtain a homomorphically encrypted second identifier;

[0102] A hierarchical deterministic key derivation mechanism is adopted to dynamically derive a first encryption key corresponding to the second identifier according to an attribute value of the second identifier and a master key, and the second identifier, the access structure and the encryption key derivation parameters are stored in association with each other;

[0103] When a data access request is received, it is determined whether the requirements of the access structure are met based on the user attributes in the data access request. If the user attributes meet the requirements of the access structure, a new encryption key is re-derived based on the derivation parameters of the encryption key, and the first identifier is re-encrypted using the new encryption key to achieve adaptive encryption protection.

[0104] For example, when introducing the attribute-based encryption mechanism, a set of attribute sets is first defined, including the sensitivity attribute of the data and the access permission attribute of the user. The sensitivity attribute of the data is graded according to factors such as the confidentiality and importance of the data, and the access permission attribute of the user is divided according to factors such as the user's identity, role, and security level.

[0105] During the encryption process, the corresponding access structure is dynamically generated according to the attribute values ​​in the attribute set. The access structure specifies a set of logical combination conditions of attributes, and only users who meet the conditions can successfully decrypt the data. By flexibly setting the access structure, fine-grained access control and authorization management can be achieved.

[0106] Different homomorphic encryption algorithms and key lengths are used for encryption of data identifiers of different sensitivities. Highly sensitive data identifiers use encryption algorithms with higher security strength (such as homomorphic encryption algorithms based on ideal lattices) and longer keys, while low-sensitivity data identifiers can use relatively efficient homomorphic encryption algorithms (such as homomorphic encryption algorithms based on integers) and shorter keys.

[0107] In terms of key management, a hierarchical deterministic key derivation mechanism (HD Wallets) is introduced to dynamically derive the corresponding encryption key based on the attribute value of the data identifier and a master key. Specifically, an encrypted random number generator is used to generate a sufficiently long master key. The master key, as the root of the HD Wallets system, needs to be highly confidential and can be stored in a hardware security module (HSM). The seed is derived from the master key and used to derive the subsequent subkeys. For the data identifier, a hierarchical tree structure is designed. Each node corresponds to an attribute value of the identifier. The root node of the tree is the first identifier, which corresponds to the block hash value. The HMAC-SHA512 hash algorithm is used to generate subkeys from the parent key (master key or subkey) and the current path (node ​​index). According to the attribute value of the data, the data identifier hierarchical tree is traversed, and the current node index is used to derive new subkeys from the previous subkey in turn until the leaf node of the tree, and the derived key corresponding to the data identifier is finally obtained.

[0108] In addition, when the attributes change or the key is leaked, a key update and re-encryption mechanism is introduced. By updating the master key and attribute value, a new encryption key is generated to re-encrypt the data identifier, ensuring the forward and backward security of the key.

[0109] In this embodiment, by defining sensitivity attributes and access rights attributes, and dynamically generating access structures based on attribute values, fine-grained data access control can be achieved. Different data has different sensitivities, and the corresponding access rights requirements are also different. This solution can finely control who can access which data according to the specific situation, and maximize the privacy of sensitive data. According to the different sensitivity of the data, different homomorphic encryption algorithms and key lengths are used, and adaptive encryption protection can be implemented for data of different importance. By utilizing a hierarchical deterministic key derivation mechanism, the corresponding encryption key is dynamically derived according to the attribute value of the second identifier, and attribute-based key management is achieved. The first identifier is encrypted by homomorphic encryption technology to generate a second identifier, thereby protecting the privacy of the data. At the same time, the encrypted data is stored on the blockchain to ensure the integrity and immutability of the data.

[0110] S102. After receiving the unique identifier, the proxy server generates a target verification code corresponding to the unique identifier, sends the unique identifier and the target verification code to the browser, and stores the unique identifier, the target verification code and the data to be stored in the local storage;

[0111] In an optional embodiment,

[0112] After receiving the unique identifier, the proxy server generates a target verification code corresponding to the unique identifier, including:

[0113] Obtaining the user's biometric information, combining it with the unique identifier, and performing hash calculation on the combined data using a secure hash function to obtain a hash value;

[0114] Get the current timestamp, concatenate the current timestamp with the hash value to generate the data to be signed, and use the threshold key splitting technology to split the private key of the proxy server into multiple subkeys, and store them in multiple key escrow servers. Perform threshold signing on the data to be signed through multiple key escrow servers to generate partial signature values.

[0115] Combine partial signature values ​​generated by multiple key escrow servers and use the threshold signature recovery algorithm to obtain the complete digital signature value;

[0116] Use the pre-shared key, combined with the hash value and timestamp, generate a message authentication code through the hash message authentication code algorithm, combine the generated message authentication code, the complete digital signature value and the timestamp to generate the target check code.

[0117] For example, a biometric identification device (such as a fingerprint scanner, iris scanner, etc.) is first used to collect the user's biometric data, and the biometric feature value is encoded into a binary string for subsequent calculations. The user's biometric information is concatenated with the received unique identifier, and the unique identifier is hashed using a secure hash function (such as SHA-256) to obtain a hash value.

[0118] Get the current precise timestamp of the operating system (such as Unix timestamp), which can be accurate to milliseconds or smaller granularity, and directly concatenate the timestamp with the previously calculated hash value to generate the data to be signed.

[0119] Threshold key splitting technology, such as Shamirs secret sharing algorithm, is applied to split the private key of the proxy server into multiple sub-key shares, and each sub-key is stored in a corresponding independent key escrow server.

[0120] Each key trustee server uses its own stored subkey share to perform partial signature operations on the signed data, such as threshold signature based on ECDSA, to generate the corresponding partial signature value. The proxy server collects different partial signature values ​​and uses a threshold signature recovery algorithm, such as the Lagrange interpolation recovery algorithm, to merge and recover the partial signature values ​​to obtain a complete digital signature value.

[0121] The proxy server and the target server pre-negotiate and share a key, use a standard HMAC algorithm, such as HMAC-SHA256, take the previously calculated hash value and timestamp as input, and combine the shared key to calculate the message authentication code MAC.

[0122] Finally, the complete digital signature value, timestamp and message authentication code MAC are concatenated to form the target check code.

[0123] In an optional embodiment,

[0124] Combining the partial signature values ​​generated by multiple key escrow servers and using the threshold signature recovery algorithm, the complete digital signature value is obtained, including:

[0125] Each key trustee server generates a ciphertext proof using a zero-knowledge proof protocol while generating a partial signature value. The key trustee server sends the generated partial signature value and the corresponding ciphertext proof to the designated reconstruction server through a secure channel.

[0126] After the reconstruction server receives partial signature values ​​and ciphertext proofs from multiple key trustee servers, it uses a multi-party computing protocol to jointly verify the received ciphertext proofs;

[0127] For the partial signature values ​​that have passed verification, the coefficients of the corresponding Lagrange interpolation polynomials are calculated. Based on the coefficients of the Lagrange interpolation polynomials of each partial signature value, the pre-built threshold signature recovery function is used to merge the partial signature values ​​into a complete digital signature value, and a reconstruction proof is generated using the zero-knowledge proof protocol.

[0128] The restored complete digital signature value and reconstruction proof are returned to the requester through a secure channel. After the requester receives the complete digital signature value and reconstruction proof returned by the reconstruction server, it uses a zero-knowledge proof verification algorithm to verify the reconstruction proof.

[0129] Exemplarily, a zero-knowledge proof protocol such as zk-SNARK is first used to generate a ciphertext proof. Specifically, the key escrow server needs to first select a suitable encryption scheme, such as the ElGamal encryption scheme, the Paillier encryption scheme, etc. The key escrow server and the reconstruction server initialize the protocol, establish a secure communication channel, and generate the keys and parameters required for the protocol. The key escrow server determines the input and output definitions of the protocol, including partial signature values, encrypted messages, zero-knowledge proofs, and verification results, and then uses the encryption scheme to encrypt the partial signature values ​​and encrypted messages, generate the corresponding ciphertext, and encapsulate the generated partial signature values ​​and the corresponding ciphertext proof, and then send them to the designated reconstruction server through a secure channel.

[0130] The reconstruction server collects partial signature values ​​and corresponding ciphertext proofs from each key trustee server, and then initializes the protocol, including establishing a secure communication channel, generating keys and parameters required for the protocol, etc. It is necessary to select a suitable multi-party computing protocol, such as the Secure Multi-Party Computation (SMC) protocol. Each key trustee server uses a private key to decrypt the received ciphertext and restore it to plaintext. The reconstruction server and each key trustee server verify the partial signature to ensure the legitimacy of each partial signature value. According to the verification logic, the reconstruction server and each key trustee server interact and calculate according to the steps and calculation logic specified in the protocol. During the calculation process, the participants will provide the required information according to the protocol requirements and perform corresponding calculations and verifications. After the protocol is executed, the reconstruction server obtains the output verification result of the protocol.

[0131] Filter out the partial signature values ​​that have passed the verification from the verification results. These partial signature values ​​will be used to merge and generate the complete digital signature value. According to the requirements of the threshold signature scheme, determine the threshold value and the total number of signature scheme participants. Select multiple partial signature values ​​that have passed the verification as interpolation points. These points will be used to calculate the coefficients of the Lagrange interpolation polynomial. Using the definition of interpolation points and Lagrange interpolation polynomials, calculate the coefficients of the Lagrange interpolation polynomials. These coefficients will be used to merge the partial signature values.

[0132] According to the requirements of the threshold signature scheme, select a suitable threshold signature recovery function. Provide the verified partial signature value and the calculated coefficients of the Lagrange interpolation polynomial as input parameters to the threshold signature recovery function. Then, the threshold signature recovery function will combine and calculate the partial signature value according to the input parameters to generate a complete digital signature value.

[0133] In this embodiment, by adopting the threshold signature technology, the single private key is dispersed and held, thus avoiding the risks of the traditional single-point private key. Even if part of the subkey is leaked, it will not affect the security of the entire signature system, which fundamentally enhances the reliability of the signature. The user's biometric information is combined with the unique identifier to form a dual identity authentication mechanism based on biometrics, which improves the reliability and authenticity of the identity. In the communication process between the key hosting server and the reconstruction server, an anonymous communication protocol such as the Tor network is used, which can effectively hide the real identity and IP address of the communicating parties and protect the identity privacy of the participants. The target check code contains timestamp information, which can effectively defend against replay attacks. The attacker cannot pass the timestamp verification even if he replays the old signature, which ensures the uniqueness of the signature.

[0134] S103. When executing a data reading operation in the browser, the unique identifier and target verification code of the data to be read are read from the local storage and sent to the proxy server. The proxy server verifies the target verification code. If the verification is successful, the unique identifier of the data to be read is forwarded to the target server. The target server queries the target encrypted data corresponding to the unique identifier of the data to be read from the database and sends it to the proxy server. The proxy server decrypts the target encrypted data, sends the decrypted data to the browser, and stores it in the local storage.

[0135] Exemplarily, the browser sends a data read request to the proxy server, and the proxy server reads the unique identifier and target verification code of the data to be read from the local storage. According to the unique identifier of the data to be read, the corresponding target data is obtained from the local storage or other trusted sources. The proxy server uses the same verification algorithm (such as a hash algorithm) to calculate the obtained target data, generates a verification code, and compares the calculated verification code with the received target verification code. If the calculated verification code matches the received target verification code, the verification passes, indicating that the data is complete and legal, and the unique identifier of the data to be read is forwarded to the target server. If the verification code does not match, the verification fails, indicating that the data may be tampered with or illegal.

[0136] After receiving the unique identifier, the target server queries the target encrypted data corresponding to the unique identifier from the database, and the target server sends the queried target encrypted data to the proxy server. The proxy server uses the appropriate decryption algorithm and key to decrypt the target encrypted data to obtain the original data, and then sends the decrypted data to the browser, and the browser stores the received data in the local storage for subsequent use. Among them, the proxy server can select a suitable key for decryption operation. The key can be a symmetric key or an asymmetric key, depending on the encryption algorithm and security scheme used. The proxy server can obtain the key required for decryption from the target server in a secure manner. This can be achieved through a pre-negotiated key exchange protocol, public key encryption algorithm, etc. According to the encryption algorithm and key type of the encrypted data, the proxy server selects a suitable decryption algorithm. If symmetric key encryption is used, a symmetric decryption algorithm such as AES can be selected. If asymmetric key encryption is used, an asymmetric decryption algorithm such as RSA can be selected to restore the ciphertext to the original data.

[0137] In this embodiment, when the proxy server receives a data read request, it verifies the target verification code attached to the request. Since the target verification code contains multiple identity authentication factors such as user biometrics, signature, and timestamp, it can effectively verify the legitimacy of the request, prevent unauthorized access, and achieve refined data read access control. The target verification code is bound to the unique identifier of the data to be read and stored locally in the browser. If the local storage is illegally tampered with, the target verification code will become invalid. By verifying the target verification code, the proxy server can determine whether the data has been modified, ensuring the integrity of the locally stored data. With the help of the browser local storage mechanism, some commonly used data can be read directly from the local without having to obtain it from the remote server every time. This alleviates the reading pressure of the server to a certain extent, reduces system latency, and improves the overall response capability. It not only ensures the security of data transmission and access, but also takes into account the high availability, high responsiveness, good privacy and scalability of the system. It is a safe data reading solution with good comprehensive performance.

[0138] Figure 2 Schematic diagram of the structure of the LocalStorage anti-loss system based on the proxy mode according to an embodiment of the present invention. Figure 2 As shown, the system comprises:

[0139] The first unit is used for sending the data to be stored to the proxy server when performing the data storage operation in the browser. After receiving the data to be stored, the proxy server encrypts the data to obtain the encrypted data, forwards the encrypted data to the target server and generates a unique identifier corresponding to the data, and sends the unique identifier to the proxy server;

[0140] The second unit is used for the proxy server to generate a target verification code corresponding to the unique identifier after receiving the unique identifier, send the unique identifier and the target verification code to the browser, and store the unique identifier, the target verification code and the data to be stored in the local storage;

[0141] The third unit is used to read the unique identifier and target verification code of the data to be read from the local storage when performing a data reading operation in the browser, and send them to the proxy server. The proxy server verifies the target verification code. If the verification is successful, the unique identifier of the data to be read is forwarded to the target server. The target server queries the target encrypted data corresponding to the unique identifier of the data to be read from the database and sends it to the proxy server. The proxy server decrypts the target encrypted data, sends the decrypted data to the browser, and stores it in the local storage.

[0142] According to a third aspect of the embodiments of the present invention,

[0143] An electronic device is provided, comprising:

[0144] processor;

[0145] a memory for storing processor-executable instructions;

[0146] The processor is configured to call the instructions stored in the memory to execute the aforementioned method.

[0147] A fourth aspect of the embodiments of the present invention is:

[0148] A computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the aforementioned method is implemented.

[0149] The present invention may be a method, an apparatus, a system and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for executing various aspects of the present invention.

[0150] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A LocalStorage anti-loss method based on proxy mode, characterized in that: include: When performing a data storage operation in the browser, the data to be stored is sent to the proxy server. After receiving the data to be stored, the proxy server encrypts the data to obtain the encrypted data, forwards the encrypted data to the target server and generates a unique identifier corresponding to the data, and sends the unique identifier to the proxy server. After receiving the unique identifier, the proxy server generates a target verification code corresponding to the unique identifier, sends the unique identifier and the target verification code to the browser, and stores the unique identifier, the target verification code and the data to be stored in the local storage; When performing a data reading operation in the browser, the unique identifier and target verification code of the data to be read are read from the local storage and sent to the proxy server. The proxy server verifies the target verification code. If the verification is successful, the unique identifier of the data to be read is forwarded to the target server. The target server queries the target encrypted data corresponding to the unique identifier of the data to be read from the database and sends it to the proxy server. The proxy server decrypts the target encrypted data and sends the decrypted data to the browser and stores it in the local storage. Forwarding the encrypted data to the target server and generating a unique identifier corresponding thereto includes: The proxy server forwards the encrypted data to the target server, and adds the encrypted data as a new block to the blockchain maintained by the proxy server and the target server. Through the consensus algorithm, a consensus is reached on the newly added block, and the new block is added to the end of the blockchain, and the block hash value of the new block is used as the first identifier; Based on the first identifier, according to the sensitivity of the data and the user's access rights, dynamically generate encryption parameters and keys corresponding to the first identifier, and encrypt the first identifier using homomorphic encryption technology according to the generated encryption parameters and keys to obtain a homomorphically encrypted second identifier; Based on the second identifier after homomorphic encryption, a multi-party secure computing protocol is introduced to calculate the encryption parameters of the proxy server and the target server respectively, and the encryption parameters of the proxy server and the target server are combined to generate a complete unique identifier; After receiving the unique identifier, the proxy server generates a target verification code corresponding to the unique identifier, including: Obtaining the user's biometric information, combining it with the unique identifier, and performing hash calculation on the combined data using a secure hash function to obtain a hash value; Get the current timestamp, concatenate the current timestamp with the hash value to generate the data to be signed, and use the threshold key splitting technology to split the private key of the proxy server into multiple subkeys, and store them in multiple key escrow servers. Perform threshold signing on the data to be signed through multiple key escrow servers to generate partial signature values. Combine the partial signature values ​​generated by multiple key escrow servers and use the threshold signature recovery algorithm to obtain the complete digital signature value; Use the pre-shared key, combined with the hash value and timestamp, generate a message authentication code through the hash message authentication code algorithm, combine the generated message authentication code, the complete digital signature value and the timestamp to generate the target check code.

2. The method according to claim 1, characterized in that After receiving the data to be stored, the proxy server encrypts it and obtains the encrypted data including: After receiving the data to be stored, the proxy server uses a deep learning algorithm to extract features of the data to be stored and obtains a feature vector of the data to be stored; An initial encryption algorithm model is trained according to the feature vector of the data to be stored, and multiple initial encryption algorithm models are aggregated using federated learning technology to obtain the final target encryption algorithm selection model; The feature vector of the data to be stored is input into the trained target encryption algorithm selection model, the optimal encryption algorithm is dynamically selected, the data to be stored is encrypted, and the encrypted data is obtained.

3. The method according to claim 2, characterized in that Each proxy server trains an initial encryption algorithm model based on the feature vector of the data to be stored. Using federated learning technology, multiple initial encryption algorithm models are aggregated to obtain the final target encryption algorithm selection model, including: Send the feature vector of the data to be stored to the federated learning coordinator; The federated learning coordinator receives feature vectors of data to be stored from multiple proxy servers, aggregates the received feature vectors of the data to be stored to form a global feature vector set, and sends the global feature vector set to the proxy servers participating in the federated learning; The proxy server trains the encryption algorithm to select the model based on the received global feature vector set, obtains the local model parameters, and sends the local model parameters to the federated learning coordinator; The federated learning coordinator securely aggregates the received local model parameters to obtain the final target encryption algorithm selection model.

4. The method according to claim 1, characterized in that: Dynamically generating encryption parameters and keys corresponding to the first identifier according to the sensitivity of the data and the access rights of the user includes: Define a set of attributes, including data sensitivity attributes and user access rights attributes. Classify data sensitivity attributes according to the confidentiality and importance of the data, and classify user access rights attributes according to user identity, role, and security level. According to the attribute values ​​in the attribute set, an access structure corresponding to the attribute values ​​is dynamically generated, and according to the sensitivity attribute of the first identifier, different homomorphic encryption algorithms and key lengths are used to encrypt the first identifier to obtain a homomorphically encrypted second identifier; A hierarchical deterministic key derivation mechanism is adopted to dynamically derive a first encryption key corresponding to the second identifier according to an attribute value of the second identifier and a master key, and the second identifier, the access structure and the encryption key derivation parameters are stored in association with each other; When a data access request is received, it is determined whether the requirements of the access structure are met based on the user attributes in the data access request. If the user attributes meet the requirements of the access structure, a new encryption key is re-derived based on the derivation parameters of the encryption key, and the first identifier is re-encrypted using the new encryption key to achieve adaptive encryption protection.

5. The method according to claim 1, characterized in that Combining the partial signature values ​​generated by multiple key escrow servers and using the threshold signature recovery algorithm, the complete digital signature value is obtained, including: Each key trustee server generates a ciphertext proof using a zero-knowledge proof protocol while generating a partial signature value. The key trustee server sends the generated partial signature value and the corresponding ciphertext proof to the designated reconstruction server through a secure channel. After the reconstruction server receives partial signature values ​​and ciphertext proofs from multiple key trustee servers, it uses a multi-party computing protocol to jointly verify the received ciphertext proofs; For the partial signature values ​​that have passed verification, the coefficients of the corresponding Lagrange interpolation polynomials are calculated. Based on the coefficients of the Lagrange interpolation polynomials of each partial signature value, the pre-built threshold signature recovery function is used to merge the partial signature values ​​into a complete digital signature value, and a reconstruction proof is generated using the zero-knowledge proof protocol. The restored complete digital signature value and reconstruction proof are returned to the requester through a secure channel. After the requester receives the complete digital signature value and reconstruction proof returned by the reconstruction server, it uses a zero-knowledge proof verification algorithm to verify the reconstruction proof.

6. A LocalStorage anti-loss system based on proxy mode, used to implement the method described in any one of claims 1 to 5, characterized in that: include: The first unit is used for sending the data to be stored to the proxy server when performing the data storage operation in the browser. After receiving the data to be stored, the proxy server encrypts the data to obtain the encrypted data, forwards the encrypted data to the target server and generates a unique identifier corresponding to the data, and sends the unique identifier to the proxy server; The second unit is used for the proxy server to generate a target verification code corresponding to the unique identifier after receiving the unique identifier, send the unique identifier and the target verification code to the browser, and store the unique identifier, the target verification code and the data to be stored in the local storage; The third unit is used to read the unique identifier and target verification code of the data to be read from the local storage when performing a data reading operation in the browser, and send them to the proxy server. The proxy server verifies the target verification code. If the verification is successful, the unique identifier of the data to be read is forwarded to the target server. The target server queries the target encrypted data corresponding to the unique identifier of the data to be read from the database and sends it to the proxy server. The proxy server decrypts the target encrypted data, sends the decrypted data to the browser, and stores it in the local storage.

7. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to call the instructions stored in the memory to execute the method described in any one of claims 1 to 5.

8. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 5 is implemented.