[go: up one dir, main page]

CN115499223A - A key exchange method, device, electronic equipment and storage medium - Google Patents

A key exchange method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115499223A
CN115499223A CN202211145321.1A CN202211145321A CN115499223A CN 115499223 A CN115499223 A CN 115499223A CN 202211145321 A CN202211145321 A CN 202211145321A CN 115499223 A CN115499223 A CN 115499223A
Authority
CN
China
Prior art keywords
exchange
key
terminal
ciphertext
signature
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.)
Pending
Application number
CN202211145321.1A
Other languages
Chinese (zh)
Inventor
胡厚鹏
肖勇
欧家祥
钱斌
高正浩
罗奕
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China South Power Grid International Co ltd
Guizhou Power Grid Co Ltd
Original Assignee
China South Power Grid International Co ltd
Guizhou Power Grid Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by China South Power Grid International Co ltd, Guizhou Power Grid Co Ltd filed Critical China South Power Grid International Co ltd
Priority to CN202211145321.1A priority Critical patent/CN115499223A/en
Publication of CN115499223A publication Critical patent/CN115499223A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/06Network architectures or network communication protocols for network security for supporting key management in a packet data network
    • H04L63/061Network architectures or network communication protocols for network security for supporting key management in a packet data network for key exchange, e.g. in peer-to-peer networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities
    • H04L63/0869Network architectures or network communication protocols for network security for authentication of entities for achieving mutual authentication
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/20Network architectures or network communication protocols for network security for managing network security; network security policies in general
    • H04L63/205Network architectures or network communication protocols for network security for managing network security; network security policies in general involving negotiation or determination of the one or more network security mechanisms to be used, e.g. by negotiation between the client and the server or between peers or by selection according to the capabilities of the entities involved
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0816Key establishment, i.e. cryptographic processes or cryptographic protocols whereby a shared secret becomes available to two or more parties, for subsequent use
    • H04L9/0819Key transport or distribution, i.e. key establishment techniques where one party creates or otherwise obtains a secret value, and securely transfers it to the other(s)
    • H04L9/0825Key transport or distribution, i.e. key establishment techniques where one party creates or otherwise obtains a secret value, and securely transfers it to the other(s) using asymmetric-key encryption or public key infrastructure [PKI], e.g. key signature or public key certificates
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3247Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving digital signatures

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a key exchange method, a key exchange device, electronic equipment and a storage medium, which are used for solving the technical problem that the conventional key exchange protocol cannot meet the requirements of various scenes. The invention comprises the following steps: receiving an exchange key generation request sent by the proposing party terminal; determining an exchange protocol according to the exchange key generation request; and carrying out key exchange on the proposing party terminal and the exchanging party terminal by adopting the exchange protocol.

Description

一种密钥交换方法、装置、电子设备及存储介质A key exchange method, device, electronic equipment and storage medium

技术领域technical field

本发明涉及密钥认证技术领域,尤其涉及一种密钥交换方法、装置、电子设备及存储介质。The invention relates to the technical field of key authentication, in particular to a key exchange method, device, electronic equipment and storage medium.

背景技术Background technique

如今,互联网上数百万的设备和服务器为了进行会话,需要频繁地交换密钥(加密会话),这催生了密钥交换协议(KE)。密钥交换协议是指通话双方需要用密钥来加密会话的时候,为了不暴露会话密钥,双方不能直接发送密钥,因此通过发送双方各自的一些可公开的信息,用此信息构造一个双方都能通过私有信息和公开信息计算出来的相同密钥k。这个密钥不会被第三方得知,因为双方的私有信息都各自保留了。Today, millions of devices and servers on the Internet need to frequently exchange keys (encrypted sessions) in order to conduct sessions, which gave rise to the Key Exchange Protocol (KE). The key exchange protocol means that when both parties need to use a key to encrypt the session, in order not to expose the session key, the two parties cannot directly send the key, so by sending some public information of both parties, use this information to construct a two-party The same key k can be calculated from both private and public information. This key will not be known by a third party, because the private information of both parties is kept separately.

传统的密钥交换无法抵抗中间人攻击,模拟攻击,重放攻击等,因此需要加入带身份认证的密钥交换协议,也称为认证密钥交换(AKE),认证密钥交换协议应该允许两个用户建立一个共享的密钥,并在协议结束时清楚地知道他们正在与哪个用户交谈。在目前常用的认证密钥交换协议中,传统的是以由数字认证中心CA发放数字证书的形式,将公钥和用户身份绑定。但是,这样的协议存在可信第三方的需求:数字认证中心CA负责分发数字证书,使得中心化问题突出。于是分布式的认证密钥交换协议应运而生。现有技术对于实现分布式的认证密钥交换一般都是基于区块链实现的。Traditional key exchange cannot resist man-in-the-middle attacks, simulation attacks, replay attacks, etc., so it is necessary to join the key exchange protocol with identity authentication, also known as authenticated key exchange (AKE), and the authenticated key exchange protocol should allow two Users establish a shared key and at the end of the agreement it is clear which user they are talking to. In the currently commonly used authentication key exchange protocols, the traditional method is to bind the public key with the user identity in the form of a digital certificate issued by the digital certification center CA. However, there is a need for a trusted third party in such an agreement: the digital certification center CA is responsible for distributing digital certificates, which makes the problem of centralization prominent. So the distributed authenticated key exchange protocol came into being. Existing technologies are generally based on block chains for realizing distributed authentication key exchange.

一般来说,这些基于区块链的协议提供了解决由可信第三方引起的安全问题的方法。然而,它们仍然存在局限性。一些技术提出构建一个新的区块链来实现去中心化协议,但维系公共区块链无疑导致成本过高。因此,一些技术依赖于链外集中组件来提供有效性和公平性的证明。也有一些技术采用以太坊区块链来实现认证密钥交换协议,但这些都只实现了静态安全属性。不同协议实现的安全特性不同,无法满足多种场景需求。In general, these blockchain-based protocols provide a solution to the security issues posed by trusted third parties. However, they still have limitations. Some technologies propose building a new blockchain to implement a decentralized protocol, but maintaining a public blockchain is undoubtedly cost-prohibitive. Therefore, some technologies rely on off-chain centralized components to provide proofs of validity and fairness. There are also some technologies that use the Ethereum blockchain to implement authenticated key exchange protocols, but these only achieve static security properties. Different protocols implement different security features, which cannot meet the needs of various scenarios.

发明内容Contents of the invention

本发明提供了一种密钥交换方法、装置、电子设备及存储介质,用于解决现有的密钥交换协议无法满足多种场景需求的技术问题。The invention provides a key exchange method, device, electronic equipment and storage medium, which are used to solve the technical problem that the existing key exchange protocol cannot meet the requirements of various scenarios.

本发明提供了一种密钥交换方法,应用于以太坊区块链平台;所述以太坊区块链平台与提出方终端和交换方终端通信;所述方法包括:The present invention provides a key exchange method, which is applied to the Ethereum block chain platform; the Ethereum block chain platform communicates with the proposer terminal and the exchange party terminal; the method includes:

接收所述提出方终端发送的交换密钥生成请求;receiving an exchange key generation request sent by the proposer terminal;

根据所述交换密钥生成请求确定交换协议;determining an exchange protocol according to the exchange key generation request;

采用所述交换协议对所述提出方终端和所述交换方终端进行密钥交换。Exchanging keys between the proposer terminal and the exchanging party terminal by using the exchange protocol.

可选地,所述交换协议包括第一交换协议、第二交换协议和第三交换协议;所述根据所述交换密钥生成请求确定交换协议的步骤,包括:Optionally, the exchange protocol includes a first exchange protocol, a second exchange protocol, and a third exchange protocol; the step of determining the exchange protocol according to the exchange key generation request includes:

从所述交换密钥生成请求中获取保护条件和保持条件;Obtain protection conditions and retention conditions from the exchange key generation request;

当所述保护条件为不需要保护,且所述保持条件为不长期保存时,确定所述交换协议为所述第一交换协议;When the protection condition is that protection is not required, and the preservation condition is no long-term preservation, determine that the exchange protocol is the first exchange agreement;

当所述保持条件为长期保存时,确定所述交换协议为所述第二交换协议;When the preservation condition is long-term preservation, determine that the exchange protocol is the second exchange agreement;

当所述保护条件为需要保护时,确定所述交换协议为所述第三交换协议。When the protection condition is that protection is required, determine that the exchange protocol is the third exchange protocol.

可选地,所述采用所述交换协议对所述提出方终端和所述交换方终端进行密钥交换的步骤,包括:Optionally, the step of exchanging keys between the proposer terminal and the exchange party terminal by using the exchange protocol includes:

当所述交换协议为所述第一交换协议时,接收所述提出方终端发送的随机数;When the exchange protocol is the first exchange protocol, receive the random number sent by the proposer terminal;

获取所述提出方终端的第一身份信息和第一公钥;Obtain the first identity information and the first public key of the proposer terminal;

将所述随机数、所述第一身份信息、所述第一公钥发送至交换方终端;sending the random number, the first identity information, and the first public key to the terminal of the exchanging party;

接收所述交换方终端返回的密文和签名;所述密文为所述交换方终端对会话密钥和所述第一身份信息进行加密得到;所述签名为所述交换方终端通过所述交换方终端的第二私钥对所述密文进行签名得到;receiving the ciphertext and signature returned by the exchange party terminal; the ciphertext is obtained by encrypting the session key and the first identity information by the exchange party terminal; the signature is obtained by the exchange party terminal through the Obtained by signing the ciphertext with the second private key of the terminal of the exchanging party;

