CN114417374A - Blockchain-based smart contract business card method, device, device and storage medium - Google Patents
Blockchain-based smart contract business card method, device, device and storage medium Download PDFInfo
- Publication number
- CN114417374A CN114417374A CN202111639480.2A CN202111639480A CN114417374A CN 114417374 A CN114417374 A CN 114417374A CN 202111639480 A CN202111639480 A CN 202111639480A CN 114417374 A CN114417374 A CN 114417374A
- Authority
- CN
- China
- Prior art keywords
- user
- account
- business card
- information
- blockchain
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/602—Providing cryptographic facilities or services
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/08—Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
- H04L9/0861—Generation of secret information including derivation or calculation of cryptographic keys or passwords
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/14—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using a plurality of keys or algorithms
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Theoretical Computer Science (AREA)
- General Health & Medical Sciences (AREA)
- Bioethics (AREA)
- Computer Hardware Design (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Health & Medical Sciences (AREA)
- Storage Device Security (AREA)
Abstract
Description
技术领域technical field
本发明涉及区块链技术领域,尤其涉及一种基于区块链的智能合约名片方法、装置、电子设备及计算机可读存储介质。The present invention relates to the field of blockchain technology, and in particular, to a blockchain-based smart contract business card method, device, electronic device and computer-readable storage medium.
背景技术Background technique
在各行各业的工作和社交中,名片一直扮演着不可或缺的角色,在面对客户时都少不了要递上自己的名片,然而随着消费型态的改变,以及因特网的普及,面对面营销不再是唯一的方法,许多用户逐渐在利用因特网提供另一种消费模式,电子名片也因应网络的消费模式而产生。Business cards have always played an indispensable role in work and social interaction in all walks of life. When facing customers, it is indispensable to hand over your business card. However, with the change of consumption patterns and the popularity of the Internet, face-to-face marketing It is no longer the only method, many users are gradually using the Internet to provide another consumption pattern, and electronic business cards are also produced in response to the consumption pattern of the network.
现有的电子名片生成方法通常是从商家的数据库中获取用户相关数据,并结合现有的名片模板生成电子名片,这种方法无法确保用户相关数据的及时性及生成电子名片的准确性,同时通过用户相关数据生成名片的安全性不够高。The existing electronic business card generation method usually obtains user-related data from the merchant's database, and combines the existing business card templates to generate electronic business cards. This method cannot ensure the timeliness of user-related data and the accuracy of generating electronic business cards. The security of generating business cards from user-related data is not high enough.
发明内容SUMMARY OF THE INVENTION
本发明提供一种基于区块链的智能合约名片方法、装置及计算机可读存储介质,其主要目的在于解决名片生成的安全性不够高的问题。The present invention provides a blockchain-based smart contract business card method, device and computer-readable storage medium, the main purpose of which is to solve the problem that the security of business card generation is not high enough.
为实现上述目的,本发明提供的一种基于区块链的智能合约名片方法,包括:To achieve the above purpose, the present invention provides a blockchain-based smart contract business card method, including:
获取用户基本信息及用户区块链账号,并对所述用户区块链账号进行激活处理;Obtain the user's basic information and the user's blockchain account, and activate the user's blockchain account;
当所述用户区块链账号经过激活处理后,索引出所述用户区块链账号所属机构的机构信息,分别将所述用户区块链账号、所述用户基本信息中的用户标识和所述机构信息中的机构区块链账号写入预构建初始名片的多个账号字段中;After the user's blockchain account is activated, the organization information of the institution to which the user's blockchain account belongs is indexed, and the user's blockchain account, the user ID in the basic user information and the The institutional blockchain account number in the institutional information is written into multiple account fields of the pre-built initial business card;
基于预设的加密算法生成加密密钥和所述加密密钥对应的解密密钥,利用所述加密密钥对所述用户基本信息中的个人信息进行加密,得到加密信息;Generate an encryption key and a decryption key corresponding to the encryption key based on a preset encryption algorithm, and use the encryption key to encrypt the personal information in the basic user information to obtain encrypted information;
基于预设的哈希算法计算所述个人信息的哈希值,并将所述哈希值、所述加密密钥和所述加密信息写入所述初始名片中的内容字段中;Calculate the hash value of the personal information based on a preset hash algorithm, and write the hash value, the encryption key and the encryption information into the content field in the initial business card;
将所述机构信息中的机构账号写入所述初始名片中的账号字段中,并利用所述机构账号对应的公钥对所述解密密钥进行加密,将加密后的第一密文写入所述账号字段对应的密文字段中;Write the organization account in the organization information into the account field in the initial business card, encrypt the decryption key with the public key corresponding to the organization account, and write the encrypted first ciphertext into the account field. in the ciphertext field corresponding to the account number field;
利用所述用户基本信息中的用户账号对应的公钥对所述解密密钥进行加密,将加密后的第二密文和所述用户账号写入字段中,得到用户名片。The decryption key is encrypted by using the public key corresponding to the user account in the basic user information, and the encrypted second ciphertext and the user account are written into a field to obtain a user card.
可选地,所述对所述用户区块链账号进行激活处理,包括:Optionally, the activation process for the user blockchain account includes:
根据所述用户区块链账号查询出对应的用户,并获取所述用户对应的公钥;Query the corresponding user according to the user blockchain account, and obtain the public key corresponding to the user;
将所述公钥和所述用户区块链账号写入预设区块链上的激活账号列表中。Write the public key and the user blockchain account into the activated account list on the preset blockchain.
可选地,所述基于预设的哈希算法计算所述个人信息的哈希值,包括:Optionally, calculating the hash value of the personal information based on a preset hash algorithm includes:
判断所述个人信息的大小是否满足预设的填充要求;Determine whether the size of the personal information meets the preset filling requirements;
若所述个人信息的大小满足所述填充要求,则在所述个人信息的末尾处添加第一位数的值,得到第一填充数据;If the size of the personal information meets the filling requirement, then add a value of the first digit at the end of the personal information to obtain the first filling data;
若所述个人信息的大小不满足所述填充要求,则对所述个人信息进行补位处理,得到第二填充数据;If the size of the personal information does not meet the filling requirement, perform a fill-in process on the personal information to obtain second filling data;
将所述第一填充数据或者第二填充数据输入至预设的哈希函数缓存器中进行数据处理,得到所述个人信息对应的哈希值。Inputting the first padding data or the second padding data into a preset hash function buffer for data processing to obtain a hash value corresponding to the personal information.
可选地,所述得到用户名片之后,所述方法还包括:Optionally, after obtaining the user card, the method further includes:
获取对所述用户名片执行名片操作的指令,并对所述指令进行解析处理;obtaining an instruction for performing a business card operation on the user's business card, and performing parsing processing on the instruction;
当解析后的指令为分享名片时,则根据所述用户区块链账号对所述用户名片执行名片分享操作;或When the parsed instruction is to share a business card, perform a business card sharing operation on the user's business card according to the user's blockchain account; or
当解析后的指令为更新名片时,利用所述机构区块链账号对所述用户名片执行名片更新操作;或When the parsed instruction is to update the business card, use the institutional blockchain account to perform a business card update operation on the user's business card; or
当解析后的指令为销毁名片时,利用所述机构区块链账号对所述用户名片中的状态字段设置为销毁。When the parsed instruction is to destroy the business card, use the institutional blockchain account to set the status field in the user's business card to be destroyed.
可选地,所述根据所述用户区块链账号对所述用户名片执行名片分享操作,包括:Optionally, performing a business card sharing operation on the user business card according to the user blockchain account number includes:
获取分享对象的账号,并基于所述区块链上的激活账号列表查询所述分享对象的账号对应的公钥;Obtain the account of the shared object, and query the public key corresponding to the account of the shared object based on the activated account list on the blockchain;
在所述用户名片中搜索所述用户区块链账号对应的加密密文,并利用所述用户区块链账号的私钥对所述加密密文进行解密,得到解密密文;Searching for the encrypted ciphertext corresponding to the user's blockchain account in the user business card, and decrypting the encrypted ciphertext by using the private key of the user's blockchain account to obtain the decrypted ciphertext;
将所述分享对象的账号写入所述用户名片的账号字段中,并利用所述分享对象的账号对应的公钥对所述解密密文进行加密,将加密后的解密密文存入所述账号字段对应的密文字段中,得到分享名片。Write the account of the shared object into the account field of the user card, and encrypt the decrypted ciphertext by using the public key corresponding to the account of the shared object, and store the encrypted decrypted ciphertext in the In the cipher text field corresponding to the account field, get the shared business card.
可选地,所述利用所述机构区块链账号对所述用户名片执行名片更新操作,包括:Optionally, performing a business card update operation on the user business card by using the institutional blockchain account number includes:
对预获取的待更新信息进行哈希运算,得到标准更新信息,并将所述标准更新信息写入所述用户名片的哈希值字段中;Perform a hash operation on the pre-acquired information to be updated to obtain standard update information, and write the standard update information into the hash value field of the user card;
利用所述机构区块链账号读取所述用户名片中的加密密钥,并利用所述加密密钥对所述待更新信息进行加密,将加密后的待更新信息写入所述用户名片中的信息字段,得到更新后的名片。Use the institutional blockchain account to read the encryption key in the user card, use the encryption key to encrypt the information to be updated, and write the encrypted information to be updated into the user card information field to get the updated business card.
可选地,所述基于预设的加密算法生成加密密钥和所述加密密钥对应的解密密钥,包括:Optionally, generating an encryption key based on a preset encryption algorithm and a decryption key corresponding to the encryption key, including:
获取预设的生成元、循环群及所述循环群对应的阶数;obtaining a preset generator, a cyclic group, and the order corresponding to the cyclic group;
基于所述循环群阶数构建循环区间,并在所述循环区间中任意选择一个随机数;Constructing a cyclic interval based on the order of the cyclic group, and arbitrarily selecting a random number in the cyclic interval;
根据预设的离散公式计算所述生成元对应的离散数;Calculate the discrete number corresponding to the generator according to a preset discrete formula;
根据所述离散数、所述生成元、所述随机数和所述阶数构建得到加密密钥,令所述随机数为所述解密密钥。The encryption key is constructed and obtained according to the discrete number, the generator, the random number and the order, and the random number is the decryption key.
为了解决上述问题,本发明还提供一种基于区块链的智能合约名片装置,所述装置包括:In order to solve the above problems, the present invention also provides a smart contract business card device based on blockchain, the device includes:
账号激活模块,用于获取用户基本信息及用户区块链账号,并对所述用户区块链账号进行激活处理;The account activation module is used to obtain the user's basic information and the user's blockchain account, and activate the user's blockchain account;
字段填充模块,用于当所述用户区块链账号经过激活处理后,索引出所述用户区块链账号所属机构的机构信息,分别将所述用户区块链账号、所述用户基本信息中的用户标识和所述机构信息中的机构区块链账号写入预构建初始名片的多个账号字段中;The field filling module is used to index the institution information of the institution to which the user blockchain account belongs after the user blockchain account has been activated, and respectively enter the user blockchain account and the user basic information into the user's blockchain account. The user ID and the institutional blockchain account number in the institutional information are written into the multiple account fields of the pre-built initial business card;
密钥生成模块,用于基于预设的加密算法生成加密密钥和所述加密密钥对应的解密密钥,利用所述加密密钥对所述用户基本信息中的个人信息进行加密,得到加密信息;A key generation module for generating an encryption key and a decryption key corresponding to the encryption key based on a preset encryption algorithm, and encrypting the personal information in the basic user information by using the encryption key to obtain an encrypted key information;
名片创建模块,用于基于预设的哈希算法计算所述个人信息的哈希值,并将所述哈希值、所述加密密钥和所述加密信息写入所述初始名片中的内容字段中,将所述机构信息中的机构账号写入所述初始名片中的账号字段中,并利用所述机构账号对应的公钥对所述解密密钥进行加密,将加密后的第一密文写入所述账号字段对应的密文字段中,利用所述用户基本信息中的用户账号对应的公钥对所述解密密钥进行加密,将加密后的第二密文和所述用户账号写入字段中,得到用户名片。A business card creation module, configured to calculate the hash value of the personal information based on a preset hash algorithm, and write the hash value, the encryption key and the encrypted information into the content of the initial business card In the field, write the organization account in the organization information into the account field in the initial business card, and encrypt the decryption key with the public key corresponding to the organization account, and encrypt the encrypted first password. The text is written into the cipher text field corresponding to the account field, and the decryption key is encrypted by using the public key corresponding to the user account in the basic user information, and the encrypted second cipher text and the user account are encrypted. Write into the field to get the user card.
为了解决上述问题,本发明还提供一种电子设备,所述电子设备包括:In order to solve the above problems, the present invention also provides an electronic device, the electronic device includes:
至少一个处理器;以及,at least one processor; and,
与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein,
所述存储器存储有可被所述至少一个处理器执行的计算机程序,所述计算机程序被所述至少一个处理器执行,以使所述至少一个处理器能够执行上述所述的基于区块链的智能合约名片方法。The memory stores a computer program executable by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the above-described blockchain-based Smart contract business card method.
为了解决上述问题,本发明还提供一种计算机可读存储介质,所述计算机可读存储介质中存储有至少一个计算机程序,所述至少一个计算机程序被电子设备中的处理器执行以实现上述所述的基于区块链的智能合约名片方法。In order to solve the above problems, the present invention also provides a computer-readable storage medium, where at least one computer program is stored in the computer-readable storage medium, and the at least one computer program is executed by a processor in an electronic device to realize the above-mentioned The blockchain-based smart contract business card method described above.
本发明实施例通过基于预设的加密算法生成加密密钥和所述加密密钥对应的解密密钥,利用所述加密密钥对所述用户基本信息中的个人信息进行加密,得到加密信息,用加密密钥来加密个人信息并保存数据上链,保证关键数据的安全,利用所述机构账号对应的公钥对所述解密密钥进行加密,将加密后的密文写入所述账号字段对应的密文字段中,保证只有机构账号对应的持有人可以可以查看到解密密钥,从而可以解密出明文。利用所述用户基本信息中的用户账号对应的公钥对所述解密密钥进行加密,将加密后的第二密文和所述用户账号写入字段中,得到用户名片。因此本发明提出的基于区块链的智能合约名片方法、装置、电子设备及计算机可读存储介质,可以实现解决名片生成的安全性不够高的问题。In the embodiment of the present invention, an encryption key and a decryption key corresponding to the encryption key are generated based on a preset encryption algorithm, and the personal information in the basic user information is encrypted by using the encryption key to obtain encrypted information, Encrypt personal information with an encryption key and save the data on the chain to ensure the security of key data, encrypt the decryption key with the public key corresponding to the institution account, and write the encrypted ciphertext into the account field In the corresponding ciphertext field, it is guaranteed that only the holder corresponding to the institutional account can view the decryption key, so that the plaintext can be decrypted. The decryption key is encrypted by using the public key corresponding to the user account in the basic user information, and the encrypted second ciphertext and the user account are written into a field to obtain a user card. Therefore, the blockchain-based smart contract business card method, device, electronic device and computer-readable storage medium proposed by the present invention can solve the problem that the security of business card generation is not high enough.
附图说明Description of drawings
图1为本发明一实施例提供的基于区块链的智能合约名片方法的流程示意图;1 is a schematic flowchart of a blockchain-based smart contract business card method provided by an embodiment of the present invention;
图2为本发明一实施例提供的基于区块链的智能合约名片装置的功能模块图;2 is a functional block diagram of a blockchain-based smart contract business card device provided by an embodiment of the present invention;
图3为本发明一实施例提供的实现所述基于区块链的智能合约名片方法的电子设备的结构示意图。FIG. 3 is a schematic structural diagram of an electronic device for implementing the blockchain-based smart contract business card method according to an embodiment of the present invention.
本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization, functional characteristics and advantages of the present invention will be further described with reference to the accompanying drawings in conjunction with the embodiments.
具体实施方式Detailed ways
应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。It should be understood that the specific embodiments described herein are only used to explain the present invention, but not to limit the present invention.
本申请实施例提供一种基于区块链的智能合约名片方法。所述基于区块链的智能合约名片方法的执行主体包括但不限于服务端、终端等能够被配置为执行本申请实施例提供的该方法的电子设备中的至少一种。换言之,所述基于区块链的智能合约名片方法可以由安装在终端设备或服务端设备的软件或硬件来执行,所述软件可以是区块链平台。所述服务端包括但不限于:单台服务器、服务器集群、云端服务器或云端服务器集群等。所述服务器可以是独立的服务器,也可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、内容分发网络(ContentDeliveryNetwork,CDN)、以及大数据和人工智能平台等基础云计算服务的云服务器。The embodiment of the present application provides a method for a smart contract business card based on a blockchain. The execution subject of the blockchain-based smart contract business card method includes, but is not limited to, at least one of the electronic devices that can be configured to execute the method provided by the embodiments of the present application, such as a server and a terminal. In other words, the blockchain-based smart contract business card method can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, and the like. The server can be an independent server, or can provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), as well as cloud servers for basic cloud computing services such as big data and artificial intelligence platforms.
参照图1所示,为本发明一实施例提供的基于区块链的智能合约名片方法的流程示意图。在本实施例中,所述基于区块链的智能合约名片方法包括:Referring to FIG. 1 , it is a schematic flowchart of a blockchain-based smart contract business card method provided by an embodiment of the present invention. In this embodiment, the blockchain-based smart contract business card method includes:
S1、获取用户基本信息及用户区块链账号,并对所述用户区块链账号进行激活处理。S1. Acquire basic information of the user and the user's blockchain account, and activate the user's blockchain account.
本发明实施例中,所述用户基本信息可以为某公司中的多个员工的基本信息,例如员工姓名、职位、邮箱、员工工号及联系方式等。可以从第三方数据库中获取用户基本信息,其中,所述第三方数据库为存储大量用户相关信息的数据库,实现对数据的集中控制和管理。In this embodiment of the present invention, the basic user information may be basic information of multiple employees in a company, such as employee names, positions, email addresses, employee IDs, and contact information. User basic information can be acquired from a third-party database, wherein the third-party database is a database that stores a large amount of user-related information, so as to realize centralized control and management of data.
具体地,所述对所述用户区块链账号进行激活处理,包括:Specifically, the activation process for the user's blockchain account includes:
根据所述用户区块链账号查询出对应的用户,并获取所述用户对应的公钥;Query the corresponding user according to the user blockchain account, and obtain the public key corresponding to the user;
将所述公钥和所述用户区块链账号写入预设区块链上的激活账号列表中。Write the public key and the user blockchain account into the activated account list on the preset blockchain.
详细地,用户需要激活自己的区块链账号,激活处理的过程就是将用户自己的区块链账号和对应的公钥写入所述区块链上的激活账号列表中,所述激活账号列表中包含多个account及公钥和状态。其中,所述区块链包括第一区块链节点、第二区块链节点、第三区块链节点、第N-1区块链节点、第N区块链节点,其中,N为正整数,N的值可以为预设的。每个区块链节点之间相互连接,共同形成一个区跨链网,各个区块链节点之间可进行信息相互传输,同步同时更新。In detail, the user needs to activate his own blockchain account, and the activation process is to write the user's own blockchain account and the corresponding public key into the activated account list on the blockchain, and the activated account list Contains multiple accounts and public keys and states. The blockchain includes a first blockchain node, a second blockchain node, a third blockchain node, an N-1th blockchain node, and an Nth blockchain node, where N is a positive Integer, the value of N can be preset. Each blockchain node is connected to each other to form a cross-chain network together, and each blockchain node can transmit information to each other and update at the same time.
S2、当所述用户区块链账号经过激活处理后,索引出所述用户区块链账号所属机构的机构信息,分别将所述用户区块链账号、所述用户基本信息中的用户标识和所述机构信息中的机构区块链账号写入预构建初始名片的多个账号字段中。S2. After the user's blockchain account is activated, index the organization information of the institution to which the user's blockchain account belongs, and respectively index the user's blockchain account, the user ID in the user's basic information and The institutional blockchain account number in the institutional information is written into multiple account fields of the pre-built initial business card.
本发明实施例中,当所述用户区块链账号经过激活处理后,索引出所述用户区块链账号所属机构的机构信息,其中,所述用户区块链账号即员工的区块链账号,所述用户区块链账号所属机构的机构信息即员工所在公司的公司信息,公司信息包括但不限于机构区块链账号。In the embodiment of the present invention, after the user's blockchain account is activated, the organization information of the institution to which the user's blockchain account belongs is indexed, wherein the user's blockchain account is the employee's blockchain account , the institutional information of the institution to which the user's blockchain account belongs is the company information of the company where the employee is located, and the company information includes but is not limited to the institutional blockchain account.
具体地,分别将所述用户区块链账号、所述用户基本信息中的用户标识和所述机构信息中的机构区块链账号写入预构建初始名片的多个账号字段中,其中,所述预构建初始名片中包含多个预先设定的账号字段,例如,id字段、issuer字段、owner字段、status字段以及content里面的info-hash字段、encrypt_key字段和info(密文)字段。Specifically, the user blockchain account number, the user ID in the user basic information, and the institutional blockchain account number in the institution information are written into the multiple account fields of the pre-built initial business card, wherein all the The above-mentioned pre-built initial business card contains a number of pre-set account fields, for example, the id field, the issuer field, the owner field, the status field, and the info-hash field, encrypt_key field and info (cipher text) field in the content.
例如,将所述用户区块链账号写入owner字段,将机构区块链账号写入issuer字段,将所述用户基本信息中的用户标识即员工工号写入id字段,将status字段设置为激活。For example, write the user's blockchain account into the owner field, write the institution's blockchain account into the issuer field, write the user ID in the basic user information, that is, the employee ID, into the id field, and set the status field to activation.
S3、基于预设的加密算法生成加密密钥和所述加密密钥对应的解密密钥,利用所述加密密钥对所述用户基本信息中的个人信息进行加密,得到加密信息。S3. Generate an encryption key and a decryption key corresponding to the encryption key based on a preset encryption algorithm, and encrypt the personal information in the basic user information by using the encryption key to obtain encrypted information.
本发明实施例中,基于预设的加密算法生成加密密钥和所述加密密钥对应的解密密钥,并利用所述加密密钥对所述用户基本信息中的个人信息进行加密,进一步保证所述用户基本信息存储的安全性。所述加密算法一般可以划分为对称加密算法和非对称加密算法,其中,所述对称加密算法是指加密和解密都使用同一个密钥,例如DES加密算法或者AES加密算法。所述非对称加密算法需要公开密钥和私有密钥等两个密钥,所述公开密钥与所述私有密钥是一对,如果用所述公开密钥对数据进行加密,只有用对应的所述私有密钥才能解密。所述非对称加密算法包括但不限于RSA算法、D-H算法、国密SM2算法。In this embodiment of the present invention, an encryption key and a decryption key corresponding to the encryption key are generated based on a preset encryption algorithm, and the encryption key is used to encrypt the personal information in the basic user information to further ensure The security of the user's basic information storage. The encryption algorithm can generally be divided into a symmetric encryption algorithm and an asymmetric encryption algorithm, wherein the symmetric encryption algorithm means that both encryption and decryption use the same key, such as the DES encryption algorithm or the AES encryption algorithm. The asymmetric encryption algorithm requires two keys, such as a public key and a private key. The public key and the private key are a pair. If the public key is used to encrypt data, only the corresponding key is used. of the private key to decrypt. The asymmetric encryption algorithm includes but is not limited to RSA algorithm, D-H algorithm, and national secret SM2 algorithm.
在本发明一个实施例中,所述基于预设的加密算法生成加密密钥和所述加密密钥对应的解密密钥,包括:In an embodiment of the present invention, generating an encryption key and a decryption key corresponding to the encryption key based on a preset encryption algorithm includes:
获取预设的生成元、循环群及所述循环群对应的阶数;obtaining a preset generator, a cyclic group, and the order corresponding to the cyclic group;
基于所述循环群阶数构建循环区间,并在所述循环区间中任意选择一个随机数;Constructing a cyclic interval based on the order of the cyclic group, and arbitrarily selecting a random number in the cyclic interval;
根据预设的离散公式计算所述生成元对应的离散数;Calculate the discrete number corresponding to the generator according to a preset discrete formula;
根据所述离散数、所述生成元、所述随机数和所述阶数构建得到加密密钥,令所述随机数为所述解密密钥。The encryption key is constructed and obtained according to the discrete number, the generator, the random number and the order, and the random number is the decryption key.
详细地,在本发明实施例中,采用的所述加密算法为ElGamal加密算法,获取预设的生成元g及q阶循环群G,基于所述循环群阶数q构建循环区间{1,……,q-1},从所述循环区间中随机选择一个x作为随机数,通过所述离散公式h=gx计算所述生成元对应的离散数,并令所述离散数h、所述生成元g、所述随机数x和所述阶数q构建得到加密密钥(h,g,x,q),令所述随机数x为所述解密密钥。In detail, in the embodiment of the present invention, the encryption algorithm adopted is the ElGamal encryption algorithm, a preset generator g and a q-order cyclic group G are obtained, and a cyclic interval {1, . . . is constructed based on the cyclic group order q ...,q-1}, randomly select an x from the cycle interval as a random number, calculate the discrete number corresponding to the generator through the discrete formula h=g x , and set the discrete number h, the The generator g, the random number x and the order q are constructed to obtain an encryption key (h, g, x, q), and the random number x is the decryption key.
在本发明另一个实施例中,所述基于预设的加密算法生成加密密钥和所述加密密钥对应的解密密钥,包括:In another embodiment of the present invention, generating an encryption key based on a preset encryption algorithm and a decryption key corresponding to the encryption key includes:
随机获取两个不同的素数;Get two different prime numbers at random;
分别对所述素数进行非对称计算处理,得到加密密钥和解密密钥。Perform asymmetric calculation processing on the prime numbers respectively to obtain an encryption key and a decryption key.
具体地,所述分别对所述素数进行非对称计算处理,得到加密密钥和解密密钥,包括:Specifically, performing asymmetric calculation processing on the prime numbers to obtain an encryption key and a decryption key, including:
对随机获取的两个不同的素数p和q,计算乘积n=pq, For two different prime numbers p and q obtained randomly, calculate the product n=pq,
选取一个满足的整数e,将所述整数e作为加密密钥;choose one that satisfies the integer e of , using the integer e as the encryption key;
选取一个满足的整数d,将所述整数d作为解密密钥。choose one that satisfies The integer d is used as the decryption key.
详细地,本发明实施例中采用的所述加密算法为RSA算法。In detail, the encryption algorithm adopted in the embodiment of the present invention is the RSA algorithm.
其中,只有利用所述对应的解密密钥才能对所述加密后的信息进行解密,所述解密密钥的存在是保证只有在获取解密密钥才能对数据进行解密,而未获取所述解密密钥则无法进行查看和解密。The encrypted information can only be decrypted by using the corresponding decryption key, and the existence of the decryption key is to ensure that the data can be decrypted only when the decryption key is obtained, and the decryption key is not obtained. The key cannot be viewed and decrypted.
详细地,利用所述加密密钥对所述用户基本信息中的个人信息进行加密,得到加密信息。其中,所述用户基本信息中的个人信息为员工的姓名、职位和邮箱等。Specifically, the personal information in the basic user information is encrypted by using the encryption key to obtain encrypted information. Wherein, the personal information in the basic user information is the employee's name, position, email address, and the like.
S4、基于预设的哈希算法计算所述个人信息的哈希值,并将所述哈希值、所述加密密钥和所述加密信息写入所述初始名片中的内容字段中。S4. Calculate the hash value of the personal information based on a preset hash algorithm, and write the hash value, the encryption key and the encryption information into the content field in the initial business card.
本发明实施例中,所述哈希算法可以将一个数据转换为一个标志,这个标志和转换之前的数据中的每一个字节都有十分紧密的关系。所述哈希算法包括MD4(MessageDigest,消息摘要算法4)算法、哈希函数(Message Digest,消息摘要算法5)算法和SHA-1(Secure Hash Algorithm 1,安全散列算法1)算法,其中,在本方案中,可以使用哈希函数算法计算所述个人信息的哈希值。所述哈希函数算法,一种被广泛使用的密码散列函数,可以产生出一个128位的散列值,用于确保信息传输完整一致。In this embodiment of the present invention, the hash algorithm can convert a data into a flag, and the flag has a very close relationship with each byte in the data before conversion. The hash algorithm includes MD4 (MessageDigest, Message Digest Algorithm 4) algorithm, Hash Function (Message Digest, Message Digest Algorithm 5) algorithm and SHA-1 (Secure Hash Algorithm 1, Secure Hash Algorithm 1) algorithm, wherein, In this solution, a hash function algorithm can be used to calculate the hash value of the personal information. The hash function algorithm, a widely used cryptographic hash function, can generate a 128-bit hash value to ensure complete and consistent information transmission.
具体地,所述基于预设的哈希算法计算所述个人信息的哈希值,包括:Specifically, calculating the hash value of the personal information based on a preset hash algorithm includes:
判断所述个人信息的大小是否满足预设的填充要求;Determine whether the size of the personal information meets the preset filling requirements;
若所述个人信息的大小满足所述填充要求,则在所述个人信息的末尾处添加第一位数的值,得到第一填充数据;If the size of the personal information meets the filling requirement, then add a value of the first digit at the end of the personal information to obtain the first filling data;
若所述个人信息的大小不满足所述填充要求,则对所述个人信息进行补位处理,得到第二填充数据;If the size of the personal information does not meet the filling requirement, perform a fill-in process on the personal information to obtain second filling data;
将所述第一填充数据或者第二填充数据输入至预设的哈希函数缓存器中进行数据处理,得到所述个人信息对应的哈希值。Inputting the first padding data or the second padding data into a preset hash function buffer for data processing to obtain a hash value corresponding to the personal information.
详细地,判断所述个人信息的大小是否满足预设的填充要求即判断所述个人信息的大小对512求模的结果是否为448。若所述个人信息的大小满足所述填充要求即所述个人信息的大小对512求模的结果为448,则在所述个人信息的末尾处添加64位的值,值的内容为所述个人信息的长度,若所述个人信息的大小不满足所述填充要求,则对所述个人信息进行补位处理,其中,所述补位处理是指对所述拼接字符串先填充一个1bit再继续填充多个0bit直至满足所述填充要求。Specifically, judging whether the size of the personal information satisfies the preset filling requirement is judging whether the result of modulo 512 by the size of the personal information is 448. If the size of the personal information meets the filling requirement, that is, the result of the size of the personal information modulo 512 is 448, then a 64-bit value is added at the end of the personal information, and the content of the value is the personal information. The length of the information. If the size of the personal information does not meet the filling requirements, the personal information will be complemented, wherein the complemented processing means that the spliced string is filled with one bit before continuing. Fill multiple 0bits until the filling requirements are met.
进一步地,所述初始名片中的内容字段中包含info-hash字段、encrypt_key字段和info(密文)字段,将所述加密密钥写入encrypt_key字段中,将所述哈希值写入info-hash字段中,将所述加密信息写入info(密文)字段中。Further, the content field in the initial business card includes an info-hash field, an encrypt_key field and an info (ciphertext) field, the encryption key is written into the encrypt_key field, and the hash value is written into the info- In the hash field, the encrypted information is written into the info (cipher text) field.
S5、将所述机构信息中的机构账号写入所述初始名片中的账号字段中,并利用所述机构账号对应的公钥对所述解密密钥进行加密,将加密后的第一密文写入所述账号字段对应的密文字段中。S5. Write the organization account in the organization information into the account field in the initial business card, and encrypt the decryption key with the public key corresponding to the organization account, and encrypt the encrypted first ciphertext Write into the ciphertext field corresponding to the account number field.
本发明实施例中,在所述初始名片中还包含一个holder_list部分,在holder_list中包含多个account字段及account字段对应的decrypt_key(密文)字段,将所述机构信息中的机构账号写入所述初始名片中的账号字段中的意思即将公司账号填写到holder_list部分中的account字段中,并利用所述公司账号对应的公钥对所述解密私钥进行加密,将加密后的第一密文写入包含公司账号的account字段对应的decrypt_key(密文)字段中。In this embodiment of the present invention, the initial business card further includes a holder_list part, the holder_list includes a plurality of account fields and a decrypt_key (ciphertext) field corresponding to the account field, and the organization account in the organization information is written into all the account fields. The meaning in the account field in the initial business card is that the company account number is filled in the account field in the holder_list part, and the decryption private key is encrypted with the public key corresponding to the company account, and the encrypted first ciphertext is encrypted. Write to the decrypt_key (ciphertext) field corresponding to the account field containing the company account.
S6、利用所述用户基本信息中的用户账号对应的公钥对所述解密密钥进行加密,将加密后的第二密文和所述用户账号写入字段中,得到用户名片。S6. Encrypt the decryption key by using the public key corresponding to the user account in the basic user information, and write the encrypted second ciphertext and the user account into a field to obtain a user card.
本发明实施例中,将所述用户基本信息中的用户账号写入所述初始名片中的字段中的意思即将员工账号填写到holder_list部分中的account字段中,并利用所述员工账号对应的公钥对所述解密私钥进行加密,将加密后的第二密文写入包含员工账号的account字段对应的decrypt_key(密文)字段中,得到用户名片。In the embodiment of the present invention, the meaning of writing the user account in the basic user information into the field in the initial business card means that the employee account is filled in the account field in the holder_list part, and the public account corresponding to the employee account is used. The decryption private key is encrypted with the key, and the encrypted second ciphertext is written into the decrypt_key (ciphertext) field corresponding to the account field containing the employee account to obtain the user card.
具体地,在得到用户名片之后,所述方法还包括:Specifically, after obtaining the user's business card, the method further includes:
获取对所述用户名片执行名片操作的指令,并对所述指令进行解析处理;obtaining an instruction for performing a business card operation on the user's business card, and performing parsing processing on the instruction;
当解析后的指令为分享名片时,则根据所述用户区块链账号对所述用户名片执行名片分享操作;或When the parsed instruction is to share a business card, perform a business card sharing operation on the user's business card according to the user's blockchain account; or
当解析后的指令为更新名片时,利用所述机构区块链账号对所述用户名片执行名片更新操作;或When the parsed instruction is to update the business card, use the institutional blockchain account to perform a business card update operation on the user's business card; or
当解析后的指令为销毁名片时,利用所述机构区块链账号对所述用户名片中的状态字段设置为销毁。When the parsed instruction is to destroy the business card, use the institutional blockchain account to set the status field in the user's business card to be destroyed.
进一步地,所述根据所述用户区块链账号对所述用户名片执行名片分享操作,包括:Further, performing a business card sharing operation on the user business card according to the user blockchain account number includes:
获取分享对象的账号,并基于所述区块链上的激活账号列表查询所述分享对象的账号对应的公钥;Obtain the account of the shared object, and query the public key corresponding to the account of the shared object based on the activated account list on the blockchain;
在所述用户名片中搜索所述用户区块链账号对应的加密密文,并利用所述用户区块链账号的私钥对所述加密密文进行解密,得到解密密文;Searching for the encrypted ciphertext corresponding to the user's blockchain account in the user business card, and decrypting the encrypted ciphertext by using the private key of the user's blockchain account to obtain the decrypted ciphertext;
将所述分享对象的账号写入所述用户名片的账号字段中,并利用所述分享对象的账号对应的公钥对所述解密密文进行加密,将加密后的解密密文存入所述账号字段对应的密文字段中,得到分享名片。Write the account of the shared object into the account field of the user card, and encrypt the decrypted ciphertext by using the public key corresponding to the account of the shared object, and store the encrypted decrypted ciphertext in the In the cipher text field corresponding to the account field, get the shared business card.
详细地,首先获得分享对象的账号并在所述激活账号列表中查找所述分享对象的账号,将其设为pubkeyX,在所述用户名片中搜索所述用户区块链账号对应的加密密文即在所述用户名片的holder_list部分中读取对应的加密密文,并利用存储用户区块链账号的owner字段的私钥对所述加密密文进行解密,将解密后的结果设为decryptX,将所述分享对象的账号填写到所述holder_list部分中的account字段中,利用pubkeyX对decryptX进行加密,并将加密后的密文填写到holder_list对应的decrypt_key字段中。In detail, first obtain the account of the shared object and search for the account of the shared object in the activated account list, set it as pubkeyX, and search for the encrypted ciphertext corresponding to the user's blockchain account in the user card. That is, the corresponding encrypted ciphertext is read in the holder_list part of the user card, and the encrypted ciphertext is decrypted by using the private key of the owner field of the user's blockchain account, and the decrypted result is set as decryptX, Fill in the account of the shared object into the account field in the holder_list part, encrypt decryptX with pubkeyX, and fill in the encrypted ciphertext into the decrypt_key field corresponding to the holder_list.
具体地,所述利用所述机构区块链账号对所述用户名片执行名片更新操作,包括:Specifically, using the institutional blockchain account to perform a business card update operation on the user business card includes:
对预获取的待更新信息进行哈希运算,得到标准更新信息,并将所述标准更新信息写入所述用户名片的哈希值字段中;Perform a hash operation on the pre-acquired information to be updated to obtain standard update information, and write the standard update information into the hash value field of the user card;
利用所述机构区块链账号读取所述用户名片中的加密密钥,并利用所述加密密钥对所述待更新信息进行加密,将加密后的待更新信息写入所述用户名片中的信息字段,得到更新后的名片。Use the institutional blockchain account to read the encryption key in the user card, use the encryption key to encrypt the information to be updated, and write the encrypted information to be updated into the user card information field to get the updated business card.
其中,由于所述用户名片上的信息可能是过时信息,例如手机号码、就职公司及职位这些都可能因为现实生活中有变动而过时,为了保证名片的准确性,需要对所述用户名片进行名片更新处理。通常会在接收到对所述用户名片进行名片更新的指令时,对所述用户名片进行更新处理。Among them, since the information on the user's business card may be outdated information, such as mobile phone number, employment company and position, these may be out of date due to changes in real life. Update processing. Usually, when an instruction to update the business card of the user is received, the business card of the user is updated.
详细地,有且仅有所述机构区块链账号即issuer账号可以对名片内容进行更新,即只有公司能更新员工的名片内容,员工不能自己更新自己的名片,Issuer账号对待更新信息做哈希运算,将进行哈希运算的结果写入content的info_hash字段中,Issuer账号读取content的encrypt_key字段,用来加密待更新信息,用encrypt_key加密待更新信息然后把加密后的待更新信息写入info字段。In detail, there is and only the institutional blockchain account, that is, the issuer account, can update the content of the business card, that is, only the company can update the content of the employee's business card, and the employee cannot update his own business card, and the Issuer account treats the update information as a hash Operation, write the result of the hash operation into the info_hash field of the content, the Issuer account reads the encrypt_key field of the content to encrypt the information to be updated, encrypt the information to be updated with encrypt_key, and then write the encrypted information to be updated into info field.
进一步地,当解析后的指令为销毁名片时,利用所述机构区块链账号对所述用户名片中的status字段设置为销毁。其中,有且仅有issuer账号可以对名片进行销毁,即只有公司能销毁员工的名片,员工不能销毁自己的名片。Further, when the parsed instruction is to destroy the business card, use the institutional blockchain account to set the status field in the user's business card to be destroyed. Among them, there are and only issuer accounts that can destroy business cards, that is, only the company can destroy employees' business cards, and employees cannot destroy their own business cards.
本发明实施例通过基于预设的加密算法生成加密密钥和所述加密密钥对应的解密密钥,利用所述加密密钥对所述用户基本信息中的个人信息进行加密,得到加密信息,用加密密钥来加密个人信息并保存数据上链,保证关键数据的安全,利用所述机构账号对应的公钥对所述解密密钥进行加密,将加密后的密文写入所述账号字段对应的密文字段中,保证只有机构账号对应的持有人可以可以查看到解密密钥,从而可以解密出明文。利用所述用户基本信息中的用户账号对应的公钥对所述解密密钥进行加密,将加密后的第二密文和所述用户账号写入字段中,得到用户名片。因此本发明提出的基于区块链的智能合约名片方法可以实现解决名片生成的安全性不够高的问题。In the embodiment of the present invention, an encryption key and a decryption key corresponding to the encryption key are generated based on a preset encryption algorithm, and the personal information in the basic user information is encrypted by using the encryption key to obtain encrypted information, Encrypt personal information with an encryption key and save the data on the chain to ensure the security of key data, encrypt the decryption key with the public key corresponding to the institution account, and write the encrypted ciphertext into the account field In the corresponding ciphertext field, it is guaranteed that only the holder corresponding to the institutional account can view the decryption key, so that the plaintext can be decrypted. The decryption key is encrypted by using the public key corresponding to the user account in the basic user information, and the encrypted second ciphertext and the user account are written into a field to obtain a user card. Therefore, the blockchain-based smart contract business card method proposed by the present invention can solve the problem that the security of business card generation is not high enough.
本发明实施例通过基于预设的加密算法生成加密密钥和所述加密密钥对应的解密密钥,利用所述加密密钥对所述用户基本信息中的个人信息进行加密,得到加密信息,用加密密钥来加密个人信息并保存数据上链,保证关键数据的安全,利用所述机构账号对应的公钥对所述解密密钥进行加密,将加密后的密文写入所述账号字段对应的密文字段中,保证只有机构账号对应的持有人可以可以查看到解密密钥,从而可以解密出明文。利用所述用户基本信息中的用户账号对应的公钥对所述解密密钥进行加密,将加密后的第二密文和所述用户账号写入字段中,得到用户名片。因此本发明提出的基于区块链的智能合约名片方法可以实现解决名片生成的安全性不够高的问题。In the embodiment of the present invention, an encryption key and a decryption key corresponding to the encryption key are generated based on a preset encryption algorithm, and the personal information in the basic user information is encrypted by using the encryption key to obtain encrypted information, Encrypt personal information with an encryption key and save the data on the chain to ensure the security of key data, encrypt the decryption key with the public key corresponding to the institution account, and write the encrypted ciphertext into the account field In the corresponding ciphertext field, it is guaranteed that only the holder corresponding to the institutional account can view the decryption key, so that the plaintext can be decrypted. The decryption key is encrypted by using the public key corresponding to the user account in the basic user information, and the encrypted second ciphertext and the user account are written into a field to obtain a user card. Therefore, the blockchain-based smart contract business card method proposed by the present invention can solve the problem that the security of business card generation is not high enough.
如图2所示,是本发明一实施例提供的基于区块链的智能合约名片装置的功能模块图。As shown in FIG. 2 , it is a functional block diagram of a smart contract business card device based on blockchain provided by an embodiment of the present invention.
本发明所述基于区块链的智能合约名片装置100可以安装于电子设备中。根据实现的功能,所述基于区块链的智能合约名片装置100可以包括账号激活模块101、字段填充模块102、密钥生成模块103及名片创建模块104。本发明所述模块也可以称之为单元,是指一种能够被电子设备处理器所执行,并且能够完成固定功能的一系列计算机程序段,其存储在电子设备的存储器中。The blockchain-based smart contract
在本实施例中,关于各模块/单元的功能如下:In this embodiment, the functions of each module/unit are as follows:
所述账号激活模块101,用于获取用户基本信息及用户区块链账号,并对所述用户区块链账号进行激活处理;The
所述字段填充模块102,用于当所述用户区块链账号经过激活处理后,索引出所述用户区块链账号所属机构的机构信息,分别将所述用户区块链账号、所述用户基本信息中的用户标识和所述机构信息中的机构区块链账号写入预构建初始名片的多个账号字段中;The
所述密钥生成模块103,用于基于预设的加密算法生成加密密钥和所述加密密钥对应的解密密钥,利用所述加密密钥对所述用户基本信息中的个人信息进行加密,得到加密信息;The
所述名片创建模块104,用于基于预设的哈希算法计算所述个人信息的哈希值,并将所述哈希值、所述加密密钥和所述加密信息写入所述初始名片中的内容字段中,将所述机构信息中的机构账号写入所述初始名片中的账号字段中,并利用所述机构账号对应的公钥对所述解密密钥进行加密,将加密后的第一密文写入所述账号字段对应的密文字段中,利用所述用户基本信息中的用户账号对应的公钥对所述解密密钥进行加密,将加密后的第二密文和所述用户账号写入字段中,得到用户名片。The business
详细地,所述基于区块链的智能合约名片装置100各模块的具体实施方式如下:In detail, the specific implementation of each module of the blockchain-based smart contract
步骤一、获取用户基本信息及用户区块链账号,并对所述用户区块链账号进行激活处理。Step 1: Obtain the basic information of the user and the user's blockchain account, and activate the user's blockchain account.
本发明实施例中,所述用户基本信息可以为某公司中的多个员工的基本信息,例如员工姓名、职位、邮箱、员工工号及联系方式等。可以从第三方数据库中获取用户基本信息,其中,所述第三方数据库为存储大量用户相关信息的数据库,实现对数据的集中控制和管理。In this embodiment of the present invention, the basic user information may be basic information of multiple employees in a company, such as employee names, positions, email addresses, employee IDs, and contact information. User basic information can be acquired from a third-party database, wherein the third-party database is a database that stores a large amount of user-related information, so as to realize centralized control and management of data.
具体地,所述对所述用户区块链账号进行激活处理,包括:Specifically, the activation process for the user's blockchain account includes:
根据所述用户区块链账号查询出对应的用户,并获取所述用户对应的公钥;Query the corresponding user according to the user blockchain account, and obtain the public key corresponding to the user;
将所述公钥和所述用户区块链账号写入预设区块链上的激活账号列表中。Write the public key and the user blockchain account into the activated account list on the preset blockchain.
详细地,用户需要激活自己的区块链账号,激活处理的过程就是将用户自己的区块链账号和对应的公钥写入所述区块链上的激活账号列表中,所述激活账号列表中包含多个account及公钥和状态。其中,所述区块链包括第一区块链节点、第二区块链节点、第三区块链节点、第N-1区块链节点、第N区块链节点,其中,N为正整数,N的值可以为预设的。每个区块链节点之间相互连接,共同形成一个区跨链网,各个区块链节点之间可进行信息相互传输,同步同时更新。In detail, the user needs to activate his own blockchain account, and the activation process is to write the user's own blockchain account and the corresponding public key into the activated account list on the blockchain, and the activated account list Contains multiple accounts and public keys and states. The blockchain includes a first blockchain node, a second blockchain node, a third blockchain node, an N-1th blockchain node, and an Nth blockchain node, where N is a positive Integer, the value of N can be preset. Each blockchain node is connected to each other to form a cross-chain network together, and each blockchain node can transmit information to each other and update at the same time.
步骤二、当所述用户区块链账号经过激活处理后,索引出所述用户区块链账号所属机构的机构信息,分别将所述用户区块链账号、所述用户基本信息中的用户标识和所述机构信息中的机构区块链账号写入预构建初始名片的多个账号字段中。Step 2: After the user's blockchain account is activated, index the organization information of the institution to which the user's blockchain account belongs, and respectively index the user's blockchain account and the user ID in the user's basic information. And the institutional blockchain account number in the institutional information is written into multiple account fields of the pre-built initial business card.
本发明实施例中,当所述用户区块链账号经过激活处理后,索引出所述用户区块链账号所属机构的机构信息,其中,所述用户区块链账号即员工的区块链账号,所述用户区块链账号所属机构的机构信息即员工所在公司的公司信息,公司信息包括但不限于机构区块链账号。In the embodiment of the present invention, after the user's blockchain account is activated, the organization information of the institution to which the user's blockchain account belongs is indexed, wherein the user's blockchain account is the employee's blockchain account , the institutional information of the institution to which the user's blockchain account belongs is the company information of the company where the employee is located, and the company information includes but is not limited to the institutional blockchain account.
具体地,分别将所述用户区块链账号、所述用户基本信息中的用户标识和所述机构信息中的机构区块链账号写入预构建初始名片的多个账号字段中,其中,所述预构建初始名片中包含多个预先设定的账号字段,例如,id字段、issuer字段、owner字段、status字段以及content里面的info-hash字段、encrypt_key字段和info(密文)字段。Specifically, the user blockchain account number, the user ID in the user basic information, and the institutional blockchain account number in the institution information are written into the multiple account fields of the pre-built initial business card, wherein all the The above-mentioned pre-built initial business card contains a number of pre-set account fields, for example, the id field, the issuer field, the owner field, the status field, and the info-hash field, encrypt_key field and info (cipher text) field in the content.
例如,将所述用户区块链账号写入owner字段,将机构区块链账号写入issuer字段,将所述用户基本信息中的用户标识即员工工号写入id字段,将status字段设置为激活。For example, write the user's blockchain account into the owner field, write the institution's blockchain account into the issuer field, write the user ID in the basic user information, that is, the employee ID, into the id field, and set the status field to activation.
步骤三、基于预设的加密算法生成加密密钥和所述加密密钥对应的解密密钥,利用所述加密密钥对所述用户基本信息中的个人信息进行加密,得到加密信息。Step 3: Generate an encryption key and a decryption key corresponding to the encryption key based on a preset encryption algorithm, and use the encryption key to encrypt the personal information in the basic user information to obtain encrypted information.
本发明实施例中,基于预设的加密算法生成加密密钥和所述加密密钥对应的解密密钥,并利用所述加密密钥对所述用户基本信息中的个人信息进行加密,进一步保证所述用户基本信息存储的安全性。所述加密算法一般可以划分为对称加密算法和非对称加密算法,其中,所述对称加密算法是指加密和解密都使用同一个密钥,例如DES加密算法或者AES加密算法。所述非对称加密算法需要公开密钥和私有密钥等两个密钥,所述公开密钥与所述私有密钥是一对,如果用所述公开密钥对数据进行加密,只有用对应的所述私有密钥才能解密。所述非对称加密算法包括但不限于RSA算法、D-H算法、国密SM2算法。In this embodiment of the present invention, an encryption key and a decryption key corresponding to the encryption key are generated based on a preset encryption algorithm, and the encryption key is used to encrypt the personal information in the basic user information to further ensure The security of the user's basic information storage. The encryption algorithm can generally be divided into a symmetric encryption algorithm and an asymmetric encryption algorithm, wherein the symmetric encryption algorithm means that both encryption and decryption use the same key, such as the DES encryption algorithm or the AES encryption algorithm. The asymmetric encryption algorithm requires two keys, such as a public key and a private key. The public key and the private key are a pair. If the public key is used to encrypt data, only the corresponding key is used. of the private key to decrypt. The asymmetric encryption algorithm includes but is not limited to RSA algorithm, D-H algorithm, and national secret SM2 algorithm.
在本发明一个实施例中,所述基于预设的加密算法生成加密密钥和所述加密密钥对应的解密密钥,包括:In an embodiment of the present invention, generating an encryption key and a decryption key corresponding to the encryption key based on a preset encryption algorithm includes:
获取预设的生成元、循环群及所述循环群对应的阶数;obtaining a preset generator, a cyclic group, and the order corresponding to the cyclic group;
基于所述循环群阶数构建循环区间,并在所述循环区间中任意选择一个随机数;Constructing a cyclic interval based on the order of the cyclic group, and arbitrarily selecting a random number in the cyclic interval;
根据预设的离散公式计算所述生成元对应的离散数;Calculate the discrete number corresponding to the generator according to a preset discrete formula;
根据所述离散数、所述生成元、所述随机数和所述阶数构建得到加密密钥,令所述随机数为所述解密密钥。The encryption key is constructed and obtained according to the discrete number, the generator, the random number and the order, and the random number is the decryption key.
详细地,在本发明实施例中,采用的所述加密算法为ElGamal加密算法,获取预设的生成元g及q阶循环群G,基于所述循环群阶数q构建循环区间{1,……,q-1},从所述循环区间中随机选择一个x作为随机数,通过所述离散公式h=gx计算所述生成元对应的离散数,并令所述离散数h、所述生成元g、所述随机数x和所述阶数q构建得到加密密钥(h,g,x,q),令所述随机数x为所述解密密钥。In detail, in the embodiment of the present invention, the encryption algorithm adopted is the ElGamal encryption algorithm, a preset generator g and a q-order cyclic group G are obtained, and a cyclic interval {1, . . . is constructed based on the cyclic group order q ...,q-1}, randomly select an x from the cycle interval as a random number, calculate the discrete number corresponding to the generator through the discrete formula h=g x , and set the discrete number h, the The generator g, the random number x and the order q are constructed to obtain an encryption key (h, g, x, q), and the random number x is the decryption key.
在本发明另一个实施例中,所述基于预设的加密算法生成加密密钥和所述加密密钥对应的解密密钥,包括:In another embodiment of the present invention, generating an encryption key based on a preset encryption algorithm and a decryption key corresponding to the encryption key includes:
随机获取两个不同的素数;Get two different prime numbers at random;
分别对所述素数进行非对称计算处理,得到加密密钥和解密密钥。Perform asymmetric calculation processing on the prime numbers respectively to obtain an encryption key and a decryption key.
具体地,所述分别对所述素数进行非对称计算处理,得到加密密钥和解密密钥,包括:Specifically, performing asymmetric calculation processing on the prime numbers to obtain an encryption key and a decryption key, including:
对随机获取的两个不同的素数p和q,计算乘积n=pq, For two different prime numbers p and q obtained randomly, calculate the product n=pq,
选取一个满足的整数e,将所述整数e作为加密密钥;choose one that satisfies The integer e of , and the integer e is used as the encryption key;
选取一个满足的整数d,将所述整数d作为解密密钥。choose one that satisfies The integer d is used as the decryption key.
详细地,本发明实施例中采用的所述加密算法为RSA算法。In detail, the encryption algorithm adopted in the embodiment of the present invention is the RSA algorithm.
其中,只有利用所述对应的解密密钥才能对所述加密后的信息进行解密,所述解密密钥的存在是保证只有在获取解密密钥才能对数据进行解密,而未获取所述解密密钥则无法进行查看和解密。The encrypted information can only be decrypted by using the corresponding decryption key, and the existence of the decryption key is to ensure that the data can be decrypted only when the decryption key is obtained, and the decryption key is not obtained. The key cannot be viewed and decrypted.
详细地,利用所述加密密钥对所述用户基本信息中的个人信息进行加密,得到加密信息。其中,所述用户基本信息中的个人信息为员工的姓名、职位和邮箱等。Specifically, the personal information in the basic user information is encrypted by using the encryption key to obtain encrypted information. Wherein, the personal information in the basic user information is the employee's name, position, email address, and the like.
步骤四、基于预设的哈希算法计算所述个人信息的哈希值,并将所述哈希值、所述加密密钥和所述加密信息写入所述初始名片中的内容字段中。Step 4: Calculate the hash value of the personal information based on a preset hash algorithm, and write the hash value, the encryption key and the encryption information into the content field in the initial business card.
本发明实施例中,所述哈希算法可以将一个数据转换为一个标志,这个标志和转换之前的数据中的每一个字节都有十分紧密的关系。所述哈希算法包括MD4(MessageDigest,消息摘要算法4)算法、哈希函数(Message Digest,消息摘要算法5)算法和SHA-1(Secure Hash Algorithm 1,安全散列算法1)算法,其中,在本方案中,可以使用哈希函数算法计算所述个人信息的哈希值。所述哈希函数算法,一种被广泛使用的密码散列函数,可以产生出一个128位的散列值,用于确保信息传输完整一致。In this embodiment of the present invention, the hash algorithm can convert a data into a flag, and the flag has a very close relationship with each byte in the data before conversion. The hash algorithm includes MD4 (MessageDigest, Message Digest Algorithm 4) algorithm, Hash Function (Message Digest, Message Digest Algorithm 5) algorithm and SHA-1 (Secure Hash Algorithm 1, Secure Hash Algorithm 1) algorithm, wherein, In this solution, a hash function algorithm can be used to calculate the hash value of the personal information. The hash function algorithm, a widely used cryptographic hash function, can generate a 128-bit hash value to ensure complete and consistent information transmission.
具体地,所述基于预设的哈希算法计算所述个人信息的哈希值,包括:Specifically, calculating the hash value of the personal information based on a preset hash algorithm includes:
判断所述个人信息的大小是否满足预设的填充要求;Determine whether the size of the personal information meets the preset filling requirements;
若所述个人信息的大小满足所述填充要求,则在所述个人信息的末尾处添加第一位数的值,得到第一填充数据;If the size of the personal information meets the filling requirement, then add a value of the first digit at the end of the personal information to obtain the first filling data;
若所述个人信息的大小不满足所述填充要求,则对所述个人信息进行补位处理,得到第二填充数据;If the size of the personal information does not meet the filling requirement, perform a fill-in process on the personal information to obtain second filling data;
将所述第一填充数据或者第二填充数据输入至预设的哈希函数缓存器中进行数据处理,得到所述个人信息对应的哈希值。Inputting the first padding data or the second padding data into a preset hash function buffer for data processing to obtain a hash value corresponding to the personal information.
详细地,判断所述个人信息的大小是否满足预设的填充要求即判断所述个人信息的大小对512求模的结果是否为448。若所述个人信息的大小满足所述填充要求即所述个人信息的大小对512求模的结果为448,则在所述个人信息的末尾处添加64位的值,值的内容为所述个人信息的长度,若所述个人信息的大小不满足所述填充要求,则对所述个人信息进行补位处理,其中,所述补位处理是指对所述拼接字符串先填充一个1bit再继续填充多个0bit直至满足所述填充要求。Specifically, judging whether the size of the personal information satisfies the preset filling requirement is judging whether the result of modulo 512 by the size of the personal information is 448. If the size of the personal information meets the filling requirement, that is, the result of the size of the personal information modulo 512 is 448, then a 64-bit value is added at the end of the personal information, and the content of the value is the personal information. The length of the information. If the size of the personal information does not meet the filling requirements, the personal information will be complemented, wherein the complemented processing means that the spliced string is filled with one bit before continuing. Fill multiple 0bits until the filling requirements are met.
进一步地,所述初始名片中的内容字段中包含info-hash字段、encrypt_key字段和info(密文)字段,将所述加密密钥写入encrypt_key字段中,将所述哈希值写入info-hash字段中,将所述加密信息写入info(密文)字段中。Further, the content field in the initial business card includes an info-hash field, an encrypt_key field and an info (ciphertext) field, the encryption key is written into the encrypt_key field, and the hash value is written into the info- In the hash field, the encrypted information is written into the info (cipher text) field.
步骤五、将所述机构信息中的机构账号写入所述初始名片中的账号字段中,并利用所述机构账号对应的公钥对所述解密密钥进行加密,将加密后的第一密文写入所述账号字段对应的密文字段中。Step 5: Write the institution account number in the institution information into the account number field in the initial business card, and encrypt the decryption key with the public key corresponding to the institution account number, and encrypt the encrypted first password. The text is written into the cipher text field corresponding to the account number field.
本发明实施例中,在所述初始名片中还包含一个holder_list部分,在holder_list中包含多个account字段及account字段对应的decrypt_key(密文)字段,将所述机构信息中的机构账号写入所述初始名片中的账号字段中的意思即将公司账号填写到holder_list部分中的account字段中,并利用所述公司账号对应的公钥对所述解密私钥进行加密,将加密后的第一密文写入包含公司账号的account字段对应的decrypt_key(密文)字段中。In this embodiment of the present invention, the initial business card further includes a holder_list part, the holder_list includes a plurality of account fields and a decrypt_key (ciphertext) field corresponding to the account field, and the organization account in the organization information is written into all the account fields. The meaning in the account field in the initial business card is that the company account number is filled in the account field in the holder_list part, and the decryption private key is encrypted with the public key corresponding to the company account, and the encrypted first ciphertext is encrypted. Write to the decrypt_key (ciphertext) field corresponding to the account field containing the company account.
步骤六、利用所述用户基本信息中的用户账号对应的公钥对所述解密密钥进行加密,将加密后的第二密文和所述用户账号写入字段中,得到用户名片。Step 6: Encrypt the decryption key by using the public key corresponding to the user account in the basic user information, and write the encrypted second ciphertext and the user account into a field to obtain a user card.
本发明实施例中,将所述用户基本信息中的用户账号写入所述初始名片中的字段中的意思即将员工账号填写到holder_list部分中的account字段中,并利用所述员工账号对应的公钥对所述解密私钥进行加密,将加密后的第二密文写入包含员工账号的account字段对应的decrypt_key(密文)字段中,得到用户名片。In the embodiment of the present invention, the meaning of writing the user account in the basic user information into the field in the initial business card means that the employee account is filled in the account field in the holder_list part, and the public account corresponding to the employee account is used. The decryption private key is encrypted with the key, and the encrypted second ciphertext is written into the decrypt_key (ciphertext) field corresponding to the account field containing the employee account to obtain the user card.
具体地,在得到用户名片之后,所述方法还包括:Specifically, after obtaining the user's business card, the method further includes:
获取对所述用户名片执行名片操作的指令,并对所述指令进行解析处理;obtaining an instruction for performing a business card operation on the user's business card, and performing parsing processing on the instruction;
当解析后的指令为分享名片时,则根据所述用户区块链账号对所述用户名片执行名片分享操作;或When the parsed instruction is to share a business card, perform a business card sharing operation on the user's business card according to the user's blockchain account; or
当解析后的指令为更新名片时,利用所述机构区块链账号对所述用户名片执行名片更新操作;或When the parsed instruction is to update the business card, use the institutional blockchain account to perform a business card update operation on the user's business card; or
当解析后的指令为销毁名片时,利用所述机构区块链账号对所述用户名片中的状态字段设置为销毁。When the parsed instruction is to destroy the business card, use the institutional blockchain account to set the status field in the user's business card to be destroyed.
进一步地,所述根据所述用户区块链账号对所述用户名片执行名片分享操作,包括:Further, performing a business card sharing operation on the user business card according to the user blockchain account number includes:
获取分享对象的账号,并基于所述区块链上的激活账号列表查询所述分享对象的账号对应的公钥;Obtain the account of the shared object, and query the public key corresponding to the account of the shared object based on the activated account list on the blockchain;
在所述用户名片中搜索所述用户区块链账号对应的加密密文,并利用所述用户区块链账号的私钥对所述加密密文进行解密,得到解密密文;Searching for the encrypted ciphertext corresponding to the user's blockchain account in the user business card, and decrypting the encrypted ciphertext by using the private key of the user's blockchain account to obtain the decrypted ciphertext;
将所述分享对象的账号写入所述用户名片的账号字段中,并利用所述分享对象的账号对应的公钥对所述解密密文进行加密,将加密后的解密密文存入所述账号字段对应的密文字段中,得到分享名片。Write the account of the shared object into the account field of the user card, and encrypt the decrypted ciphertext by using the public key corresponding to the account of the shared object, and store the encrypted decrypted ciphertext in the In the cipher text field corresponding to the account field, get the shared business card.
详细地,首先获得分享对象的账号并在所述激活账号列表中查找所述分享对象的账号,将其设为pubkeyX,在所述用户名片中搜索所述用户区块链账号对应的加密密文即在所述用户名片的holder_list部分中读取对应的加密密文,并利用存储用户区块链账号的owner字段的私钥对所述加密密文进行解密,将解密后的结果设为decryptX,将所述分享对象的账号填写到所述holder_list部分中的account字段中,利用pubkeyX对decryptX进行加密,并将加密后的密文填写到holder_list对应的decrypt_key字段中。In detail, first obtain the account of the shared object and search for the account of the shared object in the activated account list, set it as pubkeyX, and search for the encrypted ciphertext corresponding to the user's blockchain account in the user card. That is, the corresponding encrypted ciphertext is read in the holder_list part of the user card, and the encrypted ciphertext is decrypted by using the private key of the owner field of the user's blockchain account, and the decrypted result is set as decryptX, Fill in the account of the shared object into the account field in the holder_list part, encrypt decryptX with pubkeyX, and fill in the encrypted ciphertext into the decrypt_key field corresponding to the holder_list.
具体地,所述利用所述机构区块链账号对所述用户名片执行名片更新操作,包括:Specifically, using the institutional blockchain account to perform a business card update operation on the user business card includes:
对预获取的待更新信息进行哈希运算,得到标准更新信息,并将所述标准更新信息写入所述用户名片的哈希值字段中;Perform a hash operation on the pre-acquired information to be updated to obtain standard update information, and write the standard update information into the hash value field of the user card;
利用所述机构区块链账号读取所述用户名片中的加密密钥,并利用所述加密密钥对所述待更新信息进行加密,将加密后的待更新信息写入所述用户名片中的信息字段,得到更新后的名片。Use the institutional blockchain account to read the encryption key in the user card, use the encryption key to encrypt the information to be updated, and write the encrypted information to be updated into the user card information field to get the updated business card.
其中,由于所述用户名片上的信息可能是过时信息,例如手机号码、就职公司及职位这些都可能因为现实生活中有变动而过时,为了保证名片的准确性,需要对所述用户名片进行名片更新处理。通常会在接收到对所述用户名片进行名片更新的指令时,对所述用户名片进行更新处理。Among them, since the information on the user's business card may be outdated information, such as mobile phone number, employment company and position, these may be out of date due to changes in real life. Update processing. Usually, when an instruction to update the business card of the user is received, the business card of the user is updated.
详细地,有且仅有所述机构区块链账号即issuer账号可以对名片内容进行更新,即只有公司能更新员工的名片内容,员工不能自己更新自己的名片,Issuer账号对待更新信息做哈希运算,将进行哈希运算的结果写入content的info_hash字段中,Issuer账号读取content的encrypt_key字段,用来加密待更新信息,用encrypt_key加密待更新信息然后把加密后的待更新信息写入info字段。In detail, there is and only the institutional blockchain account, that is, the issuer account, can update the content of the business card, that is, only the company can update the content of the employee's business card, and the employee cannot update his own business card, and the Issuer account treats the update information as a hash Operation, write the result of the hash operation into the info_hash field of the content, the Issuer account reads the encrypt_key field of the content to encrypt the information to be updated, encrypt the information to be updated with encrypt_key, and then write the encrypted information to be updated into info field.
进一步地,当解析后的指令为销毁名片时,利用所述机构区块链账号对所述用户名片中的status字段设置为销毁。其中,有且仅有issuer账号可以对名片进行销毁,即只有公司能销毁员工的名片,员工不能销毁自己的名片。Further, when the parsed instruction is to destroy the business card, use the institutional blockchain account to set the status field in the user's business card to be destroyed. Among them, there are and only issuer accounts that can destroy business cards, that is, only the company can destroy employees' business cards, and employees cannot destroy their own business cards.
本发明实施例通过基于预设的加密算法生成加密密钥和所述加密密钥对应的解密密钥,利用所述加密密钥对所述用户基本信息中的个人信息进行加密,得到加密信息,用加密密钥来加密个人信息并保存数据上链,保证关键数据的安全,利用所述机构账号对应的公钥对所述解密密钥进行加密,将加密后的密文写入所述账号字段对应的密文字段中,保证只有机构账号对应的持有人可以可以查看到解密密钥,从而可以解密出明文。利用所述用户基本信息中的用户账号对应的公钥对所述解密密钥进行加密,将加密后的第二密文和所述用户账号写入字段中,得到用户名片。因此本发明提出的基于区块链的智能合约名片装置可以实现解决名片生成的安全性不够高的问题。In the embodiment of the present invention, an encryption key and a decryption key corresponding to the encryption key are generated based on a preset encryption algorithm, and the personal information in the basic user information is encrypted by using the encryption key to obtain encrypted information, Encrypt personal information with an encryption key and save the data on the chain to ensure the security of key data, encrypt the decryption key with the public key corresponding to the institution account, and write the encrypted ciphertext into the account field In the corresponding ciphertext field, it is guaranteed that only the holder corresponding to the institutional account can view the decryption key, so that the plaintext can be decrypted. The decryption key is encrypted by using the public key corresponding to the user account in the basic user information, and the encrypted second ciphertext and the user account are written into a field to obtain a user card. Therefore, the smart contract business card device based on the blockchain proposed by the present invention can solve the problem that the security of business card generation is not high enough.
如图3所示,是本发明一实施例提供的实现基于区块链的智能合约名片方法的电子设备的结构示意图。As shown in FIG. 3 , it is a schematic structural diagram of an electronic device for implementing a method for a smart contract business card based on a blockchain provided by an embodiment of the present invention.
所述电子设备1可以包括处理器10、存储器11、通信总线12以及通信接口13,还可以包括存储在所述存储器11中并可在所述处理器10上运行的计算机程序,如基于区块链的智能合约名片程序。The electronic device 1 may include a
其中,所述处理器10在一些实施例中可以由集成电路组成,例如可以由单个封装的集成电路所组成,也可以是由多个相同功能或不同功能封装的集成电路所组成,包括一个或者多个中央处理器(Central Processing unit,CPU)、微处理器、数字处理芯片、图形处理器及各种控制芯片的组合等。所述处理器10是所述电子设备的控制核心(ControlUnit),利用各种接口和线路连接整个电子设备的各个部件,通过运行或执行存储在所述存储器11内的程序或者模块(例如执行基于区块链的智能合约名片程序等),以及调用存储在所述存储器11内的数据,以执行电子设备的各种功能和处理数据。The
所述存储器11至少包括一种类型的可读存储介质,所述可读存储介质包括闪存、移动硬盘、多媒体卡、卡型存储器(例如:SD或DX存储器等)、磁性存储器、磁盘、光盘等。所述存储器11在一些实施例中可以是电子设备的内部存储单元,例如该电子设备的移动硬盘。所述存储器11在另一些实施例中也可以是电子设备的外部存储设备,例如电子设备上配备的插接式移动硬盘、智能存储卡(Smart Media Card,SMC)、安全数字(Secure Digital,SD)卡、闪存卡(Flash Card)等。进一步地,所述存储器11还可以既包括电子设备的内部存储单元也包括外部存储设备。所述存储器11不仅可以用于存储安装于电子设备的应用软件及各类数据,例如基于区块链的智能合约名片程序的代码等,还可以用于暂时地存储已经输出或者将要输出的数据。The
所述通信总线12可以是外设部件互连标准(peripheral componentinterconnect,简称PCI)总线或扩展工业标准结构(extended industry standardarchitecture,简称EISA)总线等。该总线可以分为地址总线、数据总线、控制总线等。所述总线被设置为实现所述存储器11以及至少一个处理器10等之间的连接通信。The
所述通信接口13用于上述电子设备与其他设备之间的通信,包括网络接口和用户接口。可选地,所述网络接口可以包括有线接口和/或无线接口(如WI-FI接口、蓝牙接口等),通常用于在该电子设备与其他电子设备之间建立通信连接。所述用户接口可以是显示器(Display)、输入单元(比如键盘(Keyboard)),可选地,用户接口还可以是标准的有线接口、无线接口。可选地,在一些实施例中,显示器可以是LED显示器、液晶显示器、触控式液晶显示器以及OLED(Organic Light-Emitting Diode,有机发光二极管)触摸器等。其中,显示器也可以适当的称为显示屏或显示单元,用于显示在电子设备中处理的信息以及用于显示可视化的用户界面。The
图3仅示出了具有部件的电子设备,本领域技术人员可以理解的是,图3示出的结构并不构成对所述电子设备1的限定,可以包括比图示更少或者更多的部件,或者组合某些部件,或者不同的部件布置。FIG. 3 only shows an electronic device with components. Those skilled in the art can understand that the structure shown in FIG. 3 does not constitute a limitation on the electronic device 1, and may include fewer or more components than those shown in the figure. components, or a combination of certain components, or a different arrangement of components.
例如,尽管未示出,所述电子设备还可以包括给各个部件供电的电源(比如电池),优选地,电源可以通过电源管理装置与所述至少一个处理器10逻辑相连,从而通过电源管理装置实现充电管理、放电管理、以及功耗管理等功能。电源还可以包括一个或一个以上的直流或交流电源、再充电装置、电源故障检测电路、电源转换器或者逆变器、电源状态指示器等任意组件。所述电子设备还可以包括多种传感器、蓝牙模块、Wi-Fi模块等,在此不再赘述。For example, although not shown, the electronic device may also include a power source (such as a battery) for powering the various components, preferably, the power source may be logically connected to the at least one
应该了解,所述实施例仅为说明之用,在专利申请范围上并不受此结构的限制。It should be understood that the embodiments are only used for illustration, and are not limited by this structure in the scope of the patent application.
所述电子设备1中的所述存储器11存储的基于区块链的智能合约名片程序是多个指令的组合,在所述处理器10中运行时,可以实现:The blockchain-based smart contract business card program stored in the
获取用户基本信息及用户区块链账号,并对所述用户区块链账号进行激活处理;Obtain the user's basic information and the user's blockchain account, and activate the user's blockchain account;
当所述用户区块链账号经过激活处理后,索引出所述用户区块链账号所属机构的机构信息,分别将所述用户区块链账号、所述用户基本信息中的用户标识和所述机构信息中的机构区块链账号写入预构建初始名片的多个账号字段中;After the user's blockchain account is activated, the organization information of the institution to which the user's blockchain account belongs is indexed, and the user's blockchain account, the user ID in the basic user information and the The institutional blockchain account number in the institutional information is written into multiple account fields of the pre-built initial business card;
基于预设的加密算法生成加密密钥和所述加密密钥对应的解密密钥,利用所述加密密钥对所述用户基本信息中的个人信息进行加密,得到加密信息;Generate an encryption key and a decryption key corresponding to the encryption key based on a preset encryption algorithm, and use the encryption key to encrypt the personal information in the basic user information to obtain encrypted information;
基于预设的哈希算法计算所述个人信息的哈希值,并将所述哈希值、所述加密密钥和所述加密信息写入所述初始名片中的内容字段中;Calculate the hash value of the personal information based on a preset hash algorithm, and write the hash value, the encryption key and the encryption information into the content field in the initial business card;
将所述机构信息中的机构账号写入所述初始名片中的账号字段中,并利用所述机构账号对应的公钥对所述解密密钥进行加密,将加密后的第一密文写入所述账号字段对应的密文字段中;Write the organization account in the organization information into the account field in the initial business card, encrypt the decryption key with the public key corresponding to the organization account, and write the encrypted first ciphertext into the account field. in the ciphertext field corresponding to the account number field;
利用所述用户基本信息中的用户账号对应的公钥对所述解密密钥进行加密,将加密后的第二密文和所述用户账号写入字段中,得到用户名片。The decryption key is encrypted by using the public key corresponding to the user account in the basic user information, and the encrypted second ciphertext and the user account are written into a field to obtain a user card.
具体地,所述处理器10对上述指令的具体实现方法可参考附图对应实施例中相关步骤的描述,在此不赘述。Specifically, for the specific implementation method of the above-mentioned instruction by the
进一步地,所述电子设备1集成的模块/单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读存储介质中。所述计算机可读存储介质可以是易失性的,也可以是非易失性的。例如,所述计算机可读介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)。Further, if the modules/units integrated in the electronic device 1 are implemented in the form of software functional units and sold or used as independent products, they may be stored in a computer-readable storage medium. The computer-readable storage medium may be volatile or non-volatile. For example, the computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a removable hard disk, a magnetic disk, an optical disc, a computer memory, a read-only memory (ROM, Read-Only). Memory).
本发明还提供一种计算机可读存储介质,所述可读存储介质存储有计算机程序,所述计算机程序在被电子设备的处理器所执行时,可以实现:The present invention also provides a computer-readable storage medium, where the readable storage medium stores a computer program, and when executed by a processor of an electronic device, the computer program can realize:
获取用户基本信息及用户区块链账号,并对所述用户区块链账号进行激活处理;Obtain the user's basic information and the user's blockchain account, and activate the user's blockchain account;
当所述用户区块链账号经过激活处理后,索引出所述用户区块链账号所属机构的机构信息,分别将所述用户区块链账号、所述用户基本信息中的用户标识和所述机构信息中的机构区块链账号写入预构建初始名片的多个账号字段中;After the user's blockchain account is activated, the organization information of the institution to which the user's blockchain account belongs is indexed, and the user's blockchain account, the user ID in the basic user information and the The institutional blockchain account number in the institutional information is written into multiple account fields of the pre-built initial business card;
基于预设的加密算法生成加密密钥和所述加密密钥对应的解密密钥,利用所述加密密钥对所述用户基本信息中的个人信息进行加密,得到加密信息;Generate an encryption key and a decryption key corresponding to the encryption key based on a preset encryption algorithm, and use the encryption key to encrypt the personal information in the basic user information to obtain encrypted information;
基于预设的哈希算法计算所述个人信息的哈希值,并将所述哈希值、所述加密密钥和所述加密信息写入所述初始名片中的内容字段中;Calculate the hash value of the personal information based on a preset hash algorithm, and write the hash value, the encryption key and the encryption information into the content field in the initial business card;
将所述机构信息中的机构账号写入所述初始名片中的账号字段中,并利用所述机构账号对应的公钥对所述解密密钥进行加密,将加密后的第一密文写入所述账号字段对应的密文字段中;Write the organization account in the organization information into the account field in the initial business card, encrypt the decryption key with the public key corresponding to the organization account, and write the encrypted first ciphertext into the account field. in the ciphertext field corresponding to the account number field;
利用所述用户基本信息中的用户账号对应的公钥对所述解密密钥进行加密,将加密后的第二密文和所述用户账号写入字段中,得到用户名片。The decryption key is encrypted by using the public key corresponding to the user account in the basic user information, and the encrypted second ciphertext and the user account are written into a field to obtain a user card.
在本发明所提供的几个实施例中,应该理解到,所揭露的设备,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。In the several embodiments provided by the present invention, it should be understood that the disclosed apparatus, apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are only illustrative. For example, the division of the modules is only a logical function division, and there may be other division manners in actual implementation.
所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。The modules described as separate components may or may not be physically separated, and components shown as modules may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
另外,在本发明各个实施例中的各功能模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能模块的形式实现。In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware, or can be implemented in the form of hardware plus software function modules.
对于本领域技术人员而言,显然本发明不限于上述示范性实施例的细节,而且在不背离本发明的精神或基本特征的情况下,能够以其他的具体形式实现本发明。It will be apparent to those skilled in the art that the present invention is not limited to the details of the above-described exemplary embodiments, but that the present invention may be embodied in other specific forms without departing from the spirit or essential characteristics of the invention.
因此,无论从哪一点来看,均应将实施例看作是示范性的,而且是非限制性的,本发明的范围由所附权利要求而不是上述说明限定,因此旨在将落在权利要求的等同要件的含义和范围内的所有变化涵括在本发明内。不应将权利要求中的任何附关联图标记视为限制所涉及的权利要求。Therefore, the embodiments are to be regarded in all respects as illustrative and not restrictive, and the scope of the invention is to be defined by the appended claims rather than the foregoing description, which are therefore intended to fall within the scope of the claims. All changes within the meaning and range of the equivalents of , are included in the present invention. Any reference signs in the claims shall not be construed as limiting the involved claim.
本发明所指区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链(Blockchain),本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链可以包括区块链底层平台、平台产品服务层以及应用服务层等。The blockchain referred to in the present invention is a new application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. Blockchain, essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information to verify its Validity of information (anti-counterfeiting) and generation of the next block. The blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.
本申请实施例可以基于人工智能技术对相关的数据进行获取和处理。其中,人工智能(Artificial Intelligence,AI)是利用数字计算机或者数字计算机控制的机器模拟、延伸和扩展人的智能,感知环境、获取知识并使用知识获得最佳结果的理论、方法、技术及应用系统。The embodiments of the present application may acquire and process related data based on artificial intelligence technology. Among them, artificial intelligence (AI) is a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. .
此外,显然“包括”一词不排除其他单元或步骤,单数不排除复数。系统权利要求中陈述的多个单元或装置也可以由一个单元或装置通过软件或者硬件来实现。第一、第二等词语用来表示名称,而并不表示任何特定的顺序。Furthermore, it is clear that the word "comprising" does not exclude other units or steps and the singular does not exclude the plural. Several units or means recited in the system claims can also be realized by one unit or means by means of software or hardware. The words first, second, etc. are used to denote names and do not denote any particular order.
最后应说明的是,以上实施例仅用以说明本发明的技术方案而非限制,尽管参照较佳实施例对本发明进行了详细说明,本领域的普通技术人员应当理解,可以对本发明的技术方案进行修改或等同替换,而不脱离本发明技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be Modifications or equivalent substitutions can be made without departing from the spirit and scope of the technical solutions of the present invention.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202111639480.2A CN114417374B (en) | 2021-12-29 | 2021-12-29 | Smart contract business card method, device, equipment and storage medium based on blockchain |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202111639480.2A CN114417374B (en) | 2021-12-29 | 2021-12-29 | Smart contract business card method, device, equipment and storage medium based on blockchain |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN114417374A true CN114417374A (en) | 2022-04-29 |
| CN114417374B CN114417374B (en) | 2025-04-11 |
Family
ID=81269710
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202111639480.2A Active CN114417374B (en) | 2021-12-29 | 2021-12-29 | Smart contract business card method, device, equipment and storage medium based on blockchain |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN114417374B (en) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN116074115A (en) * | 2023-03-06 | 2023-05-05 | 广州市悦智计算机有限公司 | Method for realizing cross-chain encryption session based on intelligent contract |
| CN117097476A (en) * | 2023-10-19 | 2023-11-21 | 浪潮云洲工业互联网有限公司 | Data processing method, equipment and medium based on industrial Internet |
| CN117874044A (en) * | 2023-12-27 | 2024-04-12 | 中国建筑国际集团有限公司 | Management method, device, equipment and storage medium of basic business card system |
| TWI875371B (en) * | 2023-12-12 | 2025-03-01 | 事必得科技有限公司 | Electronic business card verification system |
Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20170171140A1 (en) * | 2015-08-17 | 2017-06-15 | Kartomi, Inc. | Platform for digital business cards that facilitates connections between individuals and a method thereof |
| CN109472161A (en) * | 2018-11-21 | 2019-03-15 | 京东方科技集团股份有限公司 | A network server, information storage method, information exchange method and blockchain system |
| CN113793406A (en) * | 2021-09-16 | 2021-12-14 | 中国平安人寿保险股份有限公司 | Portrait business card generating method and device, electronic equipment and storage medium |
-
2021
- 2021-12-29 CN CN202111639480.2A patent/CN114417374B/en active Active
Patent Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20170171140A1 (en) * | 2015-08-17 | 2017-06-15 | Kartomi, Inc. | Platform for digital business cards that facilitates connections between individuals and a method thereof |
| CN109472161A (en) * | 2018-11-21 | 2019-03-15 | 京东方科技集团股份有限公司 | A network server, information storage method, information exchange method and blockchain system |
| CN113793406A (en) * | 2021-09-16 | 2021-12-14 | 中国平安人寿保险股份有限公司 | Portrait business card generating method and device, electronic equipment and storage medium |
Non-Patent Citations (2)
| Title |
|---|
| MIGUEL TAVARES等: "Wallid: Secure your ID in an Ethereum Wallet", 《2018 INTERNATIONAL CONFERENCE ON INTELLIGENT SYSTEM》, 9 May 2019 (2019-05-09), pages 714 - 721 * |
| 江宁: "基于联盟区块链的公安情报共享模型研究", 《中国优秀硕士学位论文全文数据库》, 31 December 2020 (2020-12-31), pages 113 - 19 * |
Cited By (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN116074115A (en) * | 2023-03-06 | 2023-05-05 | 广州市悦智计算机有限公司 | Method for realizing cross-chain encryption session based on intelligent contract |
| CN116074115B (en) * | 2023-03-06 | 2023-06-23 | 广州市悦智计算机有限公司 | Method for realizing cross-chain encryption session based on intelligent contract |
| CN117097476A (en) * | 2023-10-19 | 2023-11-21 | 浪潮云洲工业互联网有限公司 | Data processing method, equipment and medium based on industrial Internet |
| CN117097476B (en) * | 2023-10-19 | 2024-01-26 | 浪潮云洲工业互联网有限公司 | Data processing method, equipment and medium based on industrial Internet |
| TWI875371B (en) * | 2023-12-12 | 2025-03-01 | 事必得科技有限公司 | Electronic business card verification system |
| CN117874044A (en) * | 2023-12-27 | 2024-04-12 | 中国建筑国际集团有限公司 | Management method, device, equipment and storage medium of basic business card system |
Also Published As
| Publication number | Publication date |
|---|---|
| CN114417374B (en) | 2025-04-11 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN114417374B (en) | Smart contract business card method, device, equipment and storage medium based on blockchain | |
| CN113434906B (en) | Data query method, device, computer equipment and storage medium | |
| CN114124502B (en) | Message transmission method, device, equipment and medium | |
| CN114826736B (en) | Information sharing method, device, equipment and storage medium | |
| CN111612458A (en) | Method, device and readable storage medium for blockchain data processing | |
| CN112217642A (en) | Data encryption sharing method and device, electronic equipment and computer storage medium | |
| CN114389889B (en) | File full life cycle management method and device based on block chain technology | |
| CN114006689B (en) | Data processing method, device and medium based on federal learning | |
| CN113420049A (en) | Data circulation method and device, electronic equipment and storage medium | |
| CN112069525A (en) | Encryption method, device and device for generating key based on attribute of information | |
| WO2022227317A1 (en) | Blockchain-based resource transfer method and apparatus, electronic device, and storage medium | |
| CN114726644A (en) | Data transmission method, device and equipment based on secret key encryption and storage medium | |
| CN114760073B (en) | Block chain-based warehouse commodity distribution method and device, electronic equipment and medium | |
| CN114860713A (en) | Block chain-based data matching method and device, electronic equipment and storage medium | |
| CN115374150A (en) | Character string data query method, device, electronic equipment and storage medium | |
| CN112217639B (en) | Data encryption sharing method and device, electronic equipment and computer storage medium | |
| CN119227143A (en) | A zero-privacy leakage ciphertext data query method, system and device | |
| CN113918517A (en) | Multi-type file centralized management method, device, equipment and storage medium | |
| CN114500037A (en) | Configurable interface encryption method and device, computer equipment and storage medium | |
| CN113221154A (en) | Service password obtaining method and device, electronic equipment and storage medium | |
| CN115146315B (en) | Privacy data protection method, device, equipment and storage medium for low-code platform | |
| CN115734216A (en) | Physical layer information encryption method, device, equipment and medium based on communication network | |
| CN116055144A (en) | Data security analysis method, device, equipment and storage based on internet of things | |
| CN115643090A (en) | Longitudinal federal analysis method, device, equipment and medium based on privacy retrieval | |
| CN114629663A (en) | Blockchain-based digital commodity transaction method and device |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |