区块链聊天加密怎么设置,区块链聊天加密软件
近年来,随着区块链技术的发展,越来越多的人开始关注区块链聊天加密的安全性。在区块链技术的帮助下,聊天加密可以提供更安全的环境,让用户可以放心地交流。那么,区块链聊天加密怎么设置呢?
首先,要了解区块链聊天加密的安全机制,这将有助于更好地设置加密。区块链聊天加密的安全机制主要包括两个方面:一是对称加密,二是非对称加密。对称加密是一种加密方式,它使用相同的密钥来加密和解密信息,这样可以有效地保护信息不被他人破解;非对称加密也是一种加密方式,它使用不同的密钥来加密和解密信息,这样可以更有效地保护信息的安全性。
其次,在设置区块链聊天加密之前,需要了解区块链聊天加密软件。区块链聊天加密软件是一种特殊的软件,它可以为用户提供更安全的通信环境,使用户可以放心地交流。除此之外,这种软件还可以提供一种简单的界面,用户可以更容易地使用它,而不需要太多的技术知识。
最后,在设置区块链聊天加密时,需要注意一些安全措施,以确保信息的安全性。首先,用户需要使用强大的密码,以防止他人破解;其次,用户需要定期更换密码,以防止被他人盗取;最后,用户需要使用安全的设备,以防止信息被窃取。
总之,区块链聊天加密是一项重要的安全技术,它可以为用户提供更安全的环境,让用户可以放心地交流。如果想要更好地设置区块链聊天加密,用户需要了解区块链聊天加密的安全机制,并使用区块链聊天加密软件,同时还要注意一些安全措施,以确保信息的安全性。
请查看相关英文文档
⑴ What is a blockchain encryption algorithm
Blockchain encryption algorithm (EncryptionAlgorithm)
Asymmetric encryption algorithm is a function that uses an encryption key. Convert the original plaintext file or data into a string of unreadable ciphertext codes. The encryption process is irreversible. Only by holding the corresponding decryption key can the encrypted information be decrypted into readable plain text. Encryption allows private data to be transmitted through public networks with low risk and protects data from being stolen and read by third parties.
The core advantage of blockchain technology is decentralization. It can achieve decentralized credit in a distributed system where nodes do not need to trust each other by using data encryption, timestamps, distributed consensus and economic incentives. Point-to-point transactions, coordination and collaboration, thus providing solutions to the problems of high cost, low efficiency and insecure data storage common in centralized institutions.
The application fields of blockchain include digital currency, certificates, finance, anti-counterfeiting and traceability, privacy protection, supply chain, entertainment, etc. With the popularity of blockchain and Bitcoin, many related top domain names have been registered. , which has had a relatively large impact on the domain name industry.
⑵ Blockchain: Tamper-proof Hash Encryption Algorithm
Students A and B toss a coin in the classroom and bet on who will clean the house. If the head comes up, A will clean the house. If it's facing up, then B sweeps. There's nothing wrong with this strategy.
However, if the scenario is transferred to an online chat room, and A and B also play a coin-tossing game, B will probably not agree, because when A tosses a coin, B will not guess.
Heads or tails, A can say that B guessed wrong.
How to solve this problem? How about encrypting the result of the coin toss first, and then B guesses? You can try this method.
Assume that any odd number represents the front side of the coin, and any even number represents the tail side. A wants a number 375, then multiplies it by 258, tells B the result is 96750, and declares that the 375 A wants is the key, which he keeps for safekeeping.
When verifying the result next, A can lie and claim that 258 is the number he wants and 375 is the key, and A is still invincible. What if A tells B the key in advance? B can directly calculate the original number, losing the confidentiality function.
This method of knowing the encryption method and knowing the decryption method obviously does not work. Is there a way to know the encryption method and still not be able to recover the original text?
Obviously there is, it is OK to add irreversible operations to the encryption process. A designs a new encryption method:
Assume that the number A wants is 375 and encrypts it:
B gets the result 120943, but he can hardly calculate the key 375 based on 120943.
If B wants to verify whether A is lying:
Finally it's time to flip the coin...
This encryption method that loses part of the information is called "one-way encryption", also called hash algorithm.
There is a problem:
This is possible, but it can be solved by increasing the difficulty of the above algorithm so that A is difficult to find.
According to the above statement, a reliable hash algorithm should satisfy:
The hash function in cryptography has three important properties, namely collision resistance and irreversibility of the preimage. , problem friendliness.
Collision means that student A can find out an odd and an even number in advance to make the hash results consistent, which is computationally infeasible.
First of all, if the news about the large space sauna is compressed into a small space, there will definitely be a collision. Assume that the length of the hash value is fixed to 256 bits. If the order is 1, 2,...2 256 + 1, these 2 256 + 1 input values, and the hash values are calculated one by one, you will definitely be able to find two input values that make the hash The values are the same.
Student A, when you see this, please don’t be too happy too early. Because you have to have time to figure it out before it's yours. Why do you say that?
According to the birthday paradox, if 2 130 +1 inputs are randomly selected, there is a 99.8% probability of finding at least one pair of collision inputs. Then for a hash function with a hash value length of 256 bits, an average of 2128 hash calculations need to be completed to find the collision pair. If a computer performed 10,000 hash calculations per second, it would take approximately 10 27 years to complete 2 128 hash calculations.
Student A, don’t think about cheating, I guess you won’t live this long. Of course, it is possible if computer computing power is greatly improved.
So what other uses does integrity have?
Used to verify the integrity of the information, because if the information is not tampered with during transmission, the hash value obtained by running the hash calculation will be different from the original hash value.
Therefore, in the blockchain, the collision resistance of the hash function can be used to verify the integrity of blocks and transactions.
Because a hash value corresponds to countless plaintexts, theoretically you don't know which one it is. For example, the results of 4+5=9 and 2+7=9 are the same. I know that the result I entered is 9, but can I know what number I entered?
If, when performing hash calculation on message m, a random prefix r is introduced, and based on the hash value H(r||m), it is difficult to recover message m, which means that the hash function The value hides message m.
Therefore, student B, it is impossible to deduce the original data based on the results. It is like finding a needle in a haystack.
Problem friendliness means that there is no convenient way to generate a hash value that meets special requirements.What does it mean? In layman's terms, there is no shortcut, you need to figure it out step by step. If the required hash result starts with several 0s, then the number of hash calculations required to find a hash value with the first 3 digits all being 0 and a hash value with the first 6 digits all being 0 is a certain number. Quantitative relationship.
How can this be used? In the blockchain, it can be used as proof of work in the consensus algorithm.
Mainly describes three important properties of the hash function: collision resistance, preimage irreversibility, and problem friendliness.
Because of these important properties, functions such as integrity verification of blocks and transactions in the blockchain and workload proof of the consensus algorithm are implemented using hash functions.
[1]. Zou Jun, Zhang Haining. Blockchain Technology Guide [M]. Beijing: Mechanical Press, 2016.11
[2]. Chang Chai, Han Feng. Blockchain From digital currency to credit society [M]. Beijing: CITIC Press, 2016.7
[3]. Zhang Jian. Blockchain defines the new future financial and economic landscape [M]. Beijing: Machinery Industry Press, 2016.6
⑶ How does Heshu Software blockchain technology achieve digital encryption
Blockchain refers to the collective maintenance of a reliable database through decentralization and trustlessness. technical solutions. This technical solution mainly allows any number of nodes participating in the system to associate and generate a series of data blocks (blocks) using cryptographic methods. Each data block contains all the information exchange data of the system within a certain period of time, and generates The data fingerprint is used to verify the validity of its information and chain to the next database block.
Blockchain technology originated from Bitcoin. Its essence is to use computer algorithms and cryptography to create a decentralized digital currency system to realize the issuance and transaction functions of currency.
Characteristics of blockchain technology:
1. Decentralized: The entire network has no centralized hardware or management organization, and the rights and obligations between any nodes are equal, and any The damage or loss of one node will not affect the operation of the entire system. Therefore, the blockchain system can also be considered to have excellent robustness.
2. Trustless: Data exchange between each node participating in the entire system does not require mutual trust. The operating rules of the entire system are open and transparent, and all data contents are also open and transparent. It is public, so within the rule range and time range specified by the system, nodes cannot and cannot deceive other nodes.
3. Collectively maintain: The data blocks in the system are jointly maintained by all nodes with maintenance functions in the entire system, and these nodes with maintenance functions can be participated by anyone.
4. ReliableDatabase (Reliable Database): The entire system will be divided into databases so that each participating node can obtain a copy of the complete database. Unless more than 51% of the nodes in the entire system can be controlled at the same time, modifications to the database on a single node are invalid and cannot affect the data content on other nodes. Therefore, the more nodes and stronger computing power participating in the system, the higher the data security in the system.
The four characteristics will lead to two other characteristics:
5. Open Source: Since the operating rules of the entire system must be open and transparent, for the program, the entire system must It's open source.
6. Anonymity: Since nodes do not need to trust each other, there is no need to disclose their identities between nodes. Each participating node in the system is anonymous.
Encrypted digital asset EGD: E-Gold Coin, referred to as EGD, is a network encrypted digital asset based on the peer-to-peer Internet open source protocol. It circulates in a decentralized network system. As a consumer asset that global business consumers receive from merchants, EGD is used to replace the points issued by merchants in traditional commercial society, realizing the network, integration and assetization of global business points.
EGD, Internet gold, is an encrypted digital asset generated based on decentralized digital encryption technology. EGD was born in January 2014 and was developed by a team of 17 technical experts from 7 countries around the world, headed by a former Microsoft engineer. EGD has introduced encrypted digital asset technology into the field of global commercial unified points, allowing global consumers to continue to share the profits of the commercial society through the circulation and value-added of EGD commercial points, creating a win-win economic model for merchants and consumers.
Features of customized EGD:
Using customized technology, we can easily build a variety of smart assets based on the EGD protocol, including stocks, bonds, or various derivative points, etc.
More importantly, while customization technology expands the application scope of EGD, it still retains the characteristics of clear property rights and decentralization of EGD. Moreover, because the number of customization points is limited, customization points are even more scarce.
⑷ What you must understand is the blockchain digital signature mechanism
The blockchain uses the Hash function to ensure that transaction information and address information cannot be tampered with, ensuring the integrity of the data transmission process. Integrity, but the Hash function cannot achieve non-repudiation of transaction information (also known as non-repudiation and non-repudiation). It means that during the information interaction process, both parties in the network communication are convinced that the participants themselves and the information provided are true and identical, that is, all Participants cannot deny or deny their true identity, as well as the authenticity of the information provided and the completed operations and commitments.). Blockchain uses the digital signature mechanism in public key encryption technology to ensure the non-repudiation of information.
Digital signature mainly includes signature algorithm and verification algorithm. In the signature algorithm, the signer uses his private key to perform a signature operation on the electronic file to obtain the signature ciphertext of the electronic file; in the verification algorithm, the verifier uses the signer's public key to verify the signature ciphertext of the electronic file. operation, and determines the legality of the signature file based on the results of the verification algorithm. During the signing process, only the signer knows his or her private key, and any person who does not know his or her private key cannot forge or correctly sign an electronic document; during the verification process, only a legitimate signed electronic document can effectively pass verification, and any illegal signature None of the files satisfy its validation algorithm.
Commonly used digital signature algorithms include RSA digital signature, DSA digital signature, ECDSA digital signature, Schnorr digital signature and other algorithms.
We will introduce it with RSA digital signature: People may ask what is the difference between RSA signature and encryption? Encryption and signing are both for security reasons, but are slightly different. People often ask whether to use private keys or public keys for encryption and signatures? In fact, they are all confused about the role of encryption and signature. Simply put, encryption is to prevent information from being leaked, and signature is to prevent information from being tampered with.
Example: After A receives the message from B, it needs to reply "received" - RSA signature process:
First: A generates a pair of keys (public key and private key), the private key is not made public and A keeps it to himself. The public key is public and can be obtained by anyone.
Then: A signs the message with its own private key to form a signature, and passes the signed message and the message itself to B.
Finally: After B receives the message, it obtains A's public key to verify the signature. If the content of the signature is consistent with the message itself, it proves that the message is replied by A.
In this process, there are only 2 transfer processes.The first time is when A delivers the signed message and the message itself to B, and the second time is when B obtains A's public key. Even if both are intercepted by the enemy, there is no danger, because only A's private key can sign the message. , even if the message content is known, it cannot forge a signed reply to B, preventing the tampering of the message content.
In summary, from books and the Internet, we have an intuitive understanding.
⑸ Blockchain encryption technology
Digital encryption technology is the key to the application and development of blockchain technology. Once the encryption method is cracked, the data security of the blockchain will be challenged, and the tamperability of the blockchain will no longer exist. Encryption algorithms are divided into symmetric encryption algorithms and asymmetric encryption algorithms. Blockchain primarily uses asymmetric encryption algorithms. Public key cryptography systems in asymmetric encryption algorithms are generally divided into three categories according to the problems they are based on: large integer differentiation problems, discrete logarithm problems and elliptic curve problems. First, introduce blockchain encryption technology. Encryption algorithms are generally divided into symmetric encryption and asymmetric encryption. Asymmetric encryption refers to encryption technology integrated into the blockchain to meet security requirements and ownership verification requirements. Asymmetric encryption usually uses two asymmetric keys, called public and private keys, in the encryption and decryption process. Asymmetric key pairs have two characteristics: First, after one key (public key or private key) encrypts information, it can only decrypt the other corresponding key. Second, the public key can be disclosed to others, while the private key is kept confidential, and others cannot calculate the corresponding private key through the public key. Asymmetric encryption is generally divided into three main types: large integer differentiation problems, discrete logarithm problems and elliptic curve problems. The problem class of large integer differentiation refers to using the product of two large prime numbers as the encrypted number. Since the appearance of prime numbers is irregular, solutions can only be found through constant trial calculations. The discrete logarithm problem class refers to an asymmetric distributed encryption algorithm based on the difficulty of discrete logarithms and strong one-way hash functions. Elliptic curve refers to the use of planar elliptic curves to calculate a set of asymmetric special values. Bitcoin uses this encryption algorithm. The application scenarios of asymmetric encryption technology in blockchain mainly include information encryption, digital signature and login authentication. (1) In the information encryption scenario, the sender (denoted as A) encrypts the information with the public key of the receiver (denoted as B) and sends it to
B, who uses his own private key Decrypt the information. Encryption of Bitcoin transactions falls into this scenario. (2) In the digital signature scenario, sender A uses its own private key to encrypt the information and sends it to B. B uses A's public key to decrypt the information and then ensures that the information was sent by A. (3) In the login authentication scenario, the client uses the private key to encrypt the login information and sends it to the server. The server then uses the client's public key to decrypt the authenticated login information. Please note the differences between the above three encryption schemes: information encryption is public key encryption and private key decryption, ensuring the security of the information; digital signature is private key encryption and public key decryption, ensuring the ownership of the digital signature. Authenticated private key encryption and public key decryption. To compareTake the Bitcoin system as an example. Its asymmetric encryption mechanism is shown in Figure 1: The Bitcoin system generally generates a 256-bit random number as a private key by calling the random number generator at the bottom of the operating system. The total number of Bitcoin's private keys is large, and it is extremely difficult to traverse all private key spaces to obtain Bitcoin's private keys, so cryptography is safe. In order to facilitate identification, the 256-bit binary Bitcoin private key will be converted through the SHA256 hash algorithm and Base58 to form a 50-character long private key, which is easy for users to identify and write. Bitcoin's public key is a 65-byte random number generated by the private key through the Secp256k1 elliptic curve algorithm. Public keys can be used to generate addresses used in Bitcoin transactions. The generation process is that the public key is first hashed through SHA256 and RIPEMD160 to generate a 20-byte summary result (that is, the result of Hash160), and then converted through the SHA256 hash algorithm and Base58 to form a 33-character Bitcoin address. The public key generation process is irreversible, that is, the private key cannot be derived from the public key. Bitcoin’s public and private keys are usually stored in Bitcoin wallet files, with the private key being the most important. Losing the private key means losing all the Bitcoin assets of the corresponding address. In the existing Bitcoin and blockchain systems, multi-private key encryption technology has been derived based on actual application requirements to meet more flexible and complex scenarios such as multi-signatures.
⑹ [In-depth knowledge] Illustration of the encryption principle of the blockchain (encryption, signature)
First put an architecture diagram of Ethereum:
In The learning process mainly uses a single module to learn and understand, including P2P, cryptography, network, protocols, etc. Let’s start with the summary directly:
The problem of secret key distribution is also the problem of secret key transmission. If the secret key is symmetric, then the secret key can only be exchanged offline. If the secret key is transmitted online, it may be intercepted. Therefore, asymmetric encryption is used, with two keys, one private key is kept privately, and the other public key is made public. Public keys can be transmitted over the Internet. No offline transactions required. Ensure data security.
As shown in the figure above, node A sends data to node B, and public key encryption is used at this time. Node A obtains the public key of node B from its own public key, encrypts the plaintext data, and sends the ciphertext to node B. Node B uses its own private key to decrypt.
2. Unable to solve message tampering.
As shown in the figure above, node A uses B's public key to encrypt, and then transmits the ciphertext to node B. Node B uses the public key of node A to decrypt the ciphertext.
1. Since A’s public key is public, once an online hacker intercepts the messageInformation, the cipher text is in name only. To put it bluntly, this encryption method can be decrypted as long as the message is intercepted.
2. There is also the problem of being unable to determine the source of the message and the problem of message tampering.
As shown in the figure above, before sending data, node A first encrypts it with B's public key to obtain ciphertext 1, and then uses A's private key to encrypt ciphertext 1 to obtain ciphertext 2. After node B obtains the ciphertext, it first decrypts it using A's public key to obtain ciphertext 1, and then decrypts it using B's private key to obtain the plaintext.
1. When data ciphertext 2 is intercepted on the network, since A's public key is public, you can use A's public key to decrypt ciphertext 2 and obtain ciphertext 1. So this seems to be double encryption, but in fact the private key signature of the last layer is invalid. Generally speaking, we all hope that the signature is signed on the most original data. If the signature is placed later, the signature lacks security since the public key is public.
2. There are performance issues. Asymmetric encryption itself is very inefficient, and two encryption processes are performed.
As shown in the figure above, node A is first encrypted with A's private key, and then encrypted with B's public key. After receiving the message, node B first uses B's private key to decrypt it, and then uses A's public key to decrypt it.
1. When ciphertext data 2 is intercepted by a hacker, since ciphertext 2 can only be decrypted using B’s private key, and B’s private key is only owned by node B, others cannot keep it secret. Therefore, the safety is the highest.
2. When node B decrypts and obtains ciphertext 1, it can only use A’s public key to decrypt it. Only data encrypted by A's private key can be successfully decrypted with A's public key. Only node A has A's private key, so it can be determined that the data was transmitted by node A.
After two asymmetric encryptions, the performance problem is serious.
Based on the above problem of data tampering, we introduced message authentication. The encryption process after message authentication is as follows:
Before node A sends a message, it first performs a hash calculation on the plaintext data. A digest is obtained, and then the illumination and original data are sent to Node B at the same time. When node B receives the message, it decrypts the message. Parse out the hash digest and original data, then perform the same hash calculation on the original data to obtain digest 1, and compare the digest and digest 1. If they are the same, they have not been tampered with; if they are different, they have been tampered with.
As long as ciphertext 2 is tampered with during the transmission process, the resulting hash will be different from hash1.
The signature problem cannot be solved, that is, both parties attack each other.hit. A never acknowledges the message he sent. For example, A sends an error message to B, causing B to suffer losses. But A denied that he did not send it himself.
In the process of (3), there is no way to solve the problem of mutual attacks between the two interacting parties. What does that mean? It may be that the message sent by A is not good for node A, and later A denies that the message was not sent by it.
In order to solve this problem, signatures were introduced. Here we combine the encryption method in (2)-4 with the message signature.
In the above figure, we use node A's private key to sign the summary information sent by it, then add the signature + original text, and then use B's public key to encrypt. After B obtains the ciphertext, he first uses B's private key to decrypt it, and then uses A's public key to decrypt the digest. Only the content of the two digests is compared to see if they are the same. This not only avoids the problem of anti-tampering, but also circumvents the problem of attacks from both parties. Because A signed the information, it cannot be repudiated.
In order to solve the performance problem when asymmetrically encrypting data, hybrid encryption is often used. Here we need to introduce symmetric encryption, as shown below:
When encrypting data, we use a symmetric secret key shared by both parties to encrypt. The symmetric secret key should not be transmitted on the network to avoid loss. The shared symmetric key here is calculated based on one's own private key and the other party's public key, and then the symmetric key is used to encrypt the data. When the other party receives the data, it also calculates the symmetric secret key and decrypts the ciphertext.
The above symmetric secret key is unsafe because A's private key and B's public key are generally fixed in the short term, so the shared symmetric secret key is also fixed. To enhance security, the best way is to generate a temporary shared symmetric key for each interaction. So how can we generate a random symmetric key during each interaction without transmitting it?
So how to generate a random shared secret key for encryption?
For the sender node A, a temporary asymmetric secret key pair is generated every time it is sent, and then a symmetric secret key can be calculated based on the public key of node B and the temporary asymmetric private key. (KA algorithm-Key Agreement). The symmetric secret key is then used to encrypt the data. The process here for the shared secret key is as follows:
For node B, when receiving the transmitted data, the random public key of node A is parsed. Then the symmetric secret key (KA algorithm) is calculated using the random public key of node A and the private key of node B itself. Later use theCalled the secret key confidential data.
For the above encryption methods, there are still many problems, such as how to avoid replay attacks (adding Nonce to the message), and problems such as rainbow tables (refer to the KDF mechanism to solve). Due to limited time and ability, I will ignore it for now.
So what kind of encryption should be used?
Mainly based on the security level of the data to be transmitted. Unimportant data can actually be authenticated and signed, but very important data needs to use an encryption scheme with a relatively high security level.
Cipher suite is a concept of network protocol. It mainly includes algorithms for identity authentication, encryption, message authentication (MAC), and secret key exchange.
During the entire network transmission process, algorithms are mainly divided into the following categories according to cipher suites:
Secret key exchange algorithms: such as ECDHE, RSA. Mainly used for authentication when the client and server handshake.
Message authentication algorithm: such as SHA1, SHA2, SHA3. Mainly used for message summarization.
Batch encryption algorithm: such as AES, mainly used to encrypt information flow.
Pseudo-random number algorithm: For example, the pseudo-random function of TLS 1.2 uses the hash function of the MAC algorithm to create a master key - a 48-byte private key shared by both parties in the connection. The master key serves as a source of entropy when creating session keys (such as creating a MAC).
In the network, a message transmission generally needs to be encrypted in the following four stages to ensure safe and reliable transmission of the message.
Handshake/network negotiation phase:
During the handshake phase between both parties, link negotiation is required. The main encryption algorithms include RSA, DH, ECDH, etc.
Identity authentication phase:
In the identity authentication phase, the source of the sent message needs to be determined. The main encryption methods used include RSA, DSA, ECDSA (ECC encryption, DSA signature), etc.
Message encryption stage:
Message encryption refers to encrypting the sent information flow. The main encryption methods used include DES, RC4, AES, etc.
Message identity authentication phase/anti-tampering phase:
Mainly to ensure that the message has not been tampered with during transmission. The main encryption methods include MD5, SHA1, SHA2, SHA3, etc.
ECC: Elliptic Curves Cryptography, elliptical curveLine cryptography. It is an algorithm that generates public and private keys based on point multiple products on ellipses. Used to generate public and private keys.
ECDSA: used for digital signatures and is a digital signature algorithm. A valid digital signature gives the recipient reason to believe that the message was created by a known sender, so that the sender cannot deny that the message has been sent (authentication and non-repudiation), and that the message has not been altered in transit. The ECDSA signature algorithm is a combination of ECC and DSA. The entire signature process is similar to DSA. The difference is that the algorithm used in the signature is ECC, and the final signed value is also divided into r and s. Mainly used in the identity authentication phase.
ECDH: It is also a Huffman tree secret key based on the ECC algorithm. Through ECDH, both parties can negotiate a shared secret without sharing any secrets, and this shared secret key is the current The communication is temporarily generated randomly, and the secret key disappears once the communication is interrupted. Mainly used in the handshake negotiation phase.
ECIES: is an integrated encryption scheme, also known as a hybrid encryption scheme, which provides semantic security against selected plaintext and selected ciphertext attacks. ECIES can use different types of functions: key agreement function (KA), key derivation function (KDF), symmetric encryption scheme (ENC), hash function (HASH), H-MAC function (MAC).
ECC is an elliptical encryption algorithm, which mainly describes how the public and private keys are generated on the ellipse, and is irreversible. ECDSA mainly uses the ECC algorithm to make signatures, while ECDH uses the ECC algorithm to generate symmetric keys. All three of the above are applications of the ECC encryption algorithm. In real-world scenarios, we often use hybrid encryption (a combination of symmetric encryption, asymmetric encryption, signature technology, etc.). ECIES is a set of integrated (hybrid) encryption solutions provided by the underlying ECC algorithm. This includes asymmetric encryption, symmetric encryption and signature functions.
<meta charset="utf-8">
This precondition is to ensure that the curve does not contain singular points .
Therefore, as the curve parameters a and b continue to change, the curve also shows different shapes. For example:
The basic principles of all asymmetric encryption are basically based on a formula K = k G. Among them, K represents the public key, k represents the private key, and G represents a selected base point. The asymmetric encryption algorithm is to ensure that the formula cannot be inverted (that is, G/K cannot be calculated). *
How does ECC calculate the public and private keys? Here I describe it according to my own understanding.
I understand that the core idea of ECC is to select a base point G on the curve, then randomly pick a point k on the ECC curve (as the private key), and then calculate our public key based on k G K. And ensure that the public key K is also on the curve. *
So how to calculate k G? How to calculate k G to ensure that the final result is irreversible? This is what the ECC algorithm is supposed to solve.
First, we randomly select an ECC curve, a = -3, b = 7 and get the following curve:
On this curve, I randomly select two points. How to calculate the multiplication of points? We can simplify the problem. Multiplication can be expressed by addition, such as 2 2 = 2+2, 3 5 = 5+5+5. Then as long as we can calculate addition on the curve, we can theoretically calculate multiplication. Therefore, as long as addition calculations can be performed on this curve, multiplication can be calculated theoretically, and the value of expressions such as k*G can also be calculated theoretically.
How to calculate the addition of two points on the curve? Here, in order to ensure irreversibility, ECC has customized an addition system on the curve.
In reality, 1+1=2, 2+2=4, but in the ECC algorithm, the addition system we understand is impossible. Therefore, it is necessary to customize a set of addition systems suitable for this curve.
The definition of ECC is to randomly find a straight line in the graph and intersect the ECC curve at three points (or possibly two points). These three points are P, Q, and R respectively.
Then P+Q+R = 0. Among them, 0 is not the 0 point on the coordinate axis, but the infinity point in ECC. In other words, the infinity point is defined as point 0.
Similarly, we can get P+Q = -R. Since R and -R are symmetrical about the X-axis, we can find their coordinates on the curve.
P+R+Q = 0, so P+R = -Q, as shown in the figure above.
The above describes how addition operations are performed in the world of ECC curves.
As can be seen from the above figure, there are only two intersection points between a straight line and a curve, which means that the straight line is the tangent line of the curve. At this time, P and R coincide.
That is, P = R. According to the above-mentioned ECC addition system, P+R+Q = 0, it can be concluded that P+R+Q = 2P+Q = 2R+Q=0
So we get 2 P = -Q (is it getting closer to the formula K = k G of our asymmetric algorithm?).
So we come to the conclusion that multiplication can be calculated, but it can only be calculated at the tangent point, and it can only be calculated by 2.
If 2 can be turned into any number for multiplication, then it means that multiplication can be performed in the ECC curve, then the ECC algorithm can meet the requirements of an asymmetric encryption algorithm.
So can we calculate the multiplication of any random number? The answer is yes. That is the dot product calculation method.
Choose a random number k, then what is k * P equal to?
We know that in the computer world, everything is binary. Since ECC can calculate the multiplication of 2, we can describe the random number k as binary and then calculate it. Suppose k = 151 = 10010111
Since 2 P = -Q, so k P is calculated. This is the dot product algorithm. Therefore, multiplication can be calculated under the ECC curve system, so this asymmetric encryption method is feasible.
As for why this calculation is irreversible. This requires a lot of deduction, and I don't understand it either. But I think it can be understood this way:
Our watches usually have time scales. Now if we take 0:00:00 on January 1, 1990 as the starting point, and if we tell you that a full year has passed until the starting point, then we can calculate the current time, that is, we can calculate it on the watch. The hour, minute and second hands should point to 00:00:00. But conversely, I said that the hour, minute and second hands on the watch are now pointing to 00:00:00. Can you tell me how many years have passed since the starting point?
The ECDSA signature algorithm is basically similar to other DSA and RSA, both using private key signature and public key verification. It’s just that the algorithm system uses the ECC algorithm. Both parties interacting must adopt the same set of parameter systems. The signature principle is as follows:
Select on the curveTake an infinite point as the base point G = (x,y). Randomly pick a point k on the curve as the private key, and K = k*G to calculate the public key.
Signature process:
Generate a random number R and calculate RG.
According to the random number R, the HASH value H of the message M, and the private key k, Calculate the signature S = (H+kx)/R.
Send the message M, RG, S to the receiver.
Signature verification process:
Receive message M, RG, S
Calculate the HASH value H according to the message
According to the sender For the public key K, calculate HG/S + xK/S, and compare the calculated result with RG. If equal, the verification is successful.
Formula inference:
HG/S + xK/S = HG/S + x(kG)/S = (H+xk)/GS = RG
< p> Before introducing the principle, explain that ECC satisfies the associative law and the commutative law, that is to say, A+B+C = A+C+B = (A+C)+B.Here is an example on WIKI to illustrate how to generate a shared secret key. You can also refer to the example of Alice And Bob.
For Alice and Bob to communicate, both parties must have public and private keys generated by ECC based on the same parameter system. So there is a common base point G for ECC.
Secret key generation stage:
Alice uses the public key algorithm KA = ka * G, generates the public key KA and the private key ka, and makes the public key KA public.
Bob uses the public key algorithm KB = kb * G, generates the public key KB and the private key kb, and makes the public key KB public.
Calculation ECDH stage:
Alice uses the calculation formula Q = ka * KB to calculate a secret key Q.
Bob uses the calculation formula Q' = kb * KA to calculate a secret key Q'.
Shared key verification:
Q = ka KB = ka * kb * G = ka * G * kb = KA * kb = kb * KA = Q'
Therefore, the shared secret keys calculated by both parties do not need to be disclosed before they can be encrypted using Q. We call Q the shared secret key.
In Ethereum, other contents of the ECIEC encryption suite used:
1. The HASH algorithm uses the most secure SHA3 algorithm Keccak.
2. The signature algorithm uses ECDSA
3. The authentication method uses H-MAC
4. The ECC parameter system uses secp256k1, others The parameter system can be found here
The whole process of H-MAC is called Hash-based Message Authentication Code. Its model is as follows:
In Ethereum's UDP communication (RPC communication encryption methods are different), then The above implementation method is adopted and extended.
First of all, the structure of Ethereum's UDP communication is as follows:
Among them, sig is the signature information encrypted by the private key. mac can be understood as a summary of the entire message, ptype is the event type of the message, and data is the RLP-encoded transmission data.
The entire encryption, authentication, and signature model of UDP is as follows: