A method for implementing identity-based key management by using a smart contract comprising: running the smart contract to execute a key management process, wherein the key management process comprises: responsive to that a key of a target user needs to be updated and the target user is an unsupervised user, generating a master public key and a master private key belonging to the target user; acquiring identity information of the target user from a blockchain; generating a first target private key based on the master public key and the master private key belonging to the target user and the identity information of the target user; and replacing a present private key of the target user with the first target private key; wherein the key management process further comprises: responsive to that the target user is an unsupervised user and the present private key of the target user is leaked, or responsive to that the target user is a supervised user, acquiring the identity information of the target user from the blockchain; updating the identity information of the target user, and taking the updated identity information as target identity information; generating a second target private key by using the target identity information; and replacing the present private key of the target user with the second target private key, wherein a private key of the supervised user is obtained by an administrator of the smart contract, and is to be updated by the administrator, and a private key of the unsupervised user is not obtained by the administrator after user registration, and is to be updated by the unsupervised user. running the smart contract to execute a key management process, wherein the key management process comprises: responsive to that a key of a target user needs to be updated and the target user is an unsupervised user, generating a master public key and a master private key belonging to the target user; acquiring identity information of the target user from a blockchain; generating a first target private key based on the master public key and the master private key belonging to the target user and the identity information of the target user; and replacing a present private key of the target user with the first target private key; responsive to that a key of a target user needs to be updated and the target user is an unsupervised user, generating a master public key and a master private key belonging to the target user; acquiring identity information of the target user from a blockchain; generating a first target private key based on the master public key and the master private key belonging to the target user and the identity information of the target user; and replacing a present private key of the target user with the first target private key; wherein the key management process further comprises: responsive to that the target user is an unsupervised user and the present private key of the target user is leaked, or responsive to that the target user is a supervised user, acquiring the identity information of the target user from the blockchain; updating the identity information of the target user, and taking the updated identity information as target identity information; generating a second target private key by using the target identity information; and replacing the present private key of the target user with the second target private key, wherein a private key of the supervised user is obtained by an administrator of the smart contract, and is to be updated by the administrator, and a private key of the unsupervised user is not obtained by the administrator after user registration, and is to be updated by the unsupervised user. responsive to that the target user is an unsupervised user and the present private key of the target user is leaked, or responsive to that the target user is a supervised user, acquiring the identity information of the target user from the blockchain; updating the identity information of the target user, and taking the updated identity information as target identity information; generating a second target private key by using the target identity information; and replacing the present private key of the target user with the second target private key, wherein a private key of the supervised user is obtained by an administrator of the smart contract, and is to be updated by the administrator, and a private key of the unsupervised user is not obtained by the administrator after user registration, and is to be updated by the unsupervised user.