Position: Home page » Blockchain » Where does blockchain information exist
Where does blockchain information exist
Publish: 2021-05-25 22:18:11
1. const SHA256 = require(crypto-js/SHA256);< br />class Block{
constructor(index,timestamp,data,previousHash=' 39;)< br />{
this.index=index;< br />this.timestamp=timestamp;< br />this.data=data;< br />this.previousHash=previousHash;< br />$this.hash=this.calculateHash();< br />}
calculateHash(){
return SHA256(this,index+this.previousHash+this.timestamp+JSON.stringify(this.data)).tostring();< br />}
}
class blockchain{
constructor(){
this.chain=[this.createGenesisBlock()];<
}
/ / create a generated information block
creategenesis block() {
return new block (0, & quot; 01/01/2019",& quot; Genesis block", 0);
/ / the date is the user's data. In fact, it is the hash value obtained by adding several values together. Here, the information is encrypted and the picture is encrypted. Then the data is still stored in the database, but all the data are hash values. To get this data, you must know the hash value of the previous data block. Then, if the hacker needs to crack all the nodes, the hash value is decrypted, Then all the blocks from the first node to the last node can be decrypted to get the real data. So the security of data stored in the blockchain depends on whether the data is encrypted. If the plaintext is not encrypted, then it is not a blockchain
}
/ / get the last block
getlatesblock() {
return this.chain [this.chain. Length-1]
}
/ / create block
addblock (newblock) {
newblock. Previoushash = this. Getlatesblock(). Hash< br />newBlock.hash=newBlock.calculateHash();< br />this.chain.push(newBlock);< br />}
}
constructor(index,timestamp,data,previousHash=' 39;)< br />{
this.index=index;< br />this.timestamp=timestamp;< br />this.data=data;< br />this.previousHash=previousHash;< br />$this.hash=this.calculateHash();< br />}
calculateHash(){
return SHA256(this,index+this.previousHash+this.timestamp+JSON.stringify(this.data)).tostring();< br />}
}
class blockchain{
constructor(){
this.chain=[this.createGenesisBlock()];<
}
/ / create a generated information block
creategenesis block() {
return new block (0, & quot; 01/01/2019",& quot; Genesis block", 0);
/ / the date is the user's data. In fact, it is the hash value obtained by adding several values together. Here, the information is encrypted and the picture is encrypted. Then the data is still stored in the database, but all the data are hash values. To get this data, you must know the hash value of the previous data block. Then, if the hacker needs to crack all the nodes, the hash value is decrypted, Then all the blocks from the first node to the last node can be decrypted to get the real data. So the security of data stored in the blockchain depends on whether the data is encrypted. If the plaintext is not encrypted, then it is not a blockchain
}
/ / get the last block
getlatesblock() {
return this.chain [this.chain. Length-1]
}
/ / create block
addblock (newblock) {
newblock. Previoushash = this. Getlatesblock(). Hash< br />newBlock.hash=newBlock.calculateHash();< br />this.chain.push(newBlock);< br />}
}
2. How to store information on the blockchain: call the API provided by the blockchain platform
generally, the blockchain platform will provide corresponding interfaces, such as RPC, json-rpc, HTTP, etc. of course, the platforms are not the same, and the degree of friendliness is different
some companies specializing in API, such as blockcypher, can provide friendly calling interfaces, and it is not very convenient to write answers on the mobile phone, Search below
as for the storage content, add a point: in addition to the conventional cloud storage, file entities on the file hash record chain also have blockchain based storage schemes, such as IPFs, storej and so on
generally, the blockchain platform will provide corresponding interfaces, such as RPC, json-rpc, HTTP, etc. of course, the platforms are not the same, and the degree of friendliness is different
some companies specializing in API, such as blockcypher, can provide friendly calling interfaces, and it is not very convenient to write answers on the mobile phone, Search below
as for the storage content, add a point: in addition to the conventional cloud storage, file entities on the file hash record chain also have blockchain based storage schemes, such as IPFs, storej and so on
3. At present, there are still many problems in the practical application of blockchain technology, such as low performance, less transaction frequency per unit time, lack of technology application ecological environment, lack of relevant application cases and fraud in the name of blockchain.
4. Blockchain mainly solves the trust and security problems of transactions, so it proposes four technological innovations to solve this problem:
(1) distributed ledger, that is, transaction bookkeeping is completed by multiple nodes distributed in different places, and each node records complete accounts, so they can participate in monitoring the legitimacy of transactions, At the same time, they can testify together
different from traditional distributed storage, the uniqueness of distributed storage of blockchain is mainly reflected in two aspects: one is that each node of blockchain stores complete data according to block chain structure, while traditional distributed storage generally stores data in multiple copies according to certain rules. Second, the storage of each node in the blockchain is independent and has the same status, which relies on the consensus mechanism to ensure the consistency of storage, while the traditional distributed storage generally synchronizes data from the central node to other backup nodes[ 8]
no single node can record the account data separately, so as to avoid the possibility that a single bookkeeper is controlled or bribed to record false accounts. In theory, unless all the nodes are destroyed, the accounts will not be lost, so as to ensure the security of the account data
(2) asymmetric encryption and authorization technology, the transaction information stored on the blockchain is public, but the account identity information is highly encrypted, which can only be accessed under the authorization of the data owner, thus ensuring the data security and personal privacy
(3) consensus mechanism is how to reach a consensus among all accounting nodes to determine the validity of a record, which is not only a means of identification, but also a means of preventing tampering. Blockchain proposes four different consensus mechanisms, which are suitable for different application scenarios and achieve a balance between efficiency and security
the consensus mechanism of blockchain has the characteristics of "the minority is subordinate to the majority" and "everyone is equal", in which "the minority is subordinate to the majority" does not completely refer to the number of nodes, but also can be the computing power, the number of shares or other characteristics that can be compared by computers“ "Everyone is equal" means that when the nodes meet the conditions, all nodes have the right to put forward the consensus results first, and then directly recognized by other nodes, and finally may become the final consensus results. Taking bitcoin as an example, the workload proof is adopted. Only when more than 51% of the accounting nodes in the whole network are controlled can a nonexistent record be forged. When there are enough nodes in the blockchain, this is basically impossible, thus eliminating the possibility of fraud.
(4) smart contract, which is based on these trusted and tamperable data, can automatically execute some pre-defined rules and terms. Take insurance as an example. If everyone's information (including medical information and risk occurrence information) is true and reliable, it is easy to carry out automatic claim settlement in some standardized insurance procts
(1) distributed ledger, that is, transaction bookkeeping is completed by multiple nodes distributed in different places, and each node records complete accounts, so they can participate in monitoring the legitimacy of transactions, At the same time, they can testify together
different from traditional distributed storage, the uniqueness of distributed storage of blockchain is mainly reflected in two aspects: one is that each node of blockchain stores complete data according to block chain structure, while traditional distributed storage generally stores data in multiple copies according to certain rules. Second, the storage of each node in the blockchain is independent and has the same status, which relies on the consensus mechanism to ensure the consistency of storage, while the traditional distributed storage generally synchronizes data from the central node to other backup nodes[ 8]
no single node can record the account data separately, so as to avoid the possibility that a single bookkeeper is controlled or bribed to record false accounts. In theory, unless all the nodes are destroyed, the accounts will not be lost, so as to ensure the security of the account data
(2) asymmetric encryption and authorization technology, the transaction information stored on the blockchain is public, but the account identity information is highly encrypted, which can only be accessed under the authorization of the data owner, thus ensuring the data security and personal privacy
(3) consensus mechanism is how to reach a consensus among all accounting nodes to determine the validity of a record, which is not only a means of identification, but also a means of preventing tampering. Blockchain proposes four different consensus mechanisms, which are suitable for different application scenarios and achieve a balance between efficiency and security
the consensus mechanism of blockchain has the characteristics of "the minority is subordinate to the majority" and "everyone is equal", in which "the minority is subordinate to the majority" does not completely refer to the number of nodes, but also can be the computing power, the number of shares or other characteristics that can be compared by computers“ "Everyone is equal" means that when the nodes meet the conditions, all nodes have the right to put forward the consensus results first, and then directly recognized by other nodes, and finally may become the final consensus results. Taking bitcoin as an example, the workload proof is adopted. Only when more than 51% of the accounting nodes in the whole network are controlled can a nonexistent record be forged. When there are enough nodes in the blockchain, this is basically impossible, thus eliminating the possibility of fraud.
(4) smart contract, which is based on these trusted and tamperable data, can automatically execute some pre-defined rules and terms. Take insurance as an example. If everyone's information (including medical information and risk occurrence information) is true and reliable, it is easy to carry out automatic claim settlement in some standardized insurance procts
5. I don't know. I haven't heard of it
blockchain: in a narrow sense, blockchain is a kind of chained data structure composed of data blocks connected in sequence according to the time sequence, and it can not be tampered with and forged by cryptography. In a broad sense, blockchain technology is a new distributed infrastructure and computing method, which uses blockchain data structure to verify and store data, uses distributed node consensus algorithm to generate and update data, uses cryptography to ensure the security of data transmission and access, and uses intelligent contract composed of automated script code to program and operate data
blockchain: in a narrow sense, blockchain is a kind of chained data structure composed of data blocks connected in sequence according to the time sequence, and it can not be tampered with and forged by cryptography. In a broad sense, blockchain technology is a new distributed infrastructure and computing method, which uses blockchain data structure to verify and store data, uses distributed node consensus algorithm to generate and update data, uses cryptography to ensure the security of data transmission and access, and uses intelligent contract composed of automated script code to program and operate data
6. The increase of blockchain network information is bound to need expansion, but it is not limited to a BTC public chain. No matter which public chain develops to a certain stage, it needs expansion technical support network. Therefore, it can be said that expansion is a necessary link for the implementation of blockchain scheme
the expansion of blockchain is the general trend, but there are differences in the specific operation. According to the different levels of blockchain architecture, the instry has proposed a number of expansion solutions: first, optimize the data transmission protocol for the underlying data layer of blockchain, do not change the upper structure of blockchain, and improve the scalability, such as bloxroute, the 0-layer expansion scheme of blockchain; The second is to change the data structure and consensus algorithm to improve the scalability of the basic protocol of blockchain, such as DAG (directed acyclic graph), fragmentation, dpos algorithm, etc; Third, aiming at the application level, such as side chain, sub chain, state channel lightning network and so on, part of the on chain transactions are transferred to the off chain execution to rece the on chain processing pressure and improve the overall efficiency.
the expansion of blockchain is the general trend, but there are differences in the specific operation. According to the different levels of blockchain architecture, the instry has proposed a number of expansion solutions: first, optimize the data transmission protocol for the underlying data layer of blockchain, do not change the upper structure of blockchain, and improve the scalability, such as bloxroute, the 0-layer expansion scheme of blockchain; The second is to change the data structure and consensus algorithm to improve the scalability of the basic protocol of blockchain, such as DAG (directed acyclic graph), fragmentation, dpos algorithm, etc; Third, aiming at the application level, such as side chain, sub chain, state channel lightning network and so on, part of the on chain transactions are transferred to the off chain execution to rece the on chain processing pressure and improve the overall efficiency.
7. Blockchain technology has the disadvantage of slow transaction speed.
Hot content