获取所述交换方终端的第二身份信息和第二公钥;Acquiring the second identity information and the second public key of the exchanging party terminal;

将所述密文、所述签名、所述第二身份信息和所述第二公钥发送至所述提出方终端;所述提出方终端用于采用所述第二身份信息和所述第二公钥对所述签名进行验证;还用于采用所述提出方终端的第一私钥对所述密文进行解密,得到所述会话密钥。sending the ciphertext, the signature, the second identity information, and the second public key to the proposer terminal; the proposer terminal is used to adopt the second identity information and the second The public key is used to verify the signature; it is also used to decrypt the ciphertext by using the first private key of the proposer terminal to obtain the session key.

可选地,所述采用所述交换协议对所述提出方终端和所述交换方终端进行密钥交换的步骤,包括:Optionally, the step of exchanging keys between the proposer terminal and the exchange party terminal by using the exchange protocol includes:

当所述交换协议为第二交换协议时,接收所述提出方终端发送的第一公钥、短暂公钥和第一签名;所述第一签名为所述提出方终端采用预设的第一私钥对所述短暂公钥签名得到;When the exchange protocol is the second exchange protocol, receive the first public key, ephemeral public key, and first signature sent by the proposer terminal; the first signature is the preset first The private key is obtained by signing the ephemeral public key;

获取所述提出方终端的第一身份信息;Obtain the first identity information of the proposer terminal;

向所述交换方终端发送所述短暂公钥、所述第一身份信息和所述第一公钥;sending the ephemeral public key, the first identity information, and the first public key to the exchanging party terminal;

接收所述交换方终端返回的会话密钥密文和第二签名;所述会话密钥密文为所述交换方对所述第一签名验证通过后,采用所述短暂密钥对会话密钥和所述交换方终端的第二身份信息加密后得到;所述第二签名为所述交换方对所述短暂密钥、所述会话密钥密文和所述第一身份信息进行签名得到;receiving the session key ciphertext and the second signature returned by the exchanging party terminal; the session key ciphertext is that the ephemeral key is used to pair the session key after the exchanging party passes the verification of the first signature obtained by encrypting the second identity information of the exchanging party terminal; the second signature is obtained by signing the ephemeral key, the session key ciphertext, and the first identity information by the exchanging party;

获取所述交换方终端的第二公钥和所述第二身份信息;Obtain the second public key and the second identity information of the exchanging party terminal;

将所述会话密钥密文、所述签名、所述第二公钥和所述第二身份信息发送至所述提出方终端;所述提出方终端用于采用所述第二身份信息和所述第二公钥对所述签名进行验证;还用于采用所述提出方的短暂私钥对所述会话密钥密文进行解密,得到所述会话密钥。sending the session key ciphertext, the signature, the second public key, and the second identity information to the proposer terminal; the proposer terminal is configured to adopt the second identity information and the The second public key is used to verify the signature; it is also used to decrypt the session key ciphertext by using the ephemeral private key of the proposer to obtain the session key.

可选地,所述采用所述交换协议对所述提出方终端和所述交换方终端进行密钥交换的步骤,包括:Optionally, the step of exchanging keys between the proposer terminal and the exchange party terminal by using the exchange protocol includes:

当所述交换协议为第三交换协议时,接收所述提出方终端发送的第一公钥和短暂公钥;When the exchange protocol is the third exchange protocol, receiving the first public key and the ephemeral public key sent by the proposer terminal;

将所述第一公钥和所述短暂公钥发送至所述交换方终端;sending the first public key and the ephemeral public key to the exchanging party terminal;

接收所述交换方终端返回的第一密文和第二密文;所述第一密文为所述交换方终端采用所述短暂公钥加密第一加密密钥、第二加密密钥和会话密钥得到;所述第二密文为所述交换方终端采用所述第一加密密钥对所述第一签名和所述交换方终端的第二身份信息进行加密得到;所述第一签名为所述交换端终端对所述第一加密密钥、短暂密钥和所述第一密文进行加密得到;Receive the first ciphertext and the second ciphertext returned by the exchanging party terminal; the first ciphertext is that the exchanging party terminal uses the ephemeral public key to encrypt the first encryption key, the second encryption key and the session The key is obtained; the second ciphertext is obtained by encrypting the first signature and the second identity information of the exchanging terminal by the exchanging terminal using the first encryption key; the first signature Obtained by encrypting the first encryption key, the ephemeral key, and the first ciphertext for the switching terminal;

将所述第一密文和所述第二密文发送至所述提出方终端;所述提出方终端用于对第一密文进行解密得到所述第一加密密钥、第二加密密钥和所述会话密钥;以及通过所述第一加密密钥对所述第二密文进行解密得到第一签名和第二身份信息;以及对第二加密密钥、短暂密钥和第一密文进行签名得到第二签名;以及对所述第二签名和所述提出方的第一身份信息进行加密得到第三密文;Sending the first ciphertext and the second ciphertext to the proposer terminal; the proposer terminal is used to decrypt the first ciphertext to obtain the first encryption key and the second encryption key and the session key; and use the first encryption key to decrypt the second ciphertext to obtain the first signature and second identity information; and the second encryption key, ephemeral key and first secret Sign the text to obtain a second signature; and encrypt the second signature and the first identity information of the proposer to obtain a third ciphertext;

接收所述提出方终端发送的所述第三密文,并将所述第三密文发送至所述交换方终端;所述交换方终端用于采用所述第二加密密钥对所述第三密文进行解密,得到所述第二签名和所述第一身份信息,并验证所述第二签名。receiving the third ciphertext sent by the proposer terminal, and sending the third ciphertext to the exchanging terminal; the exchanging terminal is configured to use the second encryption key to Decrypt the three ciphertexts to obtain the second signature and the first identity information, and verify the second signature.

本发明还提供了一种密钥交换装置,应用于以太坊区块链平台;所述以太坊区块链平台与提出方终端和交换方终端通信;所述装置包括:The present invention also provides a key exchange device, which is applied to the Ethereum block chain platform; the Ethereum block chain platform communicates with the proposer terminal and the exchange party terminal; the device includes:

交换密钥生成请求接收模块,用于接收所述提出方终端发送的交换密钥生成请求;an exchange key generation request receiving module, configured to receive the exchange key generation request sent by the proposer terminal;

交换协议确定模块,用于根据所述交换密钥生成请求确定交换协议;an exchange protocol determination module, configured to determine an exchange protocol according to the exchange key generation request;

密钥交换模块,用于采用所述交换协议对所述提出方终端和所述交换方终端进行密钥交换。A key exchange module, configured to exchange keys between the proposer terminal and the exchange party terminal by using the exchange protocol.

可选地,所述交换协议包括第一交换协议、第二交换协议和第三交换协议;所述交换协议确定模块,包括:Optionally, the exchange protocol includes a first exchange protocol, a second exchange protocol, and a third exchange protocol; the exchange protocol determination module includes:

从所述交换密钥生成请求中获取保护条件和保持条件;Obtain protection conditions and retention conditions from the exchange key generation request;

第一交换协议确定子模块,用于当所述保护条件为不需要保护,且所述保持条件为不长期保存时,确定所述交换协议为所述第一交换协议;A first exchange protocol determination submodule, configured to determine that the exchange protocol is the first exchange protocol when the protection condition is that protection is not required and the maintenance condition is not long-term preservation;

第二交换协议确定子模块,用于当所述保持条件为长期保存时,确定所述交换协议为所述第二交换协议;A second exchange protocol determining submodule, configured to determine that the exchange protocol is the second exchange protocol when the storage condition is long-term storage;

第三交换协议确定子模块,用于当所述保护条件为需要保护时,确定所述交换协议为所述第三交换协议。A third exchange protocol determining submodule, configured to determine that the exchange protocol is the third exchange protocol when the protection condition is that protection is required.

可选地,所述密钥交换模块,包括:Optionally, the key exchange module includes:

随机数接收子模块,用于当所述交换协议为所述第一交换协议时,接收所述提出方终端发送的随机数;A random number receiving submodule, configured to receive the random number sent by the proposer terminal when the exchange protocol is the first exchange protocol;

第一身份信息和第一公钥获取子模块,用于获取所述提出方终端的第一身份信息和第一公钥;The first identity information and the first public key acquisition submodule, configured to acquire the first identity information and the first public key of the proposer terminal;

第一发送子模块,用于将所述随机数、所述第一身份信息、所述第一公钥发送至交换方终端;A first sending submodule, configured to send the random number, the first identity information, and the first public key to the exchanging terminal;

密文和签名接收子模块,用于接收所述交换方终端返回的密文和签名;所述密文为所述交换方终端对会话密钥和所述第一身份信息进行加密得到;所述签名为所述交换方终端通过所述交换方终端的第二私钥对所述密文进行签名得到;The ciphertext and signature receiving submodule is used to receive the ciphertext and signature returned by the exchanging party terminal; the ciphertext is obtained by encrypting the session key and the first identity information by the exchanging party terminal; the The signature is obtained by signing the ciphertext by the terminal of the exchange party through the second private key of the terminal of the exchange party;

第二身份信息和第二公钥获取子模块,用于获取所述交换方终端的第二身份信息和第二公钥;The second identity information and the second public key acquisition submodule, configured to acquire the second identity information and the second public key of the exchanging party terminal;

第二发送子模块,用于将所述密文、所述签名、所述第二身份信息和所述第二公钥发送至所述提出方终端;所述提出方终端用于采用所述第二身份信息和所述第二公钥对所述签名进行验证;还用于采用所述提出方终端的第一私钥对所述密文进行解密,得到所述会话密钥。The second sending submodule is configured to send the ciphertext, the signature, the second identity information, and the second public key to the proposer terminal; the proposer terminal is configured to adopt the first The second identity information and the second public key are used to verify the signature; and are also used to decrypt the ciphertext by using the first private key of the proposer terminal to obtain the session key.

本发明还提供了一种电子设备,所述设备包括处理器以及存储器:The present invention also provides an electronic device, the device includes a processor and a memory:

所述存储器用于存储程序代码,并将所述程序代码传输给所述处理器;The memory is used to store program codes and transmit the program codes to the processor;

所述处理器用于根据所述程序代码中的指令执行如上任一项所述的密钥交换方法。The processor is configured to execute the key exchange method described in any one of the above items according to the instructions in the program code.

本发明还提供了一种计算机可读存储介质,所述计算机可读存储介质用于存储程序代码,所述程序代码用于执行如上任一项所述的密钥交换方法。The present invention also provides a computer-readable storage medium, where the computer-readable storage medium is used to store program codes, and the program codes are used to execute the key exchange method described in any one of the above items.

从以上技术方案可以看出,本发明具有以下优点:本发明公开了一种密钥交换方法,应用于与提出方终端和交换方终端通信的以太坊区块链平台,包括:接收提出方终端发送的交换密钥生成请求;根据交换密钥生成请求确定交换协议;采用交换协议对提出方终端和交换方终端进行密钥交换。通过本发明实施例,可以根据不同场景选择不同的交换协议,从而满足不同场景的安全需求。As can be seen from the above technical solutions, the present invention has the following advantages: the present invention discloses a key exchange method, which is applied to the Ethereum block chain platform communicating with the proposer terminal and the exchange party terminal, including: receiving the proposer terminal The exchange key generation request is sent; the exchange protocol is determined according to the exchange key generation request; the exchange protocol is used to exchange keys between the proposer terminal and the exchange party terminal. Through the embodiments of the present invention, different exchange protocols can be selected according to different scenarios, so as to meet the security requirements of different scenarios.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其它的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. For those skilled in the art, other drawings can also be obtained according to these drawings on the premise of not paying creative efforts.

图1为本发明实施例提供的一种密钥交换方法的步骤流程图;Fig. 1 is a flow chart of the steps of a key exchange method provided by an embodiment of the present invention;

图2为本发明另一实施例提供的一种密钥交换方法的步骤流程图;FIG. 2 is a flowchart of steps of a key exchange method provided by another embodiment of the present invention;

图3为本发明实施例提供的一种密钥交换装置的结构框图。Fig. 3 is a structural block diagram of a key exchange device provided by an embodiment of the present invention.

具体实施方式detailed description

本发明实施例提供了一种密钥交换方法、装置、电子设备及存储介质,用于解决现有的密钥交换协议无法满足多种场景需求的技术问题。Embodiments of the present invention provide a key exchange method, device, electronic equipment, and storage medium, which are used to solve the technical problem that existing key exchange protocols cannot meet the requirements of various scenarios.

为使得本发明的发明目的、特征、优点能够更加的明显和易懂,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,下面所描述的实施例仅仅是本发明一部分实施例,而非全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。In order to make the purpose, features and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the following The described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.

请参阅图1,图1为本发明实施例提供的一种密钥交换方法的步骤流程图。Please refer to FIG. 1 . FIG. 1 is a flowchart of steps of a key exchange method provided by an embodiment of the present invention.

本发明提供的一种密钥交换方法,应用于以太坊区块链平台;以太坊区块链平台与提出方终端和交换方终端通信;具体可以包括以下步骤:A key exchange method provided by the present invention is applied to the Ethereum block chain platform; the Ethereum block chain platform communicates with the proposer terminal and the exchange party terminal; specifically, the following steps may be included:

步骤101,接收提出方终端发送的交换密钥生成请求;Step 101, receiving an exchange key generation request sent by the proposer terminal;

以太坊是一个开源的有智能合约功能的公共区块链平台,通过其专用加密货币以太币提供去中心化的以太虚拟机来处理点对点合约。Ethereum is an open source public blockchain platform with smart contract functions, providing a decentralized Ethereum virtual machine through its dedicated cryptocurrency Ether to process peer-to-peer contracts.

在本发明实施例中,提出方终端和交换方终端是进行密钥交换的双方。In the embodiment of the present invention, the proposing terminal and the exchanging terminal are two parties performing key exchange.

本发明首先为将所有合法的用户(假设为n个)初始化一些基础信息,The present invention first initializes some basic information for all legal users (assumed to be n),

系统分别为其各自生成一个三元组信息idS,skS,pkS(S=1,...,n),其中idS 表示第S个用户的身份信息,skS和pkS是一对对称密钥对,它能同时用来进行公钥加密操作和ECDSA公钥签名操作。最后,系统初始化阶段通过对可以公开的信息的上链(把idS,pkS和paramS信息放到各自用户的区块链区块 1,...,n上,其中paramS是指一些区块链上链操作需要的信息,例如合约地址等)。The system generates a triple information idS, skS, pkS (S=1,...,n) for each of them, where idS represents the identity information of the Sth user, skS and pkS are a pair of symmetric key pairs, It can be used for both public key encryption operations and ECDSA public key signature operations. Finally, in the system initialization stage, the information that can be disclosed is uploaded to the chain (put the idS, pkS and paramS information on the blockchain blocks 1,...,n of the respective users, where paramS refers to the information on some blockchains Information needed for chain operations, such as contract address, etc.).

当接收到提出方终端发送的交换密钥生成请求时,触发密钥交换操作。When receiving the exchange key generation request sent by the proposer terminal, the key exchange operation is triggered.

步骤102,根据交换密钥生成请求确定交换协议;Step 102, determining the exchange protocol according to the exchange key generation request;

以太坊区块链平台在接收到交换密钥生成请求后,可以确定提出方终端的保密要求,此时可以根据交换密钥生成请求确定交换协议。After receiving the exchange key generation request, the Ethereum blockchain platform can determine the confidentiality requirements of the proposer terminal, and at this time, the exchange protocol can be determined according to the exchange key generation request.

步骤103,采用交换协议对提出方终端和交换方终端进行密钥交换。Step 103, using the exchange protocol to perform key exchange between the proposer terminal and the exchange party terminal.

当确定了交换协议后,可以基于交换协议进行提出方终端和交换方终端之间的密钥交换。After the exchange protocol is determined, key exchange between the proposer terminal and the exchange party terminal can be performed based on the exchange protocol.

本发明公开了一种密钥交换方法,应用于与提出方终端和交换方终端通信的以太坊区块链平台,包括:接收提出方终端发送的交换密钥生成请求;根据交换密钥生成请求确定交换协议;采用交换协议对提出方终端和交换方终端进行密钥交换。通过本发明实施例,可以根据不同场景选择不同的交换协议,从而满足不同场景的安全需求。The invention discloses a key exchange method, which is applied to the Ethereum block chain platform communicating with the terminal of the proposer and the terminal of the exchange party, including: receiving the exchange key generation request sent by the proposer terminal; generating the request according to the exchange key Determine the exchange protocol; use the exchange protocol to exchange keys between the proposer terminal and the exchange party terminal. Through the embodiments of the present invention, different exchange protocols can be selected according to different scenarios, so as to meet the security requirements of different scenarios.

请参阅图2,图2为本发明另一实施例提供的一种密钥交换方法的步骤流程图,具体可以包括以下步骤:Please refer to FIG. 2. FIG. 2 is a flow chart of the steps of a key exchange method provided by another embodiment of the present invention, which may specifically include the following steps:

步骤201,接收提出方终端发送的交换密钥生成请求;Step 201, receiving an exchange key generation request sent by the proposer terminal;

步骤201与步骤101相同,具体可以参考步骤101的描述,此处不再赘述。Step 201 is the same as step 101, for details, please refer to the description of step 101, which will not be repeated here.

步骤202,从交换密钥生成请求中获取保护条件和保持条件;Step 202, obtaining the protection condition and the retention condition from the exchange key generation request;

步骤203,当保护条件为不需要保护,且保持条件为不长期保存时,确定交换协议为第一交换协议;Step 203, when the protection condition is that no protection is required, and the preservation condition is no long-term preservation, determine that the exchange protocol is the first exchange agreement;

步骤204,当保持条件为长期保存时,确定交换协议为第二交换协议;Step 204, when the preservation condition is long-term preservation, determine that the exchange protocol is the second exchange agreement;

步骤205,当保护条件为需要保护时,确定交换协议为第三交换协议;Step 205, when the protection condition is that protection is required, determine that the exchange protocol is the third exchange agreement;

在本发明实施例中,不同的保护条件和保持条件对应不同的交换协议,在获取到交换密钥生成请求后,可以从中获取相应的保护条件和保持条件。In the embodiment of the present invention, different protection conditions and retention conditions correspond to different exchange protocols, and after obtaining the exchange key generation request, corresponding protection conditions and retention conditions can be obtained therefrom.

当用户的身份不需要保护且交换的密钥不需要长期保存时,选择第一交换协议。第一交换协议具有最快的交换速度。当用户交换的密钥需要长期保存时,选择第二交换协议。第二交换协议可以确保交换后的密钥即使丢失,也不会对之前使用该密钥进行的操作造成安全问题。当进行密钥交换的用户身份需要进行保护时,选择第三种交换协议。其交换速度相对较慢但能提供用户的身份保护。When the user's identity does not need to be protected and the exchanged key does not need to be stored for a long time, the first exchange protocol is selected. The first switching protocol has the fastest switching speed. When the keys exchanged by users need to be stored for a long time, the second exchange protocol is selected. The second exchange protocol can ensure that even if the exchanged key is lost, it will not cause security problems to operations performed using the key before. The third exchange protocol is chosen when the identity of the user performing the key exchange needs to be protected. Its exchange speed is relatively slow but can provide user's identity protection.

