Privacy data access time control method and device based on blockchain smart contract

By using a blockchain-based smart contract approach, a symmetric key is generated and object-level encryption is performed. Combined with ciphertext validity period and access control policies, the problem of inflexible control over user access permissions in existing technologies is solved, and access control of privacy data is achieved in the time dimension.

CN116668070BActive Publication Date: 2026-04-17ZHONGJINKE INFORMATION TECH CO LTD +1
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHONGJINKE INFORMATION TECH CO LTD
Filing Date
2023-04-20
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Existing technologies cannot flexibly control user access permissions without affecting other users' keys, especially in scenarios where data is time-sensitive, and cannot achieve time-dimensional access control of private data.

Method used

By using a blockchain-based smart contract approach, a symmetric key is generated and object-level encryption is performed. Combined with ciphertext expiration and access control policies, it is ensured that user keys cannot decrypt data outside of their expiration period, and on-chain ciphertext cannot be accessed outside of its expiration period, thus achieving access control in the time dimension.

Benefits of technology

It enables flexible control of user permissions without affecting other user keys, ensuring that user keys cannot decrypt on-chain data outside of their validity period, and that on-chain ciphertext cannot be accessed outside of its validity period, thus achieving access control of privacy data in the time dimension.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116668070B_ABST
    Figure CN116668070B_ABST
Patent Text Reader

Abstract

The application discloses a kind of privacy data access time control method and device based on blockchain smart contract, it is related to blockchain technical field, wherein including: in response to the data query request sent by user end, obtain the first ciphertext corresponding to the data to be queried from blockchain;First ciphertext is parsed, and ciphertext validity period and access control strategy are obtained;If the first ciphertext is verified by validity using ciphertext validity period detection, then symmetric key is randomly generated, and according to symmetric key and first ciphertext, second ciphertext is generated;According to the initiation time of data query request and access control strategy, object-level encryption is carried out to symmetric key;Second ciphertext and encrypted symmetric key are fed back to user end, so that user end carries out validity verification to the key held by user itself according to encrypted symmetric key, and second ciphertext is restored into the data to be queried.The application can realize the access control of privacy data in time dimension, and flexibly control access permission.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of blockchain technology, and more specifically, to a method and apparatus for controlling privacy data access time based on blockchain smart contracts. Background Technology

[0002] In recent years, the Chinese government has been continuously promoting the application of blockchain technology in fields such as finance. In the financial sector, once financial data is uploaded to the blockchain, its security and reliability are greatly enhanced, and regulatory agencies can directly access the data to improve regulatory efficiency. Therefore, the secure and reliable characteristics of blockchain make it suitable for a wide range of applications in the financial industry. However, some on-chain data involves privacy and is not suitable for public viewing; encryption is a common method for protecting privacy. In certain scenarios, data also has a time limit. For example, when banks raise funds by issuing financial bonds, the sales information expires after the designated issuance period, and users cannot purchase the bonds. In applications where data has a time limit, the data uploaded to the blockchain cannot be accessed immediately; access is only permitted after a certain period, or there is a time limit for access. After this period, even if the access requirements are met, the data will still be inaccessible. Therefore, achieving access control for privacy data in the time dimension is a technical problem that needs to be solved when applying blockchain.

[0003] Currently, in attribute-based encryption access control, if a user is no longer able to access data, it is necessary to revoke a certain attribute in the user's key to modify the user's access permissions. However, because the common parameters of this method change, it is necessary to regenerate keys for all users with this attribute and re-encrypt the previous data. This would affect all users, meaning that this method cannot revoke a user's access permissions without affecting other users' keys, which is not conducive to achieving flexible control of access permissions. Summary of the Invention

[0004] This invention provides a method and apparatus for controlling the access time of privacy data based on blockchain smart contracts. The main feature is that by realizing access control of privacy data in the time dimension, it is possible to flexibly control the user's access permissions, that is, to modify the user's access permissions without affecting other users' keys.

[0005] According to a first aspect of the present invention, a privacy data access time control method based on blockchain smart contracts is provided, applied to a data sharing end, comprising:

[0006] In response to a data query request sent by the user, the first ciphertext corresponding to the data to be queried is obtained from the blockchain;

[0007] If the first ciphertext requires time-based access control, then the first ciphertext is parsed to obtain the ciphertext validity period and access control policy.

[0008] If the validity period of the ciphertext is used to detect that the first ciphertext has passed the validity verification, a symmetric key is randomly generated, and a second ciphertext is generated based on the symmetric key and the first ciphertext.

[0009] Based on the initiation time of the data query request and the access control policy, the symmetric key is encrypted at the object level to obtain the encrypted symmetric key.

[0010] The second ciphertext and the encrypted symmetric key are fed back to the user terminal, wherein the user terminal is used to verify the validity of the key held by the user based on the encrypted symmetric key; if the key held by the user passes the validity verification, the second ciphertext is restored to the data to be queried.

[0011] According to a first aspect of the present invention, a method for controlling privacy data access time based on blockchain smart contracts is provided, applied to a user terminal, comprising:

[0012] The system receives a second ciphertext and an encrypted symmetric key from a data sharing terminal. The data sharing terminal retrieves a first ciphertext corresponding to the data to be queried from the blockchain. If the first ciphertext requires time-based access control, it parses the first ciphertext to obtain its validity period and access control policy. If the validity period of the first ciphertext is used to detect that it has passed validity verification, a symmetric key is randomly generated, and a second ciphertext is generated based on the symmetric key and the first ciphertext. The symmetric key is then object-level encrypted according to the initiation time of the data query request and the access control policy to obtain an encrypted symmetric key.

[0013] Based on the encrypted symmetric key, the validity of the key held by the user is verified.

[0014] If the key held by the user passes the validity verification, the second key is restored to the data to be queried.

[0015] According to a third aspect of the present invention, a privacy data access time control device based on a blockchain smart contract is provided, applied at a data sharing end, comprising:

