A method and device for processing time series data

By encrypting time series data at the data block level and building ciphertext indexes, the security issues of time series data in cloud storage and access are solved, and data confidentiality and legal access control are achieved.

CN119004507BActive Publication Date: 2025-09-09WEBANK (CHINA)
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411091424.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-09
Publication Date
2025-09-09
Estimated Expiration
2044-08-09

AI Technical Summary

Technical Problem

In existing technologies, time series data has security risks during transmission and storage, especially the possibility of data leakage and theft when the cloud database is compromised, which cannot effectively protect the confidentiality of time series data.

Method used

The time series data is divided into multiple data blocks, and each data block is encrypted using a key set and stored as data ciphertext. Homomorphic encryption and summary operations are supported, and a ciphertext index with a K-ary tree structure is constructed to achieve fine-grained data access control.

Benefits of technology

Even if the time series database is compromised, attackers cannot obtain plaintext data, which improves the security of time series data. It also eliminates the concerns of data owners through fine-grained access control, ensuring the legitimacy and security of data access.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119004507B_ABST
    Figure CN119004507B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention provides a time series data processing method and apparatus for improving the security of time series data. The method includes: a first device obtains time series data to be stored, and divides the time series data to be stored into N data blocks according to a preset time interval, where N is a positive integer; obtains a first key set from a server, where the first key set includes at least N first keys; for the i-th data block in the N data blocks, encrypts the i-th data block according to the i-th first key in the first key set to obtain a data ciphertext corresponding to the i-th data block, where i is an integer between 1 and N; and sends encrypted data to the server, where the encrypted data includes the data ciphertext corresponding to each of the N data blocks, and the encrypted data is used to store in a time series database on the server. This allows encrypted data to be stored in the time series database, thereby improving the security of the time series data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and more particularly to a method and apparatus for processing time series data. Background Art

[0002] With the development of the Internet, the Industrial Internet of Things, and artificial intelligence, more and more devices and services are storing collected time series data in the cloud. For example, this data is stored in a cloud-based time series database for query and analysis by third-party applications. Because the time series data collected by devices contains a large amount of data that may leak users' personal privacy, it is crucial to ensure the confidentiality of this data while ensuring its availability.

[0003] In related technologies, data producers send time series data to the cloud through encrypted channels to ensure the security of the time series data during transmission. The time series data is then stored in plaintext in a time series database. On the one hand, there are currently a variety of attack methods targeting various cloud platforms. Once a time series database is compromised, the time series data will be leaked, and the security of time series data cannot be guaranteed in data storage scenarios. On the other hand, time series databases can also provide data query and analysis services for data users. Currently, authorized data users can access all plaintext data in the time series database, which poses a risk of time series data being stolen in data access scenarios. Therefore, there is an urgent need for a time series data processing method to improve the security of time series data. Summary of the Invention

[0004] Embodiments of the present invention provide a time series data processing method and apparatus to improve the security of time series data.

[0005] In a first aspect, an embodiment of the present invention provides a time series data processing method, which is applied to a first device, and includes: obtaining time series data to be stored, and dividing the time series data to be stored into N data blocks according to a preset time interval, where N is a positive integer; obtaining a first key set from a server, where the first key set includes at least N first keys; for the i-th data block in the N data blocks, encrypting the i-th data block according to the i-th first key in the first key set to obtain a data ciphertext corresponding to the i-th data block, where i is an integer between 1 and N; sending encrypted data to the server, where the encrypted data includes the data ciphertexts corresponding to the N data blocks, and the encrypted data is used to store in a time series database in the server.

[0006] Through this solution, time series data is stored in the time series database in the form of data ciphertext. Even if the time series database is hacked, the attacker cannot obtain the plaintext data corresponding to the encrypted data even if he obtains the encrypted data in the time series database, thereby improving the security of the time series data.

[0007] Optionally, the encrypted data also includes a set of homomorphic ciphertexts corresponding to N data blocks, wherein the set of homomorphic ciphertexts corresponding to the i-th data block includes P homomorphic ciphertexts corresponding to the i-th data block; before sending the encrypted data to the server, it also includes: for the i-th data block in the N data blocks, executing: performing preset P statistical operations on the i-th data block respectively to obtain P statistical values ​​corresponding to the i-th data block; according to the second key corresponding to the i-th data block, homomorphically encrypting the P statistical values ​​corresponding to the i-th data block respectively to obtain P homomorphic ciphertexts corresponding to the i-th data block; the second key corresponding to the i-th data block is determined based on the i-th first key and the i+1-th first key in the first key set.

[0008] Optionally, the encrypted data also includes a digest set corresponding to each of the N data blocks, wherein the digest set corresponding to the i-th data block includes the digest of each homomorphic ciphertext in the homomorphic ciphertext set corresponding to the i-th data block; before sending the encrypted data to the server, it also includes: for the j-th homomorphic ciphertext in the homomorphic ciphertext set corresponding to the i-th data block, executing: determining the digest corresponding to the j-th homomorphic ciphertext based on the j-th homomorphic ciphertext, the second key corresponding to the i-th data block, the digest key and the first public parameter, where j is an integer from 1 to P.

[0009] In a second aspect, an embodiment of the present invention provides a time series data processing method, which is applied to a server, and the server includes a time series database; the method includes: sending a first key set to a first device, the first key set including N first keys, where N is a positive integer; receiving encrypted data sent by the first device, the encrypted data including data ciphertexts corresponding to N data blocks, the N data blocks being the time series data to be stored divided according to a preset time interval, the data ciphertext corresponding to the i-th data block in the N data blocks being obtained by encrypting the i-th data block using the i-th first key in the first key set, where i is an integer ranging from 1 to N; and storing the encrypted data in the time series database. By storing the time series data in the time series database as data ciphertext, even if the time series database is hacked, the attacker cannot obtain the data plaintext corresponding to the encrypted data even if he obtains the encrypted data in the time series database, thereby improving the security of the time series data.

[0010] Optionally, the encrypted data also includes a set of homomorphic ciphertexts corresponding to the N data blocks; wherein the set of homomorphic ciphertexts corresponding to the i-th data block includes: P homomorphic ciphertexts corresponding to the i-th data block, the P homomorphic ciphertexts are obtained by homomorphically encrypting the P statistical values ​​corresponding to the i-th data block according to the second key corresponding to the i-th data block, and the P statistical values ​​corresponding to the i-th data block are obtained by performing preset P statistical operations on the i-th data block.

[0011] Optionally, the encrypted data also includes a digest set corresponding to N data blocks respectively; wherein, the digest set corresponding to the i-th data block includes the digest corresponding to each homomorphic ciphertext in the homomorphic ciphertext set corresponding to the i-th data block, and the j-th digest in the digest set corresponding to the i-th data block is obtained based on the j-th homomorphic ciphertext in the homomorphic ciphertext set corresponding to the i-th data block, the second key corresponding to the i-th data block, the digest key and the first public parameter, and j is an integer from 1 to P.

[0012] Optionally, storing the encrypted data in a time series database includes: storing the data ciphertexts corresponding to the N data blocks in a disk corresponding to the time series database, and storing the homomorphic ciphertext sets corresponding to the N data blocks and the summary sets corresponding to the N data blocks in a memory corresponding to the time series database.

[0013] Optionally, the homomorphic ciphertext sets corresponding to the N data blocks and the summary sets corresponding to the N data blocks are stored in the memory corresponding to the time series database, including: constructing a ciphertext index in the memory corresponding to the time series database according to the received homomorphic ciphertext sets corresponding to the N data blocks and the summary sets corresponding to the N data blocks; wherein the ciphertext index is a K-ary tree structure, the i-th leaf node in the K-ary tree structure is used to store the homomorphic ciphertext set corresponding to the i-th data block and the summary set corresponding to the i-th data block, the first parent node in the K-ary tree structure is used to store the aggregation value of the homomorphic ciphertext set stored in each child node of the first parent node and the aggregation value of the summary set stored in each child node of the first parent node, and the first parent node is any parent node in the K-ary tree structure.

[0014] In a third aspect, an embodiment of the present invention provides a method for processing time series data, which is applied to a server, and the server includes a time series database; the method includes: receiving a data query request sent by a third device, the data query request includes a first time range and a first query operation; if the first time range and the first query operation are within the access rights indicated by the access control information, performing the first query operation on the encrypted data of the first time range in the time series database to obtain a ciphertext result corresponding to the first query operation; sending the ciphertext result corresponding to the first query operation to the third device; receiving a key request sent by the third device, the key request is used to request the key corresponding to the accessed encrypted data; and sending a first credential ciphertext to the third device according to the key request.

[0015] Through this solution, when a third device queries the time series database, it can only access the time series database within the access permissions allowed by the data owner. Compared with access policies that only support database-level or data table-level access policies, the time series database in this solution supports data queries at the data block level, which can achieve fine-grained data access control, thereby eliminating the data owner's concerns about data access and improving the security of time series data.

[0016] Optionally, the server also includes a key management service, and the method also includes: receiving access control information sent by the second device, the access control information is used to indicate the access rights authorized for the third device to access the time series database, the access rights including the time range corresponding to the encrypted data allowed to be accessed by the third device and the allowed query operations; determining the decryption key corresponding to the access control information based on the first key set and the access control information; encrypting the decryption key corresponding to the access control information using the public key of the third device to obtain a first credential ciphertext; and storing the first credential ciphertext in the key management service.

[0017] Optionally, the first query operation is an ALL operation, and the ciphertext result corresponding to the first query operation includes data ciphertexts corresponding to L data blocks within a first time range in the time series database.

[0018] Optionally, the first query operation includes a first statistical operation, which is at least one of P statistical operations; performing the first query operation on the encrypted data in the first time range in the time series database to obtain the ciphertext result corresponding to the first query operation, including: querying the homomorphic ciphertext set and summary set corresponding to the L data blocks in the first time range in the time series database, and determining a first aggregation result and a second aggregation result, wherein the first aggregation result is the aggregation value of the homomorphic ciphertext set corresponding to the L data blocks, and the second aggregation result is the aggregation value of the summary set corresponding to the L data blocks; using the first aggregation result and the second aggregation result as the ciphertext result corresponding to the first query operation.

[0019] Optionally, querying the homomorphic ciphertext sets and digest sets corresponding to L data blocks within a first time range in the time series database, and determining a first aggregation result and a second aggregation result, includes: traversing L leaf nodes belonging to the first time range in a K-ary tree structure, and adding them to an aggregation set; performing a first operation on each node in the aggregation set, wherein performing the first operation on the first node includes: accessing the parent node of the first node, recording the number of times the parent node of the first leaf node is accessed, and adding the parent node of the first node to the parent node set; the first node is any node in the aggregation set; A second operation is performed on each parent node in the parent node set, wherein the second operation performed on the first parent node includes: determining the number of times the first parent node is visited; if the number of times the first parent node is visited is equal to K, transferring the first parent node from the parent node set to the aggregation set, and deleting all child nodes of the first parent node from the aggregation set; the first parent node is any parent node in the parent node set; the aggregation value of the homomorphic ciphertext set stored by each node in the aggregation set is determined as the first aggregation result; the aggregation value of the summary set stored by each node in the aggregation set is determined as the second aggregation result.

[0020] In a fourth aspect, an embodiment of the present invention provides a time series data processing method, which is a time series data processing method applied to a third device, and includes: sending a data query request to a server, the data query request including a first time range and a first query operation; the query request is used to request the time series database in the server to perform a first query operation on the encrypted data in the first time range; receiving a ciphertext result corresponding to the first query operation sent by the server; sending a key request to the server, the key request is used to request a decryption key corresponding to the accessed encrypted data; receiving a first credential ciphertext sent by the server, the first credential ciphertext is sent when the server determines that the first time range and the first query operation are within the access rights indicated by the access control information; decrypting the first credential ciphertext according to the private key of the third device to obtain a first decryption key; determining the plaintext result corresponding to the first query operation according to the ciphertext result corresponding to the first query operation and the first decryption key.

[0021] Through this solution, when a third device queries the time series database, it can only access the time series database within the access permissions allowed by the data owner. Compared with access policies that only support database-level or data table-level access policies, the time series database in this solution supports data queries at the data block level, which can achieve fine-grained data access control, thereby eliminating the data owner's concerns about data access and improving the security of time series data.

[0022] Optionally, the first query operation is an ALL operation; the ciphertext result corresponding to the first query operation includes the data ciphertexts corresponding to the L data blocks within the first time range in the time series database; the first decryption key includes L first keys, and the data ciphertexts corresponding to the L data blocks are obtained by encrypting the L data blocks according to the L first keys; according to the ciphertext result corresponding to the first query operation and the first decryption key, determining the plaintext result corresponding to the first query operation, including: for the data ciphertext corresponding to the f-th data block among the L data blocks, executing: according to the f-th first key among the L first keys, decrypting the data ciphertext corresponding to the f-th data block to obtain the data plaintext of the f-th data block; wherein, f is an integer between 1 and L.

[0023] Optionally, the first query operation includes a first statistical operation; the ciphertext result corresponding to the first query operation includes a first aggregation result and a second aggregation result, wherein the first aggregation result is the aggregation value of the homomorphic ciphertext set corresponding to the L data blocks within the first time range in the time series database, and the second aggregation result is the aggregation value of the summary set corresponding to the L data blocks, and the homomorphic ciphertext set corresponding to the f-th data block in the L data blocks is obtained by homomorphically encrypting the P statistical values ​​corresponding to the f-th data block according to the second key corresponding to the f-th data block; the j-th summary in the summary set corresponding to the f-th data block is determined based on the j-th homomorphic ciphertext in the homomorphic ciphertext set corresponding to the f-th data block, the second key corresponding to the f-th data block, the summary key and the first public parameter; the first decryption key includes a first key difference, and the first key difference is the difference between the first key corresponding to the first data block in the L data blocks and the first key corresponding to the next data block of the L data blocks.

[0024] Optionally, the method also includes: performing integrity verification on the first aggregation result based on the first aggregation result, the second aggregation result, the first decryption key and the second public parameter; determining the plaintext result corresponding to the first query operation based on the ciphertext result corresponding to the first query operation and the first decryption key, including: if the result of the integrity verification is valid, determining the plaintext result corresponding to the first query operation based on the ciphertext result corresponding to the first query operation and the first decryption key.

[0025] Optionally, an integrity check is performed on the first aggregation result based on the first aggregation result, the second aggregation result, the first decryption key and the second public parameter, including: determining a key check value based on the first aggregation result, the second aggregation result and the second public parameter; if it is determined that the first decryption key is equal to the key check value, then determining that the result of the integrity check is valid; or, if it is determined that the first decryption key is not equal to the key check value, then determining that the result of the integrity check is invalid.

[0026] Optionally, based on the ciphertext result corresponding to the first query operation and the first decryption key, the plaintext result corresponding to the first query operation is determined, including: decrypting the first aggregation result according to the first key difference to obtain the plaintext result corresponding to the first aggregation result, the plaintext result corresponding to the first aggregation result includes P statistical aggregation values, the j-th statistical value among the P statistical aggregation values ​​is the aggregation value of the j-th statistical values ​​corresponding to the L data blocks within the first time range, where j is an integer from 0 to P; based on the plaintext result corresponding to the first aggregation result and the first query operation, the plaintext result corresponding to the first query operation is determined.

[0027] In the fifth aspect, an embodiment of the present invention provides a time series data processing method, which is applied to a second device, and the method includes: receiving an access authorization request sent by a third device, the access authorization request is used to request authorized access rights; based on the access authorization request, generating access control information, the access control information is used to indicate the access rights authorized for the third device to access the time series database, the access rights include the time range corresponding to the encrypted data allowed to be accessed by the third device and the allowed query operations; sending the access control information to the server.

[0028] Optionally, the allowed query operation includes an ALL operation; the ALL operation is used to access all data blocks within a time range allowed for access.

[0029] Optionally, the allowed query operations include at least one of the following statistical operations:

[0030] SUM operation: The SUM operation is used to count the data within the time range allowed for access;

[0031] AVG operation: The AVG operation is used to calculate the average value of data within the time range allowed for access;

[0032] COUNT operation: The COUNT operation is used to count the number of data items within the time range allowed for access;

[0033] VAR operation,VAR operation is used to count the variance of data blocks within the time range allowed for access;

[0034] STDEV operation, the STDEV operation is used to count the covariance of data within the time range that can be accessed;

[0035] MAX operation: The MAX operation is used to count the data with the highest number of occurrences within the time range allowed for access;

[0036] MIN operation: The MIN operation is used to count the data with the least number of occurrences within the time range allowed for access.

[0037] In a sixth aspect, an embodiment of the present invention further provides a device, including:

[0038] an acquisition unit, configured to acquire time series data to be stored, and divide the time series data to be stored into N data blocks according to a preset time interval, where N is a positive integer; and acquire a first key set from a server, where the first key set includes at least N first keys;

[0039] a processing unit, configured to encrypt, for an i-th data block among the N data blocks, the i-th data block according to the i-th first key in the first key set, to obtain a data ciphertext corresponding to the i-th data block, where i is an integer between 1 and N;

[0040] The communication unit is used to send encrypted data to the server. The encrypted data includes data ciphertexts corresponding to N data blocks. The encrypted data is used to store in the time series database in the server.

[0041] In a seventh aspect, an embodiment of the present invention further provides a device, including:

[0042] A communication unit is used to send a first key set to a first device, where the first key set includes N first keys, where N is a positive integer; receive encrypted data sent by the first device, where the encrypted data includes data ciphertexts corresponding to N data blocks, where the N data blocks are time series data to be stored and are divided according to preset time intervals, and the data ciphertext corresponding to the i-th data block in the N data blocks is obtained by encrypting the i-th data block using the i-th first key in the first key set, where i is an integer between 1 and N; and a processing unit is used to store the encrypted data in a time series database.

[0043] In an eighth aspect, an embodiment of the present invention further provides a device, including:

[0044] a communication unit, configured to receive a data query request sent by a third device, the data query request including a first time range and a first query operation;

[0045] a processing unit, configured to, if the first time range and the first query operation are within the access rights indicated by the access control information, perform the first query operation on the encrypted data in the first time range in the time series database to obtain a ciphertext result corresponding to the first query operation;

[0046] The communication unit is also used to send the ciphertext result corresponding to the first query operation to the third device; receive the key request sent by the third device, the key request is used to request the key corresponding to the accessed encrypted data; and send the first credential ciphertext to the third device according to the key request.

[0047] In a ninth aspect, an embodiment of the present invention further provides a device, including:

[0048] A communication unit is configured to send a data query request to a server, the data query request including a first time range and a first query operation; the query request is configured to request a time series database in the server to perform the first query operation on encrypted data within the first time range; receive a ciphertext result corresponding to the first query operation sent by the server; send a key request to the server, the key request being configured to request a decryption key corresponding to the accessed encrypted data; and receive a first credential ciphertext sent by the server, the first credential ciphertext being sent when the server determines that the first time range and the first query operation are within the access rights indicated by the access control information;

[0049] The processing unit is configured to decrypt the first credential ciphertext according to the private key of the third device to obtain a first decryption key; and determine the plaintext result corresponding to the first query operation according to the ciphertext result corresponding to the first query operation and the first decryption key.

[0050] In a tenth aspect, an embodiment of the present invention further provides a device, including:

[0051] a communication unit, configured to receive an access authorization request sent by a third device, the access authorization request being used to request authorization of access rights;

[0052] a processing unit, configured to generate access control information based on the access authorization request, where the access control information is used to indicate access rights authorized for the third device to access the time series database, where the access rights include a time range corresponding to the encrypted data that the third device is allowed to access and permitted query operations;

[0053] The processing unit is further configured to send access control information to the server.

[0054] In an eleventh aspect, an embodiment of the present invention provides a computing device, including:

[0055] a memory for storing program instructions;

[0056] The processor is used to call the program instructions stored in the memory and execute the method steps in any implementation of the first to third aspects according to the obtained program.

[0057] In the twelfth aspect, an embodiment of the present invention provides a computer-readable storage medium, which stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the method steps in any implementation method of the above-mentioned first to third aspects. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0059] Figure 1 A schematic diagram of a system architecture provided by an embodiment of the present invention;

[0060] Figure 2 A flowchart of a time series data processing method provided by an embodiment of the present invention;

[0061] Figure 3 A flowchart of a time series data processing method provided by an embodiment of the present invention;

[0062] Figure 4 A flowchart of a time series data processing method provided by an embodiment of the present invention;

[0063] Figure 5 A schematic diagram of a ciphertext index provided by an embodiment of the present invention;

[0064] Figure 6 A schematic diagram of a ciphertext index provided by an embodiment of the present invention;

[0065] Figure 7 A schematic structural diagram of a device provided in an embodiment of the present invention;

[0066] Figure 8 A schematic structural diagram of a device provided in an embodiment of the present invention;

[0067] Figure 9 A schematic structural diagram of a device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0068] To make the objectives, technical solutions, and advantages of the present invention more apparent, the present invention will be further described in detail below with reference to the accompanying drawings. It is apparent that the embodiments described are only some of the embodiments of the present invention, rather than all of them. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without creative effort are intended to fall within the scope of protection of the present invention.

[0069] Figure 1 A system architecture is provided for an embodiment of the present invention. Figure 1As shown, the system architecture may include a data owner 101, a data producer 102, a storage service 103, and a data user 104. It should be understood that this application does not limit the number of data producers 102 and data users 104 included in the system architecture.

[0070] The data producer 101 is a device or service that generates and encrypts time series data, and can obtain the data encryption key from the key management service in the storage service 103 .

[0071] The data owner 101 has access rights to the time series data generated by the data producer and is responsible for data authorization, such as authorizing access rights to the data user 104. The authorization operation is performed at the granularity of data blocks. The granularity of data blocks in this application is configurable, such as 1 second, 1 minute, etc.

[0072] The storage service 103 includes a key management service and a time series database. The data key management service is responsible for generating a key for each data block, and the time series database is responsible for storing encrypted time series data and running data analysis operations such as summation, averaging, and variance based on the encrypted data.

[0073] The data user 104 can initiate operations such as data query and data analysis within the scope of authority set by the data owner, and use the authorized key to decrypt the obtained ciphertext data to obtain the plaintext result.

[0074] It should be noted that the above Figure 1 The structure shown is only an example and is not limited in the embodiments of the present invention. The embodiments of the present application can be applied to data storage and data access scenarios.

[0075] Based on the above description, the time series data processing method is introduced below.

[0076] Figure 2 The flow chart of a time series data processing method provided by an embodiment of the present invention is shown as an example. Figure 2 As shown, the method flow includes:

[0077] In step 201 , a first device obtains time series data to be stored, and divides the time series data to be stored into N data blocks according to a preset time interval, where N is a positive integer.

[0078] The first device may be Figure 1 The data producer 102, a first device, can collect time series data. Time series data, also known as time series data, is a series of data generated continuously over time, i.e., data with timestamps. Time series data can include, but is not limited to, metrics from servers and applications, data from sensors such as those in the Internet of Things (IoT), and stock market data.

[0079] In one example, for example, the first device collects [t0,t k ] time series data within the time range, denoted as D, where k is a positive integer. The time series data D is divided into multiple data blocks according to a certain time interval. For example, the data within the time range of t0 to t1 is recorded as data block D0, the data within the time range of t1 to t2 is recorded as data block D1, and so on. k-1 to t k The data within the time range is recorded as data block D k-1 The time series data D collected by the first device can be divided into k data blocks, namely: D0, D1, ... D k-2 ,D k-1 .

[0080] In step 202 , the first device obtains a first key set from a server, where the first key set includes at least N first keys.

[0081] In a specific implementation, a first device may send a first request to a server, the first request including the number of keys requested from the server. The server includes a key management service. Then, the key management service in the server sends a first key set to the first device based on the number of keys requested by the server. For example, if the number of keys requested in the first request is N, the first key set includes N first keys; or for another example, if the number of keys requested in the first request is N+1, the first key set includes N+1 first keys.

[0082] In the above example [t0,t k ] Take k data blocks corresponding to the time series data D within the time range as an example, the first key set obtained by the first device from the key management service in the server includes at least k keys, which are recorded as {K0, K1, ...K k-2 ,K k-1 Of course, the first key set may include more keys, such as K k , and can also include more keys. The number of keys included in the first key set can be determined according to the first request sent by the first device. The number of keys set in the first request can be set according to the number of data blocks into which the time series data to be stored is divided by the first device. There is no restriction here.

[0083] In step 203 , the first device encrypts the i-th data block among the N data blocks according to the i-th first key in the first key set to obtain a data ciphertext corresponding to the i-th data block.

[0084] In the above step 203, i is an integer between 1 and N. That is, step 203 is performed once for each of the N data blocks, so that the data ciphertexts corresponding to the N data blocks can be obtained.

[0085] Take the above k data blocks D0, D1, ...D k-2 ,D k-1 Data block D in i For example, the first device uses the key set {K0, K1, ...K k-2 ,K k-1 K in i , using AES symmetric encryption algorithm to encrypt D i Encrypt and get data block D i Corresponding data ciphertext CipherBlock i That is, the first device uses the first key K0 to symmetrically encrypt the data block D0, and obtains the data ciphertext CipherBlock0 corresponding to the data block D0; uses the first key K1 to symmetrically encrypt the data block D1, and obtains the data ciphertext CipherBlock1 corresponding to the data block D1; uses the first key K2 to symmetrically encrypt the data block D2, and obtains the data ciphertext CipherBlock2 corresponding to the data block D2; and so on. k-1 For data block D k-1 Perform symmetric encryption to obtain data block D k-1 Corresponding data ciphertext CipherBloc k-1 . Thus, the data ciphertext corresponding to the k data blocks is:

[0086] CipherBlock0, CipherBlock1,…, CipherBlock k-1 .

[0087] In step 204 , the first device sends encrypted data to the server. The encrypted data includes data ciphertexts corresponding to the N data blocks. The encrypted data is used to store in a time series database in the server.

[0088] Accordingly, the server receives the encrypted data sent by the first device and stores the encrypted data in the time series database. In one possible implementation, the encrypted data includes ciphertext data corresponding to N data blocks. The server stores the ciphertext data corresponding to the N data blocks in the time series database. Since the ciphertext data corresponding to the N data blocks is relatively large, it can be stored on the disk corresponding to the time series database, which has sufficient space to accommodate the ciphertext data.

[0089] In another possible implementation, the encrypted data in the above step 204 includes, in addition to the data ciphertexts corresponding to the N data blocks, also a set of homomorphic ciphertexts corresponding to the N data blocks, where the set of homomorphic ciphertexts corresponding to the i-th data block includes P homomorphic ciphertexts corresponding to the i-th data block, and i is an integer between 1 and N.

[0090] In this embodiment, before sending the encrypted data to the server, the first device performs the following steps S11 and S12 for the i-th data block among the N data blocks. Here, i is an integer between 1 and N. That is, steps S11 and S12 are performed once for each data block among the N data blocks:

[0091] S11, the first device performs P preset statistical operations on the i-th data block to obtain P statistical values ​​corresponding to the i-th data block;

[0092] S12, the first device homomorphically encrypts the P statistical values ​​corresponding to the i-th data block according to the second key corresponding to the i-th data block, and obtains P homomorphic ciphertexts corresponding to the i-th data block; wherein, the second key corresponding to the i-th data block is determined based on the i-th first key and the i+1-th first key in the first key set.

[0093] In the above S11, the preset P statistical operations include at least one of the following:

[0094] (1) SUM operation: The SUM operation is used to calculate the sum of data;

[0095] (2) Average (AVG) operation, which is used to calculate the average value of a data;

[0096] (3) Counting data items (COUNT) operation: COUNT operation is used to count data items;

[0097] (4) VAR operation, which is used to calculate the variance of statistical data;

[0098] (5) STDEV operation, which is used to calculate the covariance of statistical data;

[0099] (6) Maximum value (MAX) operation, which is used to count the data with the most occurrences;

[0100] (7) Minimum value (MIN) operation: MIN operation is used to count the data with the least number of occurrences;

[0101] (8) TOP X operation: The TOP X operation is used to count the top X percent of data in the data arranged in descending order.

[0102] The second key corresponding to the i-th data block in the above step S12 is, for example, the i-th first key (K i ) and the i+1th first key (K i+1 ), that is, the following formula (1):

[0103] K=K i -K i+1 Formula (1);

[0104] The jth statistical value m among the P statistical values ​​corresponding to the i-th data block ij The corresponding homomorphic ciphertext C ij The calculation formula is as follows:

[0105] C ij =m ij +K mod M formula (2);

[0106] In formula (2), m ij is the jth statistical value among the P statistical values ​​corresponding to the i-th data block, C ij is the homomorphic ciphertext obtained by homomorphically encrypting the jth statistical value among the P statistical values ​​corresponding to the i-th data block, K is the second key corresponding to the i-th data block, M is the plaintext space, which is a public parameter. If the plaintext statistical result range is [0,2 n ], then M=2 n .

[0107] For the i-th data block, when using formula (2) to calculate the homomorphic ciphertext of each corresponding statistical value, the K value substituted into formula (2) is the same, which is K i -K i+1 , M value is also the same. For different data blocks, when using formula (2) to calculate the j-th statistical value corresponding to different data blocks, the K value substituted into formula (2) is different, but the M value is the same. For example, when calculating the j-th statistical value corresponding to the i-th data block, the K value substituted into formula (2) is K i -K i+1 , when calculating the jth statistical value corresponding to the i+1th data block, the K value entered into formula (2) is K i+1 -K i+2 .

[0108] The homomorphic ciphertext set corresponding to the i-th data block is denoted as CipherStat i , including the homomorphic ciphertext of P statistical values ​​corresponding to the i-th data block, that is, the following formula (3):

[0109] CipherStat i ={c i0,c i1 ,..,c i(P-1)} Formula (3);

[0110] The specific method for determining the homomorphic ciphertext set corresponding to other data blocks among the N data blocks except the i-th data block can refer to the relevant description of the homomorphic ciphertext set corresponding to the i-th data block, which will not be repeated here.

[0111] Taking P statistical operations including a SUM operation, an AVG operation, a COUNT operation, and a VAR operation as an example, the above steps S11 and S12 are illustrated.

[0112] For example, the i-th data block is the k data blocks D0, D1, ... D in the above example. k-2 ,D k-1 For the data block D1 in the data block, the corresponding second key can be determined by K1 and K2, for example, the difference between K1 and K2.

[0113] The above S11 can be implemented in the following manner: the first device performs SUM operation, AVG operation, COUNT operation and VAR operation on the data block D1 respectively to obtain the SUM statistical value, AVG statistical value, COUNT statistical value and VAR statistical value corresponding to the data block D1 respectively.

[0114] The above S12 can be implemented in the following manner: the first device performs homomorphic encryption on the SUM statistical value, AVG statistical value, COUNT statistical value and VAR statistical value corresponding to the data block D1 according to K1-K2, and obtains the homomorphic ciphertext of the SUM statistical value corresponding to the data block D1, the homomorphic ciphertext of the AVG statistical value corresponding to the data block D1, the homomorphic ciphertext of the COUNT statistical value corresponding to the data block D1, and the homomorphic ciphertext of the VAR statistical value corresponding to the data block D1.

[0115] In this embodiment, the data ciphertexts corresponding to the N data blocks can be stored in the disk corresponding to the time series database, and the server can store the homomorphic ciphertext sets corresponding to the N data blocks in the memory corresponding to the time series database.

[0116] In another possible implementation, the encrypted data in the above step 204 may include, in addition to the data ciphertexts corresponding to the N data blocks, a homomorphic ciphertext set corresponding to the N data blocks and a digest set corresponding to the N data blocks, wherein the digest set corresponding to the i-th data block includes the digest of each homomorphic ciphertext in the homomorphic ciphertext set corresponding to the i-th data block, and i is an integer between 1 and N.

[0117] In this embodiment, before sending encrypted data to the server, the first device executes the following step S21 for the jth homomorphic ciphertext in the homomorphic ciphertext set corresponding to the i-th data block in the N data blocks: determine the digest corresponding to the j-th homomorphic ciphertext based on the j-th homomorphic ciphertext, the second key corresponding to the i-th data block, the digest key and the first public parameter, where j is an integer from 1 to P, that is, step S21 is executed once for each statistical value in the P statistical values ​​corresponding to the i-th data block.

[0118] The jth homomorphic ciphertext C in the homomorphic ciphertext set corresponding to the i-th data block ij The corresponding digest HMAC(C ij ) is calculated as follows:

[0119]

[0120] In formula (4), C ij is the jth homomorphic ciphertext in the set of homomorphic ciphertexts corresponding to the i-th data block, K is the second key corresponding to the i-th data block, Z is the digest key, and p is the first public parameter.

[0121] The digest set corresponding to the i-th data block is denoted as CipherHMac i , including the digests corresponding to the P homomorphic ciphertexts in the homomorphic ciphertext set corresponding to the i-th data block, namely CipherHMac i ={HMAC(C i0 ),HMAC(C i1 ),..,HMAC(C i(P-1) )}.

[0122] In this embodiment, the encrypted data Cipher sent by the first device to the server includes data ciphertexts, homomorphic ciphertext sets and digest sets corresponding to N data blocks, wherein the data ciphertexts, homomorphic ciphertext sets and digest sets corresponding to the i-th data block can be recorded as Cipher i , then the encrypted data Cipher={Cipher0,Cipher0,…,Cipher N-1}.

[0123] Cipher i ={CipherBlock i ,CipherStat i ,CipherHMac i}.

[0124] The above-mentioned server can store the data ciphertexts corresponding to the N data blocks in the disk corresponding to the time series database, and store the homomorphic ciphertext sets corresponding to the N data blocks and the summary sets corresponding to the N data blocks in the memory corresponding to the time series database.

[0125] In one possible implementation, the server stores the homomorphic ciphertext sets corresponding to the N data blocks and the digest sets corresponding to the N data blocks in the memory corresponding to the time series database. This can be achieved in the following manner: the server constructs a ciphertext index in the memory corresponding to the time series database based on the homomorphic ciphertext sets corresponding to the N data blocks and the digest sets corresponding to the N data blocks received. The ciphertext index is a K-ary tree structure, the i-th leaf node in the K-ary tree structure is used to store the homomorphic ciphertext set corresponding to the i-th data block and the digest set corresponding to the i-th data block, the first parent node in the K-ary tree structure is used to store the aggregate value of the homomorphic ciphertext set stored in each child node of the first parent node and the aggregate value of the digest set stored in each child node of the first parent node, and the first parent node is any parent node in the K-ary tree structure.

[0126] like Figure 3 As shown, the data in the time range t0 to t1 is data block 0, the data in the time range t1 to t2 is data block 1, and so on. k-1 ~t k The data in the data block is k-1, and the time range is t k ~t k+1 The data in the data block is k, and the time range is t 2k-1 ~t 2k The data in the data block is data block 2k-1. Data blocks 0 to 2k-1 are stored on the disk corresponding to the time series database. The homomorphic ciphertext set and digest set corresponding to data blocks 0 to 2k-1 are stored in the memory corresponding to the time series data block. Specifically, a K-ary tree structure is constructed in the memory for storage.

[0127] like Figure 3 In the K-ary tree structure shown, only two layers are shown, where the yth layer includes multiple leaf nodes. Figure 3Only leaf nodes 0 to 2k-1 are shown as examples. Leaf node 0 stores homomorphic ciphertext set 0 and digest set 0 corresponding to data block 0, leaf node 1 stores homomorphic ciphertext set 1 and digest set 1 corresponding to data block 1, and so on. Leaf node k-1 stores homomorphic ciphertext set k-1 and digest set k-1 corresponding to data block k-1; leaf node k stores homomorphic ciphertext set k and digest set k corresponding to data block k, leaf node 1 stores homomorphic ciphertext set k+1 and digest set k+1 corresponding to data block k+1, and so on. Leaf node 2k-1 stores homomorphic ciphertext set 2k-1 and digest set 2k-1 corresponding to data block 2k-1.

[0128] Node 0 of the y-1th layer is the parent node of leaf nodes 0 to leaf node k-1. The aggregation result 0 stored in node 0 of the y-1th layer includes the aggregation value of the homomorphic ciphertext set of all child nodes of node 0 of the y-1th layer and the aggregation value of the digest set of all child nodes of node 0 of the y-1th layer, that is, the sum value of homomorphic ciphertext set 0 to homomorphic ciphertext set k-1, and the sum value of digest set 0 to digest set k-1.

[0129] Node 1 of the y-1th layer is the parent node of leaf nodes k to leaf nodes 2k-1. The aggregation result 1 stored in node 1 of the y-1th layer includes the aggregation value of the homomorphic ciphertext set of all child nodes of node 1 of the y-1th layer and the aggregation value of the digest set of all child nodes of node 1 of the y-1th layer, that is, the sum value of homomorphic ciphertext set k to homomorphic ciphertext set 2k-1, and the sum value of digest set k to digest set 2k-1.

[0130] The following takes the ciphertext index as a k-ary tree structure as an example to introduce the server receiving the data block D i The corresponding homomorphic ciphertext CipherStat i And the corresponding summary CipherHMac i The process of updating the ciphertext index is described below. The ciphertext index update process is as follows:

[0131] S31, {CipherStat i 、CipherHMac i} is inserted into the position of the i-th leaf node in the memory as a leaf node;

[0132] S32, update the homomorphic ciphertext aggregation result of the parent node i / k of the i-th leaf node;

[0133] Suppose the homomorphic ciphertext aggregation result of the parent node of the i-th leaf node before the update is: CipherStat, numbered as m, and the homomorphic ciphertext aggregation result after the update is recorded as CipherStat_updated, and its calculation formula is as follows: Formula (5):

[0134] CipherStatupdated=CipherStat i +CipherStat formula (5);

[0135] The right side of formula (5) is equal to It can be calculated by the following formula (6):

[0136]

[0137] The above formula (6) is simplified to the following formula (7):

[0138]

[0139] S33, updating the summary aggregation result of the parent node i / k of the i-th leaf node;

[0140] Suppose the summary aggregation result of the parent node of the i-th leaf node before updating is: CipherHMac, numbered as m, and the summary aggregation result after updating is recorded as CipherHMac_updated, which is calculated as follows: Formula (8):

[0141] CipherHMac updated =CipherHMac i +CipherHMac formula(8);

[0142] The above formula (8) can be further transformed into the following formula (9):

[0143] CipherHMac_updated=[(K m*k -K m*k+1 )-CipherState m*k +(K m*k+1 -K m*k+2 )-CipherState m*k+1 +…+(K i -K i+1 )-CipherStat i ] / Z mod p

[0144] Formula (9);

[0145] The above formula (9) is simplified to the following formula (10):

[0146]

[0147] S34: Repeat steps S31 to S33 to continue updating the homomorphic ciphertext aggregation results and digest aggregation results of the parent node in the previous layer of parent node i / k until there are no parent nodes in the previous layer. This completes the storage of the homomorphic ciphertext set and digest set corresponding to the i-th data block.

[0148] Through the above method, time series data is stored in the time series database in the form of data ciphertext. Even if the time series database is compromised, the attacker can obtain the encrypted data in the time series database, but the attacker cannot obtain the plaintext data corresponding to the encrypted data, thereby improving the security of the time series data.

[0149] Based on the encrypted data stored in the time series database of the server in any of the above embodiments, the data user can query the encrypted data in the time series database. The time series data processing method for the data query scenario is introduced in detail below.

[0150] Figure 4 The flow chart of a time series data processing method provided by an embodiment of the present invention is shown as an example. Figure 4 As shown, the method flow includes:

[0151] In step 401, a third device sends a data query request to a server. Correspondingly, the server receives the data query request sent by the third device.

[0152] Here, the third device is, for example, Figure 1 The data user 104 is shown. In step 401, a data query request includes a first time range and a first query operation; the query request is used to request the time series database in the server to perform the first query operation on the encrypted data in the first time range.

[0153] In step 402, if the first time range and the first query operation are within the access rights allowed by the data owner, the server performs the first query operation on the encrypted data in the first time range in the time series database to obtain the ciphertext result corresponding to the first query operation.

[0154] The following describes the access permissions allowed by the data owner.

[0155] In an embodiment of the present application, the time series database can be accessed by multiple data users. Any data user who wants to access the time series database needs to obtain authorization from the data owner first, that is, the data owner defines access rights for each data user.

[0156] In one possible implementation, before step 402 above, the second device generates access control information and sends the access control information to the server. The access control information is used to indicate the access rights allowed when authorizing the third device to access the time series database. The allowed access rights include the time range corresponding to the encrypted data allowed to be accessed by the third device and the allowed query operations.

[0157] In another embodiment, before step 402, the second device may receive an access authorization request sent by the third device, where the access authorization request is used to request authorization of access rights. The second device generates access control information based on the access authorization request and sends the access control information to the server.

[0158] Based on the above two implementations, the allowed query operations indicated in the access control information may include but are not limited to ALL operations and / or at least one statistical operation.

[0159] In one embodiment, the allowed query operations include an ALL operation for accessing all data blocks within a time range allowed for access.

[0160] In another embodiment, the allowed query operations include at least one of the following statistical operations:

[0161] SUM operation: The SUM operation is used to count the data within the time range allowed for access;

[0162] AVG operation: The AVG operation is used to calculate the average value of data within the time range allowed for access;

[0163] COUNT operation: The COUNT operation is used to count the number of data items within the time range allowed for access;

[0164] VAR operation,VAR operation is used to count the variance of data blocks within the time range allowed for access;

[0165] STDEV operation, the STDEV operation is used to count the covariance of data within the time range that can be accessed;

[0166] MAX operation: The MAX operation is used to count the data with the highest number of occurrences within the time range allowed for access;

[0167] MIN operation: The MIN operation is used to count the data with the least number of occurrences within the time range allowed for access.

[0168] In yet another embodiment, the allowed query operations include an ALL operation and at least one statistical operation.

[0169] It should be understood that the allowed query operations indicated in the access control information can be expanded as needed, for example, to also include linear regression, logistic regression, etc., and this application does not impose any restrictions on this.

[0170] Based on any of the above implementations, after the server receives the access control information sent by the second device, the server can determine the decryption key corresponding to the access control information based on the first key set and the access control information, use the public key of the third device to encrypt the decryption key corresponding to the access control information, obtain the first credential ciphertext, and store the first credential ciphertext in the key management service in the server so that it can be sent to the third device when the third device requests the decryption key.

[0171] In implementation A1, if the permitted query operation includes the ALL operation, the decryption key corresponding to the access control information includes the encryption keys corresponding to all data blocks within the permitted access time range. For example, if the data ciphertext within the permitted access time range is L data blocks, the decryption key corresponding to the access control information includes L first keys corresponding to the L data blocks. The L first keys are then encrypted using the public key of the third device to obtain the first credential ciphertext.

[0172] For example, the time range for access is [t i ,…,t j ], the query operation allowed is ALL operation, the decryption keys corresponding to the access control information include: K i ,K i+1 ,…,K j , the public key of the third device is PK, and the public key PK is used to i ,K i+1 ,…,K j After encryption, the first credential ciphertext is obtained, which is recorded as token(t i ,t j ). Among them, token(t i ,t j ) can be calculated using the following formula (11):

[0173] token(i,j)=Enc(PK,{K i ,K i+1 ,…,K j}) Formula (11);

[0174] In implementation A2, if the permitted query operation includes at least one statistical operation, for example, the ciphertext data within the permitted access time range corresponds to the ciphertext data of L data blocks, and the decryption key corresponding to the access control information is the first key difference, i.e., the difference between the encryption key corresponding to the first data block in the L data blocks and the encryption key corresponding to the next data block in the L data blocks. The first key difference is then encrypted using the public key of the third device to obtain the first credential ciphertext.

[0175] For example, the time range for access is [t i ,…,t j ], the allowed query operation includes at least one statistical operation, then the decryption key corresponding to the access control information is K, and the calculation formula (12) of K is as follows:

[0176] K=K i -K j+1 Formula (12);

[0177] The public key of the third device is PK. The first credential ciphertext is obtained by encrypting K with the public key PK, which is recorded as token(t i ,t j ), where token(t i ,t j ) can be calculated using the following formula (13):

[0178] token(i,j)=Enc(PK,{K}) Formula (13);

[0179] There are many possible implementations of the above step 402.

[0180] Implementation method B1, the first query operation is an ALL operation. If the first time range is within the time range allowed for access by the data owner, and the query operations allowed by the data owner include ALL operations, the server executes the first query operation and obtains L data blocks in the first time range in the time series database corresponding to the data ciphertext respectively.

[0181] The ciphertext result corresponding to the first query operation includes ciphertext data corresponding to L data blocks within the first time range in the time series database. The server performs the first query operation on the encrypted data within the first time range in the time series database to obtain the ciphertext result corresponding to the first query operation.

[0182] For example, the first time range is [t i ,…,t j ], the first query operation is ALL operation, then the ciphertext results corresponding to the first query operation include [t i ,…,t j ] All data ciphertext within.

[0183] Implementation method B2, the first query operation includes a first statistical operation, and the first statistical operation is at least one of the P statistical operations. If the first time range and the first query operation are within the access rights allowed by the data owner, the server queries the homomorphic ciphertext set and the summary set corresponding to the L data blocks within the first time range in the time series database, and determines the first aggregation result and the second aggregation result. Then, the server uses the first aggregation result and the second aggregation result as the ciphertext results corresponding to the first query operation. The first aggregation result is the aggregation value of the homomorphic ciphertext set corresponding to the L data blocks, and the second aggregation result is the aggregation value of the summary set corresponding to the L data blocks.

[0184] Specifically, the server queries the homomorphic ciphertext set and digest set corresponding to the L data blocks within the first time range in the time series database, and determines the first aggregation result and the second aggregation result, which can be achieved by the following steps:

[0185] S41: The time series database in the server traverses L leaf nodes belonging to the first time range in the K-ary tree structure and adds them to the aggregation set;

[0186] S42, the time series database performs the first operation on each node in the aggregation set;

[0187] Among them, the process of performing the first operation on the first node includes: accessing the parent node of the first node, recording the number of times the parent node of the first leaf node is visited, and adding the parent node of the first node to the parent node set; the first node is any node in the aggregation set.

[0188] S43: The time series database performs a second operation on each parent node in the parent node set. The second operation performed on the first parent node includes: determining the number of times the first parent node has been visited; if the number of times the first parent node has been visited is equal to K, transferring the first parent node from the parent node set to the aggregate set, and deleting all child nodes of the first parent node from the aggregate set; the first parent node is any parent node in the parent node set;

[0189] When a new node is added to the aggregated set, the first operation is performed on the new node to ensure that every node in the aggregated set is visited. Similarly, when a new parent node is added to the parent node set, the second operation is performed on the new parent node to ensure that the number of visits to each parent node in the parent node set is accurately recorded.

[0190] The time series database loops through steps S42 and S43 until there are no new parent nodes in the parent node set and all parent nodes in the parent node set are traversed. The loop ends and steps S44 and S45 are executed.

[0191] S44, determining the aggregate value of the homomorphic ciphertext set stored by each node in the aggregated set as a first aggregation result;

[0192] S45 , determining the aggregate value of the summary set stored by each node in the aggregated set as a second aggregation result.

[0193] It should be understood that if the encrypted data stored in the time series database includes data ciphertext and a homomorphic ciphertext set, the time series database executes the above steps S41 to S44; if the encrypted data stored in the time series database includes data ciphertext, a homomorphic ciphertext set and a summary set, the time series database executes the above steps S41 to S45.

[0194] The following takes the binary tree structure of the ciphertext index as an example, and the time series database in the server is used to calculate the first time range [t i ,…,t j ] is used as an example to illustrate the statistical operation performed on encrypted data.

[0195] Example 1: i is m+1, j is m+6, and the ciphertext index is Figure 5 Taking the binary tree structure shown in the figure as an example, the process of performing statistical operations in a time series database is as follows:

[0196] Step S51, first traverse Figure 5 The binary tree structure shown belongs to the time range [t m+1 ,…,t m+6 ] all nodes within.

[0197] Access node 31 in the binary tree structure, and access the parent node of node 31, that is, node 20, record the number of times node 20 is accessed as 1, and add node 31 to the aggregation set, and add node 20 to the parent node set; then access node 32, and access the parent node of node 32, that is, node 21. At this time, the number of times node 21 is accessed is 1, add node 32 to the aggregation set, and add node 21 to the parent node set. Then continue to visit node 33 and its parent node 21. At this time, the number of visits to node 21 is increased by 1, that is, the number of visits to node 21 is recorded as 2, and node 33 is added to the aggregation node; continue to visit node 34 and its parent node 22. At this time, the number of visits to node 22 is 1 and node 34 is added to the aggregation set, and node 22 is added to the parent node set; continue to visit node 35 and its parent node 22. At this time, the number of visits to node 22 is increased by 1, that is, the number of visits to node 22 is recorded as 2, and node 35 is added to the aggregation node; continue to visit node 36 and its parent node 23, record the number of visits to node 23 as 1, and add node 36 to the aggregation set, and add node 23 to the parent node set.

[0198] The aggregated set includes node 31 , node 32 , node 33 , node 34 , node 35 , and node 36 , and the parent node set includes node 20 , node 21 , node 22 , and node 23 .

[0199] Step S52, traverse all parent nodes in the parent node set and determine the number of visits to each parent node. The number of visits to node 20 in the parent node set is 1, the number of visits to node 21 is 2, the number of visits to node 22 is 2, and the number of visits to node 23 is 1.

[0200] Step S53, determine whether the number of visits to each parent node in the parent node set is equal to the path number 2 of the binary tree. If equal, delete the parent node with the number of visits equal to 2 from the parent node set and add it to the aggregation set, and delete the child node of the parent node with the number of visits equal to 2 from the aggregation set.

[0201] In step S52, the number of visits to nodes 21 and 22 in the parent node set is 2. Nodes 21 and 22 are added to the aggregated set, and all child nodes of node 21 (i.e., nodes 32 and 33) are deleted from the aggregated set. All child nodes of node 22 (i.e., nodes 34 and 35) are deleted from the aggregated set. The aggregated set now includes nodes 31, 36, 21, and 22. Nodes 21 and 22 are deleted from the parent node set. The updated parent node set includes nodes 20 and 23.

[0202] Step S54, traverse the newly added nodes in the aggregation set, namely node 21 and node 22, and access the parent node of node 21, namely node 10, record the number of visits to node 10 as 1, and add node 10 to the parent node set; access the parent node of node 22, namely node 11, record the number of visits to node 11 as 1, and add node 11 to the parent node set. The updated parent node set includes: node 20, node 23, node 10, and node 11.

[0203] Step S55, traverse all parent nodes in the updated parent node set obtained in step S54 and determine the number of visits to each parent node. The number of visits to all parent nodes in the updated parent node set is 1, and the parent node set and the aggregation set are no longer updated.

[0204] Step S56: sum the homomorphic ciphertext sets stored by nodes 31, 36, 21, and 22 in the aggregated set to obtain a first aggregated result.

[0205] Step S57 , summing up the summary sets stored respectively by node 31 , node 36 , node 21 , and node 22 in the aggregated set to obtain a second aggregation result.

[0206] Example 2: Let i be m, j be m+7, and the ciphertext index be Figure 6 Taking the binary tree structure shown in the figure as an example, the process of performing statistical operations in a time series database is as follows:

[0207] Step S61, first traverse Figure 6 The binary tree structure shown belongs to the time range [t m ,…,t m+7 ] all nodes within.

[0208] Access node 30 in the binary tree structure, and access the parent node of node 30, that is, node 20, record the number of visits to node 20 as 1, and add node 30 to the aggregation set, and add node 20 to the parent node set; then continue to access node 31 and its parent node 20, at this time the number of visits to node 20 is increased by 1, that is, the number of visits to node 20 is recorded as 2, and node 31 is added to the aggregation node; then access node 32, and access the parent node of node 32, that is, node 21, at this time the number of visits to node 21 is 1, add node 32 to the aggregation set, and add node 21 to the parent node set. Then continue to visit node 33 and its parent node 21. At this time, the number of visits to node 21 is increased by 1, that is, the number of visits to node 21 is recorded as 2, and node 33 is added to the aggregation node; continue to visit node 34 and its parent node 22. At this time, the number of visits to node 22 is 1 and node 34 is added to the aggregation set, and node 22 is added to the parent node set; continue to visit node 35 and its parent node 22. At this time, the number of visits to node 22 is increased by 1, that is, the number of visits to node 22 is recorded as 2, and node 35 is added to the aggregation node; continue to visit node 36 and its parent node 23, record the number of visits to node 23 as 1, and add node 36 to the aggregation set, and add node 23 to the parent node set; continue to visit node 37 and its parent node 23. At this time, the number of visits to node 23 is increased by 1, that is, the number of visits to node 23 is recorded as 2, and node 37 is added to the aggregation node.

[0209] The aggregated set includes node 30 , node 31 , node 32 , node 33 , node 34 , node 35 , node 36 , and node 37 , and the parent node set includes node 20 , node 21 , node 22 , and node 23 .

[0210] Step S62 , traverse all parent nodes in the parent node set and determine the number of visits to each parent node. The number of visits to nodes 20 , 21 , 22 , and 23 in the parent node set is 2.

[0211] Step S63, determine whether the number of visits to each parent node in the parent node set is equal to the path number 2 of the binary tree. If equal, delete the parent node with the number of visits equal to 2 from the parent node set and add it to the aggregation set, and delete the child node of the parent node with the number of visits equal to 2 from the aggregation set.

[0212] In step S62, nodes 20, 21, 22, and 23 in the parent node set are added to the aggregated set, and the number of visits to nodes 21 and 22 is set to 2. All child nodes of nodes 21 and 22 (i.e., 8 nodes from 30 to 37) are deleted from the aggregated set. At this time, the updated aggregated set includes nodes 20, 21, 22, and 23. Nodes 20, 21, 22, and 23 are deleted from the parent node set, and the updated parent node set is empty.

[0213] Step S64, traverse the newly added nodes in the aggregated set, namely node 20, node 21, node 22, and node 23, and access the parent node of node 20, namely node 10, add node 10 to the parent node set, and record the number of visits to node 10 as 1; continue to access the parent node of node 21, namely node 10, record the number of visits to node 10 plus 1, and the number of visits to node 10 is now 2; continue to access the parent node of node 22, namely node 11, add node 11 to the parent node set, and record the number of visits to node 11 as 1; continue to access the parent node of node 23, namely node 11, record the number of visits to node 11 plus 1, and the number of visits to node 11 is now 2; the updated parent node set now includes: node 10 and node 11.

[0214] Step S65, traverse all parent nodes in the updated parent node set obtained in step S64 and determine the number of visits to each parent node. The number of visits to all parent nodes in the updated parent node set is 2. Node 10 and node 11 are deleted from the updated parent node set and added to the aggregated set. At this time, the updated parent node set is empty, and all child nodes of node 10 (i.e., node 20 and node 21) and all child nodes of node 11 (i.e., node 22 and node 23) are deleted from the aggregated set. The updated aggregated set includes node 10 and node 11.

[0215] Step S66: sum the homomorphic ciphertext sets stored by nodes 10 and 11 in the aggregation set to obtain a first aggregation result.

[0216] Step S67: sum up the summary sets stored in nodes 10 and 11 in the aggregated set to obtain a second aggregation result.

[0217] In step 403, the server sends the ciphertext result corresponding to the first query operation to the third device. Correspondingly, the third device receives the ciphertext result corresponding to the first query operation sent by the server.

[0218] Based on the above implementation mode B1, the ciphertext result corresponding to the first query operation received by the third device is: the L data blocks in the first time range of the time series database respectively correspond to the data ciphertext.

[0219] Based on the above-mentioned implementation mode B2, the ciphertext result corresponding to the first query operation received by the third device is: the aggregation value of the homomorphic ciphertext set corresponding to the L data blocks within the first time range in the time series database and the aggregation value of the summary set corresponding to the L data blocks.

[0220] In step 404 , the third device sends a key request to the server. The key request is used to request a decryption key corresponding to the accessed encrypted data. Correspondingly, the server receives the key request sent by the third device.

[0221] In step 405 , the server sends the first credential ciphertext to the third device according to the key request; correspondingly, the third device receives the first credential ciphertext sent by the server.

[0222] The first credential ciphertext is sent to the third device when the server determines that the first time range and the first query operation are within the access rights indicated by the access control information. The specific implementation of the first credential ciphertext in step 405 can refer to the above-mentioned implementation A1 and implementation A2, which will not be repeated here.

[0223] Step 406: The third device decrypts the first credential ciphertext using the third device's private key to obtain a first decryption key.

[0224] Based on the above implementation mode A1, the first credential ciphertext in the above implementation mode A1 is decrypted using the private key of the third device to obtain L first keys corresponding to the L data blocks.

[0225] Based on the above-mentioned implementation A2, the first certificate ciphertext in the above-mentioned implementation A2 is decrypted using the private key of the third device, and a first key difference can be obtained, that is, the difference between the encryption key corresponding to the first data block in the L data blocks and the encryption key corresponding to the next data block of the L data blocks.

[0226] Step 407: The third device determines the plaintext result corresponding to the first query operation based on the ciphertext result corresponding to the first query operation and the first decryption key.

[0227] Implementation C1 is based on Implementation A1 and Implementation B1 above, that is, the first decryption key includes L first keys, and the ciphertext result corresponding to the first query operation includes L data blocks within the first time range, each corresponding to the data ciphertext. The above step 407 can be implemented as follows:

[0228] For the data ciphertext corresponding to the f-th data block among the L data blocks, execute: the third device decrypts the data ciphertext corresponding to the f-th data block according to the f-th first key among the L first keys, to obtain the data plaintext of the f-th data block; wherein f is an integer between 1 and L, that is, the data ciphertext corresponding to each data block in the L data blocks is decrypted separately, thereby obtaining the data plaintext of the L data blocks.

[0229] Implementation C2, based on Implementation A2 and Implementation B2 above, i.e., the first decryption key includes a first key difference, and the ciphertext result corresponding to the first query operation includes a first aggregate result, i.e., an aggregate value of the homomorphic ciphertext set corresponding to L data blocks within a first time range. Step 407 above can be implemented as follows: the third device decrypts the first aggregate result based on the first key difference to obtain P statistical aggregate values, where the j-th statistical value is the aggregate value of the j-th statistical values ​​corresponding to the L data blocks, where j is an integer between 0 and P. Then, the third device determines the plaintext result corresponding to the first query operation based on the P statistical aggregate values ​​and the first query operation.

[0230] Implementation C3, based on Implementation A2 and Implementation B2 above, wherein the first decryption key includes a first key difference, and the ciphertext result corresponding to the first query operation includes a first aggregate result and a second aggregate result, wherein the first aggregate result includes an aggregate value of a homomorphic ciphertext set corresponding to L data blocks within a first time range, and the first aggregate result includes an aggregate value of a digest set corresponding to the L data blocks. Step 407 above can be implemented as follows: If the result of the integrity check on the first aggregate result is valid, the third device determines the plaintext result corresponding to the first query operation based on the ciphertext result corresponding to the first query operation and the first decryption key. Specifically, the third device decrypts the first aggregate result based on the first key difference to obtain P statistical aggregate values, where the jth statistical value is the aggregate value of the jth statistical values ​​corresponding to the L data blocks, where j is an integer between 0 and P. Then, the third device determines the plaintext result corresponding to the first query operation based on the P statistical aggregate values ​​and the first query operation.

[0231] The third device may perform an integrity check on the first aggregation result based on the first aggregation result, the second aggregation result, the first decryption key, and the second public parameter. Specifically, the third device determines a key check value based on the first aggregation result, the second aggregation result, and the second public parameter; if the first decryption key and the key check value are equal, the third device determines that the result of the integrity check is valid; otherwise, if the first decryption key and the key check value are not equal, the third device determines that the result of the integrity check is invalid.

[0232] For example, the first time range [t i ,…,t j ], in the ciphertext result corresponding to the first query operation received by the third device, the first aggregation result is recorded as CipherStat, and the second aggregation result is recorded as CipherHMac,

[0233] Where CipherStat = CipherStat i +CipherStat i+1 +…+CipherStat j , which can be transformed into the following formula (14):

[0234] CipherStat=[K i -K i+1 +M i +K i+1 -K i+2 +M i+1 +…+K j -K j+1 +M j ]mod M formula (14);

[0235] The above formula (14) can be transformed into the following formula (15):

[0236]

[0237] In formula (15), K i is the first key corresponding to the i-th data block, M i is the homomorphic ciphertext set corresponding to the i-th data block.

[0238] Where CipherHMac=CipherStat i +CipherStat i+1 +…+CipherStat j , which can be transformed into the following formula (16):

[0239] CipherHMac=(K i -K i+1 -CipherStat i +K i+1 -K i+2 -CipherStat i+1 +…+K j -K j+1 -CipherStat j ) / Z mod p formula (16);

[0240] The above formula (16) can be transformed into the following formula (17):

[0241] CipherHMac=(K i -K j+1 -CipherStat) / Z mod p formula (17);

[0242] The third device determines the key check value K' according to the first aggregation result CipherStat, the second aggregation result CipherHMac, and the second public parameter Z. The key check value K' can be calculated using the following formula (18):

[0243] K'=CipherHMac*Z+CipherStat formula (18);

[0244] Then, it is determined whether the key check value K' calculated according to formula (18) is equal to the first decryption key K, where the first decryption key K can be K i -K i+1 If the two values ​​are equal, it means that the result of the integrity check of the first aggregated result by the third device is valid, and the first aggregated result can be decrypted to determine the plaintext result corresponding to the first query operation; if the two values ​​are not equal, it means that the result of the integrity check of the first aggregated result by the third device is invalid, and the first aggregated result is directly discarded;

[0245] In the above-mentioned implementation C2 and implementation C3, the first query operations are different, and the third device determines, based on P statistical aggregation values ​​and the first query operation, that the plaintext results corresponding to the first query operation are different.

[0246] For example, if the first query operation is a SUM operation, then the plaintext result corresponding to the first query operation is the decryption result of decrypting the first aggregation result using the first key difference, that is, P statistical aggregation values.

[0247] For another example, if the first query operation is an AVG operation, then the plaintext result corresponding to the first query operation is the sum of the decryption results of decrypting the first aggregated result using the first key difference divided by the number of data items.

[0248] For another example, if the first query operation is a COUNT operation, then the plaintext result corresponding to the first query operation is the decryption result of decrypting the first aggregated result using the first key difference.

[0249] For another example, if the first query operation is a VAR operation, then the plaintext result corresponding to the first query operation is the decryption result of decrypting the first aggregated result using the first key difference.

[0250] Taking the first time range as [t i ,…,t j] as an example, the decryption result is the variance of the data in all data blocks between the i-th data block and the j-th data block. The variance can be specifically calculated using the formula Calculated, where n is the number of data, x i is the variance of the i-th data block.

[0251] For another example, if the first query operation is a STDEV operation, then the plaintext result corresponding to the first query operation is the square root of the variance.

[0252] For another example, if the first query operation is a MAX operation, then the plaintext result corresponding to the first query operation is the data that appears the most times in the decryption result of decrypting the first aggregated result using the first key difference.

[0253] For another example, if the first query operation is a MIN operation, then the plaintext result corresponding to the first query operation is the data that appears the least number of times in the decryption result of decrypting the first aggregated result using the first key difference.

[0254] It should be understood that the above Figure 2 The method shown can be used with Figure 4 The methods shown can be used alone or in combination. Figure 2 Execute the method shown, and then follow Figure 3 implementation of the plan.

[0255] In an embodiment of the present application, when a third device serving as a data user queries a time series database, it can only access the time series database within the access permissions allowed by the data owner. The time series database in this solution supports data queries at the data block level. Compared with access strategies that only support the database level or data table level, this solution can achieve fine-grained data access control, thereby eliminating the data owner's concerns about data supply, and thus improving the security of time series data.

[0256] Based on the same technical concept, Figure 7 The structure of a device provided by an embodiment of the present invention is exemplarily shown, and the device can execute the method executed by the first device in the above-mentioned time series data processing method flow. Figure 7 As shown, the apparatus 700 includes an acquisition unit 701, a processing unit 702, and a communication unit 703, wherein:

[0257] An acquisition unit 701 is configured to acquire time series data to be stored, and divide the time series data to be stored into N data blocks according to a preset time interval, where N is a positive integer; and acquire a first key set from a server, where the first key set includes at least N first keys.

[0258] a processing unit 702 configured to encrypt an i-th data block among the N data blocks using an i-th first key in the first key set to obtain a ciphertext corresponding to the i-th data block, where i is an integer between 1 and N;

[0259] The communication unit 703 is used to send encrypted data to the server, where the encrypted data includes data ciphertexts corresponding to the N data blocks respectively, and the encrypted data is used to be stored in the time series database in the server.

[0260] Optionally, the encrypted data also includes homomorphic ciphertext sets corresponding to the N data blocks, wherein the homomorphic ciphertext set corresponding to the i-th data block includes P homomorphic ciphertexts corresponding to the i-th data block; the processing unit 702 is further used to execute, for the i-th data block among the N data blocks: performing preset P statistical operations on the i-th data block to obtain P statistical values ​​corresponding to the i-th data block; according to the second key corresponding to the i-th data block, homomorphically encrypting the P statistical values ​​corresponding to the i-th data block to obtain P homomorphic ciphertexts corresponding to the i-th data block; the second key corresponding to the i-th data block is determined based on the i-th first key and the i+1-th first key in the first key set.

[0261] Optionally, the encrypted data also includes digest sets corresponding to the N data blocks, respectively, wherein the digest set corresponding to the i-th data block includes the digest of each homomorphic ciphertext in the homomorphic ciphertext set corresponding to the i-th data block; the processing unit 702 is also used to execute, for the j-th homomorphic ciphertext in the homomorphic ciphertext set corresponding to the i-th data block: determine the digest corresponding to the j-th homomorphic ciphertext based on the j-th homomorphic ciphertext, the second key corresponding to the i-th data block, the digest key and the first public parameter, where j is an integer from 1 to P.

[0262] Based on the same technical concept, Figure 8 The structure of another device provided by an embodiment of the present invention is exemplarily shown. The device 800 can be used to perform Figure 2 or Figure 4 The server of the time series data processing method shown in FIG. Figure 8 As shown, the device 800 includes a processing unit 801 and a communication unit 802 .

[0263] The device 800 is used to perform Figure 2 or Figure 4 In the time series data processing method shown in the flow, the server includes a time series database:

[0264] The communication unit 802 sends a first key set to the first device, where the first key set includes N first keys, where N is a positive integer; and receives encrypted data sent by the first device, where the encrypted data includes data ciphertexts corresponding to the N data blocks, where the N data blocks are time series data to be stored divided according to preset time intervals, and the data ciphertext corresponding to the i-th data block in the N data blocks is obtained by encrypting the i-th data block using the i-th first key in the first key set, where i is an integer ranging from 1 to N.

[0265] The processing unit 801 is configured to store the encrypted data in a time series database.

[0266] Optionally, the encrypted data also includes a set of homomorphic ciphertexts corresponding to the N data blocks respectively; wherein, the set of homomorphic ciphertexts corresponding to the i-th data block includes: P homomorphic ciphertexts corresponding to the i-th data block, the P homomorphic ciphertexts are obtained by homomorphically encrypting P statistical values ​​corresponding to the i-th data block according to the second key corresponding to the i-th data block, and the P statistical values ​​corresponding to the i-th data block are obtained by performing preset P statistical operations on the i-th data block.

[0267] Optionally, the encrypted data also includes a digest set corresponding to each of the N data blocks; wherein, the digest set corresponding to the i-th data block includes the digest corresponding to each homomorphic ciphertext in the homomorphic ciphertext set corresponding to the i-th data block, and the j-th digest in the digest set corresponding to the i-th data block is obtained based on the j-th homomorphic ciphertext in the homomorphic ciphertext set corresponding to the i-th data block, the second key corresponding to the i-th data block, the digest key and the first public parameter, and j is an integer from 1 to P.

[0268] Optionally, the processing unit 801 is specifically used to: store the data ciphertexts corresponding to the N data blocks in a disk corresponding to the time series database, and store the homomorphic ciphertext sets corresponding to the N data blocks and the summary sets corresponding to the N data blocks in a memory corresponding to the time series database.

[0269] Optionally, the processing unit 801 is specifically used to: construct a ciphertext index in the memory corresponding to the time series database according to the homomorphic ciphertext sets corresponding to the N received data blocks and the summary sets corresponding to the N received data blocks; wherein the ciphertext index is a K-ary tree structure, and the i-th leaf node in the K-ary tree structure is used to store the homomorphic ciphertext set corresponding to the i-th data block and the summary set corresponding to the i-th data block, and the first parent node in the K-ary tree structure is used to store the aggregation value of the homomorphic ciphertext set stored in each child node of the first parent node and the aggregation value of the summary set stored in each child node of the first parent node, and the first parent node is any parent node in the K-ary tree structure.

[0270] The device 800 is used to perform Figure 2 or Figure 4 In the time series data processing method shown in the flow, the server includes a time series database:

[0271] A communication unit 802 is configured to receive a data query request sent by a third device, where the data query request includes the first time range and a first query operation;

[0272] Processing unit 801 is configured to perform a first query operation on the encrypted data in the first time range in the time series database within the first time range and the access permission indicated by the access control information, and obtain a ciphertext result corresponding to the first query operation;

[0273] The communication unit 802 is also used to send the ciphertext result corresponding to the first query operation to the third device; receive a key request sent by the third device, where the key request is used to request the key corresponding to the accessed encrypted data; and send the first credential ciphertext to the third device according to the key request.

[0274] Optionally, the server also includes a key management service, and the communication unit 802 is further used to receive access control information sent by the second device, where the access control information is used to indicate the access rights authorized for the third device to access the time series database, and the access rights include the time range corresponding to the encrypted data that the third device is allowed to access and the allowed query operations; the processing unit 801 is also used to determine the decryption key corresponding to the access control information based on the first key set and the access control information; use the public key of the third device to encrypt the decryption key corresponding to the access control information to obtain a first credential ciphertext; and store the first credential ciphertext in the key management service.

[0275] Optionally, the first query operation is an ALL operation, and the ciphertext result corresponding to the first query operation includes data ciphertexts corresponding to L data blocks within the first time range in the time series database.

[0276] Optionally, the first query operation includes a first statistical operation, which is at least one of the P statistical operations; the processing unit 801 is specifically used to: query the homomorphic ciphertext sets and summary sets corresponding to the L data blocks within the first time range in the time series database, and determine a first aggregation result and a second aggregation result, wherein the first aggregation result is the aggregation value of the homomorphic ciphertext sets corresponding to the L data blocks, and the second aggregation result is the aggregation value of the summary sets corresponding to the L data blocks; use the first aggregation result and the second aggregation result as the ciphertext results corresponding to the first query operation.

[0277] Optionally, the processing unit 801 is specifically used to: traverse the L leaf nodes belonging to the first time range in the K-ary tree structure, and add them to the aggregation set; perform a first operation on each node in the aggregation set, wherein performing the first operation on the first node includes: accessing the parent node of the first node, recording the number of times the parent node of the first leaf node is accessed, and adding the parent node of the first node to the parent node set; the first node is any node in the aggregation set; perform a second operation on each parent node in the parent node set, wherein performing the second operation on the first parent node includes: determining the number of times the first parent node is accessed; if the number of times the first parent node is accessed is equal to K, transfer the first parent node from the parent node set to the aggregation set, and delete all child nodes of the first parent node from the aggregation set; the first parent node is any parent node in the parent node set; determine the aggregation value of the homomorphic ciphertext set stored by each node in the aggregation set as the first aggregation result; determine the aggregation value of the summary set stored by each node in the aggregation set as the second aggregation result.

[0278] When the apparatus 800 is used to execute the steps executed by the third device in the aforementioned embodiment of the time series data processing method:

[0279] Communication unit 802 is configured to send a data query request to a server, the data query request including the first time range and a first query operation; the query request is used to request the time series database in the server to perform the first query operation on the encrypted data in the first time range; receive a ciphertext result corresponding to the first query operation sent by the server; send a key request to the server, the key request being used to request a decryption key corresponding to the accessed encrypted data; receive a first credential ciphertext sent by the server, the first credential ciphertext being sent when the server determines that the first time range and the first query operation are within the access rights indicated by the access control information;

[0280] The processing unit 801 is used to decrypt the first credential ciphertext according to the private key of the third device to obtain a first decryption key; and determine the plaintext result corresponding to the first query operation according to the ciphertext result corresponding to the first query operation and the first decryption key.

[0281] Optionally, the first query operation is an ALL operation; the ciphertext result corresponding to the first query operation includes the data ciphertexts corresponding to the L data blocks within the first time range in the time series database; the first decryption key includes L first keys, and the data ciphertexts corresponding to the L data blocks are obtained by encrypting the L data blocks according to the L first keys; the processing unit 801 is specifically used to execute, for the data ciphertext corresponding to the f-th data block among the L data blocks: decrypt the data ciphertext corresponding to the f-th data block according to the f-th first key among the L first keys to obtain the data plaintext of the f-th data block; wherein f is an integer between 1 and L.

[0282] Optionally, the first query operation includes a first statistical operation; the ciphertext result corresponding to the first query operation includes a first aggregation result and a second aggregation result, wherein the first aggregation result is the aggregation value of the homomorphic ciphertext set corresponding to the L data blocks within the first time range in the time series database, and the second aggregation result is the aggregation value of the summary set corresponding to the L data blocks, and the homomorphic ciphertext set corresponding to the f-th data block in the L data blocks is obtained by homomorphically encrypting the P statistical values ​​corresponding to the f-th data block according to the second key corresponding to the f-th data block; the j-th summary in the summary set corresponding to the f-th data block is determined according to the j-th homomorphic ciphertext in the homomorphic ciphertext set corresponding to the f-th data block, the second key corresponding to the f-th data block, the summary key and the first public parameter; the first decryption key includes a first key difference, and the first key difference is the difference between the first key corresponding to the first data block in the L data blocks and the first key corresponding to the next data block of the L data blocks.

[0283] Optionally, the processing unit 801 is also used to perform an integrity check on the first aggregation result based on the first aggregation result, the second aggregation result, the first decryption key and the second public parameter; if the result of the integrity check is valid, the plaintext result corresponding to the first query operation is determined based on the ciphertext result corresponding to the first query operation and the first decryption key.

[0284] Optionally, the processing unit 801 is specifically used to determine a key check value based on the first aggregation result, the second aggregation result and the second public parameter; if it is determined that the first decryption key is equal to the key check value, the result of the integrity check is determined to be valid; or, if it is determined that the first decryption key is not equal to the key check value, the result of the integrity check is determined to be invalid.

[0285] Optionally, the processing unit 801 is specifically used to decrypt the first aggregation result according to the first key difference to obtain a plaintext result corresponding to the first aggregation result, where the plaintext result corresponding to the first aggregation result includes P statistical aggregation values, and the j-th statistical value among the P statistical aggregation values ​​is the aggregation value of the j-th statistical value corresponding to the L data blocks within the first time range, where j is an integer from 0 to P; based on the plaintext result corresponding to the first aggregation result and the first query operation, the plaintext result corresponding to the first query operation is determined.

[0286] When the apparatus 800 is used to execute the steps executed by the second device in the aforementioned embodiment of the time series data processing method:

[0287] The communication unit 802 is configured to receive an access authorization request sent by a third device, where the access authorization request is used to request authorization of access rights;

[0288] Processing unit 801 is configured to generate access control information based on the access authorization request, where the access control information is used to indicate access rights for authorizing a third device to access the time series database, where the access rights include a time range corresponding to the encrypted data that the third device is allowed to access and permitted query operations;

[0289] The communication unit 802 is further configured to send access control information to the server.

[0290] Optionally, the allowed query operation includes an ALL operation; the ALL operation is used to access all data blocks within a time range allowed for access.

[0291] Optionally, the allowed query operations include at least one of the following statistical operations:

[0292] SUM operation, which is used to count the data within the time range allowed for access;

[0293] AVG operation, which is used to calculate the average value of data within the time range allowed for access;

[0294] COUNT operation, which is used to count the number of data items within the time range allowed for access;

[0295] A VAR operation, wherein the VAR operation is used to count the variance of data blocks within a time range within which access is allowed;

[0296] STDEV operation, the STDEV operation is used to count the covariance of data within the time range allowed for access;

[0297] MAX operation, which is used to count the data with the largest number of occurrences within the time range allowed for access;

[0298] The MIN operation is used to count the data with the least number of occurrences within the time range allowed for access.

[0299] Based on the same technical concept, an embodiment of the present invention provides a device structure. The device includes at least one processor; and a memory communicatively connected to the at least one processor; the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the time series data processing method described in the above embodiment.

[0300] Take a processor as an example, Figure 9The structure of the device provided in an embodiment of the present invention, the device 900 can be the first device, server, second device or third device in the above method, and the device 900 includes: a transceiver 901, a processor 902, a memory 903 and a bus system 904;

[0301] Memory 903 is used to store programs. Specifically, the programs may include program code, which includes computer operating instructions. Memory 903 may be random access memory (RAM) or non-volatile memory, such as at least one disk storage device. The figure shows only one memory; however, multiple memories may be provided as needed. Memory 903 may also be memory in processor 902.

[0302] The memory 903 stores the following elements, executable modules or data structures, or a subset or an extension thereof:

[0303] Operation instructions: include various operation instructions, used to implement various operations.

[0304] Operating system: includes various system programs used to implement various basic services and process hardware-based tasks.

[0305] The time series data processing method according to the embodiment of the present invention described above can be applied to processor 902, or implemented by processor 902. Processor 902 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the time series data processing method described above can be completed by hardware integrated logic circuits or software instructions in processor 902. The processor 902 described above can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The methods, steps, and logic block diagrams disclosed in the embodiments of this application can be implemented or executed. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in conjunction with the embodiments of the present invention can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium mature in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or the like. The storage medium is located in the memory 903 , and the processor 902 reads the information in the memory 903 and executes the above method in combination with its hardware.

[0306] Based on the same technical concept, an embodiment of the present invention further provides a computing device, including:

[0307] a memory for storing program instructions;

[0308] The processor is used to call the program instructions stored in the memory and execute the above-mentioned time series data processing method according to the obtained program.

[0309] Based on the same technical concept, an embodiment of the present invention also provides a computer-readable non-volatile storage medium, including computer-readable instructions. When a computer reads and executes the computer-readable instructions, the computer executes the above-mentioned time series data processing method.

[0310] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0311] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0312] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0313] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0314] Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if such changes and modifications fall within the scope of the claims and their equivalents, the present invention is intended to include such changes and modifications.

Claims

1. A time series data processing method, characterized in that: Applied to a server, the server including a time series database; the method includes: receiving a data query request sent by a third device, wherein the data query request includes a first time range and a first query operation; If the first time range and the first query operation are within the access permission indicated by the access control information, perform the first query operation on the encrypted data in the first time range in the time series database to obtain a ciphertext result corresponding to the first query operation; Sending the encrypted result corresponding to the first query operation to the third device; receiving a key request sent by the third device, where the key request is used to request a key corresponding to the accessed encrypted data; Sending a first credential ciphertext to the third device according to the key request, where the first credential ciphertext is used to decrypt the first credential ciphertext according to the private key of the third device to obtain a first decryption key; and using the first decryption key to decrypt the ciphertext result corresponding to the first query operation to obtain a plaintext result corresponding to the first query operation; Among them, if the first query operation is an ALL operation, then: the ciphertext result corresponding to the first query operation includes the data ciphertexts corresponding to the L data blocks within the first time range in the time series database; the first decryption key includes L first keys, and the data ciphertexts corresponding to the L data blocks are obtained by encrypting the L data blocks according to the L first keys; the plaintext result corresponding to the first query operation is obtained by the following method: for the data ciphertext corresponding to the f-th data block among the L data blocks, execute: according to the f-th first key among the L first keys, decrypt the data ciphertext corresponding to the f-th data block to obtain the data plaintext of the f-th data block, where f is an integer between 1 and L.

2. The method according to claim 1, wherein The server also includes a key management service, and the method further includes: Receive access control information sent by the second device, where the access control information is used to indicate access rights authorizing a third device to access the time series database, where the access rights include a time range corresponding to the encrypted data that the third device is allowed to access and allowed query operations; Determining a decryption key corresponding to the access control information based on the first key set and the access control information; Encrypting the decryption key corresponding to the access control information using the public key of the third device to obtain a first credential ciphertext; The first credential ciphertext is stored in the key management service.

3. The method according to claim 1 or 2, wherein: If the first query operation includes a first statistical operation, and the first statistical operation is at least one of P statistical operations, then performing the first query operation on the encrypted data in the first time range in the time series database to obtain a ciphertext result corresponding to the first query operation includes: Querying the homomorphic ciphertext sets and digest sets corresponding to L data blocks within the first time range in the time series database, and determining a first aggregation result and a second aggregation result, wherein the first aggregation result is an aggregation value of the homomorphic ciphertext sets corresponding to the L data blocks, and the second aggregation result is an aggregation value of the digest sets corresponding to the L data blocks; The first aggregation result and the second aggregation result are used as ciphertext results corresponding to the first query operation.

4. The method according to claim 3, wherein The querying of the homomorphic ciphertext set and the digest set corresponding to the L data blocks within the first time range in the time series database, and determining the first aggregation result and the second aggregation result, includes: Traversing L leaf nodes belonging to the first time range in the K-ary tree structure and adding them to the aggregation set; Performing a first operation on each node in the aggregated set, wherein performing the first operation on a first node includes: accessing a parent node of the first node, recording a number of times the parent node of the first node has been accessed, and adding the parent node of the first node to a parent node set; the first node is any node in the aggregated set; Performing a second operation on each parent node in the parent node set, wherein performing the second operation on the first parent node includes: determining the number of times the first parent node has been visited; if the number of times the first parent node has been visited is equal to K, transferring the first parent node from the parent node set to the aggregated set, and deleting all child nodes of the first parent node from the aggregated set; the first parent node is any parent node in the parent node set; Determine the aggregation value of the homomorphic ciphertext set stored by each node in the aggregation set as a first aggregation result; The aggregate value of the summary set stored by each node in the aggregated set is determined as a second aggregation result.