步骤206,采用交换协议对提出方终端和交换方终端进行密钥交换。Step 206, using the exchange protocol to perform key exchange between the proposer terminal and the exchange party terminal.

在确定了采用的交换协议后,以太坊区块链平台可以对提出方终端和交换方终端进行密钥交换。After determining the adopted exchange protocol, the Ethereum blockchain platform can exchange keys between the proposer terminal and the exchange party terminal.

在一个示例中,采用交换协议对提出方终端和交换方终端进行密钥交换的步骤,可以包括以下子步骤:In an example, the step of exchanging keys between the proposer terminal and the exchanging terminal by using the exchange protocol may include the following sub-steps:

S11,当交换协议为第一交换协议时,接收提出方终端发送的随机数;S11. When the exchange protocol is the first exchange protocol, receive the random number sent by the proposer terminal;

S12,获取提出方终端的第一身份信息和第一公钥;S12. Obtain the first identity information and the first public key of the proposer terminal;

S13,将随机数、第一身份信息、第一公钥发送至交换方终端;S13, sending the random number, the first identity information, and the first public key to the terminal of the exchanging party;

S14,接收交换方终端返回的密文和签名;密文为交换方终端对会话密钥和第一身份信息进行加密得到;签名为交换方终端通过交换方终端的第二私钥对密文进行签名得到;S14. Receive the ciphertext and the signature returned by the terminal of the exchanging party; the ciphertext is obtained by encrypting the session key and the first identity information by the terminal of the exchanging party; signed to get;

S15,获取交换方终端的第二身份信息和第二公钥;S15. Obtain the second identity information and the second public key of the exchanging party terminal;

S16,将密文、签名、第二身份信息和第二公钥发送至提出方终端;提出方终端用于采用第二身份信息和第二公钥对签名进行验证;还用于采用提出方终端的第一私钥对密文进行解密,得到会话密钥。S16. Send the ciphertext, signature, second identity information, and second public key to the proposer terminal; the proposer terminal is used to verify the signature by using the second identity information and the second public key; it is also used to use the proposer terminal Decrypt the ciphertext with the first private key to obtain the session key.

在具体实现中,采用第一交换协议DAKE1进行密钥交换的详细流程如下:In a specific implementation, the detailed process of key exchange using the first exchange protocol DAKE1 is as follows:

1、提出方终端O发送一个生成的随机数r到区块链上;1. The proposer terminal O sends a generated random number r to the blockchain;

2、交换方终端C从区块链拿到r、第一公钥pkO、第一身份信息idO,然后取随机数作为会话密钥,用pkO加密k和C的idC,得到一个密文 c=RSA.EncpkO(k,idC),并对密文c用C的私钥skC签名,得到签名 sig=ECDSA.SigskC(r,c,idC);实现了会话密钥与C的绑定,且签名可以用pkC 验证身份是C。其中,上述的RSA.Enc,ECDSA.Sig是指使用的是密码学的标准加密方案RSA的加密算法以及签名方案ECDSA的签名算法,其下标表示所对应使用的密钥。2. The exchanging party terminal C obtains r, the first public key pkO, and the first identity information idO from the blockchain, and then takes a random number as the session key, encrypts k and C’s idC with pkO, and obtains a ciphertext c= RSA.EncpkO(k, idC), and sign the ciphertext c with C’s private key skC, and get the signature sig=ECDSA.SigskC(r, c, idC); realize the binding of the session key and C, and sign The identity can be verified as C with pkC. Among them, the above-mentioned RSA.Enc and ECDSA.Sig refer to the encryption algorithm of RSA, the standard encryption scheme of cryptography, and the signature algorithm of ECDSA, the signature scheme, and the subscripts indicate the corresponding keys.

3、提出方终端从区块链上拿到密文c和签名sig、第二公钥pkC和第二身份信息idC后,可以用pkC来验证签名。即计算ECDSA.VerifypkC(sig,c,idC) 是否通过。用自己保存的第一私钥skO解密c,即计算AES.DecskO(c),解密结果为(k,idC)。3. After obtaining the ciphertext c and signature sig, the second public key pkC and the second identity information idC from the block chain, the proposer terminal can use pkC to verify the signature. That is, calculate whether ECDSA.VerifypkC(sig,c,idC) passes. Decrypt c with the first private key skO saved by yourself, that is, calculate AES.DecskO(c), and the decryption result is (k, idC).

4、完成之后,输出会话密钥k作为交换的密钥。4. After completion, output the session key k as the exchange key.

DAKE1协议满足了静态安全和显示认证安全。当提出方终端O完成协议时,提出方终端O可以确定交换方C是“在线的”,因为C必须对包含O的随机数r的消息进行签名。然而,当C完成了协议时,C并没有办法确信O,因为它不包含O。DAKE1 protocol satisfies static security and explicit authentication security. When the proposer terminal O completes the protocol, the proposer terminal O can determine that the exchange party C is "online" because C must sign the message containing O's random number r. However, when C completes the protocol, there is no way for C to be sure of O because it does not contain O.

静态安全:在一个认证密钥交换协议中,首先假设交换双方不泄露任何诚实用户的长期密钥。在这个假设前提下,如果从对手的角度来看,最终交换的密钥k与一个随机数不可区分,则表示这样的认证密钥交换协议具有静态安全属性。而且,即使对手看到了来自其他用户实例的会话密钥,也应该保持这种状态。Static Security: In an authenticated key exchange protocol, it is first assumed that the exchange parties do not reveal any honest user's long-term key. Under this assumption, if the final exchanged key k is indistinguishable from a random number from the perspective of the adversary, it means that such an authenticated key exchange protocol has a static security property. And, even if the adversary sees session keys from other user instances, it should remain so.

显示认证安全:显式认证安全是指,在一个认证密钥交换协议中,密钥交换的双方都能确定它所通信的对象。举例来说,如果密钥k在提出方终端O 和交换方终端C的实例之间共享,那么C的实例应该能通过该交换协议知道他是在与O进行通话,O也应该知道他在与C进行通话。Explicitly authenticated security: Explicitly authenticated security means that in an authenticated key exchange protocol, both parties to the key exchange can determine with whom it is communicating. For example, if the key k is shared between instances of the proposer terminal O and the exchange party terminal C, then the instance of C should be able to know through the exchange protocol that he is talking to O, and O should also know that he is talking to C to make a call.

在另一个示例中,采用交换协议对提出方终端和交换方终端进行密钥交换的步骤,可以包括以下子步骤:In another example, the step of exchanging keys between the proposer terminal and the exchange party terminal by using the exchange protocol may include the following sub-steps:

S21,当交换协议为第二交换协议时,接收提出方终端发送的第一公钥、短暂公钥和第一签名;第一签名为提出方终端采用预设的第一私钥对短暂公钥签名得到;S21. When the exchange protocol is the second exchange protocol, receive the first public key, ephemeral public key and first signature sent by the proposer terminal; the first signature is the first private key pair preset by the proposer terminal to the ephemeral public key signed to get;

S22,获取提出方终端的第一身份信息;S22. Obtain the first identity information of the proposer terminal;

S23,向交换方终端发送短暂公钥、第一身份信息和第一公钥;S23. Send the ephemeral public key, the first identity information, and the first public key to the exchanging party terminal;

S24,接收交换方终端返回的会话密钥密文和第二签名;会话密钥密文为交换方对第一签名验证通过后,采用短暂密钥对会话密钥和交换方终端的第二身份信息加密后得到;第二签名为交换方对短暂密钥、会话密钥密文和第一身份信息进行签名得到;S24. Receive the session key ciphertext and the second signature returned by the terminal of the exchanging party; the ciphertext of the session key is the second identity of the session key and the terminal of the exchanging party using the ephemeral key after the exchanging party passes the verification of the first signature The information is obtained after encryption; the second signature is obtained by the exchange party signing the ephemeral key, the session key ciphertext and the first identity information;

S25,获取交换方终端的第二公钥和第二身份信息;S25. Obtain the second public key and second identity information of the exchanging party terminal;

S26,将会话密钥密文、签名、第二公钥和第二身份信息发送至提出方终端;提出方终端用于采用第二身份信息和第二公钥对签名进行验证;还用于采用提出方的短暂私钥对会话密钥密文进行解密,得到会话密钥。S26. Send the session key ciphertext, signature, second public key, and second identity information to the proposer terminal; the proposer terminal is used to verify the signature by using the second identity information and the second public key; The ephemeral private key of the proposer decrypts the session key ciphertext to obtain the session key.

在具体实现中,采用第二交换协议DAKE2进行密钥交换的详细流程如下:In a specific implementation, the detailed process of key exchange using the second exchange protocol DAKE2 is as follows:

1、提出方终端O随机生成一个短暂密钥对,并用自己的第一私钥对短暂公钥pkR签名得到第一签名,随后发送第一公钥pkO和短暂公钥、第一签名、第一身份信息idO到区块链上。1. The proposer terminal O randomly generates a short-lived key pair, and uses its own first private key to sign the short-lived public key pkR to obtain the first signature, and then sends the first public key pkO and the short-lived public key, the first signature, the first Identity information idO to the blockchain.

2、交换方终端C从区块链上拿到pkR、pkO、idO、第一签名后,验证签名。取k为会话密钥,短暂密钥加密会话密钥,得到会话密钥密文 RSA.EncpkR(k,idC),C对会话密钥密文进行签名,得到第二签名 c,SigC(pkR,c,idO),并将第二签名上传到区块链上。2. Terminal C, the exchange party, obtains pkR, pkO, idO, and the first signature from the blockchain, and then verifies the signature. Take k as the session key, encrypt the session key with the ephemeral key, and obtain the session key ciphertext RSA.EncpkR(k, idC), C signs the session key ciphertext, and obtain the second signature c, SigC(pkR, c, idO), and upload the second signature to the blockchain.

3、O从区块链上拿到会话密钥密文、第二签名、交换方终端第二公钥pkC 和第二身份信息idC后,验证第二签名。3. O obtains the session key ciphertext, the second signature, the second public key pkC of the exchanging party terminal and the second identity information idC from the blockchain, and then verifies the second signature.

4、完成之后,输出会话密钥k作为交换的密钥。4. After completion, output the session key k as the exchange key.

DAKE2协议满足了静态安全、显示认证安全和前向安全。这是由于在第二交换协议DAKE2的每一次运行中,O都会产生新的临时密钥对,而用户的长期密钥只用于签名,而不是加密。因此,破解一个签名密钥不对使对手解密任何信息。DAKE2 protocol satisfies static security, explicit authentication security and forward security. This is because in each operation of the second exchange protocol DAKE2, O will generate a new temporary key pair, and the user's long-term key is only used for signature, not encryption. Therefore, cracking a signing key does not allow an adversary to decrypt any information.

前向安全:前向安全特性要求对于任何一个认证密钥交换协议,即使所交换的密钥泄露了,之前使用该密钥所保护的信息也能继续保持保密状态,而不会被解密。举例来说,如果攻击者获得了用户的长期密钥,攻击者可以模仿该用户继续攻击,并造成很大的损害。但是,如果能将损害限制在用户密钥被泄露的时间内,那么至少在泄露之前生成的会话密钥不会被泄露,这个附加的安全属性称为前向安全。Forward security: The forward security feature requires that for any authenticated key exchange protocol, even if the exchanged key is leaked, the information previously protected by the key can continue to be kept secret and will not be decrypted. For example, if an attacker obtains a user's long-term key, the attacker can impersonate the user to continue the attack and cause a lot of damage. However, if the damage can be limited to the time during which the user's key is compromised, then at least the session keys generated before the compromise cannot be compromised. This additional security property is called forward security.

DAKE2的实现需要用到一个短暂的密钥对,一个加密方案和一个签名方案。其中一个短暂密钥对用来加密会话密钥,而原来放在链上的长期密钥则用来执行签名,一个签短暂密钥,一个签用短暂密钥加密的后的密文。因此,长期密钥只用于签名,即使被破解,也不会影响之前的会话,从而实现前向安全。The implementation of DAKE2 requires the use of an ephemeral key pair, an encryption scheme and a signature scheme. One of the ephemeral key pairs is used to encrypt the session key, and the long-term key originally placed on the chain is used to perform signatures, one to sign the ephemeral key, and the other to sign the ciphertext encrypted with the ephemeral key. Therefore, the long-term key is only used for signing, and even if it is cracked, it will not affect the previous session, thus achieving forward security.

在本发明实施例中,采用交换协议对提出方终端和交换方终端进行密钥交换的步骤,可以包括以下子步骤:In the embodiment of the present invention, the step of exchanging keys between the proposer terminal and the exchange party terminal by using the exchange protocol may include the following sub-steps:

S31,当交换协议为第三交换协议时,接收提出方终端发送的第一公钥和短暂公钥;S31. When the exchange protocol is the third exchange protocol, receive the first public key and the ephemeral public key sent by the proposer terminal;

S32,将第一公钥和短暂公钥发送至交换方终端;S32, sending the first public key and the ephemeral public key to the exchanging party terminal;

S33,接收交换方终端返回的第一密文和第二密文;第一密文为交换方终端采用短暂公钥加密第一加密密钥、第二加密密钥和会话密钥得到;第二密文为交换方终端采用第一加密密钥对第一签名和交换方终端的第二身份信息进行加密得到;第一签名为交换端终端对第一加密密钥、短暂密钥和第一密文进行加密得到;S33, receiving the first ciphertext and the second ciphertext returned by the exchanging party terminal; the first ciphertext is obtained by encrypting the first encryption key, the second encryption key and the session key by the exchanging party terminal using the ephemeral public key; the second The ciphertext is obtained by encrypting the first signature and the second identity information of the exchanging terminal by the exchanging terminal using the first encryption key; The text is encrypted to obtain;

S34,将第一密文和第二密文发送至提出方终端;提出方终端用于对第一密文进行解密得到第一加密密钥、第二加密密钥和会话密钥;以及通过第一加密密钥对第二密文进行解密得到第一签名和第二身份信息;以及对第二加密密钥、短暂密钥和第一密文进行签名得到第二签名;以及对第二签名和提出方的第一身份信息进行加密得到第三密文;S34. Send the first ciphertext and the second ciphertext to the proposer terminal; the proposer terminal is used to decrypt the first ciphertext to obtain the first encryption key, the second encryption key and the session key; and through the second An encryption key decrypts the second ciphertext to obtain the first signature and second identity information; and signs the second encryption key, the ephemeral key and the first ciphertext to obtain the second signature; and the second signature and The first identity information of the proposer is encrypted to obtain the third ciphertext;

S35,接收提出方终端发送的第三密文,并将第三密文发送至交换方终端;交换方终端用于采用第二加密密钥对第三密文进行解密,得到第二签名和第一身份信息,并验证第二签名。S35. Receive the third ciphertext sent by the proposer terminal, and send the third ciphertext to the exchanging terminal; the exchanging terminal is used to decrypt the third ciphertext using the second encryption key to obtain the second signature and the second One identity information, and verify the second signature.

在本发明实施例中,DAKE3可以称为具有身份保护的协议。DAKE3的实现同样需要用到一个短暂的密钥对,一个加密方案和一个签名方案。其中,一个短暂密钥对用来加密会话密钥,而原来放在链上的长期密钥则用来执行签名,一个签短暂密钥,一个签用短暂密钥加密的后的密文。因此,长期密钥只用于签名,即使被破解,也不会影响之前的会话,从而实现前向安全。同时,在身份保护的设计上,除了一个会话密钥k,DAKE3需要随机生成多两个随机密钥k1和k2,分别用来对各自的身份进行AES加密,保护身份。In the embodiment of the present invention, DAKE3 can be called a protocol with identity protection. The implementation of DAKE3 also requires the use of an ephemeral key pair, an encryption scheme, and a signature scheme. Among them, a short-lived key pair is used to encrypt the session key, while the long-term key originally placed on the chain is used to execute the signature, one signs the short-lived key, and the other signs the ciphertext encrypted with the short-lived key. Therefore, the long-term key is only used for signing, and even if it is cracked, it will not affect the previous session, thus achieving forward security. At the same time, in the design of identity protection, in addition to a session key k, DAKE3 needs to randomly generate two more random keys k1 and k2, which are used to encrypt their respective identities with AES to protect their identities.

在具体实现中,采用第三交换协议DAKE3进行密钥交换的详细流程如下:In a specific implementation, the detailed process of key exchange using the third exchange protocol DAKE3 is as follows:

1、提出方终端O随机生成一个短暂密钥对,发送第一公钥和短暂公钥到区块链上。1. The proposer terminal O randomly generates an ephemeral key pair, and sends the first public key and the ephemeral public key to the blockchain.

2、交换方终端C取k作为会话密钥,并以第一加密密钥k1和第二加密密钥k2作为加密密钥加密短暂密钥,如下:2. The exchanging party terminal C takes k as the session key, and encrypts the ephemeral key with the first encryption key k1 and the second encryption key k2 as encryption keys, as follows:

计算:c←RSA.EncpkR(k,k1,k2),σ1←ECDSA.SigpkC(k1,pkR,c),Calculation: c←RSA.EncpkR(k,k1,k2), σ1←ECDSA.SigpkC(k1,pkR,c),

c1←AES.Enck1(σ1,idC),并将(c,c1)发送至区块链。c1←AES.Enck1(σ1,idC), and send (c,c1) to the blockchain.

其中,c为第一密文,c1为第二密文,σ1为第一签名。Among them, c is the first ciphertext, c1 is the second ciphertext, and σ1 is the first signature.

3、O从区块链上拿到(c,c1),解密c得到(k,k1,k2),利用k1 解密得到σ1,idC,并验证σ1;O同时计算σ2←ECDSA.SigP(k2,pk,c),c2← AES.Enck2(σ2,idO)并发送c2到区块链上,其中AES.Enc是指使用AES对称加密算法进行加密运算。其中,σ2为第二签名,c2为第三密文。3. O gets (c, c1) from the blockchain, decrypts c to get (k, k1, k2), uses k1 to decrypt to get σ1, idC, and verifies σ1; O calculates σ2←ECDSA.SigP(k2, pk,c), c2← AES.Enck2(σ2,idO) and send c2 to the blockchain, where AES.Enc refers to the encryption operation using the AES symmetric encryption algorithm. Among them, σ2 is the second signature, and c2 is the third ciphertext.

4、C利用k2解密c2,得到σ2和idO,并验证签名。4. C uses k2 to decrypt c2, obtains σ2 and idO, and verifies the signature.

5、完成之后,输出会话密钥k作为交换的密钥。5. After completion, output the session key k as the exchange key.

DAKE3协议满足了满足了静态安全、显式认证安全、隐式认证安全、前向安全和身份保护。DAKE3 protocol satisfies static security, explicit authentication security, implicit authentication security, forward security and identity protection.

隐式认证安全:隐式认证安全是指,在一个认证密钥交换协议中,其中一方并不能确定对方的身份。有时,具有隐式认证安全的认证密钥交换协议对某些应用程序来说非常有必要。例如,当一个领导O完成协议进行会话时,他/她可以确信C在整个会议运行期间是在线的,O实际上可以确信C的某个实例完成了协议,并持有匹配的会话密钥。然而,当C完成协议时,他/她不能有这样的保证,不仅可能没有O的实例具有匹配的会话密钥,而且O甚至可能在协议执行期间没有在线,这对于某些特定的应用场合来说较为必要。Implicit authentication security: Implicit authentication security means that in an authenticated key exchange protocol, one party cannot determine the identity of the other party. Sometimes an authenticated key exchange protocol with implicit authentication security is necessary for certain applications. For example, when a leader O completes the agreement for a session, he/she can be sure that C is online for the entire duration of the session run, and O can actually be sure that some instance of C has completed the agreement and holds the matching session key. However, when C completes the protocol, he/she cannot have such guarantees, not only may there be no instance of O with a matching session key, but also O may not even be online during the execution of the protocol, which is critical for some specific applications. Said more necessary.

身份保护:身份保护是指,除非对方要求表明身份,否则在认证密钥交换协议交互过程中,协议双方均不暴露其身份,即保持身份的匿名性。注意身份保护同时意味着除了协议双方外的其他任意敌手也无法获悉运行认证密钥交换协议的一个或两个用户的身份。Identity protection: Identity protection means that, unless the other party requests to reveal their identities, neither party in the protocol will reveal their identities during the interaction process of the authenticated key exchange protocol, that is, maintain the anonymity of identities. Note that identity protection also means that any adversary other than the parties to the protocol cannot learn the identity of one or both users running the authenticated key exchange protocol.

进一步地,对应于三个交换协议,本发明实施例还对以太坊区块链的智能合约数据结构进行设计,本发明实施例提供了两个以太坊区块链智能合约结构,其中结构1能使DAKE1、DAKE2和DAKE3“显式”发送消息到区块链,结构2能使DAEK3“隐式”发送消息到区块链,的“显式”表示系统中的任何人都可以找出消息接收者的身份,而“隐式”表示任何其他人都无法获得消息接收者的身份。数据结构如下表1所示:Further, corresponding to the three exchange protocols, the embodiment of the present invention also designs the smart contract data structure of the Ethereum block chain, and the embodiment of the present invention provides two Ethereum block chain smart contract structures, wherein structure 1 can Make DAKE1, DAKE2, and DAKE3 "explicitly" send messages to the blockchain, structure 2 enables DAEK3 to "implicitly" send messages to the blockchain, and the "explicit" means that anyone in the system can find out the message received the identity of the recipient, while "implicit" means that no one else can obtain the identity of the recipient of the message. The data structure is shown in Table 1 below:

Figure BDA0003855337970000131
Figure BDA0003855337970000131

表1Table 1

进一步地,对应上述数据结构,本发明实施例提供了下面两个用于双方通信的智能合约算法,分别称为算法1和算法2,其中,算法1实现了区块链数据的写入接口,算法2实现了区块链数据的读取接口。提出方终端O可以通过算法1为对手设置通信消息,通过算法2,交换方终端C可以读取提出方终端设置的消息。对应于本发明实施例的三个协议,则是通过O与C之间进行算法1和算法2操作,在区块链中进行数据写入和读取,最终实现密钥交换。算法1如表2所示,算法2如表3所示。Further, corresponding to the above data structure, the embodiment of the present invention provides the following two smart contract algorithms for communication between the two parties, which are respectively called Algorithm 1 and Algorithm 2, where Algorithm 1 implements the write interface of blockchain data, Algorithm 2 implements the reading interface of blockchain data. The proposer terminal O can set a communication message for the opponent through Algorithm 1, and through Algorithm 2, the exchanging party terminal C can read the message set by the proposer terminal. The three protocols corresponding to the embodiment of the present invention operate through Algorithm 1 and Algorithm 2 between O and C, write and read data in the blockchain, and finally realize key exchange. Algorithm 1 is shown in Table 2, and Algorithm 2 is shown in Table 3.

Figure BDA0003855337970000141
Figure BDA0003855337970000141

表2Table 2

Figure BDA0003855337970000142
Figure BDA0003855337970000142

表3table 3

本发明公开了一种密钥交换方法,应用于与提出方终端和交换方终端通信的以太坊区块链平台,包括:接收提出方终端发送的交换密钥生成请求;根据交换密钥生成请求确定交换协议;采用交换协议对提出方终端和交换方终端进行密钥交换。通过本发明实施例,可以根据不同场景选择不同的交换协议,从而满足不同场景的安全需求。The invention discloses a key exchange method, which is applied to the Ethereum block chain platform communicating with the terminal of the proposer and the terminal of the exchange party, including: receiving the exchange key generation request sent by the proposer terminal; generating the request according to the exchange key Determine the exchange protocol; use the exchange protocol to exchange keys between the proposer terminal and the exchange party terminal. Through the embodiments of the present invention, different exchange protocols can be selected according to different scenarios, so as to meet the security requirements of different scenarios.

请参阅图3,图3为本发明实施例提供的一种密钥交换装置的结构框图。Please refer to FIG. 3 . FIG. 3 is a structural block diagram of a key exchange device provided by an embodiment of the present invention.

本发明实施例提供了一种密钥交换装置,应用于以太坊区块链平台;以太坊区块链平台与提出方终端和交换方终端通信;装置包括:The embodiment of the present invention provides a key exchange device, which is applied to the Ethereum block chain platform; the Ethereum block chain platform communicates with the proposer terminal and the exchange party terminal; the device includes:

交换密钥生成请求接收模块301,用于接收提出方终端发送的交换密钥生成请求;The exchange key generation request receiving module 301 is configured to receive the exchange key generation request sent by the proposer terminal;

交换协议确定模块302,用于根据交换密钥生成请求确定交换协议;An exchange protocol determining module 302, configured to determine the exchange protocol according to the exchange key generation request;

密钥交换模块303,用于采用交换协议对提出方终端和交换方终端进行密钥交换。The key exchange module 303 is configured to exchange keys between the proposer terminal and the exchange party terminal by using an exchange protocol.

在本发明实施例中,交换协议包括第一交换协议、第二交换协议和第三交换协议;交换协议确定模块,包括:In an embodiment of the present invention, the exchange protocol includes a first exchange protocol, a second exchange protocol, and a third exchange protocol; the exchange protocol determination module includes:

从交换密钥生成请求中获取保护条件和保持条件;Obtain protection conditions and hold conditions from the exchange key generation request;

第一交换协议确定子模块,用于当保护条件为不需要保护,且保持条件为不长期保存时,确定交换协议为第一交换协议;The first exchange protocol determination submodule is used to determine that the exchange protocol is the first exchange protocol when the protection condition is that protection is not required and the maintenance condition is not long-term storage;

第二交换协议确定子模块,用于当保持条件为长期保存时,确定交换协议为第二交换协议;The second exchange protocol determination submodule is used to determine that the exchange protocol is the second exchange protocol when the storage condition is long-term storage;

第三交换协议确定子模块,用于当保护条件为需要保护时,确定交换协议为第三交换协议。The third exchange protocol determination submodule is used to determine the exchange protocol as the third exchange protocol when the protection condition is that protection is required.

在本发明实施例中,密钥交换模块,包括:In the embodiment of the present invention, the key exchange module includes:

随机数接收子模块,用于当交换协议为第一交换协议时,接收提出方终端发送的随机数;The random number receiving submodule is used to receive the random number sent by the proposer terminal when the exchange protocol is the first exchange protocol;

第一身份信息和第一公钥获取子模块,用于获取提出方终端的第一身份信息和第一公钥;The first identity information and the first public key acquisition submodule, configured to acquire the first identity information and the first public key of the proposer terminal;

第一发送子模块,用于将随机数、第一身份信息、第一公钥发送至交换方终端;The first sending submodule is used to send the random number, the first identity information, and the first public key to the terminal of the exchanging party;

密文和签名接收子模块,用于接收交换方终端返回的密文和签名;密文为交换方终端对会话密钥和第一身份信息进行加密得到;签名为交换方终端通过交换方终端的第二私钥对密文进行签名得到;The ciphertext and signature receiving submodule is used to receive the ciphertext and signature returned by the exchanging terminal; the ciphertext is obtained by encrypting the session key and the first identity information by the exchanging terminal; the signature is obtained by the exchanging terminal through the exchanging terminal. Sign the ciphertext with the second private key;

第二身份信息和第二公钥获取子模块,用于获取交换方终端的第二身份信息和第二公钥;The second identity information and the second public key acquisition submodule, configured to acquire the second identity information and the second public key of the exchanging party terminal;

第二发送子模块,用于将密文、签名、第二身份信息和第二公钥发送至提出方终端;提出方终端用于采用第二身份信息和第二公钥对签名进行验证;还用于采用提出方终端的第一私钥对密文进行解密,得到会话密钥。The second sending sub-module is used to send the ciphertext, the signature, the second identity information and the second public key to the proposer terminal; the proposer terminal is used to verify the signature by using the second identity information and the second public key; It is used to decrypt the ciphertext by using the first private key of the proposer terminal to obtain the session key.

在本发明实施例中,密钥交换模块,包括:In the embodiment of the present invention, the key exchange module includes:

第一公钥、短暂公钥和第一签名接收子模块,用于当交换协议为第二交换协议时,接收提出方终端发送的第一公钥、短暂公钥和第一签名;第一签名为提出方终端采用预设的第一私钥对短暂公钥签名得到;The first public key, ephemeral public key, and first signature receiving submodule, used to receive the first public key, ephemeral public key, and first signature sent by the proposer terminal when the exchange protocol is the second exchange protocol; the first signature Obtained by signing the ephemeral public key with the preset first private key by the proposer terminal;

第一身份信息获取子模块,用于获取提出方终端的第一身份信息;The first identity information acquisition sub-module is used to acquire the first identity information of the proposer terminal;

第三发送子模块,用于向交换方终端发送短暂公钥、第一身份信息和第一公钥;The third sending submodule is used to send the ephemeral public key, the first identity information and the first public key to the exchanging party terminal;

会话密钥密文和第二签名接收子模块,用于接收交换方终端返回的会话密钥密文和第二签名;会话密钥密文为交换方对第一签名验证通过后,采用短暂密钥对会话密钥和交换方终端的第二身份信息加密后得到;第二签名为交换方对短暂密钥、会话密钥密文和第一身份信息进行签名得到;The session key ciphertext and the second signature receiving submodule are used to receive the session key ciphertext and the second signature returned by the terminal of the exchanging party; The key is obtained by encrypting the session key and the second identity information of the exchanging party terminal; the second signature is obtained by the exchanging party signing the ephemeral key, the session key ciphertext, and the first identity information;

第二公钥和第二身份信息获取子模块,用于获取交换方终端的第二公钥和第二身份信息;The second public key and second identity information acquisition submodule is used to acquire the second public key and second identity information of the exchanging party terminal;

第四发送子模块,用于将会话密钥密文、签名、第二公钥和第二身份信息发送至提出方终端;提出方终端用于采用第二身份信息和第二公钥对签名进行验证;还用于采用提出方的短暂私钥对会话密钥密文进行解密,得到会话密钥。The fourth sending submodule is used to send the session key ciphertext, the signature, the second public key and the second identity information to the proposer terminal; the proposer terminal is used to use the second identity information and the second public key to perform signature Verification; it is also used to decrypt the session key ciphertext with the ephemeral private key of the proposer to obtain the session key.

在本发明实施例中,密钥交换模块,包括:In the embodiment of the present invention, the key exchange module includes:

第一公钥和短暂公钥接收子模块,用于当交换协议为第三交换协议时,接收提出方终端发送的第一公钥和短暂公钥;The first public key and ephemeral public key receiving submodule, configured to receive the first public key and ephemeral public key sent by the proposer terminal when the exchange protocol is the third exchange protocol;

第五发送子模块,用于将第一公钥和短暂公钥发送至交换方终端;The fifth sending submodule is used to send the first public key and the ephemeral public key to the terminal of the exchanging party;

第一密文和第二密文接收子模块,用于接收交换方终端返回的第一密文和第二密文;第一密文为交换方终端采用短暂公钥加密第一加密密钥、第二加密密钥和会话密钥得到;第二密文为交换方终端采用第一加密密钥对第一签名和交换方终端的第二身份信息进行加密得到;第一签名为交换端终端对第一加密密钥、短暂密钥和第一密文进行加密得到;The first ciphertext and the second ciphertext receiving submodule are used to receive the first ciphertext and the second ciphertext returned by the terminal of the exchanging party; the first ciphertext is the first encryption key encrypted by the terminal of the exchanging party using a short-lived public key, The second encryption key and the session key are obtained; the second ciphertext is obtained by encrypting the first signature and the second identity information of the exchange terminal using the first encryption key by the exchange terminal; the first signature is obtained by the exchange terminal pair Obtained by encrypting the first encryption key, the ephemeral key and the first ciphertext;

第六发送子模块,用于将第一密文和第二密文发送至提出方终端;提出方终端用于对第一密文进行解密得到第一加密密钥、第二加密密钥和会话密钥;以及通过第一加密密钥对第二密文进行解密得到第一签名和第二身份信息;以及对第二加密密钥、短暂密钥和第一密文进行签名得到第二签名;以及对第二签名和提出方的第一身份信息进行加密得到第三密文;The sixth sending submodule is used to send the first ciphertext and the second ciphertext to the proposer terminal; the proposer terminal is used to decrypt the first ciphertext to obtain the first encryption key, the second encryption key and the session a key; and decrypting the second ciphertext with the first encryption key to obtain the first signature and second identity information; and signing the second encryption key, the ephemeral key and the first ciphertext to obtain the second signature; and encrypting the second signature and the first identity information of the proposer to obtain the third ciphertext;

第三密文接收子模块,用于接收提出方终端发送的第三密文,并将第三密文发送至交换方终端;交换方终端用于采用第二加密密钥对第三密文进行解密,得到第二签名和第一身份信息,并验证第二签名。The third ciphertext receiving submodule is used to receive the third ciphertext sent by the proposer terminal, and send the third ciphertext to the exchanging party terminal; the exchanging party terminal is used to use the second encryption key to process the third ciphertext Decrypt to obtain the second signature and the first identity information, and verify the second signature.

本发明实施例还提供了一种电子设备,设备包括处理器以及存储器:The embodiment of the present invention also provides an electronic device, the device includes a processor and a memory:

存储器用于存储程序代码,并将程序代码传输给处理器;The memory is used to store the program code and transmit the program code to the processor;

处理器用于根据程序代码中的指令执行本发明实施例的密钥交换方法。The processor is configured to execute the key exchange method according to the embodiment of the present invention according to the instructions in the program code.

本发明还提供了一种计算机可读存储介质,计算机可读存储介质用于存储程序代码,程序代码用于执行本发明实施例的密钥交换方法。The present invention also provides a computer-readable storage medium, where the computer-readable storage medium is used to store program codes, and the program codes are used to execute the key exchange method of the embodiment of the present invention.

所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that for the convenience and brevity of the description, the specific working process of the above-described system, device and unit can refer to the corresponding process in the foregoing method embodiment, which will not be repeated here.

本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。Each embodiment in this specification is described in a progressive manner, each embodiment focuses on the difference from other embodiments, and the same and similar parts of each embodiment can be referred to each other.