[0016] The response unit is used to respond to the data query request sent by the user and retrieve the first ciphertext corresponding to the data to be queried from the blockchain;

[0017] The parsing unit parses the first ciphertext if it requires time-based access control, and obtains the ciphertext validity period and access control policy.

[0018] If the ciphertext generation unit detects that the first ciphertext has passed the validity verification using the ciphertext validity period, it randomly generates a symmetric key and generates a second ciphertext based on the symmetric key and the first ciphertext.

[0019] The symmetric key determination unit is used to perform object-level encryption on the symmetric key according to the initiation time corresponding to the data query request and the access control policy to obtain the encrypted symmetric key.

[0020] The feedback unit is used to feed back the second ciphertext and the encrypted symmetric key to the user terminal, wherein the user terminal is used to verify the validity of the key held by the user based on the encrypted symmetric key; if the key held by the user passes the validity verification, the second ciphertext is restored to the data to be queried.

[0021] According to a fourth aspect of the present invention, a privacy data access time control device based on a blockchain smart contract is provided, applied to a user terminal, comprising:

[0022] A receiving unit is configured to receive a second ciphertext and an encrypted symmetric key sent by a data sharing terminal. The data sharing terminal is configured to obtain a first ciphertext corresponding to the data to be queried from the blockchain; if the first ciphertext requires time-based access control, the first ciphertext is parsed to obtain a ciphertext validity period and an access control policy; if the validity period of the first ciphertext is used to detect that it has passed validity verification, a symmetric key is randomly generated, and a second ciphertext is generated based on the symmetric key and the first ciphertext; the symmetric key is then object-level encrypted according to the initiation time corresponding to the data query request and the access control policy to obtain an encrypted symmetric key.

[0023] The verification unit is used to verify the validity of the key held by the user based on the encrypted symmetric key.

[0024] The restoration unit restores the second key to the data to be queried if the key held by the user passes the validity verification.

[0025] According to a fifth aspect of the present invention, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement a privacy data access time control method based on a blockchain smart contract for a data sharing terminal.

[0026] According to a sixth aspect of the present invention, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement a user-end privacy data access time control method based on a blockchain smart contract.

[0027] According to a seventh aspect of the present invention, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements a method for controlling the privacy data access time based on a blockchain smart contract at a data sharing end.

[0028] According to an eighth aspect of the present invention, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements a user-end privacy data access time control method based on a blockchain smart contract.

[0029] According to a ninth aspect of the present invention, a privacy data access time control system based on blockchain smart contracts is provided, comprising: a privacy data access time control method based on blockchain smart contracts applied to a data sharing end; and a privacy data access time control method based on blockchain smart contracts applied to a user end.

[0030] Or, including: privacy data access time control devices based on blockchain smart contracts applied to data sharing terminals and user terminals;

[0031] Or, including: electronic devices used in data sharing terminals and user terminals;

[0032] Alternatively, it may include: computer-readable storage media used on data sharing terminals and user terminals.

[0033] The innovative aspects of this invention include:

[0034] 1. Access control of privacy data is implemented in the time dimension, ensuring that user keys cannot decrypt any on-chain data outside the validity period, and that on-chain ciphertext cannot be accessed by any user outside the validity period. This ability to flexibly control user access permissions is one of the innovations of this invention.

[0035] 2. Converting the initiation time of the data query request into a numerical attribute and transforming the problem of comparing the size of numerical attributes into the problem of determining whether the attribute exists is one of the innovations of this embodiment of the invention.

[0036] This invention provides a privacy data access time control method and apparatus based on blockchain smart contracts. Compared with existing technologies, it can respond to data query requests sent by a user terminal, obtain the first ciphertext corresponding to the data to be queried from the blockchain, and if the first ciphertext requires time access control, it is parsed to obtain the ciphertext validity period and access control policy. If the validity period of the ciphertext is used to detect that the first ciphertext has passed the validity verification, a symmetric key is randomly generated, and a second ciphertext is generated based on the symmetric key and the first ciphertext. At the same time, the symmetric key is object-level encrypted according to the initiation time of the data query request and the access control policy to obtain an encrypted symmetric key. Finally, the second ciphertext and the encrypted symmetric key are fed back to the user terminal, wherein the user terminal is used to verify the validity of its own key based on the encrypted symmetric key; if the user's own key passes the validity verification, the second ciphertext is restored to the data to be queried. Therefore, by judging the validity of the ciphertext and key at the moment the user initiates the access request, the present invention can realize access control of privacy data in the time dimension, ensuring that the user key cannot decrypt any on-chain data outside the validity period, and the on-chain ciphertext cannot be accessed by any user outside the validity period, thereby enabling flexible control of user permissions and realizing the management of user permissions in the time dimension.

[0037] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description

[0038] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0039] Figure 1 The illustration shows a flowchart of a privacy data access time control method based on blockchain smart contracts provided by an embodiment of the present invention;

[0040] Figure 2 A schematic diagram of the binary attribute set provided in an embodiment of the present invention is shown;

[0041] Figure 3 This invention provides a schematic diagram of the access tree structure corresponding to the numerical attributes provided in an embodiment of the invention.

[0042] Figure 4 This invention provides a schematic flowchart of another privacy data access time control method based on blockchain smart contracts, according to an embodiment of the present invention.

[0043] Figure 5 This diagram illustrates the structure of a privacy data access time control device based on a blockchain smart contract, according to an embodiment of the present invention.

[0044] Figure 6 A schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention is shown.

[0045] Figure 7 This invention provides a schematic diagram of another privacy data access time control device based on a blockchain smart contract, according to an embodiment of the present invention.

[0046] Figure 8 A schematic diagram of the physical structure of another electronic device provided in an embodiment of the present invention is shown. Detailed Implementation

[0047] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0048] It should be noted that the terms "comprising" and "having," and any variations thereof, in the embodiments and drawings of this invention are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the steps or units listed, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices.

[0049] Existing technologies cannot revoke a user's access permissions without affecting other users' keys, which is not conducive to achieving flexible control of access permissions.

[0050] To overcome the above-mentioned shortcomings, embodiments of the present invention provide a privacy data access time control method based on blockchain smart contracts, applied to data sharing endpoints, such as... Figure 1 As shown, the method includes:

[0051] Step 101: In response to the data query request sent by the user, retrieve the first ciphertext corresponding to the data to be queried from the blockchain.

[0052] The first ciphertext can be ciphertext encrypted at the object level or at the field level. Both object-level encryption and field-level encryption are attribute-based encryption methods. Specifically, object-level encryption refers to CP-ABE encryption, and field-level encryption refers to KP-ABE encryption.

[0053] The embodiments of the present invention are mainly applicable to scenarios where access control of privacy data is performed in the time dimension.

[0054] In this embodiment of the invention, the control of access time to privacy data is based on the use of attribute encryption on blockchain data. Attribute encryption allows for fine-grained access control management of data on the blockchain, while smart contracts are responsible for storing data in and retrieving data from the blockchain ledger, but without modifying the data. Specifically, during the data encryption phase, the data owner can use object-level encryption algorithms or field-level encryption algorithms to formulate access control policies for privacy data and encrypt the privacy data. During the data upload phase, smart contracts can be invoked to store the encrypted data (ciphertext) in the blockchain ledger. After the data is uploaded to the blockchain, users can query and decrypt the data as needed.

[0055] Furthermore, to achieve access control of privacy data over time, a key validity period can be set when generating the user key, and a ciphertext validity period can be set when encrypting the ciphertext. The key and ciphertext validity periods are then directly embedded into the key and ciphertext. The key and ciphertext validity periods are obtained through mathematical calculations based on cryptographic principles.

[0056] In specific application scenarios, when a user sends a data query request, a smart contract can be invoked to read the first ciphertext corresponding to the data to be queried from the blockchain ledger. Then, by judging the validity of the ciphertext and its corresponding key at the moment the user initiates the access request, access control of privacy data in the time dimension can be achieved, ensuring that the key held by the user cannot decrypt any on-chain data outside of its validity period, and that the on-chain ciphertext cannot be accessed by any user outside of its validity period.

[0057] Step 102: If the first ciphertext requires time-based access control, then parse the first ciphertext to obtain the ciphertext validity period and access control policy.

[0058] In this embodiment of the invention, after obtaining the first ciphertext, it is determined whether the first ciphertext carries a time-based access control identifier. If it does not carry a time-based access control identifier, it means that the first ciphertext does not require time-based access control, and in this case, the first ciphertext can be directly packaged and sent to the user. If it carries a time-based access control identifier, it means that the first ciphertext requires time-based access control, and in this case, the ciphertext validity period and access control policy in the ciphertext need to be parsed. Specifically, in object-level encryption algorithms, the ciphertext embeds an access control policy represented in the form of an access tree, and the key embeds a user attribute set. Therefore, for object-level encrypted first ciphertext, the access control policy can be directly obtained from the ciphertext. Based on this, the method includes: parsing the first ciphertext to obtain the ciphertext validity period and access control policy in the first ciphertext.

[0059] In field-level encryption algorithms, the ciphertext embeds a set of user attributes, and the key embeds an access control policy represented as an access tree. Since the key is only held by the user, the access control policy cannot be directly obtained. Therefore, the first ciphertext needs to be object-level encrypted first, and then parsed. Based on this, the method includes: object-level encryption of the first ciphertext to obtain a third ciphertext; and parsing the third ciphertext to obtain the ciphertext validity period and the access control policy.

[0060] It should be noted that the embodiments of the present invention use an attribute encryption method in which attributes and policies are not hidden. There are multiple fields in the ciphertext and its corresponding key. The validity period of the ciphertext and the access control policy can be obtained by reading the field content without decryption.

[0061] Furthermore, in a consortium blockchain, smart contracts are the sole channel for users to interact with the blockchain. Ledger queries and write operations can only be performed by smart contracts, and no user can legitimately bypass them to access on-chain data. Using smart contracts is the only way for users to access on-chain data, making them the sole bridge for pairing ciphertext and keys. When a user requests to query on-chain data, by determining the validity of the ciphertext and the key held by the user at the moment the access request is initiated, access control for privacy data can be achieved over time.

[0062] Specifically, when validating the first ciphertext, if the initiation time of the data query request is within the validity period of the ciphertext, then the first ciphertext passes the validity verification and can be accessed by the user; if the initiation time of the data query request is not within the validity period of the ciphertext, then the first ciphertext fails the validity verification and cannot be accessed by the user. Similarly, the validity verification can be performed on the third ciphertext.

[0063] Step 103: If the validity period of the ciphertext is used to detect that the first ciphertext has passed the validity verification, a symmetric key is randomly generated, and a second ciphertext is generated based on the symmetric key and the first ciphertext.

[0064] In this embodiment of the invention, after determining that the ciphertext has passed the validity verification, it is necessary to verify the validity of the key held by the user. Since the user key can only be kept by the user and the smart contract cannot obtain the user key, the user needs to prove that the user key meets the access control policy and that the user key is valid at the current moment without leaking the key.

[0065] To prove the above, a symmetric key needs to be randomly generated using a smart contract. When the first ciphertext is object-level encrypted, the first ciphertext is symmetrically encrypted using the symmetric key to generate the second ciphertext. When the first ciphertext is field-level encrypted, the third ciphertext (the ciphertext after object-level encryption of the first ciphertext) is symmetrically encrypted using the symmetric key to generate the second ciphertext.

[0066] Step 104: Based on the initiation time corresponding to the data query request and the access control policy, perform object-level encryption on the symmetric key to obtain the encrypted symmetric key.

[0067] In this embodiment of the invention, when proving that a user key satisfies an access control policy, the randomly generated symmetric key can be encrypted at the object level using the access control policy. If the user can successfully decrypt the encrypted symmetric key, it indicates that the attribute set in the user key satisfies the access control policy in the ciphertext, and the user can decrypt the ciphertext. When proving that a user key is within its validity period, the randomly generated symmetric key can be encrypted at the object level using "time > the initiation time of the data query request" as the access control policy. If the user can successfully decrypt the encrypted symmetric key, it indicates that the user key is within its validity period.

[0068] It should be noted that the user must prove both of the above points simultaneously, and cannot prove them separately, because the user may have multiple keys. If the user has two keys, one of which satisfies the ciphertext access control policy but has expired, and the other of which does not satisfy the ciphertext access control policy but is still valid, then the user can prove that they satisfy the above two requirements separately, but in fact the user does not have the right to access the ciphertext at this time.

[0069] Based on this, the embodiments of the present invention combine the access control policy in the ciphertext with the initiation time of the data query request to obtain a new access control policy, and then encrypt the symmetric key. If the user can successfully decrypt the encrypted symmetric key, it means that the key possessed by the user is within the validity period and can decrypt the ciphertext. Then, when the user decrypts the symmetric key, the data to be queried can be restored.

[0070] Furthermore, in order to encrypt the symmetric key, the step of performing object-level encryption on the symmetric key according to the initiation time corresponding to the data query request and the access control policy to obtain the encrypted symmetric key includes: generating a numerical comparison strategy according to the initiation time corresponding to the data query request; combining the numerical comparison strategy and the access control policy into a new access control policy; and performing object-level encryption on the symmetric key based on the new access control policy to obtain the encrypted symmetric key.

[0071] Furthermore, the step of generating a numerical comparison strategy based on the initiation time corresponding to the data query request includes: determining the numerical attribute corresponding to the initiation time; converting the numerical attribute into a binary attribute set; constructing an access tree based on the binary attribute set; and determining the numerical comparison strategy based on the access tree.

[0072] Specifically, time is a comparable data type. To embed time as an attribute into ciphertext or a key, the attribute encryption algorithm must first support time attributes. If a certain point in time is used as a reference point, then time can be converted into the difference between that point and the reference point. Therefore, time can be described numerically, and the time attribute is equivalently converted into a numerical attribute. Numerical attributes are relative to string attributes. String attributes are the most basic attribute type, used to describe a certain property of the ciphertext or key. These attributes do not have specific values, while numerical attributes have specific values. For example, age is a numerical attribute, and generally, the specific age needs to be specified.

[0073] Numerical attributes are special because they involve comparing numerical values. Attribute encryption algorithms can only determine the existence of an attribute, so the problem of comparing numerical attributes needs to be transformed into determining the existence of an attribute. This invention primarily discusses the implementation of integer attributes. Integers are represented in binary form in computers. When comparing numerical values, the comparison starts from the most significant bit. Taking the comparison of positive integers as an example, two positive integers are compared starting from the most significant bit. When a bit is found to be different, the integer with that bit set to 1 is considered larger. Bit comparisons only result in two possibilities: they are the same or different. Furthermore, for any two binary digits, knowing whether the other is the same allows us to determine their relative size. Therefore, the problem of comparing numerical attributes can be transformed into determining the existence of a specific binary digit according to certain rules.

[0074] Furthermore, in order to compare the magnitudes of numerical attributes, it is first necessary to convert the numerical attributes into an equivalent set of binary attributes. For example... Figure 2As shown, a numerical attribute needs to be converted into a binary attribute set consisting of all its binary bits. The number of binary bits can be set according to the requirements. It should be noted that setting too few binary bits may not be able to represent the value correctly, while setting too many will affect the efficiency of encryption and decryption. In addition, it is necessary to ensure that the ciphertext and the key use binary bits of the same number of bits.

[0075] Converting a numerical attribute into a binary attribute set consisting of all its binary bits is for the purpose of numerical comparison. A specific numerical comparison strategy is essentially an access strategy, equivalent to an access tree. Numerical comparison strategies can be divided into three categories: less than, equal to, and greater than.

[0076] The numerical comparison strategy of the equality type is equivalent to a visit tree of depth 2, where the threshold value of the root node is n / n, where n is the number of binary bits, and the set of binary attributes corresponding to the numerical attributes constitutes all the child nodes of the root node and all the leaf nodes of the visit tree.

[0077]

[0078] As this formula shows, when comparing values, the weight of a particular binary bit is greater than the sum of the weights of all subsequent lower binary bits. Therefore, higher bits should be compared first. The lower the weight of a binary bit, the farther the leaf node representing the binary attribute is from the root node. Conversely, the higher the weight of a binary bit, the closer the leaf node representing the binary attribute is to the root node. This is similar to the rules for constructing a Huffman tree; the access tree corresponding to the numerical comparison strategy is structurally similar to a Huffman tree.

[0079] Furthermore, the access tree corresponding to the numerical comparison strategies for less than and greater than types is as follows: Figure 3 As shown, Figure 3 The access tree shown in (a) corresponds to the access policy "age<10". When constructing the access tree corresponding to the numerical comparison policy of less than type, the following steps are performed:

[0080] 1. The traversal tree is a binary tree. Initially, the number of leaf nodes is equal to the number of binary bits, and all nodes are null and await further processing.

[0081] 2. All binary bits corresponding to leaf nodes are set to 0, in the form of "0***" or "**0*".

[0082] 3. When the binary bit corresponding to the value is 1, the parent node uses an OR gate (with the threshold value set to 1 / 2); when the binary bit corresponding to the value is 0, the parent node uses an AND gate (with the threshold value set to 2 / 2).

[0083] 4. The parent node of the leaf node corresponding to the last binary bit that is 1 should be ANDed, and all nodes in the access tree that have not yet been processed should be deleted. If there is a conflict with rule 3, the current rule shall prevail.

[0084] at the same time, Figure 3 (b) The corresponding access strategy is "age>10". When constructing the access tree corresponding to the numerical comparison strategy of greater than type, the following steps are performed:

[0085] 1. The traversal tree is a binary tree. Initially, the number of leaf nodes is equal to the number of binary bits, and all nodes are null and await further processing.

[0086] 2. Set all binary bits corresponding to leaf nodes to 1, in the form of "1***" or "**1*";

[0087] 3. When the binary bit corresponding to the value is 1, the parent node uses an AND gate (with the threshold value set to 2 / 2); when the binary bit corresponding to the value is 0, the parent node uses an OR gate (with the threshold value set to 1 / 2).

[0088] 4. The parent node of the leaf node corresponding to the last 0 bit uses an AND gate, and all nodes in the access tree that have not yet been processed need to be deleted. If there is a conflict with rule 3, the current rule shall prevail.

[0089] It should be noted that the access strategy for values ​​less than or equal to can be converted to the access strategy for values ​​less than. For example, "age≤10" is equivalent to "age<11". Similarly, the access strategy for values ​​greater than or equal to can be converted to the access strategy for values ​​greater than.

[0090] Step 105: Feed back the second ciphertext and the encrypted symmetric key to the user terminal.

[0091] The user terminal is used to verify the validity of its own key based on the encrypted symmetric key; if the user's own key passes the validity verification, the second ciphertext is restored to the data to be queried.

[0092] In this embodiment of the invention, the smart contract packages the second ciphertext encrypted using a symmetric encryption algorithm and the symmetric key encrypted using an object-level encryption algorithm and returns them to the user, i.e., the data accessor. During the data decryption phase, the user can only decrypt the symmetric key and use it to decrypt the second ciphertext to restore the data to be queried if the key held by the user satisfies the access control policy and is within its validity period.

[0093] This invention provides a privacy data access time control method based on blockchain smart contracts. By judging the validity of the ciphertext and key at the moment the user initiates the access request, it can realize access control of privacy data in the time dimension, ensuring that the user's key cannot decrypt any on-chain data outside the validity period, and the on-chain ciphertext cannot be accessed by any user outside the validity period. This enables flexible control of user permissions and realizes the management of user permissions in the time dimension.

[0094] Furthermore, as a refinement and extension of the above embodiments, this invention provides another method for controlling privacy data access time based on blockchain smart contracts, applied to the user end, such as... Figure 4 As shown, the method includes:

[0095] Step 201: Receive the second ciphertext and the encrypted symmetric key sent by the data sharing end.

[0096] The data sharing terminal is used to obtain the first ciphertext corresponding to the data to be queried from the blockchain; if the first ciphertext requires time-based access control, the first ciphertext is parsed to obtain the ciphertext validity period and access control policy; if the validity period of the ciphertext is used to detect that the first ciphertext has passed the validity verification, a symmetric key is randomly generated, and a second ciphertext is generated based on the symmetric key and the first ciphertext; according to the initiation time corresponding to the data query request and the access control policy, the symmetric key is object-level encrypted to obtain the encrypted symmetric key.

[0097] In this embodiment of the invention, if the ciphertext passes the validity verification, the data sharing terminal will package the second ciphertext and the encrypted symmetric key and send them to the user terminal. Regarding the second ciphertext, if the first ciphertext corresponding to the data to be queried is ciphertext obtained through object-level encryption, then the first ciphertext is directly symmetrically encrypted to obtain the second ciphertext; if the first ciphertext corresponding to the data to be queried is ciphertext obtained through field-level encryption, then the first ciphertext needs to be first encrypted at the object level to obtain the third ciphertext, and then the third ciphertext is symmetrically encrypted to obtain the second ciphertext.

[0098] Step 202: Verify the validity of the key held by the user based on the encrypted symmetric key.

[0099] In an embodiment of the present invention, the method for verifying the validity of a key includes: decrypting the encrypted symmetric key based on a key held by the user; if the symmetric key is successfully decrypted, the user-held key is determined to have passed the validity verification; if the symmetric key is not successfully decrypted, the user-held key is determined to have failed the validity verification.

[0100] Specifically, if a user successfully decrypts the symmetric key, it means that the key held by the user meets the access control policy and is within its validity period; conversely, if a user fails to decrypt the symmetric key, it means that the key held by the user does not meet the access control policy or is not within its validity period.

[0101] Step 203: If the key held by the user passes the validity verification, then the second key is restored to the data to be queried.

[0102] In this embodiment of the invention, if a user successfully decrypts the symmetric key, the user can use the symmetric key and their own key to restore the second ciphertext. The method for this process includes: if the first ciphertext is ciphertext encrypted at the field level, then the user uses the symmetric key to symmetrically decrypt the second ciphertext to obtain the third ciphertext, and uses their own key to perform object-level decryption and field-level decryption on the third ciphertext to obtain the data to be queried; if the first ciphertext is ciphertext encrypted at the object level, then the user uses the symmetric key to symmetrically decrypt the second ciphertext to obtain the first ciphertext, and uses their own key to perform object-level decryption on the first ciphertext to obtain the data to be queried.

[0103] Another privacy data access time control method based on blockchain smart contracts provided by this invention can achieve access control of privacy data in the time dimension by judging the validity of the ciphertext and key at the moment the user initiates the access request. This ensures that the user key cannot decrypt any on-chain data outside the validity period, and the on-chain ciphertext cannot be accessed by any user outside the validity period. This allows for flexible control of user permissions and the management of user permissions in the time dimension.

[0104] Furthermore, as Figure 1 In specific implementation, embodiments of the present invention provide a privacy data access time control device based on blockchain smart contracts, such as... Figure 5 As shown, the device includes: a response unit 31, a parsing unit 32, a ciphertext generation unit 33, a symmetric key determination unit 34, and a feedback unit 35.

[0105] The response unit 31 can be used to respond to a data query request sent by the user terminal and obtain the first ciphertext corresponding to the data to be queried from the blockchain.

[0106] The parsing unit 32 can be used to parse the first ciphertext if time access control is required, and obtain the ciphertext validity period and access control policy.

[0107] The ciphertext generation unit 33 can be used to randomly generate a symmetric key if the validity period of the first ciphertext is detected to have passed the validity verification, and generate a second ciphertext based on the symmetric key and the first ciphertext.

[0108] The symmetric key determination unit 34 can be used to perform object-level encryption on the symmetric key according to the initiation time corresponding to the data query request and the access control policy to obtain the encrypted symmetric key.

[0109] Feedback unit 35 can be used to feed back the second ciphertext and the encrypted symmetric key to the user terminal, wherein the user terminal is used to verify the validity of the key held by the user based on the encrypted symmetric key; if the key held by the user passes the validity verification, the second ciphertext is restored to the data to be queried.

[0110] In specific application scenarios, the ciphertext generation unit 33 can also be used to perform object-level encryption on the first ciphertext if the first ciphertext is ciphertext that has been encrypted at the field level, in order to obtain the third ciphertext.

[0111] The parsing unit 32 can also be used to parse the third ciphertext to obtain the ciphertext validity period and access control policy.

[0112] The ciphertext generation unit 33 can also be used to randomly generate a symmetric key if the validity period of the ciphertext is used to detect that the third ciphertext has passed the validity verification, and generate a second ciphertext based on the symmetric key and the third ciphertext.

[0113] In specific application scenarios, the device further includes: a validity verification unit.

[0114] The validity verification unit can be used to determine that the first ciphertext has passed the validity verification and can be accessed if the initiation time of the data query request is within the validity period of the ciphertext.

[0115] The validity verification unit can also be used to determine that the first ciphertext has failed the validity verification and cannot be accessed if the initiation time corresponding to the data query request is not within the validity period of the ciphertext.

[0116] In specific application scenarios, the symmetric key determination unit 34 includes: a generation module, a combination module, and an encryption module.

[0117] The generation module can be used to generate a numerical comparison strategy based on the initiation time corresponding to the data query request.

[0118] The combination module can be used to combine the numerical comparison strategy and the access control strategy into a new access control strategy.

[0119] The encryption module can be used to perform object-level encryption on the symmetric key based on the new access control policy to obtain the encrypted symmetric key.

[0120] Furthermore, the generation module can be specifically used to determine the numerical attribute corresponding to the initiation time; convert the numerical attribute into a binary attribute set; construct an access tree based on the binary attribute set; and determine the numerical comparison strategy based on the access tree.

[0121] It should be noted that other corresponding descriptions of the functional modules involved in the privacy data access time control device based on blockchain smart contracts provided in this embodiment of the invention can be found in [reference needed]. Figure 1 The corresponding description of the method shown will not be repeated here.

[0122] Based on the above, Figure 1 Accordingly, this embodiment of the invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, performs the following steps: In response to a data query request sent by a user terminal, obtaining a first ciphertext corresponding to the data to be queried from the blockchain; if the first ciphertext requires time-based access control, parsing the first ciphertext to obtain a ciphertext validity period and an access control policy; if the validity period of the ciphertext indicates that the first ciphertext has passed validity verification, randomly generating a symmetric key, and generating a second ciphertext based on the symmetric key and the first ciphertext; performing object-level encryption on the symmetric key according to the initiation time corresponding to the data query request and the access control policy to obtain an encrypted symmetric key; feeding back the second ciphertext and the encrypted symmetric key to the user terminal, wherein the user terminal is used to verify the validity of its own key based on the encrypted symmetric key; if the user's own key passes validity verification, restoring the second ciphertext to the data to be queried.

[0123] Based on the above, Figure 1 The method shown and as Figure 5 The embodiment of the device shown in the invention also provides a physical structural diagram of an electronic device, such as... Figure 6As shown, the electronic device includes a processor 51, a memory 52, and a computer program stored in the memory 52 and executable on the processor. Both the memory 52 and the processor 51 are mounted on a bus 53. When the processor 51 executes the program, it performs the following steps: In response to a data query request sent by a user terminal, it retrieves a first ciphertext corresponding to the data to be queried from the blockchain; if the first ciphertext requires time-based access control, it parses the first ciphertext to obtain a ciphertext validity period and an access control policy; if the validity period of the ciphertext indicates that the first ciphertext has passed validity verification, it randomly generates a symmetric key and generates a second ciphertext based on the symmetric key and the first ciphertext; it performs object-level encryption on the symmetric key according to the initiation time corresponding to the data query request and the access control policy to obtain an encrypted symmetric key; it feeds back the second ciphertext and the encrypted symmetric key to the user terminal, wherein the user terminal uses the encrypted symmetric key to verify the validity of its own key; if the user's own key passes validity verification, it restores the second ciphertext to the data to be queried.

[0124] Furthermore, as Figure 4 In specific implementation, embodiments of the present invention provide a privacy data access time control device based on blockchain smart contracts, such as... Figure 7 As shown, the device includes: a receiving unit 41, a verification unit 42, and a restoration unit 43.

[0125] The receiving unit 41 can be used to receive a second ciphertext and an encrypted symmetric key sent by the data sharing terminal. The data sharing terminal is used to obtain a first ciphertext corresponding to the data to be queried from the blockchain. If the first ciphertext requires time-based access control, the first ciphertext is parsed to obtain the ciphertext validity period and access control policy. If the validity period of the ciphertext is used to detect that the first ciphertext has passed the validity verification, a symmetric key is randomly generated, and a second ciphertext is generated based on the symmetric key and the first ciphertext. The symmetric key is then object-level encrypted according to the initiation time corresponding to the data query request and the access control policy to obtain an encrypted symmetric key.

[0126] The verification unit 42 can be used to verify the validity of the key held by the user based on the encrypted symmetric key.

