Identity authentication method and system based on block chain and zero-knowledge proof
By using the identity authentication method of blockchain and zero-knowledge proof in the IoT environment, the problems of identity leakage and privacy protection in traditional authentication schemes are solved, anonymity authentication and device information security are achieved, and the security of IoT devices is ensured. Legality and data security.
Patent Information
- Application Number
- CN202410884413.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-03
- Publication Date
- 2024-09-13
AI Technical Summary
In the massive, multi-dimensional, and heterogeneous IoT environment, traditional centralized authentication solutions have risks of identity leakage and privacy protection, making it difficult to ensure the identity legitimacy and data security of devices and users.
Adopting an identity authentication method based on blockchain and zero-knowledge proof, anonymity authentication is achieved between the device and the blockchain through a non-interactive zero-knowledge proof algorithm, and the Hyperledger Fabric alliance chain is used for device registration and verification to ensure device identity. anonymity and privacy protection.
It achieves anonymous authentication of IoT devices, protects user privacy, avoids the risk of identity leakage, reduces the risk of malicious third-party destruction through a decentralized architecture, and ensures the security of device information.
Smart Images

Figure CN118646540A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Internet of Things, and in particular to an identity authentication method and system based on blockchain and zero-knowledge proof. Background Art
[0002] With the rapid development of the Internet of Things (IoT) technology, the number of various smart devices is experiencing explosive growth. Traditional IoT authentication solutions mostly use digital certificates based on public key infrastructure (PKI).
[0003] The decentralized nature of blockchain makes it possible to implement distributed identity authentication without a trusted third party. By leveraging blockchain and smart contract technologies, authentication schemes can be implemented efficiently and securely. Due to its advantages of decentralization, tamper-proofing, traceability, security, transparency, and programmability, blockchain technology has been widely applied in fields such as supply chain, digital finance, smart agriculture, and the Internet of Things. Based on distributed networks, cryptographic algorithms, consensus mechanisms, game theory, and smart contracts, blockchain systems create a trustless network platform for distributed collaborative applications and offer a solution that replaces traditional centralized institutional credit guarantees with algorithmic credit. Blockchain's decentralized nature is naturally well-suited for large-scale, distributed IoT scenarios. Consequently, numerous studies have applied blockchain technology to IoT scenarios, proposing decentralized IoT management architectures.
[0004] In the massive, multi-dimensional, and heterogeneous IoT environment, ensuring the legitimacy of devices and users accessing the network is a paramount prerequisite for maintaining IoT system security. Identity authentication results are the primary basis for system decisions regarding whether to allow users / devices to participate in IoT events and whether to grant access rights to data requesters. The privacy needs of end users and devices regarding their identities and data during network interactions must be factored into authentication scheme design. Centralized entities pose the risk of data tampering and privacy theft.
[0005] How to implement decentralized network device identity authentication based on blockchain to ensure the security of user identity and data is a technical problem that needs to be solved. Summary of the Invention
[0006] The technical task of the present invention is to address the above shortcomings and provide an identity authentication method and system based on blockchain and zero-knowledge proof to solve the technical problem of how to implement decentralized network device identity authentication based on blockchain to ensure the security of user identity and data.
[0007] In a first aspect, the present invention provides an identity authentication method based on blockchain and zero-knowledge proof, which is applied between a device, a blockchain, and a data center. The blockchain is a consortium chain Hyperledger Fabric, and a non-interactive zero-knowledge proof algorithm is introduced into the smart contract of the blockchain. The method includes the following steps:
[0008] Key generation: The device generates a public key and a private key, calculates the hash value of the public key as the device identity, and calls a non-interactive zero-knowledge proof algorithm to generate a proof key and a verification key.
[0009] Device registration: The device uses a non-interactive zero-knowledge proof algorithm to hash its identity information to obtain encrypted identity information. It then constructs registration information based on the device identity, encrypted identity information, and verification key, and sends the registration information to the blockchain for registration application. For devices that pass verification, the blockchain stores the registration information in a block.
[0010] Device verification: The device side generates proof information based on the public key and public key hash value by calling the non-interactive zero-knowledge proof algorithm, constructs verification information based on the device identity, verification key and proof information, and sends the verification information to the blockchain for verification application. The blockchain calls the non-interactive zero-knowledge proof algorithm to verify the verification information and returns the verification results to the device side and the data center. For the device side that passes the verification, the data center provides access control and permission management for the device side.
[0011] Preferably, the key generation comprises the following steps:
[0012] Generate a public key and a private key using the P-256 elliptic curve, calculate the hash value of the public key using the SHA-256 hash algorithm, obtain a string as the public key hash value, and select a string of a predetermined length from the public key hash value as the device identity;
[0013] Based on the public key and public key hash value, the key setting function in the non-interactive zero-knowledge proof algorithm is called to generate the proof key and verification key.
[0014] Preferably, device registration includes the following steps:
[0015] The device information on the device side is used as input, and the hash function in the non-interactive zero-knowledge proof algorithm is called to perform hash calculation on the device information to generate a fixed-length string as a token;
[0016] Construct registration information based on identity information, encrypted identity information, and verification key, and send the registration information to the blockchain;
[0017] The endorsement nodes and sorting nodes in the Fabric network verify the received registration information and determine whether the corresponding device end exists in the blockchain based on the device identity. If not, the verification passes and the registration information is stored in the blockchain block in the form of key-value, where the device identity is used as the key and the encrypted identity information, device description information and verification key are used as the value.
[0018] Preferably, device verification includes the following steps:
[0019] The device generates a witness based on its public key and public key hash value by calling a non-interactive zero-knowledge proof algorithm, and generates proof information using the witness and proof key as input;
[0020] The device constructs verification information based on its device identity, verification key, and certification information, and sends the verification information to the blockchain for verification application;
[0021] After receiving the verification information, the blockchain queries whether the device identity specified in the verification information exists in the blockchain. If so, the corresponding encrypted identity information is read from the blockchain based on the device identity, and based on the encrypted identity information, a non-interactive zero-knowledge proof algorithm is called to generate a witness as a public witness. The proof information, verification key and public witness are verified, and the verification results are returned to the data center and the device end.
[0022] Preferably, the registration information and the verification information both include device description information, and the device description information includes a timestamp;
[0023] After the blockchain calls the non-interactive zero-knowledge proof algorithm to verify the verification information, it changes the device description information for the device that passes the verification.
[0024] In a second aspect, the present invention provides an identity authentication system based on blockchain and zero-knowledge proof, which is used to implement IoT device authentication through an identity authentication method based on blockchain and zero-knowledge proof as described in any one of the first aspects, wherein the system includes a device terminal, a blockchain, and a data center;
[0025] The blockchain is the consortium chain Hyperledger Fabric, and a non-interactive zero-knowledge proof algorithm is introduced into the blockchain's smart contract;
[0026] During the key generation phase, the device performs the following operations: generating a public key and a private key, calculating a hash value of the public key as the device identity, and invoking a non-interactive zero-knowledge proof algorithm to generate a proof key and a verification key;
[0027] During the device registration phase, the device performs the following operations: a non-interactive zero-knowledge proof algorithm is used to perform a hash calculation on its identity information to obtain encrypted identity information; registration information is constructed based on the device identity, encrypted identity information, and verification key; and the registration information is sent to the blockchain for registration application; correspondingly, the blockchain performs the following operations: verification of the device based on the registration information, and for devices that pass verification, the registration information is stored in a block;
[0028] During the device registration phase, the device is configured to: generate proof information based on the public key and public key hash value by invoking a non-interactive zero-knowledge proof algorithm; construct verification information based on the device identity, verification key, and proof information; and send the verification information to the blockchain for verification application. Correspondingly, the blockchain is configured to: verify the verification information by invoking a non-interactive zero-knowledge proof algorithm, and return the verification result to the device and the data center.
[0029] The data center is used to provide access control and authority management for authenticated devices.
[0030] Preferably, during the key generation phase, the device is configured to perform the following:
[0031] Generate a public key and a private key using the P-256 elliptic curve, calculate the hash value of the public key using the SHA-256 hash algorithm, obtain a string as the public key hash value, and select a string of a predetermined length from the public key hash value as the device identity;
[0032] Based on the public key and public key hash value, the key setting function in the non-interactive zero-knowledge proof algorithm is called to generate the proof key and verification key.
[0033] Preferably, during the device registration phase, the device is configured to perform the following:
[0034] The device information is used as input and the hash function in the non-interactive zero-knowledge proof algorithm is called to perform hash calculation on the device information to generate a fixed-length string as a token.
[0035] Construct registration information based on identity information, encrypted identity information, and verification key, and send the registration information to the blockchain;
[0036] Correspondingly, the blockchain is used to perform the following: verify the received registration information through the endorsement node and sorting node in the Fabric network, and determine whether the corresponding device end exists in the blockchain based on the device identity. If not, the verification is passed, and the registration information is stored in the block of the blockchain in the form of key-value, wherein the device identity is used as the key, and the encrypted identity information, device description information and verification key are used as the value.
[0037] Preferably, during the device verification phase, the device performs the following:
[0038] Based on its public key and public key hash value, a non-interactive zero-knowledge proof algorithm is called to generate a witness, and the witness and proving key are used as input to generate proof information;
[0039] Construct verification information based on its device identity, verification key and certification information, and send the verification information to the blockchain for verification application;
[0040] Correspondingly, the blockchain is used to perform the following: after receiving the verification information, query whether the device identity specified in the verification information exists in the blockchain; if so, read the corresponding encrypted identity information from the blockchain based on the device identity, and based on the encrypted identity information, call the non-interactive zero-knowledge proof algorithm to generate a witness as a public witness, verify the proof information, verification key and public witness, and return the verification result to the data center and the device end.
[0041] Preferably, the registration information and the verification information both include device description information, and the device description information includes a timestamp;
[0042] After the blockchain calls the non-interactive zero-knowledge proof algorithm to verify the verification information, it changes the device description information for the device that passes the verification.
[0043] The blockchain-based and zero-knowledge proof-based identity authentication method and system of the present invention have the following advantages:
[0044] 1. Device authentication is achieved based on blockchain and non-interactive zero-knowledge proof algorithm. During the device registration and authentication process, the hash value of the device public key is used as the device identity, and the non-interactive zero-knowledge proof algorithm is called to hash the device identity information. The registration information and verification information are constructed based on the encrypted identity and application identifier to register and verify the device. This achieves the anonymity of IoT devices, protects user privacy and avoids the risk of identity leakage;
[0045] 2. When constructing a device identity based on the device public key, a hash calculation is performed on the device public key to obtain a character string of a predetermined length. A character string of a predetermined length is intercepted from the character string of the predetermined length as the device identity, further ensuring the security of the device information and avoiding damage by malicious third parties. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] 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 embodiments or descriptions of the prior art. 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.
[0047] The present invention will be further described below with reference to the accompanying drawings.
[0048] Figure 1 This is a flowchart of an identity authentication method based on blockchain and zero-knowledge proof in Example 1;
[0049] Figure 2 This is a block diagram of the architecture of the device, blockchain, and data center in an identity authentication method based on blockchain and zero-knowledge proof in Example 1;
[0050] Figure 3 This is a performance diagram of the device registration phase in an identity authentication method based on blockchain and zero-knowledge proof in Example 1;
[0051] Figure 4 This is a performance diagram of the device authentication phase in an identity authentication method based on blockchain and zero-knowledge proof in Example 1;
[0052] Figure 5 This is a schematic diagram showing the time consumption analysis of the device registration and authentication process in an identity authentication method based on blockchain and zero-knowledge proof in Example 1;
[0053] Figure 6 This is a schematic diagram of blockchain transaction detection in an identity authentication method based on blockchain and zero-knowledge proof in Example 1. DETAILED DESCRIPTION
[0054] The present invention will be further described below with reference to the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it. However, the embodiments given are not intended to limit the present invention. Unless there is a conflict, the embodiments of the present invention and the technical features in the embodiments may be combined with each other.
[0055] The embodiments of the present invention provide an identity authentication method and system based on blockchain and zero-knowledge proof, which are used to solve the technical problem of how to implement decentralized network device identity authentication based on blockchain to ensure the security of user identity and data.
[0056] Example 1:
[0057] This invention describes an identity authentication method based on blockchain and zero-knowledge proof, applied between devices, blockchains, and data centers. The blockchain is the Hyperledger Fabric consortium blockchain, and a non-interactive zero-knowledge proof algorithm is incorporated into the blockchain's smart contracts. This method includes three steps: key generation, device registration, and device verification.
[0058] Step S100: Key generation: The device generates a public key and a private key, calculates the hash value of the public key as the device identity, and calls a non-interactive zero-knowledge proof algorithm to generate a proof key and a verification key.
[0059] Non-interactive zero-knowledge proofs (NIZKs) are a special type of zero-knowledge proof. Compared to traditional interactive zero-knowledge proofs, they do not require multiple rounds of communication interactions, but instead complete the entire verification process through a single proof. This embodiment uses a non-interactive zero-knowledge proof method called Zero-Knowledge Succinct Non-Interactive Argument of Knowledge (zkSNARKs). ZkSNARKs consists of three main steps: setup, proof, and verification. Each step is described below.
[0060] Setup(C,1λ): This function takes a security parameter λ and a program C as input and generates a pair of keys (pk,vk), where pk is the proving key and vk is the verification key. These keys are used to generate and verify the proof in subsequent steps.
[0061] Proof(pk,x,a): This function takes as input the proof key pk, the public input x of program C, and the private auxiliary input a of program C, and generates a proof of knowledge π. The proof π is generated based on the public input x and the private auxiliary input a.
[0062] Verify(vk, x, π): This function takes as input the verification key vk, the generated proof π, and the public input x of program C, and verifies the proof. If the proof is valid, the function returns b = 1, indicating that the proof is true. Otherwise, if the proof is invalid, the function returns b = 0, indicating that the proof is false.
[0063] In this example, the Go language is used to implement the zero-knowledge proof contract of the Groth16 zkSNARK scheme. This contract generates a proof for a given circuit and verifies it using a verification key.
[0064] As a specific implementation of key generation, this step includes the following operations:
[0065] S110. Generate a public key and a private key using the P-256 elliptic curve, calculate a hash value of the public key based on the SHA-256 hash algorithm, obtain a string as the public key hash value, and select a string of a predetermined length from the public key hash value as the device identity;
[0066] S120. Based on the public key and the public key hash value, call the key setting function in the non-interactive zero-knowledge proof algorithm to generate a proof key and a verification key.
[0067] In step S110, the device generates a public key and a private key. The public key is used in the subsequent authentication process. The public key is hashed with SHA-256 to obtain a 64-character hexadecimal string, and the rightmost 40 characters are selected as the device ID DeviceId.
[0068] The specific implementation of step S120 includes the following operations:
[0069] S121. Compile the circuit into a constraint system using the specified elliptic curve BN254 curve and the constraint system builder;
[0070] S122. Using the Setup function of the Groth16 zkSNARK scheme, the proof key (pk) and verification key (vk) are generated using the compiled constraint system.
[0071] pk,vk,←groth16.Setup(ccs).
[0072] S200 device registration: The device side calls a non-interactive zero-knowledge proof algorithm to perform hash calculation on its identity information to obtain encrypted identity information. It then constructs registration information based on the device identity, encrypted identity information, and verification key, and sends the registration information to the blockchain for registration application. For device sides that pass verification, the blockchain stores the registration information in a block.
[0073] As a specific implementation of device registration, this step includes the following operations:
[0074] S210, the device information of the device side is used as input, and the hash function in the non-interactive zero-knowledge proof algorithm is called to perform hash calculation on the device information to generate a fixed-length string as a token;
[0075] S220, constructing registration information based on the identity information, the encrypted identity information, and the verification key, and sending the registration information to the blockchain;
[0076] S230. The endorsement nodes and sorting nodes in the Fabric network verify the received registration information and determine whether the corresponding device end exists in the blockchain based on the device identity. If not, the verification passes and the registration information is stored in the block of the blockchain in the form of key-value, where the device identity serves as the key and the encrypted identity information, device description information, and verification key serve as the value.
[0077] In step S210 of this embodiment, the device information is hashed using the MIMC hash circuit. The specific operations are as follows:
[0078] Input: Input string (in this solution, it is multiple device information that needs to be hidden);
[0079] Constraint: The input is subjected to a series of nonlinear obfuscation operations, including addition, multiplication, and nonlinear permutation;
[0080] Output: The final hash output is a number of fixed length.
[0081] The registration information of this embodiment also includes device description information, which includes a timestamp. Based on this, the device registration information in the registration stage is expressed as (DeviceID, Token, Detail, Veritykey), where DeviceId is obtained by hashing the device public key, Token represents multiple basic identity information of the device (private information that cannot be disclosed to others) calculated by hashing, Detail represents device description information, such as a timestamp, etc., and Veritykey represents the non-interactive zero-knowledge proof verification key vk.
[0082] After the blockchain receives the registration information from the device, it executes the following:
[0083] (1) Read the device from the ledger through the device ID and determine whether the corresponding Device ID is stored in the blockchain;
[0084] (2) If the device already exists (i.e. value != nil), it returns an error indicating that the device already exists;
[0085] (3) If the device status does not exist, the device information is converted into JSON format and saved to the status database of the blockchain.
[0086] (4) If everything goes well, a success response is returned.
[0087] In this embodiment, the device identification is stored as a key value in the blockchain ledger database as a device index within the blockchain, and the encrypted identity information, device description information, and verification key are stored as value values in the data structure, as shown in Table 1 and Table 2.
[0088] Table 1. Device storage data structure
[0089] Device ID Token Detail_info VerifyKey
[0090] Table 2. Basic device identity information
[0091]
[0092]
[0093] Based on this step, the device is registered to the blockchain network. The IoT device first needs to generate a pair of keys (public key and private key), where the private key is stored on the device side, and the public key will be used for the subsequent authentication process. The key generation uses the P256 elliptic curve parameters, and then the public key is hashed with SHA-256 to obtain a 64-character hexadecimal string, and the right 40 bits are selected as the device address DeviceId. The design stores the hash result as the new device identity of the device in the blockchain ledger and as the key value of the device entity in the blockchain ledger database. The basic device identity information of the device is hashed as a Token object in the device storage data structure. Verifykey is the verification key of the zero-knowledge proof algorithm. The device can then be registered to the Fabric network. The device registers with the certificate authority (CA) of the Fabric network and submits its public key and other information to obtain a legal identity.
[0094] The device calls the chaincode's registration function, submitting its device ID and other information as parameters. The blockchain receives the call request and stores the device information in the blockchain using a key-value pair. The key is DeviceId, which serves as the device index within the blockchain. The value is the device structure defined in the chaincode.
[0095] Step S300 device verification: The device side generates proof information based on the public key and public key hash value by calling the non-interactive zero-knowledge proof algorithm, constructs verification information based on the device identity, verification key and proof information, and sends the verification information to the blockchain for verification application. The blockchain calls the non-interactive zero-knowledge proof algorithm to verify the verification information and returns the verification result to the device side and the data center. For the device side that passes the verification, the data center provides access control and permission management for the device side.
[0096] As a specific implementation of device verification, this step includes the following operations:
[0097] S310: The device generates a witness by calling a non-interactive zero-knowledge proof algorithm based on its public key and public key hash value, and generates proof information using the witness and proof key as input;
[0098] S320: The device constructs verification information based on its device identity, verification key, and certification information, and sends the verification information to the blockchain for verification application;
[0099] S330. After receiving the verification information, the blockchain queries whether the device identity specified in the verification information exists in the blockchain. If so, the blockchain reads the corresponding encrypted identity information from the blockchain based on the device identity, and based on the encrypted identity information, calls the non-interactive zero-knowledge proof algorithm to generate a witness as a public witness, verifies the proof information, verification key, and public witness, and returns the verification result to the data center and the device end.
[0100] As a specific implementation of step S310, the proof information is generated by the following operations: a witness is defined for the circuit as an input to the circuit. This witness contains the input values of the circuit, including PreImage and Hash. A proof is generated using the groth16.Prove function, which is based on the compiled constraint system, the proof key, and the previously created witness, namely:
[0101] Proof←groth16.Prove(ccs,pk,witness) / / ccs is a constraint system that represents the constraints of the circuit, describes the computational process and constraints in the circuit, and is used to generate proofs.
[0102] In this embodiment, the verification information also includes a device description, which includes a timestamp, etc. Based on this, the verification information is represented as (DeviceId, Token, Detail, proof). After the blockchain receives the verification information, it calls the authentication contract based on the non-interactive zero-knowledge proof configuration to execute the authentication function to authenticate the verification information. The authentication function Result←VerifyProof(Token, vk, proof) is executed as follows:
[0103] {
[0104] Use Token to create a public witness publicWitness through the frontend.NewWitness function
[0105] result←groth16.Verify(proof,vk,publicWitness)
[0106] }
[0107] If the authentication result is successful, the Details can be modified and specific permissions can be granted to the device.
[0108] In the authentication phase of this embodiment, the device sends authentication information to the blockchain to authenticate the identity, that is, the device submits the authentication transaction containing the zero-knowledge proof to the Fabric network.
[0109] The device generates proof information through a zero-knowledge proof algorithm, and then sends the DeviceId, Proof, and the signature ({r, s}) of the verification information sent to the blockchain using the private key through ECDSA to the blockchain end.
[0110] The chaincode deployed on the blockchain node first retrieves the device object based on the DeviceId index. If the device object exists, verification continues, completing the signature verification by calling the signature verification function in the chaincode. Next, the zero-knowledge proof verification function in the chaincode verifies the proof submitted by the device. If the zero-knowledge proof is successful, the chaincode records the device's authentication status and may update the device's permissions or status. Based on the verification result, the chaincode determines whether the device is legitimate, performs subsequent business logic operations, and returns the authentication result to the device. The device receives the authentication result, and the data end provides the device with the required information and subsequent information exchange. This concludes the authentication process.
[0111] The method in this embodiment was performance-tested using the lightweight Tape tool, which stress-tested the registration and authentication functions. The test simulated simultaneous registration and authentication of varying numbers of IoT devices, and recorded the system's response time and throughput under varying loads.
[0112] First, we conducted a performance test of the registration function. During the test, we gradually increased the number of concurrent registration requests and recorded the system's response time for each request. The results showed that the system was able to effectively handle registration requests in a highly concurrent environment, with response times remaining within acceptable limits. Furthermore, the system's throughput did not decrease rapidly with the increase in registration requests, demonstrating the system's good scalability and performance.
[0113] Next, we conducted a performance test of the authentication functionality. During the test, we simulated varying numbers of authentication requests being sent simultaneously to the system and recorded the system's response time for each request. The results showed that the system was able to effectively handle authentication requests under high load, with response times within a reasonable range. The system's throughput also remained relatively stable as the number of authentication requests increased, demonstrating excellent performance.
[0114] In summary, the performance analysis and test results demonstrate that the implemented anonymous identity authentication system for IoT devices based on blockchain Fabric and zero-knowledge proofs has good performance and scalability, operating stably and providing efficient services under high-load conditions. This provides strong support for the system's reliability and stability in practical applications and provides an important reference for future expansion and optimization efforts.
[0115] The method in this embodiment establishes a decentralized identity authentication method by using blockchain Fabric as its underlying architecture, effectively addressing the trust issues and single-point-of-failure risks inherent in traditional identity authentication schemes. Furthermore, the introduction of the zero-knowledge proof algorithm, Gosnark, enables anonymity for IoT devices, protecting user privacy and preventing identity leakage risks. The results of this research not only provide a more secure and private identity authentication solution for IoT devices, but also offer new insights and possibilities for the application of blockchain technology in the IoT sector.
[0116] Example 2:
[0117] The present invention provides an identity authentication system based on blockchain and zero-knowledge proof, including a device end, a blockchain and a data center. The system can execute the method disclosed in Example 1 to realize IoT device authentication.
[0118] The blockchain is the consortium chain Hyperledger Fabric, and a non-interactive zero-knowledge proof algorithm is introduced into the blockchain's smart contract.
[0119] During the key generation phase, the device performs the following operations: generating public and private keys, calculating the hash value of the public key as the device identity, and calling a non-interactive zero-knowledge proof algorithm to generate a proof key and a verification key.
[0120] Non-interactive zero-knowledge proofs (NIZKs) are a special type of zero-knowledge proof. Compared to traditional interactive zero-knowledge proofs, they do not require multiple rounds of communication interactions, but instead complete the entire verification process through a single proof. This embodiment uses a non-interactive zero-knowledge proof method called Zero-Knowledge Succinct Non-Interactive Argument of Knowledge (zkSNARKs). ZkSNARKs consists of three main steps: setup, proof, and verification. Each step is described below.
[0121] Setup(C,1λ): This function takes a security parameter λ and a program C as input and generates a pair of keys (pk,vk), where pk is the proving key and vk is the verification key. These keys are used to generate and verify the proof in subsequent steps.
[0122] Proof(pk,x,a): This function takes as input the proof key pk, the public input x of program C, and the private auxiliary input a of program C, and generates a proof of knowledge π. The proof π is generated based on the public input x and the private auxiliary input a.
[0123] Verify(vk, x, π): This function takes as input the verification key vk, the generated proof π, and the public input x of program C, and verifies the proof. If the proof is valid, the function returns b = 1, indicating that the proof is true. Otherwise, if the proof is invalid, the function returns b = 0, indicating that the proof is false.
[0124] In this example, the Go language is used to implement the zero-knowledge proof contract of the Groth16 zkSNARK scheme. This contract generates a proof for a given circuit and verifies it using a verification key.
[0125] As a specific implementation of the key generation module, the module performs the following to achieve key generation:
[0126] (1) Generate a public key and a private key using the P-256 elliptic curve, calculate the hash value of the public key based on the SHA-256 hash algorithm, obtain a string as the public key hash value, and select a string of predetermined length from the public key hash value as the device identity;
[0127] (2) Based on the public key and the public key hash value, the key setting function in the non-interactive zero-knowledge proof algorithm is called to generate the proof key and the verification key.
[0128] The device generates a public key and a private key. The public key is used in the subsequent authentication process. A SHA-256 hash is performed on the public key to obtain a 64-character hexadecimal string. The rightmost 40 characters are selected as the device ID (DeviceId).
[0129] The device uses the specified elliptic curve BN254 and the constraint system builder to compile the circuit into a constraint system. It then uses the Setup function of the Groth16 zkSNARK scheme to generate the proof key (pk) and verification key (vk) using the compiled constraint system.
[0130] pk,vk,←groth16.Setup(ccs).
[0131] During the device registration phase, the device side is used to perform the following: call a non-interactive zero-knowledge proof algorithm to perform hash calculation on its identity information to obtain encrypted identity information, construct registration information based on the device identity, encrypted identity information and verification key, and send the registration information to the blockchain for registration application; correspondingly, the blockchain is used to perform the following: verify the device based on the registration information, and for the device side that passes the verification, store the registration information in the block.
[0132] During the device registration phase, the device and blockchain work together to perform the following:
[0133] (1) Using device information as input, the hash function in the non-interactive zero-knowledge proof algorithm is called to perform hash calculation on the device information and generate a fixed-length string as a token;
[0134] (2) Constructing registration information based on the identity information, encrypted identity information, and verification key, and sending the registration information to the blockchain;
[0135] (3) The endorsement nodes and sorting nodes in the Fabric network verify the received registration information and determine whether the corresponding device end exists in the blockchain based on the device identity. If not, the verification passes and the registration information is stored in the block of the blockchain in the form of key-value, where the device identity is used as the key and the encrypted identity information, device description information and verification key are used as the value.
[0136] In this embodiment, the device side performs hash calculation on the device information through the MIMC hash circuit. The specific operations are as follows:
[0137] Input: Input string (in this solution, it is multiple device information that needs to be hidden);
[0138] Constraint: The input is subjected to a series of nonlinear obfuscation operations, including addition, multiplication, and nonlinear permutation;
[0139] Output: The final hash output is a number of fixed length.
[0140] The registration information of this embodiment also includes device description information, which includes a timestamp. Based on this, the device registration information in the registration stage is expressed as (DeviceID, Token, Detail, Veritykey), where DeviceId is obtained by hashing the device public key, Token represents multiple basic identity information of the device (private information that cannot be disclosed to others) calculated by hashing, Detail represents device description information, such as a timestamp, etc., and Veritykey represents the non-interactive zero-knowledge proof verification key vk.
[0141] After the blockchain receives the registration information from the device, it executes the following:
[0142] (1) Read the device from the ledger through the device ID and determine whether the corresponding Device ID is stored in the blockchain;
[0143] (2) If the device already exists (i.e. value != nil), it returns an error indicating that the device already exists;
[0144] (3) If the device status does not exist, the device information is converted into JSON format and saved to the status database of the blockchain.
[0145] (4) If everything goes well, a success response is returned.
[0146] In this embodiment, the device identification is stored as a key value in the blockchain ledger database as a device index within the blockchain, and the encrypted identity information, device description information, and verification key are stored as value values in the data structure.
[0147] During the device registration phase, the IoT device must first generate a pair of keys (public and private), where the private key is stored on the device side, and the public key will be used for subsequent authentication processes. The key generation uses the P256 elliptic curve parameters, and then performs a SHA-256 hash calculation on the public key to obtain a 64-character hexadecimal string, and selects the 40 bits on the right as the device address DeviceId. The design stores the hash result as the device's new device identity in the blockchain ledger, and as the key value of the device entity in the blockchain ledger database. The device's basic device identity is hashed as a Token object in the device storage data structure. Verifykey is the verification key of the zero-knowledge proof algorithm. The device can then register with the Fabric network. The device registers with the Fabric network's certificate authority (CA) and submits its public key and other information to obtain a legitimate identity.
[0148] The device calls the chaincode's registration function, submitting its device ID and other information as parameters. The blockchain receives the call request and stores the device information in the blockchain using a key-value pair. The key is DeviceId, which serves as the device index within the blockchain. The value is the device structure defined in the chaincode.
[0149] During the device verification phase, the device side is used to perform the following: based on the public key and public key hash value, call the non-interactive zero-knowledge proof algorithm to generate proof information, construct verification information based on the device identity, verification key and proof information, and send the verification information to the blockchain for verification application; correspondingly, the blockchain is used to perform the following: call the non-interactive zero-knowledge proof algorithm to verify the verification information, and return the verification result to the device side and the data center.
[0150] The data center is used to provide access control and permission management for authenticated devices.
[0151] During the device verification phase, the device and blockchain work together to perform the following:
[0152] (1) The device generates a witness based on its public key and public key hash value by calling a non-interactive zero-knowledge proof algorithm, and generates proof information using the witness and proof key as input;
[0153] (2) The device constructs verification information based on its device identity, verification key, and certification information, and sends the verification information to the blockchain for verification application;
[0154] (3) After receiving the verification information, the blockchain queries whether the device identity specified in the verification information exists in the blockchain. If so, the blockchain reads the corresponding encrypted identity information from the blockchain based on the device identity, and based on the encrypted identity information, calls the non-interactive zero-knowledge proof algorithm to generate a witness as a public witness, verifies the proof information, verification key and public witness, and returns the verification result to the data center and the device end.
[0155] In this embodiment, the device generates proof information by: defining a witness for the circuit as an input to the circuit. This witness contains the input values of the circuit, including the PreImage and Hash. Using the groth16.Prove function, a proof is generated based on the compiled constraint system, the proof key, and the previously created witness, namely:
[0156] Proof←groth16.Prove(ccs,pk,witness) / / ccs is a constraint system that represents the constraints of the circuit, describes the computational process and constraints in the circuit, and is used to generate proofs.
[0157] In this embodiment, the verification information also includes a device description, which includes a timestamp, etc. Based on this, the verification information is represented as (DeviceId, Token, Detail, proof). After the blockchain receives the verification information, it calls the authentication contract based on the non-interactive zero-knowledge proof configuration to execute the authentication function to authenticate the verification information. The authentication function Result←VerifyProof(Token, vk, proof) is executed as follows:
[0158] {
[0159] Use Token to create a public witness publicWitness through the frontend.NewWitness function
[0160] result←groth16.Verify(proof,vk,publicWitness)
[0161] }
[0162] If the authentication result is successful, the Details can be modified and specific permissions can be granted to the device.
[0163] In the authentication phase of this embodiment, the device sends authentication information to the blockchain to authenticate the identity, that is, the device submits the authentication transaction containing the zero-knowledge proof to the Fabric network.
[0164] The device generates proof information through a zero-knowledge proof algorithm, and then sends the DeviceId, Proof, and the signature ({r, s}) of the verification information sent to the blockchain using the private key through ECDSA to the blockchain end.
[0165] The chaincode deployed on the blockchain node first retrieves the device object based on the DeviceId index. If the device object exists, verification continues, completing the signature verification by calling the signature verification function in the chaincode. Next, the zero-knowledge proof verification function in the chaincode verifies the proof submitted by the device. If the zero-knowledge proof is successful, the chaincode records the device's authentication status and may update the device's permissions or status. Based on the verification result, the chaincode determines whether the device is legitimate, performs subsequent business logic operations, and returns the authentication result to the device. The device receives the authentication result, and the data end provides the device with the required information and subsequent information exchange. This concludes the authentication process.
[0166] The present invention has been shown and described in detail above through the accompanying drawings and preferred embodiments. However, the present invention is not limited to these disclosed embodiments. Based on the above multiple embodiments, those skilled in the art can know that the means in the above different embodiments can be combined to obtain more embodiments of the present invention, and these embodiments are also within the scope of protection of the present invention.
Claims
1. An identity authentication method based on blockchain and zero-knowledge proof, characterized in that: Applied between the device side, blockchain and data center, the blockchain selects the alliance chain platform Hyperledger Fabric, and the blockchain smart contract introduces a non-interactive zero-knowledge proof algorithm. The method includes the following steps: Key generation: The device generates a public key and a private key, calculates the hash value of the public key as the device identity, and calls a non-interactive zero-knowledge proof algorithm to generate a proof key and a verification key; Device registration: The device side calls a non-interactive zero-knowledge proof algorithm to perform hash calculation on its identity information to obtain encrypted identity information, builds registration information based on the device identity, encrypted identity information, and verification key, and sends the registration information to the blockchain for registration application. For the device side that passes the verification, the blockchain stores the registration information in the block; Device verification: The device side generates proof information based on the public key and public key hash value by calling the non-interactive zero-knowledge proof algorithm, builds verification information based on the device identity, verification key and proof information, and sends the verification information to the blockchain for verification application. The blockchain calls the non-interactive zero-knowledge proof algorithm to verify the verification information and returns the verification result to the device side and the data center. For the device side that passes the verification, the data center provides access control and permission management for the device side.
2. The identity authentication method based on blockchain and zero-knowledge proof according to claim 1, characterized in that: Key generation includes the following steps: Generate a public key and a private key through the P-256 elliptic curve, calculate the hash value of the public key based on the SHA-256 hash algorithm, obtain a string as the public key hash value, and select a string of a predetermined length from the public key hash value as the device identity; Based on the public key and the public key hash value, the key setting function in the non-interactive zero-knowledge proof algorithm is called to generate the proof key and the verification key.
3. The identity authentication method based on blockchain and zero-knowledge proof according to claim 1 is characterized in that: Device registration includes the following steps: The device information on the device side is used as input, and the hash function in the non-interactive zero-knowledge proof algorithm is called to perform hash calculation on the device information to generate a string of fixed length as a token; Construct registration information based on identity information, encrypted identity information and verification key, and send the registration information to the blockchain; The endorsement nodes and sorting nodes in the Fabric network verify the received registration information and determine whether the corresponding device exists in the blockchain based on the device identity. If not, the verification passes and the registration information is stored in the blockchain block in the form of key-value, where the device identity is used as the key, and the encrypted identity information, device description information, and verification key are used as the value.
4. The identity authentication method based on blockchain and zero-knowledge proof according to claim 1, characterized in that: Device verification includes the following steps: The device generates a witness based on its public key and public key hash value by calling a non-interactive zero-knowledge proof algorithm, and generates proof information using the witness and proof key as input; The device side constructs verification information based on its device identity, verification key and certification information, and sends the verification information to the blockchain for verification application; After receiving the verification information, the blockchain queries whether the device identity specified in the verification information exists in the blockchain. If so, the corresponding encrypted identity information is read from the blockchain based on the device identity, and based on the encrypted identity information, a non-interactive zero-knowledge proof algorithm is called to generate a witness as a public witness, and the proof information, verification key and public witness are verified, and the verification results are returned to the data center and the device end.
5. The identity authentication method based on blockchain and zero-knowledge proof according to any one of claims 1 to 4, characterized in that: The registration information and verification information both include device description information, and the device description information includes a timestamp; After the blockchain calls the non-interactive zero-knowledge proof algorithm to verify the verification information, it changes the device description information for the device that has passed the verification.
6. An identity authentication system based on blockchain and zero-knowledge proof, characterized in that: Used to implement IoT device authentication through an identity authentication method based on blockchain and zero-knowledge proof as described in any one of claims 1 to 5, the system comprising a device end, a blockchain and a data center; The blockchain is the consortium chain Hyperledger Fabric, and a non-interactive zero-knowledge proof algorithm is introduced into the smart contract of the blockchain; In the key generation phase, the device is used to perform the following: generate a public key and a private key, calculate a hash value of the public key as the device identity, and call a non-interactive zero-knowledge proof algorithm to generate a proof key and a verification key; During the device registration phase, the device is used to perform the following operations: call a non-interactive zero-knowledge proof algorithm to perform hash calculation on its identity information to obtain encrypted identity information, construct registration information based on the device identity, encrypted identity information, and verification key, and send the registration information to the blockchain for registration application; correspondingly, the blockchain is used to perform the following operations: verify the device based on the registration information, and for the verified device, store the registration information in the block; In the device verification phase, the device is used to perform the following: based on the public key and the public key hash value, call the non-interactive zero-knowledge proof algorithm to generate proof information, build verification information based on the device identity, verification key and proof information, and send the verification information to the blockchain for verification application; correspondingly, the blockchain is used to perform the following: call the non-interactive zero-knowledge proof algorithm to verify the verification information, and return the verification result to the device and the data center; The data center is used to provide access control and authority management for authenticated devices.
7. The identity authentication system based on blockchain and zero-knowledge proof according to claim 6, characterized in that: During the key generation phase, the device is used to perform the following: Generate a public key and a private key through the P-256 elliptic curve, calculate the hash value of the public key based on the SHA-256 hash algorithm, obtain a string as the public key hash value, and select a string of a predetermined length from the public key hash value as the device identity; Based on the public key and the public key hash value, the key setting function in the non-interactive zero-knowledge proof algorithm is called to generate the proof key and the verification key.
8. The identity authentication system based on blockchain and zero-knowledge proof according to claim 6, characterized in that: During the device registration phase, the device is used to perform the following: Take its device information as input, call the hash function in the non-interactive zero-knowledge proof algorithm to perform hash calculation on the device information, and generate a fixed-length string as a token; Construct registration information based on identity information, encrypted identity information and verification key, and send the registration information to the blockchain; Correspondingly, the blockchain is used to perform the following: verify the received registration information through the endorsement node and the sorting node in the Fabric network, and determine whether the corresponding device end exists in the blockchain based on the device identity. If not, the verification is passed, and the registration information is stored in the block of the blockchain in the form of key-value, wherein the device identity is used as the key, and the encrypted identity information, device description information and verification key are used as the value.
9. The identity authentication system based on blockchain and zero-knowledge proof according to claim 6, characterized in that: During the device verification phase, the device performs the following operations: Based on its public key and public key hash value, a non-interactive zero-knowledge proof algorithm is called to generate a witness, and the witness and proof key are used as input to generate proof information; Construct verification information based on its device identity, verification key and certification information, and send the verification information to the blockchain for verification application; Correspondingly, the blockchain is used to perform the following: after receiving the verification information, query whether the device identity specified in the verification information exists in the blockchain. If so, read the corresponding encrypted identity information from the blockchain based on the device identity, and based on the encrypted identity information, call the non-interactive zero-knowledge proof algorithm to generate a witness as a public witness, and verify the proof information, verification key and public witness, and return the verification result to the data center and the device end.
10. The identity authentication system based on blockchain and zero-knowledge proof according to any one of claims 6 to 9, characterized in that: The registration information and verification information both include device description information, and the device description information includes a timestamp; After the blockchain calls the non-interactive zero-knowledge proof algorithm to verify the verification information, it changes the device description information for the device that has passed the verification.
Citation Information
Cited By
Decentralization Internet of Things security framework system based on block chain
CN119210687A
A decentralized IoT security framework system based on blockchain
CN119210687B
Identity verification method based on block chain and related equipment
CN119814316A
Blockchain-based identity verification method and related device
CN119814316B
Power system hierarchical authentication method and system based on block chain and zero-knowledge proof
CN120030522A