本领域内的技术人员应明白,本发明实施例的实施例可提供为方法、装置、或计算机程序产品。因此,本发明实施例可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质 (包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present invention may be provided as methods, devices, or computer program products. Accordingly, embodiments of the invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, embodiments of the invention may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.

本发明实施例是参照根据本发明实施例的方法、终端设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理终端设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理终端设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。Embodiments of the present invention are described with reference to flowcharts and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each procedure and/or block in the flowchart and/or block diagram, and a combination of procedures and/or blocks in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor or processor of other programmable data processing terminal equipment to produce a machine such that instructions executed by the computer or processor of other programmable data processing terminal equipment Produce means for realizing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理终端设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the The instruction means implements the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.

这些计算机程序指令也可装载到计算机或其他可编程数据处理终端设备上,使得在计算机或其他可编程终端设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程终端设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded into a computer or other programmable data processing terminal equipment, so that a series of operational steps are performed on the computer or other programmable terminal equipment to produce computer-implemented processing, thereby The instructions executed above provide steps for implementing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.

尽管已描述了本发明实施例的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例做出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明实施例范围的所有变更和修改。Having described preferred embodiments of embodiments of the present invention, additional changes and modifications to these embodiments can be made by those skilled in the art once the basic inventive concept is appreciated. Therefore, the appended claims are intended to be construed to cover the preferred embodiment and all changes and modifications which fall within the scope of the embodiments of the present invention.

最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者终端设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者终端设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者终端设备中还存在另外的相同要素。Finally, it should also be noted that in this text, relational terms such as first and second etc. are only used to distinguish one entity or operation from another, and do not necessarily require or imply that these entities or operations, any such actual relationship or order exists. Furthermore, the term "comprises", "comprises" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article, or terminal equipment comprising a set of elements includes not only those elements, but also includes elements not expressly listed. other elements identified, or also include elements inherent in such a process, method, article, or end-equipment. Without further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article or terminal device comprising said element.

以上所述,以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。As mentioned above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: it can still understand the foregoing The technical solutions recorded in each embodiment are modified, or some of the technical features are replaced equivalently; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims (10)

1. A key exchange method is characterized in that the method is applied to an Ethernet house block chain platform; the Ethernet house block chain platform is communicated with the proposing party terminal and the switching party terminal; the method comprises the following steps:
receiving an exchange key generation request sent by the proposing party terminal;
determining an exchange protocol according to the exchange key generation request;
and carrying out key exchange on the proposing party terminal and the exchanging party terminal by adopting the exchange protocol.
2. The method of claim 1, wherein the exchange protocols comprise a first exchange protocol, a second exchange protocol, and a third exchange protocol; the step of determining an exchange protocol according to the exchange key generation request includes:
obtaining a protection condition and a holding condition from the exchange key generation request;
when the protection condition is that protection is not needed and the retention condition is that long-term storage is not available, determining that the exchange protocol is the first exchange protocol;
when the holding condition is long-term storage, determining that the exchange protocol is the second exchange protocol;
and when the protection condition is that protection is needed, determining that the exchange protocol is the third exchange protocol.
3. The method according to claim 2, wherein the step of exchanging keys between the presenter terminal and the exchange terminal using the exchange protocol comprises:
when the exchange protocol is the first exchange protocol, receiving a random number sent by the proposing party terminal;
acquiring first identity information and a first public key of the terminal of the proposing party;
sending the random number, the first identity information and the first public key to an exchanger terminal;
receiving a ciphertext and a signature returned by the exchange side terminal; the ciphertext is obtained by encrypting a session key and the first identity information by the exchange party terminal; the signature is obtained by the exchange side terminal signing the ciphertext through a second private key of the exchange side terminal;
acquiring second identity information and a second public key of the exchange party terminal;
sending the ciphertext, the signature, the second identity information and the second public key to the proposing party terminal; the proposing party terminal is used for verifying the signature by adopting the second identity information and the second public key; and the second private key of the proposing party terminal is used for decrypting the ciphertext to obtain the session key.
4. The method according to claim 2, wherein the step of exchanging keys between the presenter terminal and the exchange terminal using the exchange protocol comprises:
when the exchange protocol is a second exchange protocol, receiving a first public key, a transient public key and a first signature sent by the presenter terminal; the first signature is obtained by signing the transient public key by the proposing party terminal by adopting a preset first private key;
acquiring first identity information of the terminal of the proposing party;
sending the transient public key, the first identity information and the first public key to the exchanger terminal;
receiving a session key ciphertext and a second signature returned by the exchange side terminal; the session key ciphertext is obtained by encrypting the session key and second identity information of the terminal of the exchange party by adopting the transient key after the exchange party passes the verification of the first signature; the second signature is obtained by the exchange party signing the transient key, the session key ciphertext and the first identity information;
acquiring a second public key and second identity information of the exchanger terminal;
sending the session key ciphertext, the signature, the second public key and the second identity information to the presenter terminal; the proposing party terminal is used for verifying the signature by adopting the second identity information and the second public key; and the system is also used for decrypting the session key ciphertext by adopting the transient private key of the proposing party to obtain the session key.
5. The method according to claim 2, wherein the step of exchanging keys between the presenter terminal and the exchange terminal using the exchange protocol comprises:
when the exchange protocol is a third exchange protocol, receiving a first public key and a transient public key sent by the proposing party terminal;
sending the first public key and the transient public key to the exchanger terminal;
receiving a first ciphertext and a second ciphertext returned by the exchange side terminal; the first ciphertext is obtained by encrypting a first encryption key, a second encryption key and a session key by the switch side terminal by adopting the transient public key; the second ciphertext is obtained by encrypting the first signature and second identity information of the exchange party terminal by using the first encryption key; the first signature is obtained by encrypting the first encryption key, the transient key and the first ciphertext by the exchange terminal;
sending the first ciphertext and the second ciphertext to the providing side terminal; the proposing party terminal is used for decrypting the first ciphertext to obtain the first encryption key, the second encryption key and the session key; decrypting the second ciphertext through the first encryption key to obtain a first signature and second identity information; signing the second encryption key, the transient key and the first ciphertext to obtain a second signature; encrypting the second signature and the first identity information of the presenter to obtain a third ciphertext;
receiving the third ciphertext sent by the proposing side terminal, and sending the third ciphertext to the switching side terminal; and the exchange side terminal is used for decrypting the third ciphertext by adopting the second encryption key to obtain the second signature and the first identity information and verifying the second signature.
6. A key exchange device is characterized in that the key exchange device is applied to an Ethernet bay blockchain platform; the Ethernet house block chain platform is communicated with the proposing party terminal and the switching party terminal; the device comprises:
an exchange key generation request receiving module, configured to receive an exchange key generation request sent by the presenter terminal;
the exchange protocol determining module is used for determining an exchange protocol according to the exchange key generation request;
and the key exchange module is used for exchanging keys between the proposing party terminal and the exchanging party terminal by adopting the exchange protocol.
7. The apparatus of claim 6, wherein the exchange protocols comprise a first exchange protocol, a second exchange protocol, and a third exchange protocol; the exchange protocol determination module comprises:
obtaining a protection condition and a holding condition from the exchange key generation request;
a first exchange protocol determining submodule, configured to determine that the exchange protocol is the first exchange protocol when the protection condition is that protection is not required and the retention condition is that long-term storage is not performed;
a second exchange protocol determination submodule configured to determine that the exchange protocol is the second exchange protocol when the holding condition is long-term storage;
and the third exchange protocol determining submodule is used for determining that the exchange protocol is the third exchange protocol when the protection condition is that protection is required.
8. The apparatus of claim 7, wherein the key exchange module comprises:
a random number receiving submodule, configured to receive a random number sent by the presenter terminal when the exchange protocol is the first exchange protocol;
a first identity information and first public key obtaining submodule, configured to obtain first identity information and a first public key of the presenter terminal;
the first sending submodule is used for sending the random number, the first identity information and the first public key to an exchanger terminal;
the ciphertext and signature receiving submodule is used for receiving the ciphertext and the signature returned by the exchanger terminal; the ciphertext is obtained by encrypting the session key and the first identity information by the exchange side terminal; the signature is obtained by the exchange side terminal signing the ciphertext through a second private key of the exchange side terminal;
the second identity information and second public key obtaining submodule is used for obtaining second identity information and a second public key of the exchanger terminal;
the second sending submodule is used for sending the ciphertext, the signature, the second identity information and the second public key to the proposing party terminal; the proposing party terminal is used for verifying the signature by adopting the second identity information and the second public key; and the second private key of the proposing party terminal is used for decrypting the ciphertext to obtain the session key.
9. An electronic device, comprising a processor and a memory:
the memory is used for storing program codes and transmitting the program codes to the processor;
the processor is configured to perform the key exchange method of any one of claims 1-5 according to instructions in the program code.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium is configured to store a program code for executing the key exchange method of any one of claims 1-5.
CN202211145321.1A 2022-09-20 2022-09-20 A key exchange method, device, electronic equipment and storage medium Pending CN115499223A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211145321.1A CN115499223A (en) 2022-09-20 2022-09-20 A key exchange method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211145321.1A CN115499223A (en) 2022-09-20 2022-09-20 A key exchange method, device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115499223A true CN115499223A (en) 2022-12-20

Family

ID=84469707

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211145321.1A Pending CN115499223A (en) 2022-09-20 2022-09-20 A key exchange method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115499223A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109617699A (en) * 2019-01-16 2019-04-12 北京沃东天骏信息技术有限公司 A key generation method, blockchain network service platform and storage medium
CN109802940A (en) * 2018-12-12 2019-05-24 北京众享比特科技有限公司 Block chain data base encryption and decryption method, device, equipment and its storage medium
CN111682938A (en) * 2020-05-12 2020-09-18 东南大学 A three-party verifiable key agreement method for centralized mobile positioning system
CN113037499A (en) * 2021-03-15 2021-06-25 杭州链网科技有限公司 Block chain encryption communication method and system
CN114173328A (en) * 2021-12-06 2022-03-11 中国电信股份有限公司 Key exchange method and device and electronic equipment
CN114362925A (en) * 2020-09-29 2022-04-15 中国移动通信有限公司研究院 A key agreement method, device and terminal

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109802940A (en) * 2018-12-12 2019-05-24 北京众享比特科技有限公司 Block chain data base encryption and decryption method, device, equipment and its storage medium
CN109617699A (en) * 2019-01-16 2019-04-12 北京沃东天骏信息技术有限公司 A key generation method, blockchain network service platform and storage medium
CN111682938A (en) * 2020-05-12 2020-09-18 东南大学 A three-party verifiable key agreement method for centralized mobile positioning system
CN114362925A (en) * 2020-09-29 2022-04-15 中国移动通信有限公司研究院 A key agreement method, device and terminal
CN113037499A (en) * 2021-03-15 2021-06-25 杭州链网科技有限公司 Block chain encryption communication method and system
CN114173328A (en) * 2021-12-06 2022-03-11 中国电信股份有限公司 Key exchange method and device and electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
QIONG WU, YI LUO , YING ZHAO, BIN QIAN, AND BIN GUO1: "DAKEs: Decentralized Authenticated Key Exchange Protocols via Blockchain for Smart City", 《HINDAWI》, 24 August 2022 (2022-08-24), pages 2 - 9 *

Similar Documents

Publication Publication Date Title
JP7119040B2 (en) Data transmission method, device and system
US11108565B2 (en) Secure communications providing forward secrecy
CN108377189B (en) Block chain user communication encryption method and device, terminal equipment and storage medium
CN107948189B (en) Asymmetric password identity authentication method and device, computer equipment and storage medium
CN109309569B (en) SM2 algorithm-based collaborative signature method and device and storage medium
CN108199835B (en) Multi-party combined private key decryption method
CN108347404B (en) Identity authentication method and device
WO2018127118A1 (en) Identity authentication method and device
JP2013017197A (en) Method and apparatus for mutual authentication
CN107947913A (en) The anonymous authentication method and system of a kind of identity-based
CN108696518B (en) Block chain user communication encryption method and device, terminal equipment and storage medium
TWI804179B (en) Quantum safe key exchange scheme
KR20100050846A (en) System and method for interchanging key
CN104901935A (en) Bilateral authentication and data interaction security protection method based on CPK (Combined Public Key Cryptosystem)
CN105812349A (en) Asymmetric secret key distribution and message encryption method based on identity information
CN118540164B (en) Quantum security enhancement method for Internet key exchange protocol
CN118540165A (en) Quantum security enhancement method for national security IPSec VPN protocol
CN112533213B (en) A key agreement method, device, terminal and storage medium
CN114726536A (en) A time stamp generation method, device, electronic device and storage medium
CN118540163A (en) Quantum security enhancement method for national security SSL VPN protocol
CN115459932B (en) A collaborative signature and decryption method and system for communicating parties based on elliptic curves
Duits The post-quantum Signal protocol: Secure chat in a quantum world
CN115499223A (en) A key exchange method, device, electronic equipment and storage medium
EP4272102A1 (en) Methods for anonymity authentication and message exchange in a cloud
CN108429717B (en) A kind of identity authentication 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
RJ01 Rejection of invention patent application after publication

Application publication date: 20221220

RJ01 Rejection of invention patent application after publication