[0127] The restoration unit 43 can be used to restore the second key into the data to be queried if the key held by the user passes the validity verification.

[0128] In a specific application scenario, the verification unit 42 can be specifically used to decrypt the encrypted symmetric key based on the key held by the user; if the symmetric key is successfully decrypted, it is determined that the key held by the user has passed the validity verification; if the symmetric key is not successfully decrypted, it is determined that the key held by the user has failed the validity verification.

[0129] In specific application scenarios, the restoration unit 43 can be specifically used to: if the first ciphertext is ciphertext encrypted at the field level, then use the symmetric key to symmetrically decrypt the second ciphertext to obtain the third ciphertext, and use the key held by the user to perform object-level decryption and field-level decryption on the third ciphertext to obtain the data to be queried; if the first ciphertext is ciphertext encrypted at the object level, then use the symmetric key to symmetrically decrypt the second ciphertext to obtain the first ciphertext, and use the key held by the user to perform object-level decryption on the first ciphertext to obtain the data to be queried.

[0130] It should be noted that other corresponding descriptions of the functional modules involved in the privacy data access time control device based on blockchain smart contracts provided in this embodiment of the invention can be found in [reference needed]. Figure 4 The corresponding description of the method shown will not be repeated here.

[0131] Based on the above, Figure 4 Accordingly, this embodiment of the invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, performs the following steps: receiving a second ciphertext and an encrypted symmetric key sent by a data sharing terminal, wherein the data sharing terminal is used to obtain a first ciphertext corresponding to the data to be queried from the blockchain; if the first ciphertext requires time-based access control, parsing the first ciphertext to obtain a ciphertext validity period and an access control policy; if the validity period of the ciphertext is used to detect that the first ciphertext has passed validity verification, randomly generating a symmetric key, and generating a second ciphertext based on the symmetric key and the first ciphertext; performing object-level encryption on the symmetric key according to the initiation time corresponding to the data query request and the access control policy to obtain an encrypted symmetric key; verifying the validity of a key held by the user based on the encrypted symmetric key; if the key held by the user passes validity verification, restoring the second key to the data to be queried.

[0132] Based on the above, Figure 4 The method shown and as Figure 7 The embodiment of the device shown in the invention also provides a physical structural diagram of an electronic device, such as... Figure 8As shown, the electronic device includes: a processor 61, a memory 62, and a computer program stored in the memory 62 and executable on the processor. Both the memory 62 and the processor 61 are mounted on a bus 63. When the processor 61 executes the program, it performs the following steps: receiving a second ciphertext and an encrypted symmetric key sent by a data sharing terminal, wherein the data sharing terminal is used to obtain a first ciphertext corresponding to the data to be queried from the blockchain; if the first ciphertext requires time-based access control, the first ciphertext is parsed to obtain a ciphertext validity period and an access control policy; if the validity period of the first ciphertext is used to detect that it has passed validity verification, a symmetric key is randomly generated, and a second ciphertext is generated based on the symmetric key and the first ciphertext; the symmetric key is object-level encrypted according to the initiation time corresponding to the data query request and the access control policy to obtain an encrypted symmetric key; the key held by the user is validated based on the encrypted symmetric key; if the key held by the user passes validity verification, the second key is restored to the data to be queried.

[0133] By determining the validity of the ciphertext and key at the moment the user initiates an access request, this invention enables access control of privacy data in the time dimension, ensuring that the user's key cannot decrypt any on-chain data outside its validity period, and that the on-chain ciphertext cannot be accessed by any user outside its validity period. This allows for flexible control of user permissions and enables management of user permissions in the time dimension.

[0134] Those skilled in the art will understand that the accompanying drawings are merely schematic diagrams of one embodiment, and the modules or processes shown in the drawings are not necessarily essential for implementing the present invention.

[0135] Those skilled in the art will understand that the modules in the apparatus of the embodiments can be distributed in the apparatus of the embodiments as described in the embodiments, or they can be located in one or more devices different from this embodiment with corresponding changes. The modules of the above embodiments can be combined into one module, or they can be further divided into multiple sub-modules.

[0136] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for controlling access time of private data based on a blockchain smart contract, applied to a data sharing end, characterized in that, include: In response to a data query request sent by the user, the first ciphertext corresponding to the data to be queried is obtained from the blockchain; If the first ciphertext requires time-based access control, then the first ciphertext is parsed to obtain the ciphertext validity period and access control policy. If the validity period of the ciphertext is used to detect that the first ciphertext has passed the validity verification, a symmetric key is randomly generated, and a second ciphertext is generated based on the symmetric key and the first ciphertext. If the initiation time of the data query request is within the validity period of the ciphertext, it is determined that the first ciphertext has passed the validity verification and can be accessed. Based on the initiation time of the data query request and the access control policy, the symmetric key is encrypted at the object level to obtain the encrypted symmetric key. The second ciphertext and the encrypted symmetric key are fed back to the user terminal, wherein the user terminal is used to verify the validity of the key held by the user based on the encrypted symmetric key; if the key held by the user passes the validity verification, the second ciphertext is restored to the data to be queried.

2. The method of claim 1, wherein, The method further includes: If the first ciphertext is ciphertext encrypted at the field level, then the first ciphertext is encrypted at the object level to obtain the third ciphertext; The third ciphertext is parsed to obtain the ciphertext validity period and access control policy; If the validity period of the ciphertext is used to detect that the third ciphertext has passed the validity verification, then a symmetric key is randomly generated, and a second ciphertext is generated based on the symmetric key and the third ciphertext; and / or, After parsing the first ciphertext to obtain the ciphertext validity period and access control policy, the method further includes: If the initiation time of the data query request is not within the validity period of the ciphertext, then the first ciphertext is determined to have failed the validity verification and cannot be accessed.

