Hyperledger Fabric key protection method and system based on TrustZone
By generating and managing Hyperledger Fabric user keys within the secure world of TrustZone, the problem of insufficient user key protection is solved, achieving higher security and protection.
Patent Information
- Application Number
- CN202410692876.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-09-27
AI Technical Summary
In Hyperledger Fabric networks, insufficient protection of user keys can lead to problems such as unauthorized access, transaction tampering, and data leakage, affecting the security of user assets.
Using TrustZone technology, users' public and private keys are generated and managed in its secure world. The certificate signing request and signing operation are implemented through the MbedTLS library. The private key is written to a secure file and stored in an untrusted environment to ensure the security of the private key.
It improves the security of user keys during generation, storage, and use, prevents unauthorized access and data leakage, and ensures the security of the Fabric network.
Smart Images

Figure CN118709202A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer information security, and more particularly to a method and system for protecting a key in Hyperledger Fabric, and more particularly to a method and system for protecting a user key in Hyperledger Fabric by utilizing the security functions and characteristics of TrustZone. Background Art
[0002] Hyperledger Fabric (abbreviated as Fabric in the application document) is an open source blockchain platform suitable for enterprise-level applications and an implementation technology for consortium chains. Fabric's key technologies include ledgers, smart contracts (chain codes), channels, nodes, etc. Among them, the Fabric ledger is a series of ordered, tamper-proof state transition records, and its structure consists of a blockchain. Immutable, ordered records are stored in blocks, and state transitions are the results of chain code invocations and submissions; the ledger also contains a state database to record the current Fabric state, and each channel has a ledger. Each node will save a copy of the channel's ledger for each channel it belongs to.
[0003] Smart contracts are called chain codes in Fabric. They are a piece of code that runs on the blockchain and are the middleware for the interaction between the application system and the underlying blockchain. Through smart contracts, users can implement various complex applications.
[0004] Peers are the main body of blockchain transaction processing and ledger maintenance. Their main functions include participating in the consensus process and implementing read and write operations on the ledger by executing chaincodes. Nodes are divided into endorser peers and committer peers according to their functions. Endorser peers are responsible for endorsing and signing Fabric proposals according to pre-set policies, and only when the client initiates a proposal endorsement to the node, the node has the endorsement function. In general, nodes are just ordinary accounting nodes. Committer peers are responsible for maintaining state data and copies of ledgers.
[0005] A channel is a private space for information communication between two or more nodes. The data of transactions in the channel will not appear outside the channel, thus ensuring the security of the data in the channel. All transactions on the network must be executed on a channel, and each member participating in the transaction needs to be authenticated and authorized before entering the channel and participating in the transaction process.
[0006] In Fabric, the user first generates a Certificate Signing Request (CSR) with a private key and sends the CSR to the Certificate Authority (CA) in the Fabric network. After verifying the legitimacy of the CSR, the CA issues a digital certificate to the user that contains the user's public key and can represent the user's identity. With this identity certificate, the user can join the Fabric network and perform operations such as creating proposals, uploading proposals / transactions / submissions, and querying ledgers. Before uploading proposals, transactions, and submissions, the user needs to sign the proposals, transactions, and submissions with a private key, and then upload the signed proposals, transactions, and submissions to the Fabric network and wait for verification by the Fabric network.
[0007] In the specific implementation, Fabric uses contract objects and gateway objects to represent the execution environment of smart contracts (chain codes) and the interaction environment of the Fabric network respectively. The contract object contains business-related logic and operations, such as asset transfer, status query, etc., and can also read, write and manage the status of the Fabric network. The gateway object is an abstract layer for applications to interact with the Fabric network. It provides a simplified API that allows applications to connect to the Fabric network and perform contract operations. Through the gateway object, applications can submit proposals to the Fabric network.
[0008] From the above process, we can see that private keys play an important role in Fabric network's identity authentication, proposals, transactions, signature submission and other key processes. If private keys are not adequately protected, they may lead to unauthorized access, transaction tampering, data leakage and other problems, ultimately resulting in asset loss or business failure of users. Summary of the invention
[0009] In order to solve the technical problem that private keys are not fully protected in key processes such as identity authentication, proposal, transaction, and signature submission of Fabric network in the prior art, the present invention provides a Hyperledger Fabric key protection method and system based on TrustZone.
[0010] The technical solution adopted by the method of the present invention is: a Hyperledger Fabric key protection method based on TrustZone, which utilizes the security function cabinet and characteristics of TrustZone to execute the public and private key generation of Fabric users in the secure world SW of TrustZone, generate a certificate signature request CSR with a private key, write the user private key into a secure file, read the user private key from the secure file, and perform signature operations on Fabric proposals / transactions / submissions; when the private key is not in use, it is saved in the form of a secure file in the untrusted ordinary world NW.
[0011] Preferably, the method comprises the following steps:
[0012] Step 1: Generate a pair of public and private keys that meet the Fabric specification, use the private key sk to generate the user's certificate signing request CSR, write the private key to a newly created security file, and obtain the security file SF sk ;
[0013] Step 2: Upload the user's certificate signing request CSR to the certificate authority in the Fabric network, receive the user identity certificate returned by the certificate authority, and attach the user identity certificate to the security file SF. sk After association, it is saved in the local file system;
[0014] Step 3: When a Fabric proposal needs to be initiated, initialize the Fabric proposal information and obtain the user's identity certificate and the secure file SF containing the user's private key from the local file system. sk ;
[0015] Step 4: Recover the user's private key from the secure file and check the correctness of the private key;
[0016] Step 5: Use the private key to sign the initialized Fabric proposal information;
[0017] Step 6: Submit the signed Fabric proposal information to the sorting service of the Fabric network, create an unsigned submission object unsignedCom, and then complete the update of the Fabric ledger;
[0018] Step 7: Verify whether the Fabric proposal is submitted successfully, and obtain the result and submission status of the Fabric proposal.
[0019] Preferably, the specific implementation of step 1 includes the following steps:
[0020] Step 1.1: Generate a pair of public and private keys (pk, sk) that meet the ECDSA-secp256r1 specification through the mbedtls_ecp_gen_keypair() method provided by the MbedTLS library;
[0021] Step 1.2: Using the private key sk as input, generate the user's certificate signing request CSR through the mbedtls_x509write_csr_init() method provided by the MbedTLS library;
[0022] Step 1.3: Generate a secure file SF. Take the private key sk and SF as input, call the TEE_WriteObjectData() method provided by OP-TEE to write the private key sk into SF, and get the secure file SF sk .
[0023] Preferably, the Fabric proposal information is initialized in step 3, and the specific implementation includes the following steps:
[0024] Step 3.1: The user enters relevant information for generating a proposal, including the contract name and contract parameters;
[0025] Step 3.2: Based on the proposal information entered by the user, call the newProposal() method in the gateway object that comes with Fabric to create an unsigned proposal;
[0026] Step 3.3: Call the getBytes() method of the proposal object that comes with Fabric to convert proposal into byte representation and get proposalBytes;
[0027] Step 3.4: Call the getDigest() method of the proposal object that comes with Fabric to calculate the SHA-256 digest proposalDig of proposalBytes.
[0028] Preferably, the specific implementation of step 4 includes the following sub-steps:
[0029] Step 4.1: Call the TEE_ReadObjectData() method provided by OP-TEE to obtain the data from SF sk Recover the private key sk;
[0030] Step 4.2: Use the pem_pk() method to calculate the user's public key pk;
[0031] The pem_pk() method parses the user certificate and reads the public key field in the certificate by calling the MBEDTLS_X509_CSR_PARSE() method provided by MbedTLS;
[0032] Step 4.3: Check the correctness of the private key sk;
[0033] Use the tmp_pubkey() method to calculate a temporary public key pk' and check whether pk' is the same as pk; if pk' is the same as pk, it means that the private key is correct and the check passes, and execute 4-5); otherwise, the private key check fails and a key loading error message is returned;
[0034] The tmp_pubkey() method uses the private key sk to multiply the base point G of the elliptic curve to obtain another point G on the elliptic curve. pk’ , respectively take G pk’ The horizontal and vertical coordinates are the first 32 bytes and the last 32 bytes of pk'.
[0035] Preferably, in step 5, the mbedtls_ecdsa_sign() method provided by the MbedTLS library is called to calculate the signature of the initialized Fabric proposal information proposalDig under the private key sk to obtain the signature result proposalSig of the proposal; wherein, the parameters used by the mbedtls_ecdsa_sign() method are specified by secp256r1.
[0036] Preferably, the specific implementation of step 6 includes the following sub-steps:
[0037] Step 6.1: Call the newSignedProposal() method in the gateway object of Fabric to get the second signed proposal signedProposal;
[0038] Step 6.2: Call the endorse() method of the proposal object that comes with Fabric to send the signed proposal signedProposal to the endorsement node in the Fabric network;
[0039] Step 6.3: After collecting the preset amount of endorsements, an unsigned transaction object unsignedTx is generated;
[0040] Step 6.4: Call the getBytes() method of Fabric's built-in transaction object to convert unsignedTx into byte representation to get txBytes;
[0041] Step 6.5: Call the getDigest() method of Fabric's built-in transaction object to calculate the SHA-256 digest of txBytes to get txDig;
[0042] Step 6.5: Call the mbedtls_ecdsa_sign() method provided by the MbedTLS library to calculate the signature of txDig under the private key sk and obtain the signature result txSig of the transaction; the parameters used by the mbedtls_ecdsa_sign() method are specified by secp256r1;
[0043] Step 6.6: Call the newSignedTransaction() method of the gateway object that comes with Fabric to generate a signed transaction signedTx;
[0044] Step 6.7: Call the submit() method of the signed transaction object that comes with Fabric to submit signedTx to the sorting service in the Fabric network;
[0045] Step 6.8: The sorting service in the Fabric network sorts the signedTx and packages it into blocks, and sends the blocks to all peer nodes on the channel;
[0046] Step 6.9: The ordering service in the Fabric network creates an unsigned submission object unsignedCom.
[0047] Preferably, the specific implementation of step 7 includes the following sub-steps:
[0048] Step 7.1: Call the getBytes() method of the commit object that comes with Fabric to convert the unsigned commit object unsignedCom into a byte representation to get commitBytes;
[0049] Step 7.2: Call the getDigest() method of Fabric's built-in transaction object to calculate the SHA-256 digest of commitBytes and get commitDig;
[0050] Step 7.3: Call the mbedtls_ecdsa_sign() method provided by the MbedTLS library to calculate the signature of commitDig under the private key sk and obtain the submitted signature result commitSig; the parameters used by the mbedtls_ecdsa_sign() method are specified by secp256r1;
[0051] Step 7.4: With commitBytes and commitSig as input, call the newSignedCommit() method of the gateway object that comes with Fabric to generate a signed commit signedCommit;
[0052] Step 7.5: Call the getResult() method of the gateway object that comes with Fabric to obtain the result of the signed transaction;
[0053] Step 7.6: Call the getStatus() method of the gateway object that comes with Fabric to obtain the status information of the signed submission.
[0054] The technical solution adopted by the system of the present invention is: a TrustZone-based Hyperledger Fabric key protection system, including two subsystems: a Fabric key protection subsystem and a Fabric proposal processing subsystem;
[0055] The Fabric key protection subsystem includes a key processing module KPM, a secure file processing module SFPM and a Fabric proposal signature module FPSM;
[0056] The Fabric proposal processing subsystem includes a data exchange module DXM, a user registration module URM, a Fabric proposal initialization module FPIM and a Fabric proposal processing module FPPM;
[0057] The key processing module KPM is used to generate a public-private key pair that complies with the Fabric specification for the Fabric user; generate a certificate signature request CSR with the private key; interact with the data exchange module DXM to transmit the user's certificate signature request CSR to the data exchange module DXM, or receive the user identity certificate from the data exchange module DXM; interact with the secure file management module SFPM to transmit the user's private key to the secure file management module SFPM, or receive the user's private key from the secure file management module SFPM; interact with the Fabric proposal signature module FPSM to transmit the user's private key to the Fabric proposal signature module FPSM;
[0058] The secure file processing module SFPM is used to generate and manage secure files in TrustZone; interact with the key processing module KPM, receive the user private key transmitted by the key processing module KPM, and write the user private key into the secure file, or read the user private key from the secure file and transmit the user private key to the key processing module KPM; interact with the data exchange module DXM, transmit the secure file containing the user private key to the data exchange module DXM, or receive the secure file containing the user private key transmitted by the data exchange module DXM;
[0059] The Fabric proposal signature module FPSM is used to sign the Fabric proposal / transaction / submission; interact with the key processing module KPM to receive the user private key from the key processing module KPM; interact with the data exchange module DXM to receive the Fabric proposal / transaction / submission to be signed from the data exchange module DXM, or transmit the signature result of the Fabric proposal / transaction / submission to the data exchange module DXM;
[0060] The data exchange module DXM is used to provide a unified interface for data interaction between the Fabric key protection subsystem and the Fabric proposal processing subsystem, perform data exchange between the Fabric key protection subsystem and the Fabric proposal processing subsystem, and process data exchange between the Fabric proposal processing subsystem and the file system; interact with the key processing module KPM, receive the user certificate signature request CSR from the key processing module KPM, or transmit the user identity certificate to the key processing module KPM; interact with the secure file processing module SFPM, receive the secure file containing the user private key from the secure file processing module SFPM, or transmit the secure file containing the user private key to the secure file processing module SFPM; interact with the Fabric proposal signature module FPSM, forward the Fabric proposal / transaction / submission to be signed to the Fabric proposal signature module FPSM, or receive the The signature result of the Fabric proposal / transaction / submission returned by the Fabric proposal signature module FPSM; interact with the user registration module URM, pass the user certificate signature request CSR to the user registration module URM, or receive the user identity certificate from the user registration module URM; interact with the Fabric proposal initialization module FPIM, receive the initialized Fabric proposal from the Fabric proposal initialization module FPIM; interact with the Fabric proposal processing module FPPM, receive the unsigned Fabric transaction / submission from the Fabric proposal processing module FPPM, or forward the signature result of the Fabric proposal / transaction / submission to the Fabric proposal processing module FPPM; interact with the local file system, save the user identity certificate and the security file containing the user private key in the local file system, or obtain the user identity certificate and the security file containing the user private key from the local file;
[0061] The user registration module URM is used to process the user's certificate signing request CSR and the user's identity certificate; interact with the data exchange module DXM, receive the user certificate signing request CSR from the data exchange module DXM, or transmit the user identity certificate to the data exchange module DXM; interact with the certificate authority in the Fabric network, submit the user's certificate signing request CSR to the certificate authority, or receive the user identity certificate returned by the certificate authority;
[0062] The Fabric proposal initialization module FPIM is used to fill in the information required for the Fabric proposal according to the Fabric specification to generate the initialized Fabric proposal information; interact with the data exchange module DXM to transmit the initialized Fabric proposal information to the data exchange module DXM; interact with the Fabric proposal processing module FPPM to transmit the initialized Fabric proposal information to the Fabric proposal processing module FPPM;
[0063] The Fabric proposal processing module FPPM is used to process the signed Fabric proposal / transaction / submission; interact with the Fabric proposal initialization module FPIM, and receive the initialization Fabric proposal information from the Fabric proposal initialization module FPIM; interact with the data exchange module DXM, and transmit the unsigned Fabric transaction / submission to the data exchange module DXM, or receive the signature result of the Fabric proposal / transaction / submission from the data exchange module DXM; interact with the Fabric network, and upload the signed Fabric proposal / transaction / submission to the Fabric network, or receive the endorsement result and unsigned submission from the Fabric network.
[0064] Compared with the prior art, the present invention has the following main advantages:
[0065] (1) Aiming at the scenarios and requirements of mobile terminals supporting TrustZone technology accessing and using the Fabric system, the present invention applies TrustZone technology to Fabric's user key protection, generates user public and private keys, writes user private keys into a secure file, and reads user private keys from a secure file in TrustZone's SW, effectively improving the security of Fabric's user private keys during generation and storage.
[0066] (2) Aiming at the scenarios and requirements of mobile terminals supporting TrustZone technology accessing and using the Fabric system, the present invention applies TrustZone technology to Fabric's user key protection. In the TrustZone SW, the private key is used to generate a certificate signature request CSR and the private key is used to sign the Fabric proposal / transaction / submission. This can provide runtime protection for Fabric user private keys without affecting the normal functions of Fabric.
[0067] (3) The present invention integrates the MbedTLS library into TrustZone, which can effectively improve the security of Fabric user keys during the generation, storage and use of Fabric without affecting the normal functions of Fabric (including generating keys, generating and signing proposals / transactions / submissions, and uploading signed proposals / transactions / submissions). BRIEF DESCRIPTION OF THE DRAWINGS
[0068] The technical solution of the present invention is further described below using embodiments and specific implementation methods. In addition, in the process of describing the technical solution, some drawings are also used. For those skilled in the art, other drawings and the intention of the present invention can also be obtained based on these drawings without paying creative work.
[0069] Figure 1 A framework diagram of a Hyperledger Fabric key protection system based on TrustZone according to an embodiment of the present invention;
[0070] Figure 2 Workflow diagram of the Hyperledger Fabric key protection method based on TrustZone in an embodiment of the present invention;
[0071] Figure 3 Flow chart of key generation and secure storage of user private keys according to an embodiment of the present invention;
[0072] Figure 4 Fabric proposal signature flow chart in an embodiment of the present invention;
[0073] Figure 5 Fabric transaction verification flow chart in an embodiment of the present invention;
[0074] Figure 6 Schematic diagram of the result of opening a secure file in NW in the experiment of the embodiment of the present invention;
[0075] Figure 7 Schematic diagram of FA generating a Fabric proposal summary and reading the signature result returned by CA in the experiment of the embodiment of the present invention;
[0076] Figure 8 A schematic diagram showing the signing result of the Fabric proposal summary displayed by the CA in the experiment of the embodiment of the present invention;
[0077] Fig. 9 Schematic diagram of FA generating a transaction summary and reading a transaction signature result in an experiment of an embodiment of the present invention;
[0078] Fig.10 Schematic diagram of the CA signing a transaction in the experiment of the embodiment of the present invention;
[0079] Fig.11 A schematic diagram of the effect of FPPM obtaining the result of the transaction and the status of the submission in the experiment of the embodiment of the present invention;
[0080] Fig.12 A schematic diagram of block data on a browser in an experiment of an embodiment of the present invention. DETAILED DESCRIPTION
[0081] In order to facilitate ordinary technicians in the field to understand and implement the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the implementation examples described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0082] By utilizing the security function cabinet and characteristics of TrustZone, this embodiment provides a Hyperledger Fabric key protection method and system based on TrustZone.
[0083] TrustZone is a hardware virtualization technology proposed by ARM and actually applied in its chips. In TrustZone, the hardware resources of the system are divided into two worlds, namely the Normal World (NW) and the Secure World (SW). Both NW and SW have their own independent system resources, including registers, physical memory and peripherals. The code and resources in SW are protected by strict access control policies and have higher privileges; SW can access all resources of NW, and NW's access to SW resources is restricted. Therefore, some sensitive operations can be run in SW, and regular ordinary operations can be executed in NW, so as to provide runtime security protection for the code and data that perform these sensitive operations, so that they are protected from interference or attacks by NW. In addition, TrustZone also provides a secure storage function, which can store sensitive data in an untrusted local file system as a secure file, thereby providing storage protection for sensitive data.
[0084] The MbedTLS library is an open source SSL / TLS algorithm library implemented by ARM in C language to facilitate software developers to use SSL / TLS functions and various encryption algorithms in environments such as mobile terminals. The system of this embodiment uses some algorithms in the MbedTLS library, including the Fabric key generation algorithm and the Fabric proposal / transaction / submission signature algorithm.
[0085] Please see Figure 1 , a TrustZone-based Hyperledger Fabric key protection system provided in this embodiment includes two subsystems: a Fabric key protection subsystem and a Fabric proposal processing subsystem;
[0086] Among them, in the Fabric key protection subsystem, this embodiment uses the security functions and features of TrustZone technology and the interface provided by the MbedTLS library to process Fabric user private keys and related operations in the TrustZone SW. These operations include: generating user public and private keys, generating certificate signing requests CSRs with private keys, writing private keys into secure files, recovering private keys from secure files, and signing Fabric proposals / transactions / submissions with private keys. In the Fabric proposal processing subsystem, this embodiment uses the contract objects and gateway objects provided by Fabric to perform Fabric-related operations and interactions with the Fabric network, including generating unsigned proposals / transactions / submissions, interacting with endorsement nodes and sorting services, etc. In addition, operations that do not involve private key plaintext, including access to the local file system, are also processed by the Fabric proposal processing subsystem. The security features of TrustZone ensure that the data and applications in the SW will not be interfered with or attacked by the NW, thereby improving the security of Fabric user keys during generation, use and storage.
[0087] The system implementation of this embodiment includes functional modules: Key Processing Module (KPM), Secure File Processing Module (SFPM), Fabric Proposal Signing Module (FPSM), Data eXchange Module (DXM), User Registration Module (URM), Fabric Proposal Initialization Module (FPIM), Fabric Proposal Processing Module (FPPM). Among them, the key processing module KPM, the secure file processing module SFPM, and the Fabric proposal signing module FPSM are functional modules of the Fabric key protection subsystem, which are all located in the SW of TrustZone and integrated into a trusted application (TA). The data exchange module DXM, the user registration module URM, the Fabric proposal initialization module FPIM, and the Fabric proposal processing module FPPM are functional modules of the Fabric proposal processing subsystem, which are all located in the NW of TrustZone and integrated into a client application (CA).
[0088] In one embodiment, the key processing module KPM: generates a public-private key pair for a Fabric user that complies with the Fabric specification; generates a certificate signing request CSR using the private key, and the CSR contains the user's identity information. It interacts with the data exchange module DXM to pass the user's certificate signing request CSR to DXM, or receives the user's identity certificate from DXM. It interacts with the secure file management module SFPM to pass the user's private key to SFPM, or receives the user's private key from SFPM. It interacts with the Fabric proposal signature module FPSM to pass the user's private key to FPSM.
[0089] In one embodiment, the secure file processing module SFPM: generates and manages secure files in TrustZone. Interacts with the key processing module KPM, receives the user private key from KPM, and writes the user private key into the secure file, or reads the user private key from the secure file and transmits the user private key to KPM. Interacts with the data exchange module DXM, transmits the secure file containing the user private key to DXM, or receives the secure file containing the user private key from DXM.
[0090] In one embodiment, the Fabric proposal signature module FPSM: signs the Fabric proposal / transaction / submission. Interacts with the key processing module KPM and receives the user private key from the KPM. Interacts with the data exchange module DXM and receives the Fabric proposal / transaction / submission to be signed from DXM, or transmits the signature result of the Fabric proposal / transaction / submission to DXM.
[0091] In one embodiment, the data exchange module DXM: provides a unified interface for data interaction between the Fabric key protection subsystem and the Fabric proposal processing subsystem, performs data exchange between the Fabric key protection subsystem and the Fabric proposal processing subsystem, and processes data exchange between the Fabric proposal processing subsystem and the file system. Interacts with the key processing module KPM, receives the user certificate signature request CSR from KPM, or transmits the user identity certificate to KPM. Interacts with the secure file processing module SFPM, receives the secure file containing the user private key from SFPM, or transmits the secure file containing the user private key to SFPM. Interacts with the Fabric proposal signature module FPSM, forwards the Fabric proposal / transaction / submission to be signed to FPSM, or receives the signature result of the Fabric proposal / transaction / submission returned by FPSM. Interacts with the user registration module URM, transmits the user certificate signature request CSR to URM, or receives the user identity certificate from URM. Interacts with the Fabric proposal initialization module FPIM, and receives the initialized Fabric proposal from FPIM. Interact with Fabric Proposal Processing Module FPPM, receive unsigned Fabric transactions / submissions from FPPM, or forward the signature results of Fabric proposals / transactions / submissions to FPPM. Interact with the local file system, save the user identity certificate and the security file containing the user's private key in the local file system, or obtain the user identity certificate and the security file containing the user's private key from the local file.
[0092] In one embodiment, the user registration module URM: processes the user's certificate signing request CSR and the user's identity certificate. Interacts with the data exchange module DXM, receives the user's certificate signing request CSR from DXM, or transmits the user's identity certificate to DXM. Interacts with the certificate authority in the Fabric network, submits the user's certificate signing request CSR to the certificate authority, or receives the user's identity certificate returned by the certificate authority.
[0093] In one embodiment, the Fabric proposal initialization module FPIM: fills in the information required for the Fabric proposal according to the Fabric specification to generate the initialized Fabric proposal information. Interacts with the data exchange module DXM to pass the initialized Fabric proposal information to DXM. Interacts with the Fabric proposal processing module FPPM to pass the initialized Fabric proposal information to FPPM.
[0094] In one embodiment, the Fabric proposal processing module FPPM: processes the signed Fabric proposal / transaction / submission. Interacts with the Fabric proposal initialization module FPIM and receives the initialization Fabric proposal information from FPIM. Interacts with the data exchange module DXM and transmits the unsigned Fabric transaction / submission to DXM, or receives the signature result of the Fabric proposal / transaction / submission from DXM. Interacts with the Fabric network and uploads the signed Fabric proposal / transaction / submission to the Fabric network, or receives the endorsement result and unsigned submission from the Fabric network.
[0095] Please see Figure 2 , this embodiment provides a Hyperledger Fabric key protection method based on TrustZone, comprising the following steps:
[0096] 1) The user generates a pair of public and private keys that meet the Fabric specification in the Fabric key protection subsystem, uses the private key to generate the user's certificate signing request CSR, writes the private key to a newly created secure file, and passes the CSR and the secure file containing the private key to the Fabric proposal processing subsystem.
[0097] Please see Figure 3 In one implementation, step 1) is specifically implemented by comprising the following steps:
[0098] 1-1) The key processing module KPM generates a pair of public and private keys (pk, sk) that meet the ECDSA-secp256r1 specification through the mbedtls_ecp_gen_keypair() method provided by the MbedTLS library, where the length of the public key pk is 64 bytes and the length of the private key sk is 32 bytes.
[0099] 1-2) KPM uses the private key sk as input and generates the user's certificate signing request CSR through the mbedtls_x509write_csr_init() method provided by the MbedTLS library.
[0100] The fields generally included in the user's certificate signing request CSR are: Common Name (CN), Organization Name (O), Department (OU), Country Name (C), Signature Algorithm Name and User Public Key (pub), etc.
[0101] 1-3) KPM passes sk to the secure file processing module SFPM and passes the user's certificate signature request CSR to the data exchange module DXM.
[0102] 1-4) SFPM generates a security file SF, takes sk and SF as input, calls the TEE_WriteObjectData() method provided by OP-TEE to write sk into SF, and obtains SF sk .
[0103] 1-5) SFPM will SF sk Pass it to DXM.
[0104] 2) The Fabric proposal processing subsystem uploads the user's certificate signing request CSR to the certificate authority in the Fabric network, receives the user identity certificate returned by the certificate authority, associates the user identity certificate with the secure file containing the user's private key, and saves it in the local file system.
[0105] In one embodiment, step 2) is specifically implemented by comprising the following steps:
[0106] 2-1) The data exchange module DXM transmits the user's certificate signing request CSR to the user registration module URM.
[0107] 2-2) URM submits the user's certificate signing request CSR to the certificate authority in the Fabric network.
[0108] 2-3) After verifying the validity of the user's certificate signing request (CSR), the certificate authority in the Fabric network generates an identity certificate for the user and returns the user identity certificate to the URM.
[0109] 2-4) URM passes the user identity certificate to DXM.
[0110] 2-5)DXM will store the user's identity certificate and the secure file SF containing the user's private key. sk After association, it is saved in the local file system.
[0111] 3) When a Fabric proposal needs to be initiated, the user generates the initialization information of the Fabric proposal in the Fabric proposal processing subsystem, obtains the user's identity certificate and the security file containing the user's private key from the local file system, and sends the initialized Fabric proposal information, the user's identity certificate and the security file containing the user's private key to the Fabric key protection subsystem.
[0112] Please see Figure 4 In one implementation, step 3) is specifically implemented by comprising the following steps:
[0113] 3-1) The user enters relevant information for generating a proposal, including the contract name and contract parameters
[0114] 3-2) Fabric proposal initialization module FPIM calls the newProposal() method in Fabric's built-in gateway object to create an unsigned proposal based on the proposal information entered by the user. The proposal is a transaction to be executed.
[0115] 3-3) FPIM takes proposal as input and calls the getBytes() method of Fabric's built-in proposal object to convert proposal into byte representation to obtain proposalBytes.
[0116] 3-4) FPIM passes the proposalBytes to the Fabric proposal processing module FPPM.
[0117] 3-5) FPIM takes proposalBytes as input, calls the getDigest() method of the proposal object provided by Fabric, and calculates the SHA-256 digest proposalDig of proposalBytes.
[0118] 3-6) FPIM transmits proposalDig to the data exchange module DXM.
[0119] 3-7) DXM obtains the user identity certificate and the secure file SF containing the user's private key from the local file system sk .
[0120] 3-8)DXM passes proposalDig to Fabric proposal signature module FPSM.
[0121] 3-9)DXM passes the user identity certificate to the key processing module KPM.
[0122] 3-10)DXM will SF skPassed to the secure file processing module SFPM.
[0123] 4) Fabric key protection subsystem recovers the user's private key from the secure file and checks the correctness of the private key.
[0124] Please see Figure 4 In one implementation, step 4) is specifically implemented by comprising the following steps:
[0125] 4-1) SFPM is based on SF sk For input, call the TEE_ReadObjectData() method provided by OP-TEE to get the data from SF sk Recover the private key sk.
[0126] 4-2) SFPM passes sk to KPM.
[0127] 4-3) KPM takes the user's identity certificate as input and uses the patent's customized pem_pk() method to calculate the user's public key pk.
[0128] The pem_pk() method parses the user certificate and reads the public key field in the certificate by calling the MBEDTLS_X509_CSR_PARSE() method provided by MbedTLS;
[0129] 4-4) KPM checks the correctness of sk. The specific checking method is: KPM takes the private key sk as input, uses the tmp_pubkey() method customized by this patent to calculate a temporary public key pk', and checks whether pk' is the same as pk. If pk' is the same as pk, it means that the private key is correct, the check passes, and 4-5) is executed; otherwise, the private key check fails, and KPM returns a key loading error message. Among them, the tmp_pubkey() method calculates pk' by multiplying sk by the base point G of the elliptic curve to obtain another point G on the elliptic curve. pk’ , respectively take G pk’ The horizontal and vertical coordinates are the first 32 bytes and the last 32 bytes of pk'.
[0130] 4-5) KPM passes sk to the Fabric proposal signature module FPSM.
[0131] 5) Fabric key protection subsystem private key signs the Fabric proposal information and returns the signature result to the Fabric proposal processing subsystem.
[0132] Please see Figure 4 In one implementation, step 5) is specifically implemented by comprising the following steps:
[0133] 5-1) Fabric proposal signature module FPSM takes sk and proposalDig as input, calls the mbedtls_ecdsa_sign() method provided by the MbedTLS library, calculates the signature of proposalDig under sk, and obtains the signature result proposalSig of the proposal. Among them, the parameters used by the mbedtls_ecdsa_sign() method are specified by secp256r1.
[0134] 5-2) FPSM transmits proposalSig to the data exchange module DXM.
[0135] 5-3)DXM passes proposalSig to Fabric proposal processing module FPPM.
[0136] 6) The Fabric proposal processing subsystem submits the signed Fabric proposal information to the sorting service of the Fabric network, and then completes the update of the Fabric ledger.
[0137] Please see Figure 4 In one implementation, step 6) is specifically implemented by comprising the following steps:
[0138] 6-1) Fabric proposal processing module FPPM takes proposalBytes and proposalSig as input, calls the newSignedProposal() method in the gateway object provided by Fabric, and obtains the second signed proposal signedProposal;
[0139] In this embodiment, the signature result of the proposal is processed, and the name of the processed result is signedProposal. The signature process is twice. The first signature is to sign the proposal, and the processed result will be sent to the endorsement node. The second signature is to sign the transaction, and then the result is sent to the sorting service.
[0140] 6-2) FPPM takes signedProposal as input, calls the endorse() method of the proposal object that comes with Fabric, and sends the signed proposal signedProposal to the endorsement node in the Fabric network.
[0141] 6-3) The endorsing node first verifies whether the signedProposal has been submitted before to prevent replay attacks; then, the endorsing node verifies the validity of the signature in the signedProposal and interacts with the certificate authority to verify whether the user has the authority to perform the operations in the proposal on the channel. After the verification is passed, the endorsing node executes the chaincode in the signedProposal, signs the signedProposal, and returns the signature result to FPPM.
[0142] 6-4) After FPPM collects enough endorsements, it generates an unsigned transaction object unsignedTx.
[0143] 6-5) FPPM takes unsignedTx as input, calls the getBytes() method of Fabric’s built-in transaction object, converts unsignedTx into byte representation, and obtains txBytes.
[0144] 6-6) FPPM takes txBytes as input, calls the getDigest() method of Fabric's built-in transaction object, calculates the SHA-256 digest of txBytes, and obtains txDig.
[0145] 6-7) FPPM transmits txDig to the data exchange module DXM.
[0146] 6-8)DXM passes txDig to the Fabric proposal signature module FPSM.
[0147] 6-9) FPSM takes sk and txDig as input, calls the mbedtls_ecdsa_sign() method provided by the MbedTLS library, calculates the signature of txDig under sk, and obtains the signature result txSig of the transaction. Among them, the parameters used by the mbedtls_ecdsa_sign() method are specified by secp256r1.
[0148] 6-10)FPSM passes txSig to DXM.
[0149] 6-11)DXM passes txSig to FPPM.
[0150] 6-12) FPPM takes txBytes and txSig as input, calls the newSignedTransaction() method of the gateway object that comes with Fabric, and generates a signed transaction signedTx.
[0151] 6-13) FPPM takes signedTx as input, calls the submit() method of Fabric’s built-in signed transaction object, and submits signedTx to the sorting service in the Fabric network.
[0152] 6-14) The sorting service in the Fabric network sorts the signedTx and packages it into blocks, and sends the blocks to all peer nodes on the channel.
[0153] 6-15) The sorting service in the Fabric network creates an unsigned submission object unsignedCom and returns unsignedCom to FPPM.
[0154] 7) The Fabric proposal processing subsystem verifies whether the Fabric proposal is submitted successfully and obtains the result and submission status of the Fabric proposal.
[0155] Please see Figure 5 In one implementation, step 7) is specifically implemented by:
[0156] 7-1) Fabric proposal processing module FPPM takes unsignedCom as input, calls the getBytes() method of Fabric's own submission object, converts the unsigned submission object unsignedCom into a byte representation, and obtains commitBytes.
[0157] 7-2) FPPM takes commitBytes as input, calls the getDigest() method of Fabric's built-in transaction object, calculates the SHA-256 digest of commitBytes, and obtains commitDig.
[0158] 7-3) FPPM passes commitDig to DXM.
[0159] 7-4)DXM passes commitDig to the Fabric proposal signature module FPSM.
[0160] 7-5) FPSM takes sk and commitDig as input, calls the mbedtls_ecdsa_sign() method provided by the MbedTLS library, calculates the signature of commitDig under sk, and obtains the submitted signature result commitSig. Among them, the parameters used by the mbedtls_ecdsa_sign() method are specified by secp256r1.
[0161] 7-6) FPSM passes commitSig to DXM.
[0162] 7-7)DXM passes commitSig to FPPM.
[0163] 7-8) FPPM takes commitBytes and commitSig as input, calls the newSignedCommit() method of the gateway object that comes with Fabric, and generates a signed commit signedCommit.
[0164] 7-9) FPPM calls the getResult() method of the gateway object that comes with Fabric to obtain the result of the signed transaction.
[0165] 7-10) FPPM calls the getStatus() method of the gateway object that comes with Fabric to obtain the status information of the signed submission.
[0166] The present invention is further described below through specific experiments.
[0167] This experiment implements the prototype system of the present invention in the QEMU simulation environment, and its software and hardware environment is: the processor is Intel Core i7-11700 CPU@2.50GHz, the memory is 8G, and the programming language is C and JavaScript. The operating system of Fabric transaction processing module FPPM and Fabric proposal initialization module FPIM is Linux Ubuntu 20.04LTS, the operating system of Fabric proposal processing subsystem and Fabric key protection subsystem is OP-TEE, version 3.19, the version of QEMU is 7.0.0, the version of MbedTLS library is 2.0, and the version of Fabric platform is 1.10.15-stable.
[0168] OP-TEE provides a secure storage function interface, but does not contain the secp256r1 domain parameters required by the present invention. The MbedTLS library provides the interface of the relevant algorithms required by the present invention and can be applied to OP-TEE. The present invention uses the interface provided by the MbedTLS library to implement operations related to secp256r1, including generating user public and private keys and signing Fabric proposal information with private keys.
[0169] In the experiment, when the secure file processing module SFPM stores the secure file in the local file system, it will be stored in the / data / tee directory, which will have two types of files: the dirf.db file and the encrypted file named with a number. In order to verify the security of the encrypted file, the present invention directly reads the secure file in the NW, and the implementation effect is as follows: Figure 1 As shown. Figure 6The contents of part ① are all garbled characters, which means that the present invention can encrypt and store the private key. Only by using the secure storage function in the secure file processing module SFPM can the secure file be read and the correct private key be obtained.
[0170] Before starting the proposal signing step, the Fabric proposal initialization module FPIM first calculates the SHA256 summary of the proposal information, and then sends this summary to the data exchange module DXM, and then DXM passes it to the Fabric proposal signature module FPSM to complete the signing process. The implementation effect diagram is as follows: Figure 7 In this experiment, FPIM calculates the SHA256 digest of proposal proposalDig (i.e. Figure 7 Then DXM sends proposalDig to FPSM for signature. After the signature is completed, FPIM receives the signature result transmitted by FPSM (i.e. Figure 7 Finally, the signature result is processed and uploaded to the endorsement node of the Fabric network.
[0171] When signing a Fabric proposal, the implementation effect is as follows: Figure 8 In this experiment, DXM receives proposalDig (i.e. Figure 8 Part ①), its value is Figure 7 The first part is the same as in the previous section. Then DXM passes proposalDig to FPSM to complete the signature operation, generate the signature result proposalSig, and pass it to DXM (i.e. Figure 8 (Part ②) and its value is Figure 7 Part ② is the same as in the previous section. Finally, DXM passes proposalSig to Fabric transaction processing module FPPM.
[0172] After the endorsement node in the Fabric network completes the endorsement, FPPM obtains the return result unsignedTx. At this time, FPPM calculates the SHA256 digest of ussignedTx, generates TxDig, and then sends TxDig to DXM, which then passes it to FPSM for signing. The implementation effect is as follows: Fig. 9 As shown. DXM receives the signature result TxSig (i.e. Fig. 9 Part ②), and then DXM passes it to FPPM, which then processes and submits the result to the sorting service in the Fabric network to complete the transaction submission.
[0173] DXM reads TxDig from FPPM, and then DXM passes TxDig to FPSM. FPSM completes the signature process, generates TxSig and passes it to DXM. DXM then passes TxSig to FPPM. The signature result is as follows: Fig.10 As shown, the value of TxDig (i.e. Fig.10 (Part ①) and Fig. 9 The ① part is the same, and TxSig (i.e. Fig.10 (Part 2) and Fig. 9 The values of part ② are the same.
[0174] Please see Fig.11 , which is a schematic diagram of the implementation effect of FPPM obtaining the result of this transaction and the status of this submission, Fig.11 It can be seen that FPPM first generates the SHA256 digest commitDig of unsignedCom (i.e. Fig.11 In the verification phase, FPPM receives commitSig (i.e. Fig.11 After the transaction is completed, the ledger is updated and the status of the transaction is obtained (i.e. Fig.11 According to the results in the figure, the transaction has been successfully submitted to the Fabric network and the ledger has been updated.
[0175] In order to more intuitively check whether the transaction is successful, this experiment builds HyperledgerExplorer as a blockchain browser to browse the network activities on the blockchain to view the blocks and transactions in the Fabric network. The results are as follows: Fig.12 As shown in the figure, the transaction ID and Fig.11 If the ③ part is the same as the ③ part of the block, it means that the transaction has been added to the block. And opening the transaction can view the detailed information of the transaction in the block, such as hash value, timestamp, etc.
[0176] From the above results, it can be seen that the Fabric transaction based on the present invention can be successfully submitted to the Fabric network, and each node can verify that the transaction completes the account book update. This shows that it is feasible for the present invention to place the operations related to the private key in the Fabric transaction process in the TrustZone SW, and it can improve the security of the Fabric user key in the generation, storage and use process without affecting the normal transaction function of Fabric by using the security features of TrustZone.
[0177] The focus of this invention is to protect Fabric keys through TrustZone technology. Therefore, the time overhead of the proposed method is tested here, mainly testing the generation of public and private keys, transaction signatures, the endorsement process completed by the endorsement node, and the transaction time sent by the sorting service, and comparing the performance of the original Fabric system online signature and offline signature. All test results in this chapter are the average of 2000 rounds of repeated operations. For the convenience of description, this chapter refers to Fabric online signature, Fabric offline signature, and this invention as Fabric-ON, Fabric-OFF, and TZ-Fabric, respectively.
[0178] Table 1 shows the time cost of different methods at each stage. Since the endorsement process and sorting process of Fabric-OFF and TZ-Fabric are consistent, and the time cost of these two processes is determined by the network speed and has nothing to do with the performance of the method, this chapter does not test the time of endorsement and sorting process. In Fabric-OFF, the private key is generated when connecting to the network, and no interface for generating user keys is provided, so this chapter does not measure its key generation time.
[0179] Table 1 Average time cost of each method in Fabric transaction (ms)
[0180]
[0181] As can be seen from Table 1, compared with Fabric-ON and Fabric-OFF, the time overhead of the present invention is relatively large. This is because the system in this chapter is completed in the OP-TEE system, and the time overhead will definitely be longer than the signature algorithm that comes with Fabric. Secondly, the present invention runs all operations related to private keys in the key protection subsystem, but the key protection subsystem can only interact with the data exchange module DXM, so when the present invention is implemented, there are more steps than Fabric-ON and Fabric-OFF. When generating Fabric keys and signing Fabric proposals, the key protection subsystem must first interact with DXM to generate and transmit the results. These processes will increase the time overhead of the method. However, the performance overhead of the present invention in key generation and signing is about ten milliseconds, which is acceptable for users using mobile devices.
[0182] In order to further analyze the performance overhead of the method, this experiment tested the private key related processes and the data transmission time between the key protection subsystem and DXM. The results are shown in Table 2.
[0183] Table 2 Time cost and proportion of related operations in Fabric transactions
[0184]
[0185] As can be seen from Table 2, during the key generation phase, the time to write the private key to the secure file accounts for 73.1%. When signing the Fabric proposal, the time to read the private key and pass the signature result to DXM accounts for a total of 49.8%. From the experimental results, it can be seen that a large part of the performance overhead of the present invention is caused by the interaction between various operations. The interaction of these operations is determined by TrustZone itself. To implement the present invention, these operations must be implemented, so these time overheads are necessary for the present invention.
[0186] The present invention utilizes the security function cabinet and characteristics of TrustZone to perform operations such as generating the public and private keys of Fabric users, generating a certificate signature request CSR with a private key, writing the user private key into a secure file, reading the user private key from a secure file, and signing a Fabric proposal / transaction / submission in the secure world SW of TrustZone; when the private key is not in use, it is saved in the untrusted ordinary world NW in the form of a secure file. The present invention can improve the security of Fabric user keys in the generation, storage, and use process without affecting the normal functions of Fabric.
[0187] It should be understood that the embodiments described above are part of the embodiments of the present invention, rather than all of the embodiments. In addition, the technical features in the various embodiments or single embodiments provided by the present invention can be combined with each other arbitrarily to form a feasible technical solution. Such combination is not restricted by the sequence of steps and / or the structural composition mode, but must be based on the ability of ordinary technicians in the field to implement. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such combination of technical solutions does not exist and is not within the protection scope required by the present invention.
[0188] It should be understood that the above description of the preferred embodiment is relatively detailed and cannot be regarded as limiting the scope of patent protection of the present invention. Under the enlightenment of the present invention, ordinary technicians in this field can also make substitutions or modifications without departing from the scope of protection of the claims of the present invention, which all fall within the scope of protection of the present invention. The scope of protection requested for the present invention shall be based on the attached claims.
Claims
1. A Hyperledger Fabric key protection method based on TrustZone, characterized in that: By utilizing TrustZone's security function cabinets and features, Fabric users' public and private key generation, certificate signature request CSR generation with private key, user private key writing to secure file, user private key reading from secure file, and Fabric proposal / transaction / submission signature operation are performed in TrustZone's secure world SW; when the private key is not in use, it is saved in the untrusted ordinary world NW in the form of a secure file.
2. The Hyperledger Fabric key protection method based on TrustZone according to claim 1, characterized in that: The following steps are involved: Step 1: Generate a pair of public and private keys that meet the Fabric specification, use the private key sk to generate the user's certificate signing request CSR, write the private key to a newly created security file, and obtain the security file SF sk ; Step 2: Upload the user's certificate signing request CSR to the certificate authority in the Fabric network, receive the user identity certificate returned by the certificate authority, and attach the user identity certificate to the security file SF. sk After association, it is saved in the local file system; Step 3: When a Fabric proposal needs to be initiated, initialize the Fabric proposal information and obtain the user's identity certificate and the secure file SF containing the user's private key from the local file system. sk ; Step 4: Recover the user's private key from the secure file and check the correctness of the private key; Step 5: Use the private key to sign the initialized Fabric proposal information; Step 6: Submit the signed Fabric proposal information to the sorting service of the Fabric network, create an unsigned submission object unsignedCom, and then complete the update of the Fabric ledger; Step 7: Verify whether the Fabric proposal is submitted successfully, and obtain the result and submission status of the Fabric proposal.
3. The Hyperledger Fabric key protection method based on TrustZone according to claim 2, characterized in that: The specific implementation of step 1 includes the following steps: Step 1.1: Generate a pair of public and private keys (pk, sk) that meet the ECDSA-secp256r1 specification through the mbedtls_ecp_gen_keypair() method provided by the MbedTLS library; Step 1.2: Using the private key sk as input, generate the user's certificate signing request CSR through the mbedtls_x509write_csr_init() method provided by the MbedTLS library; Step 1.3: Generate a secure file SF. Take the private key sk and SF as input, call the TEE_WriteObjectData() method provided by OP-TEE to write the private key sk into SF, and get the secure file SF sk .
4. The Hyperledger Fabric key protection method based on TrustZone according to claim 2, characterized in that: Initialize the Fabric proposal information as described in step 3. The specific implementation includes the following steps: Step 3.1: The user enters relevant information for generating a proposal, including the contract name and contract parameters; Step 3.3: Based on the proposal information entered by the user, call the newProposal() method in the gateway object provided by Fabric to create an unsigned proposal; Step 3.3: Call the getBytes() method of the proposal object that comes with Fabric to convert proposal into byte representation and get proposalBytes; Step 3.4: Call the getDigest() method of the proposal object that comes with Fabric to calculate the SHA-256 digest proposalDig of proposalBytes.
5. The Hyperledger Fabric key protection method based on TrustZone according to claim 2, characterized in that: The specific implementation of step 4 includes the following sub-steps: Step 4.1: Call the TEE_ReadObjectData() method provided by OP-TEE to obtain the data from SF sk Recover the private key sk; Step 4.2: Use the pem_pk() method to calculate the user's public key pk; The pem_pk() method parses the user certificate and reads the public key field in the certificate by calling the MBEDTLS_X509_CSR_PARSE() method provided by MbedTLS; Step 4.3: Check the correctness of the private key sk; Use the tmp_pubkey() method to calculate a temporary public key pk' and check whether pk' is the same as pk; if pk' is the same as pk, it means that the private key is correct and the check passes, and execute 4-5); otherwise, the private key check fails and a key loading error message is returned; The tmp_pubkey() method uses the private key sk to multiply the base point G of the elliptic curve to obtain another point G on the elliptic curve. pk’ , respectively take G pk’ The horizontal and vertical coordinates are the first 32 bytes and the last 32 bytes of pk'.
6. The TrustZone-based Hyperledger Fabric key protection method according to claim 2, characterized in that: In step 5, the mbedtls_ecdsa_sign() method provided by the MbedTLS library is called to calculate the signature of the initialized Fabric proposal information proposalDig under the private key sk, and obtain the signature result proposalSig of the proposal; among them, the parameters used by the mbedtls_ecdsa_sign() method are specified by secp256r1.
7. The TrustZone-based Hyperledger Fabric key protection method according to claim 2, characterized in that: The specific implementation of step 6 includes the following sub-steps: Step 6.1: Call the newSignedProposal() method in the gateway object of Fabric to get the second signed proposal signedProposal; Step 6.2: Call the endorse() method of the proposal object that comes with Fabric to send the signed proposal signedProposal to the endorsement node in the Fabric network; Step 6.3: After collecting the preset amount of endorsements, an unsigned transaction object unsignedTx is generated; Step 6.4: Call the getBytes() method of Fabric's built-in transaction object to convert unsignedTx into byte representation to get txBytes; Step 6.5: Call the getDigest() method of Fabric's built-in transaction object to calculate the SHA-256 digest of txBytes to get txDig; Step 6.5: Call the mbedtls_ecdsa_sign() method provided by the MbedTLS library to calculate the signature of txDig under the private key sk and obtain the signature result txSig of the transaction; the parameters used by the mbedtls_ecdsa_sign() method are specified by secp256r1; Step 6.6: Call the newSignedTransaction() method of the gateway object that comes with Fabric to generate a signed transaction signedTx; Step 6.7: Call the submit() method of the signed transaction object that comes with Fabric to submit signedTx to the sorting service in the Fabric network; Step 6.8: The sorting service in the Fabric network sorts the signedTx and packages it into blocks, and sends the blocks to all peer nodes on the channel; Step 6.9: The ordering service in the Fabric network creates an unsigned submission object unsignedCom.
8. The TrustZone-based Hyperledger Fabric key protection method according to any one of claims 2 to 7, characterized in that: The specific implementation of step 7 includes the following sub-steps: Step 7.1: Call the getBytes() method of the commit object that comes with Fabric to convert the unsigned commit object unsignedCom into a byte representation to get commitBytes; Step 7.2: Call the getDigest() method of Fabric's built-in transaction object to calculate the SHA-256 digest of commitBytes and get commitDig; Step 7.3: Call the mbedtls_ecdsa_sign() method provided by the MbedTLS library to calculate the signature of commitDig under the private key sk and obtain the submitted signature result commitSig; the parameters used by the mbedtls_ecdsa_sign() method are specified by secp256r1; Step 7.4: With commitBytes and commitSig as input, call the newSignedCommit() method of the gateway object that comes with Fabric to generate a signed commit signedCommit; Step 7.5: Call the getResult() method of the gateway object that comes with Fabric to obtain the result of the signed transaction; Step 7.6: Call the getStatus() method of the gateway object that comes with Fabric to obtain the status information of the signed submission.
9. A Hyperledger Fabric key protection system based on TrustZone, characterized in that: It includes two subsystems: Fabric key protection subsystem and Fabric proposal processing subsystem; The Fabric key protection subsystem includes a key processing module KPM, a secure file processing module SFPM and a Fabric proposal signature module FPSM; The Fabric proposal processing subsystem includes a data exchange module DXM, a user registration module URM, a Fabric proposal initialization module FPIM and a Fabric proposal processing module FPPM; The key processing module KPM is used to generate a public-private key pair that complies with the Fabric specification for a Fabric user; generate a certificate signing request CSR using a private key; interact with the data exchange module DXM, transmit the user's certificate signing request CSR to the data exchange module DXM, or receive the user identity certificate from the data exchange module DXM; Interact with the secure file management module SFPM, transmit the user private key to the secure file management module SFPM, or receive the user private key from the secure file management module SFPM; interact with the Fabric proposal signature module FPSM, transmit the user private key to the Fabric proposal signature module FPSM; The secure file processing module SFPM is used to generate and manage secure files in TrustZone; interact with the key processing module KPM, receive the user private key transmitted by the key processing module KPM, and write the user private key into the secure file, or read the user private key from the secure file and transmit the user private key to the key processing module KPM; interact with the data exchange module DXM, transmit the secure file containing the user private key to the data exchange module DXM, or receive the secure file containing the user private key transmitted by the data exchange module DXM; The Fabric proposal signature module FPSM is used to sign the Fabric proposal / transaction / submission; interact with the key processing module KPM to receive the user private key from the key processing module KPM; interact with the data exchange module DXM to receive the Fabric proposal / transaction / submission to be signed from the data exchange module DXM, or transmit the signature result of the Fabric proposal / transaction / submission to the data exchange module DXM; The data exchange module DXM is used to provide a unified interface for data interaction between the Fabric key protection subsystem and the Fabric proposal processing subsystem, perform data exchange between the Fabric key protection subsystem and the Fabric proposal processing subsystem, and process data exchange between the Fabric proposal processing subsystem and the file system; Interact with the key processing module KPM, receive the user certificate signature request CSR from the key processing module KPM, or transmit the user identity certificate to the key processing module KPM; interact with the secure file processing module SFPM, receive the secure file containing the user private key from the secure file processing module SFPM, or transmit the secure file containing the user private key to the secure file processing module SFPM; interact with the Fabric proposal signature module FPSM, forward the Fabric proposal / transaction / submission to be signed to the Fabric proposal signature module FPSM, or receive the signature result of the Fabric proposal / transaction / submission returned by the Fabric proposal signature module FPSM; Interact with the user registration module URM, transmit the user certificate signature request CSR to the user registration module URM, or receive the user identity certificate from the user registration module URM; interact with the Fabric proposal initialization module FPIM, receive the initialized Fabric proposal from the Fabric proposal initialization module FPIM; interact with the Fabric proposal processing module FPPM, receive the unsigned Fabric transaction / submission from the Fabric proposal processing module FPPM, or forward the signature result of the Fabric proposal / transaction / submission to the Fabric proposal processing module FPPM; interact with the local file system, save the user identity certificate and the security file containing the user private key in the local file system, or obtain the user identity certificate and the security file containing the user private key from the local file; The user registration module URM is used to process the user's certificate signing request CSR and the user's identity certificate; Interact with the data exchange module DXM, receive the user certificate signing request CSR from the data exchange module DXM, or transmit the user identity certificate to the data exchange module DXM; interact with the certificate authority in the Fabric network, submit the user's certificate signing request CSR to the certificate authority, or receive the user identity certificate returned by the certificate authority; The Fabric proposal initialization module FPIM is used to fill in the information required for the Fabric proposal according to the Fabric specification to generate the initialized Fabric proposal information; interact with the data exchange module DXM to transmit the initialized Fabric proposal information to the data exchange module DXM; interact with the Fabric proposal processing module FPPM to transmit the initialized Fabric proposal information to the Fabric proposal processing module FPPM; The Fabric proposal processing module FPPM is used to process the signed Fabric proposal / transaction / submission; interact with the Fabric proposal initialization module FPIM, and receive the initialization Fabric proposal information from the Fabric proposal initialization module FPIM; interact with the data exchange module DXM, and transmit the unsigned Fabric transaction / submission to the data exchange module DXM, or receive the signature result of the Fabric proposal / transaction / submission from the data exchange module DXM; interact with the Fabric network, and upload the signed Fabric proposal / transaction / submission to the Fabric network, or receive the endorsement result and unsigned submission from the Fabric network.