5. The method according to claim 3, wherein The P statistical operations include at least one of the following statistical operations: SUM operation, which is used to count the data within the time range allowed for access; AVG operation, which is used to calculate the average value of data within the time range allowed for access; COUNT operation, which is used to count the number of data items within the time range allowed for access; A VAR operation, wherein the VAR operation is used to count the variance of data blocks within a time range within which access is allowed; STDEV operation, the STDEV operation is used to count the covariance of data within the time range allowed for access; MAX operation, which is used to count the data with the largest number of occurrences within the time range allowed for access; The MIN operation is used to count the data with the least number of occurrences within the time range allowed for access.

6. A time series data processing method, characterized in that: Applied to a third device, the method includes: Sending a data query request to a server, the data query request including a first time range and a first query operation; the data query request is used to request a time series database in the server to perform the first query operation on the encrypted data in the first time range; receiving a ciphertext result corresponding to the first query operation sent by the server; Sending a key request to the server, wherein the key request is used to request a decryption key corresponding to the accessed encrypted data; receiving a first credential ciphertext sent by the server, where the first credential ciphertext is sent when the server determines that the first time range and the first query operation are within the access rights indicated by the access control information; Decrypting the first credential ciphertext according to the private key of the third device to obtain a first decryption key; Determining a plaintext result corresponding to the first query operation based on the ciphertext result corresponding to the first query operation and the first decryption key; Among them, if the first query operation is an ALL operation, then: the ciphertext result corresponding to the first query operation includes the data ciphertexts corresponding to the L data blocks within the first time range in the time series database; the first decryption key includes L first keys, and the data ciphertexts corresponding to the L data blocks are obtained by encrypting the L data blocks according to the L first keys; the plaintext result corresponding to the first query operation is determined according to the ciphertext result corresponding to the first query operation and the first decryption key, including: for the data ciphertext corresponding to the f-th data block in the L data blocks, execute: according to the f-th first key in the L first keys, decrypt the data ciphertext corresponding to the f-th data block to obtain the data plaintext of the f-th data block; wherein, f is an integer between 1 and L.

7. The method according to claim 6, wherein If the first query operation includes a first statistical operation, then: the ciphertext result corresponding to the first query operation includes a first aggregation result and a second aggregation result, wherein the first aggregation result is the aggregation value of the homomorphic ciphertext set corresponding to the L data blocks within the first time range in the time series database, and the second aggregation result is the aggregation value of the digest set corresponding to the L data blocks, and the homomorphic ciphertext set corresponding to the f-th data block among the L data blocks is obtained by homomorphically encrypting the P statistical values ​​corresponding to the f-th data block according to the second key corresponding to the f-th data block; the j-th digest in the digest set corresponding to the f-th data block is determined according to the j-th homomorphic ciphertext in the homomorphic ciphertext set corresponding to the f-th data block, the second key corresponding to the f-th data block, the digest key and the first public parameter; The first decryption key includes a first key difference, which is a difference between a first key corresponding to a first data block of the L data blocks and a first key corresponding to a next data block of the L data blocks.

8. The method according to claim 7, wherein The method further comprises: Performing an integrity check on the first aggregation result according to the first aggregation result, the second aggregation result, the first decryption key, and the second public parameter; The determining, based on the ciphertext result corresponding to the first query operation and the first decryption key, a plaintext result corresponding to the first query operation includes: If the result of the integrity check is valid, determining the plaintext result corresponding to the first query operation according to the ciphertext result corresponding to the first query operation and the first decryption key.

9. The method according to claim 8, wherein The performing integrity verification on the first aggregation result according to the first aggregation result, the second aggregation result, the first decryption key, and the second public parameter includes: Determining a key check value according to the first aggregation result, the second aggregation result, and a second public parameter; If it is determined that the first decryption key is equal to the key check value, then the result of the integrity check is determined to be valid; or, If it is determined that the first decryption key is not equal to the key check value, the result of the integrity check is determined to be invalid.

10. The method according to claim 7 or 8, characterized in that The determining, based on the ciphertext result corresponding to the first query operation and the first decryption key, a plaintext result corresponding to the first query operation includes: Decrypting the first aggregation result according to the first key difference to obtain a plaintext result corresponding to the first aggregation result, where the plaintext result corresponding to the first aggregation result includes P statistical aggregation values, where a j-th statistical value among the P statistical aggregation values ​​is an aggregate value of j-th statistical values ​​corresponding to L data blocks within the first time range, where j is an integer between 0 and P; Determine the plaintext result corresponding to the first query operation according to the plaintext result corresponding to the first aggregated result and the first query operation.

11. The method according to claim 6, wherein Before sending the data query request to the server, the method further includes: An access authorization request is sent to the second device, where the access authorization request is used to request authorization for access rights; the access authorization request is used for the second device to generate access control information and send the access control information to the server, where the access control information is used to indicate the access rights that authorize the third device to access the time series database, and the access rights include the time range corresponding to the encrypted data that the third device is allowed to access and the allowed query operations.

12. The method according to claim 11, wherein The allowed query operations include an ALL operation; the ALL operation is used to access all data blocks within the time range allowed for access.

13. The method according to claim 11, wherein Allowed query operations include at least one of the following statistical operations: SUM operation, which is used to count the data within the time range allowed for access; AVG operation, which is used to calculate the average value of data within the time range allowed for access; COUNT operation, which is used to count the number of data items within the time range allowed for access; A VAR operation, wherein the VAR operation is used to count the variance of data blocks within a time range within which access is allowed; STDEV operation, the STDEV operation is used to count the covariance of data within the time range allowed for access; MAX operation, which is used to count the data with the largest number of occurrences within the time range allowed for access; The MIN operation is used to count the data with the least number of occurrences within the time range allowed for access.

14. A computing device, characterized in that include: a memory for storing program instructions; A processor, configured to call the program instructions stored in the memory and execute the method according to any one of claims 1 to 13 according to the obtained program.

15. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the method according to any one of claims 1 to 13.

Citation Information

Patent Citations

  • Database ciphertext retrieval system and method based on bidirectional security index

    CN112800088A

  • Data query method, device, system, electronic equipment and storage medium

    CN113515545A