3. The method according to claim 1 or 2, characterized in that, The step of performing object-level encryption on the symmetric key based on the initiation time corresponding to the data query request and the access control policy to obtain the encrypted symmetric key includes: A numerical comparison strategy is generated based on the initiation time of the data query request; The numerical comparison strategy and the access control strategy are combined into a new access control strategy; The symmetric key is encrypted at the object level based on the new access control policy to obtain the encrypted symmetric key.

4. The method of claim 3, wherein, The step of generating a numerical comparison strategy based on the initiation time corresponding to the data query request includes: Determine the numerical attribute corresponding to the initiation time; Convert the numerical attributes into a set of binary attributes; Based on the set of binary attributes, an access tree is constructed, and based on the access tree, the numerical comparison strategy is determined.

5. A method for controlling the time of privacy data access based on blockchain smart contracts, applied to the user end, characterized in that, include: The system receives a second ciphertext and an encrypted symmetric key from a data sharing terminal. The data sharing terminal retrieves a first ciphertext corresponding to the data to be queried from the blockchain. If the first ciphertext requires time-based access control, it parses the first ciphertext to obtain its validity period and access control policy. If the validity period of the first ciphertext is used to detect that it has passed validity verification, a symmetric key is randomly generated, and a second ciphertext is generated based on the symmetric key and the first ciphertext. The symmetric key is then object-level encrypted according to the initiation time of the data query request and the access control policy to obtain an encrypted symmetric key. Based on the encrypted symmetric key, the validity of the key held by the user is verified. If the key held by the user passes the validity verification, the second ciphertext is restored to the data to be queried.

6. The method of claim 5, wherein, The step of verifying the validity of the key held by the user based on the encrypted symmetric key includes: Decrypt the encrypted symmetric key using the key held by the user. If the symmetric key is successfully decrypted, then the key held by the user is deemed to have passed the validity verification. If the symmetric key is not successfully decrypted, it is determined that the key held by the user has failed the validity verification; and / or, the step of restoring the second ciphertext to the data to be queried includes: If the first ciphertext is ciphertext encrypted at the field level, then the second ciphertext is symmetrically decrypted using the symmetric key to obtain the third ciphertext. Then, the third ciphertext is decrypted at the object level and at the field level using the key held by the user to obtain the data to be queried. If the first ciphertext is object-level encrypted, then the second ciphertext is symmetrically decrypted using the symmetric key to obtain the first ciphertext, and the first ciphertext is object-level decrypted using the key held by the user to obtain the data to be queried.

7. A privacy data access time control device based on blockchain smart contracts, applied to a data sharing end and / or to a user end, characterized in that: When applied to data sharing endpoints, it includes: The response unit is used to respond to the data query request sent by the user and retrieve the first ciphertext corresponding to the data to be queried from the blockchain; The parsing unit is used to parse the first ciphertext if time-based access control is required, and obtain the ciphertext validity period and access control policy. The ciphertext generation unit is configured to randomly generate a symmetric key if the first ciphertext passes the validity verification by utilizing the ciphertext validity period, and generate a second ciphertext based on the symmetric key and the first ciphertext, wherein if the initiation time corresponding to the data query request is within the ciphertext validity period, it is determined that the first ciphertext has passed the validity verification and can be accessed; The symmetric key determination unit is used to perform object-level encryption on the symmetric key according to the initiation time corresponding to the data query request and the access control policy to obtain the encrypted symmetric key. A feedback unit is used to feed back the second ciphertext and the encrypted symmetric key to the user terminal, wherein the user terminal is used to verify the validity of the key held by the user based on the encrypted symmetric key; if the key held by the user passes the validity verification, the second ciphertext is restored to the data to be queried; And / or, When applied to the user end, it includes: A receiving unit is configured to receive a second ciphertext and an encrypted symmetric key sent by a data sharing terminal. The data sharing terminal is configured to obtain a first ciphertext corresponding to the data to be queried from the blockchain; if the first ciphertext requires time-based access control, the first ciphertext is parsed to obtain a ciphertext validity period and an access control policy; if the validity period of the first ciphertext is used to detect that it has passed validity verification, a symmetric key is randomly generated, and a second ciphertext is generated based on the symmetric key and the first ciphertext; the symmetric key is then object-level encrypted according to the initiation time corresponding to the data query request and the access control policy to obtain an encrypted symmetric key. The verification unit is used to verify the validity of the key held by the user based on the encrypted symmetric key. The restoration unit is used to restore the second ciphertext into the data to be queried if the key held by the user passes the validity verification.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the computer program is executed by the processor, it implements the privacy data access time control method based on blockchain smart contracts applied to the data sharing end as described in any one of claims 1 to 4; and / or, when the computer program is executed by the processor, it implements the privacy data access time control method based on blockchain smart contracts applied to the user end as described in any one of claims 5 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the privacy data access time control method based on blockchain smart contracts applied to the data sharing end as described in any one of claims 1 to 4; and / or, when the computer program is executed by the processor, it implements the privacy data access time control method based on blockchain smart contracts applied to the user end as described in any one of claims 5 to 6. 10.A system for controlling access time of private data based on a blockchain smart contract, characterized in that, include: The privacy data access time control method based on blockchain smart contracts applied to a data sharing end, as described in any one of claims 1 to 4; And, the privacy data access time control method based on blockchain smart contracts applied to the user terminal according to any one of claims 5 to 6; Alternatively, it may include: the privacy data access time control device based on blockchain smart contracts applied to the data sharing terminal and the user terminal as described in claim 7; Alternatively, it may include: the electronic device of claim 8 applied to the data sharing terminal and the user terminal; Alternatively, it may include: the computer-readable storage medium of claim 9 applied to the data sharing terminal and the user terminal.

Citation Information

Patent Citations

  • Cloud storage access control method based on attribute-based encryption

    CN107846397A

  • A blockchain data access control method and device based on attribute encryption

    CN109711184A

  • Alliance block chain data access control method based on CP-ABE algorithm

    CN111371561A