Message signature of blockchain
"blockchain is equivalent to this account book, and the block is equivalent to a page of this account book. The information carried in the block is the transaction content recorded on this page. The blockchain is block by block, and each block is filled with transaction records and connected together to form a chain, which is called blockchain. "
take bitcoin as an example, there is a "power race" every ten minutes to compete for the right to charge. It's like saying that you have a lot of calculation power, just like your muscles are stronger and more capable of fighting. Everyone will convince you to keep this account, that is, the right to write a block (note that it is not the content in the block) to the general ledger of the blockchain. However, it should be noted that computing power can only determine the probability of winning the competition. For example, there are several lotteries in total, and those with more computing power can buy more to improve the winning probability. However, those who buy more may not win the lottery in the end.
blockchain is a data block chain guaranteed by such computing power. Starting from the first block, each block collects data according to certain rules, and then attaches a value to these data, so that the result of the formed data block after similar one-way function calculation falls into a certain range. By estimating the computing power of the whole network and the size of the control result range, the data blocks that meet the requirements can be found in a long enough time. This calculation result will be included by the next block, and the chain data structure formed in this way is called blockchain
each small ledger is called a block, and each different blockchain protocol (generating different cryptocurrency) will specify the size of each block (the initial bitcoin is 1m). The ledger constitutes a block, the block constitutes a chain list, and the block header contains the hash value of the previous block, which is the blockchain. In this way, no one can modify the content or exchange the order at will. If you do, it means you need to recalculate all the special numbers
regulations allow everyone in the world to build blocks. Every person who builds a new block (finds this special number - sha256 value has 30 zeros) can get a reward. For this part of people (miners) who build a new block:
1. There is no sender information, There is no need to sign
2. Each new block will add a new virtual (encrypted) currency to the whole currency
3. The process of building a new block is also called "mining": it requires a lot of work and can inject new currency into the whole economy
4. The work of mining is: receiving transaction information, building blocks, broadcasting blocks, Then get new money as a reward
for each miner, each block is like a small lottery, and everyone is trying to guess the number quickly until a lucky person finds a special number, so that there are many zeros at the beginning of the hash value of the whole block, and they can get a reward. I remember a Zhihu respondent gave an image analogy. Blockchain is like a king with a beautiful daughter (block). Many young people are looking forward to it. The king's method is to give a very difficult topic for all young people to calculate (learning to change their lives), Who can calculate quickly (or be lucky in the process of calculating the hash value) will be able to win the beauty
for users who want to use this system to collect and pay, they don't need to listen to all the transactions, but just listen to the blocks broadcast by the miners, and then update them to their saved blockchain
"block" can also be imagined as a box, There are some digital currencies and a small note in the block, on which the only transaction information generated in the past ten minutes is recorded, such as "small a transferred to small B100 yuan"; Of course, this piece of information must have been encrypted to ensure that only small a and small B (through the key in their hands) have the ability to interpret the real content
after this magical block was created, it was soon buried underground. Where is it buried? No one does not know that all computer nodes need to participate in digging three feet before it is possible to find (find an effective workload proof). Obviously, this is an event with huge workload and random results. However, for the computer node, once the block is g out from the ground, it will get the valuable digital currency in the block, as well as the tip paid by small a in the process of "small a transferred to small B100 yuan". At the same time, for this node, only he has the right to truly record the contents of the note, which is an honor, while other nodes can only use its , a without digital currency blessing. Of course, there are some other special things about this magical block.
the process of computer nodes digging out blocks from underground is called "mining". As I said just now, this is a huge workload, a lot of luck and a lot of profits. A node on zhangheng road in Pudong New Area of Shanghai, China, suddenly jumped out and said excitedly, "I've g the block! The little notes inside are all valid! The reward belongs to me! ". Although Zhang Heng Road node has got digital currency at the moment, for other computer nodes, because it also involves some other interests, they will not choose to believe what Zhang Heng Road node says by default; Based on the principle that strangers do not trust each other, they take the so-called block () g by Zhang Heng Road node, and start to check whether the small note information in the block is true and effective, etc. In the world of blockchain, nodes check the accuracy of the small note information, or indirectly or directly judge whether the node that successfully digs out the block is lying How to define the true and effective information of a small note will be explained later, but I won't go into details here. In the verification process, each node will directly express their identification (accurate) and attitude towards zhangheng road node through the following two behaviors: stop half or even 80% of the mining process; Add the block () g out by zhangheng road node to the end of its own blockchain. You can be a little confused: if you stop mining, you may have done 80% of the mining work. Then 80% of the previous work is in vain?! Then, what the hell is at the end of the blockchain? For the first puzzle. I want to say that what you said is right, but there is no way. The reality is so cruel. Even if 80% of the work is done, you have to give up. The 80% of the work can be regarded as useless, absolutely damaging the wealth and the masses. The second puzzle is, what is the ghost at the end of blockchain and blockchain? Here, it is not clear in advance, but you can simply imagine: blocks are generated and g out periodically, and a computer node may have executed "take blocks from others" n times in advance; The process of "checking the validity of small notes" must have stored n blocks on its own node, and these blocks will be arranged in a chain in order of time. Yes, this chain is what you always think of as the blockchain. If you still can't understand, it doesn't matter. There will be many opportunities for in-depth study later in the article
go into the more microcosmic world of the block and have a look at what the little note really is, how it came into being and its mission all its life: when initiating a transaction, the initiator will receive a little note, and he needs to write the transaction record, such as "stealing transfer to a piece of RMB 340" on the paper. It's amazing that when it's finished, on the back of the note, the transaction record will be automatically formatted to at least contain the two important fields of "input value" and "output value"“ Input value is used to record the effective source of digital currency, and output value is used to record the object to which digital currency is sent. The newly created note is immediately marked as an "unconfirmed" note. Small pieces of paper that are successfully g out of the ground and eventually connected to the blockchain are initially marked as "valid.". If the valid slip is used as the input value of other transactions, the valid slip will soon be marked as invalid. Due to various reasons, the block is disconnected and discarded from the chain, and the small notes once marked as "valid" in the block will be re marked as "unconfirmed". There is no concept of account balance in the blockchain. The digital asset you really own is actually a piece of transaction information; Get the balance in your digital wallet by simple addition and subtraction. The above 1, 2 and 3 are just the knowledge points forced to you at the beginning. Some of the descriptions may be a bit confusing, which makes you feel confused. Only by understanding the whole blockchain can you have a more comprehensive understanding of the mystery
block capacity. Bitcoin specifies that the block capacity is 1m when it is created, or in the source code. The reason why it was originally designed as 1m is, on the one hand, to prevent DoS attacks. On the other hand, when Zhongben Cong created the blockchain, the capacity was 32m. However, he changed the block capacity to 1m through a humble commit like "clear up". In order to prevent the volume of the blockchain from growing too fast, he added some mystery to the problem of block capacity. The capacity of 1m means that the maximum number of transactions processed by bitcoin is about 2400 (the size of 486882 block 1034.39 is very close)
to put it bluntly, blockchain is a small book for distributed bookkeeping, a tool for bookkeeping, and based on cryptography and cryptography technology, once data transactions are recorded in the book of blockchain, data can not be tampered with and denied. The Internet is the transmission of value, and the blockchain is the transmission of trust. Under the premise of blockchain technology as a credit endorsement, each node in the blockchain changes from a single center to a unified multi center with multi-party participation, which can achieve transaction transmission without the participation of a third party organization and improve the efficiency
in fact, blockchain uses the basic principles of modern cryptography to ensure its security mechanism. The knowledge system involved in the field of cryptography and security is very complicated. Here, I only introce the basic knowledge of cryptography related to blockchain, including hash algorithm, encryption algorithm, information digest and digital signature, zero knowledge proof, quantum cryptography, etc. Through this lesson, you can learn how to ensure the confidentiality, integrity, authentication and non repudiation of the blockchain using cryptography technology
basic course lesson 7 basic knowledge of blockchain security
1. Hash algorithm (hash algorithm)
hash function (hash), also known as hash function. Hash function: hash (original information) = summary information. Hash function can map any length of binary plaintext string to a shorter (generally fixed length) binary string (hash value)
a good hash algorithm has the following four characteristics:
1. One to one correspondence: the same plaintext input and hash algorithm can always get the same summary information output
2. Input sensitivity: even if the plaintext input changes slightly, the newly generated summary information will change greatly, which is greatly different from the original output
3. Easy to verify: plaintext input and hash algorithm are public, anyone can calculate by themselves, and whether the output hash value is correct
4. Irreversibility: if there is only the output hash value, the hash algorithm can never dece the plaintext
5. Conflict avoidance: it is difficult to find two plaintexts with different contents, but their hash values are the same (collision)
for example:
hash (Zhang San lent Li Si 100000 yuan for 6 months) = 123456789012
such a record as 123456789012 is recorded in the account book
it can be seen that hash function has four functions:
simplify information
it is easy to understand, and the information after hashing becomes shorter
identification information
you can use 123456789012 to identify the original information, and summary information is also called the ID of the original information
hidden information
the account book is a record like 123456789012, and the original information is hidden
verification information
if Li Si cheated that Zhang San only lent Li Si 50000 when repaying, both parties can verify the original information with the hash value of 123456789012 recorded before
hash (Zhang San lent Li Si 50000 for 6 months) = 987654321098
987654321098 is completely different from 123456789012, which proves that Li Si lied, Then the information can't be tampered
common hash algorithms include MD4, MD5 and Sha series algorithms, and Sha series algorithms are basically used in mainstream fields. Sha (secure hash algorithm) is not an algorithm, but a group of hash algorithms. At first, it was SHA-1 series, and now the mainstream applications are sha-224, SHA-256, sha-384 and sha-512 algorithms (commonly known as SHA-2). Recently, Sha-3 related algorithms have been proposed, such as keccak-256 used by Ethereum
MD5 is a very classic hash algorithm, but unfortunately, both it and SHA-1 algorithm have been cracked. It is considered by the instry that its security is not enough to be used in business scenarios. Generally, sha2-256 or more secure algorithm is recommended
hash algorithm is widely used in blockchain. For example, in blocks, the latter block will contain the hash value of the previous block, and the content of the later block + the hash value of the previous block will jointly calculate the hash value of the later block, which ensures the continuity and non tamperability of the chain< Encryption and decryption algorithm is the core technology of cryptography, which can be divided into two basic types: symmetric encryption algorithm and asymmetric encryption algorithm. According to whether the key used in the encryption and decryption process is the same or not, the two modes are suitable for different needs, just forming a complementary relationship, and sometimes can be combined to form a hybrid encryption mechanism
symmetric cryptography (also known as common key cryptography) has the advantages of high computational efficiency and high encryption strength; Its disadvantage is that it needs to share the key in advance, which is easy to leak and lose the key. The common algorithms are des, 3DES, AES and so on
asymmetric cryptography (also known as public key cryptography) is different from the encryption and decryption key, and its advantage is that it does not need to share the key in advance; Its disadvantage is that it has low computational efficiency and can only encrypt short content. Common algorithms include RSA, SM2, ElGamal and elliptic curve series. Symmetric encryption algorithm is suitable for the encryption and decryption process of a large number of data; It can't be used in signature scenario: and it often needs to distribute the key in advance. Asymmetric encryption algorithm is generally suitable for signature scenario or key agreement, but it is not suitable for large amount of data encryption and decryption< Third, information digest and digital signature
as the name suggests, information digest is to hash the information content to obtain a unique digest value to replace the original and complete information content. Information digest is the most important use of hash algorithm. Using the anti-collision feature of hash function, information digest can solve the problem that the content has not been tampered
digital signature is similar to signing on paper contract to confirm contract content and prove identity. Digital signature is based on asymmetric encryption, which can be used to prove the integrity of a digital content and confirm the source (or non repudiation)
we have two requirements for digital signature to make it consistent with our expectation for handwritten signature. First, only you can make your own signature, but anyone who sees it can verify its validity; Second, we want the signature to be only related to a specific file and not support other files. These can be achieved by our asymmetric encryption algorithm above
in practice, we usually sign the hash value of information instead of the information itself, which is determined by the efficiency of asymmetric encryption algorithm. Corresponding to the blockchain, it is to sign the hash pointer. In this way, the front is the whole structure, not just the hash pointer itself< Zero knowledge proof means that the verifier can make the verifier believe that a certain conclusion is correct without providing any additional information to the verifier
zero knowledge proof generally meets three conditions:
1. Completeness: authentic proof can make the verifier successfully verify
2. Soundness: false proof can not make the verifier pass the verification
3. Zero knowledge: if you get proof, you can't get any information other than the proof information from the proof process< With more and more attention paid to the research of quantum computing and quantum communication, quantum cryptography will have a huge impact on the information security of cryptography in the future
the core principle of quantum computing is that qubits can be in multiple coherent superposition states at the same time. Theoretically, a large amount of information can be expressed by a small number of qubits and processed at the same time, which greatly improves the computing speed
in this way, a large number of current encryption algorithms are theoretically unreliable and can be cracked, so the encryption algorithm has to be upgraded, otherwise it will be broken by quantum computing
as we all know, quantum computing is still in the theoretical stage, which is far from large-scale commercial use. However, the new generation of encryption algorithms should consider the possibility of this situation.
isolation witness is a method of blockchain expansion, which has been successfully implemented on lightcoin and bitcoin
at present, each block in the blockchain not only records the specific information of each transfer transaction, that is, at which time point the account receives or transfers out how many bitcoins, but also contains the digital signature of each transaction, which is used to verify the legitimacy of the transaction. The miner needs to verify each transaction one by one with digital signature when packing the block. After confirming that there is no problem, the transaction will be recorded in the block
however, for ordinary users, they only care about the number of assets in each account, and do not need to verify each transaction one by one. Isolation witness is to take out the digital signature information in the block, so that each block can carry more transactions, so as to achieve the purpose of expansion.
in the distributed network of blockchain, the communication and trust between nodes need to rely on digital signature technology, which mainly realizes the identity confirmation and information authenticity and integrity verification
digital signature
digital signature (also known as public key digital signature, electronic signature) is a kind of common physical signature written on paper, but it uses the technology in the field of public key encryption to identify digital information. A digital signature usually defines two complementary operations, one for signature and the other for verification. Only the sender of information can proce a digital string which can not be forged by others. This digital string is also an effective proof of the authenticity of the information sent by the sender. Simply prove that "I am who I am."
jump out of the verification interface, click the return button in the upper left corner, and then upgrade to the latest version to refresh the node. Or uninstall again and restore the account with mnemonics Refresh node] in free communication, the + sign in the upper right corner, "node detection & quot;
blockchain is the big ledger of bitcoin network, and each block is equivalent to a page in the ledger. What information is recorded in the "account book"? At present, each block of bitcoin mainly records data such as block head, transaction details, transaction counter and block size
"block header" contains all information except transaction information, mainly including the hash value of the previous block header, which is used to ensure that blocks are connected in sequence; Time stamp: record the generation time of the block; Random number: that is, the answer to the arithmetic problem of PK for all miners in the whole network; Difficulty target: score the difficulty coefficient of the arithmetic problem
"transaction details" records in detail the transferor, income party, amount and digital signature of the transferor of each transaction, which is the main content of each block
"transaction counter" describes the number of transactions contained in each block
"block size" refers to the size of each block data. Currently, each block is limited to 1MB, which does not rule out the possibility of expansion in the future.
through the blockchain, communication services can organize the operation of communication services without the mode of central enterprise. In the future, blockchain should have a real impact on real life, not just by concept and hype, but by real landing procts. What is really landing procts is procts that can meet the needs of users. If the existing centralized procts can well meet the needs of users, then the decentralized procts will not have enough substitution effect, and can not be truly implemented
the protocol layer of blockchain mainly includes four aspects: network programming, distributed algorithm, encrypted signature and data storage technology
the ability of network programming is the main factor for us to choose a programming language, because distributed algorithm is basically the implementation of business logic and can be achieved in any language. The encryption signature technology is directly and simply used, and the database technology is mainly used. Only the implementation of point-to-point network and concurrent processing is the difficulty of development. Therefore, for those languages with strong network programming ability and simple concurrency processing, people especially prefer them
users get the initial number of tokens for free. Some of its practical use scenarios:
1. Encrypted video chat: multinational users want to have video chat, only when both sides hold a certain number of SKM can they achieve encrypted video chat
2. Large capacity file encrypted transmission: the file transmitted by one user to another user exceeds the size limit, and the sender must hold a certain token to realize encrypted transmission
3. Conversation information saving: conversation records can be saved as long as both parties agree, and both parties need to hold a certain amount of tokens
4. Retransmission reminder: if a user sends a file to another user, but he doesn't want the other user to share it, the user can use a certain token to be notified when the file is retransmitted
5. Secret key unlock file: one user transfers the secret key file to another, and only the other party is allowed to view it. The sending user can use the token to let the other party receive the fragmented file. Only by getting the secret key from the sender can the file be unlocked<
the Xueshuo innovation blockchain Technology Workstation of Lianqiao ecation online is the only approved "blockchain Technology Specialty" pilot workstation of "smart learning workshop 2020 Xueshuo innovation workstation" launched by the school planning, construction and development center of the Ministry of ecation of China. Based on providing diversified growth paths for students, the professional station promotes the reform of the training mode of the combination of professional degree research, proction, learning and research, and constructs the applied and compound talent training system.
in order to ensure the data security of users, the blockchain system is implemented through a cryptographic algorithm. Specifically, it is implemented through a public cryptographic algorithm mechanism. We all know how a cryptographic algorithm can have a secret key, and the public secret key algorithm is a pair of (that is, two) secret keys, just like tiger amulet, which are used together. One is called public key, which can be disclosed to others. The private key should be kept by itself. In the blockchain system, the public key is used to identify the identity, and the private key is equivalent to the key to decrypt. But the difference is that a public key is only for a unique private key, that is to say, if you forget the private key, it will not be retrieved for you, In the blockchain system, it will not help you retrieve the private key, so you should keep the private key properly
in the blockchain system structure, the data encrypted with public key must be decrypted with the corresponding private key, while the data encrypted with private key
must be decrypted with the corresponding public key, so the data encrypted with private key (usually called "signature") must be decrypted with the corresponding public key, which can play a great role
for a simple example, if Zhang San wants to send a check to Li Si, how can it be sent? In the past, it would be taken by the bookkeeper, so Zhang San thought of a way. He encrypted the check with Li Si's public key, and then signed his name (signed with his private key). At this time, other people would not use it even if they got the check, because only Li Si had his private key, That is, only Li Si can use this check. This function design is called "script system" in the blockchain system
therefore, the private key encrypted by the blockchain digital signature cannot be decrypted by the original encrypted private key, but must be decrypted by the corresponding public key.
12.4km
take bus 857, pass 20 stops, and reach lianbanwai book city station
walk about 710 meters to the South of lianbanxin village