1. 程式人生 > >區塊鏈工作原理

區塊鏈工作原理

sensu lse until about days details The 觀察 sam

視頻地址:https://mp.weixin.qq.com/s/89FkIOtkuCDdpFvPtfZZhA Blockchains are incredibly popular nowadays. 區塊鏈技術如今非常的流行 But what is a blockchain? 但是,區塊鏈到底是什麽呢? How do they work, what problems do they solve and how can they be used? 區塊鏈是如何工作的,它解決了哪些問題,並且它又有哪些用途呢? Like the name indicates, a blockchain is a chain of blocks that contains information.
顧名思義,區塊鏈是由一組包含信息的信息塊組成的信息鏈。 This technique was originally described in 1991 by a group of researchers and was originally 區塊鏈技術最早是在1991年由一群研究人員研發並用來給數字化文檔打時間戳 intended to timestamp digital documents so that it’s not possible to backdate them 以使得這些文檔不能被倒填日期 or to tamper with them.
或者被篡改。 Almost like a notary. 看上去區塊鏈技術就像一位公證人一樣。 However it went by mostly unused until it was adapted by Satoshi Nakamoto in 2009 to 然而,這個技術從那之後就基本上沒有再發揮其他作用,直到2009年 create the digital cryptocurrency Bitcoin. 中本聰采用區塊鏈技術創造了數字加密貨幣-比特幣。 A blockchain is a distributed ledger that is completely open to anyone.
一條區塊鏈,就是一個對所有人完全公開的分布式賬本 They have an interesting property: once some data has been recorded inside a blockchain, 它有一個很有趣的屬性:一旦某些數據被記錄到一條區塊鏈中後, it becomes very difficult to change it. 那麽數據就很難再被改變。 So how does that work? 所以,它到底是如何工作的呢? Well, let’s take a closer look at a block. 接下來,讓我們來觀察一個區塊(block)的組成 Each block contains some data, the hash of the block and the hash of the previous block. 每一個區塊包含了一些數據,這個區塊的哈希值,以及前一個區塊的哈希值。 The data that is stored inside a block depends on the type of blockchain. 並且,區塊中所保存的數據與區塊鏈的類型有關。 The Bitcoin blockchain for example stores the details about a transaction in here, such 例如,比特幣區塊鏈中的區塊保存了相關的交易信息, as the sender, receiver and amount of coins. 包括賣家,買家,以及交易比特幣的數量。 A block also has a hash. 每個區塊包含了一個哈希值。 You can compare a hash to a fingerprint. 你可以把哈希值理解成指紋。 It identifies a block and all of its contents and it’s always unique, just as a fingerprint. 哈希值用來標識一個區塊和它所包含的所有內容,並且它總是唯一的,就像指紋一樣。 Once a block is created, it’s hash is being calculated. 一旦某個區塊被創建,它的哈希值就相對應的被計算出來了。 Changing something inside the block will cause the hash to change. 改變區塊中的某些內容會使得哈希值改變。 So in other words: hashes are very useful when you want to detect changes to blocks. 所以換句話說:當你想要檢測區塊中內容的改變時,哈希值對你就很有幫助。 If the fingerprint of a block changes, it no longer is the same block. 如果一個區塊的指紋改變了,那它就再也不是之前的區塊了。 The third element inside each block is the hash of the previous block. 區塊中包含的第三個元素是前一個區塊的哈希值。 This effectively creates a chain of blocks and it’s this technique that makes a blockchain 這個元素使得區塊之間可以形成鏈接,並且能夠使得區塊鏈 so secure. 十分的安全。 Let’s take an example. 舉個例子 Here we have a chain of 3 blocks. 假設我們有一條區塊鏈包含3個區塊 As you can see, each block has a hash and the hash of the previous block. 如圖所示,每個區塊包含了一個自己的哈希值以及前一個區塊的哈希值 So block number 3 points to block number 2 and number 2 points to number 1. 所以3號區塊指向2號區塊,2號區塊又指向1號區塊。 Now the first block is a bit special, it cannot point to previous blocks because it’s the 但是現在1號區塊有點特殊,它不能指向前一個區塊,因為 first one. 它是第一個區塊。 We call this the genesis block. 我們把1號區塊叫做創世區塊。 Now let’s say that you tamper with the second block. 那麽,現在我們假設你篡改了第二個區塊。 This causes the hash of the block to change as well. 這將導致第二個區塊的哈希值改變。 In turn that will make block 3 and all following blocks invalid because they no longer store 接下來這就會導致3號區塊以及3號區塊連接的所有的後續區塊變得非法,因為現在它們存儲的 a valid hash of the previous block. 前一個區塊號的都變得非法。 So changing a single block will make all following blocks invalid. 所以改變一個區塊會使得其後所有連接的區塊變得非法 But using hashes is not enough to prevent tampering. 但是,僅僅使用哈希值的方法不足以防止用戶篡改區塊。 Computers these days are very fast and can calculate hundreds of thousands of hashes per second. 因為現在的計算機運算速度已經足夠強大,並且能夠每秒計算成千上萬的哈希值。 You could effectively tamper with a block and recalculate all the hashes of other blocks 你完全可以篡改一個區塊並且重新計算其他的區塊的哈希值, to make your blockchain valid again. 這樣就使得你的區塊再次變得合法。 So to mitigate this, blockchains have something called proof-of-work. 所以為了減少這種風險,區塊鏈還采用了一種技術叫做工作量證明。 It’s a mechanism that slows down the creation of new blocks. 這是一種減緩新區塊創建過程的機制。 In Bitcoins case: it takes about 10 minutes to calculate the required proof-of-work and 在比特幣區塊鏈中,大概需要花費10分鐘來完成所要求的工作量證明, add a new block to the chain. 並且添加一個新的區塊到區塊鏈中。 This mechanism makes it very hard to tamper with the blocks, because if you tamper with 這個機制使得區塊鏈的篡改更加困難,因為一旦 1 block, you’ll need to recalculate the proof-of-work for all the following blocks. 你篡改了一個區塊,你需要重新計算所有後續的區塊的工作量證明。 So the security of a blockchain comes from its creative use of hashing and the proof-of-work mechanism. 所以區塊鏈技術的安全性主要來自於哈希值以及工作量證明機制。 But there is one more way that blockchains secure themselves and that’s by being distributed. 但是,區塊鏈還有一種機制來保護自身的安全性,那就是分布式。 Instead of using a central entity to manage the chain, blockchains use a peer-to-peer 相對於用一個中心化的實體來管理區塊鏈網絡,區塊鏈采用的是一種peer-to-peer network and anyone is allowed to join. 網絡,並且所有人都可以加入。 When someone joins this network, he gets the full copy of the blockchain. 當有人加入這個網絡時,他就會得到整個區塊鏈的復制。 The node can use this to verify that everything is still in order. 這個人就可以以此來驗證是否所有的區塊還是合法未篡改的。 Now let’s see what happens when someone creates a new block. 那麽接下來我們就來看看,當某人創建了一個新的區塊時,會發生哪些改變 That new block is send to everyone on the network. 這個新的區塊會被發送給網絡上的所有人。 Each node then verifies the block to make sure that it hasn’t been tampered with. 每個人再驗證這個區塊以確保這個區塊沒有被篡改過 If everything checks out, each node adds this block to their own blockchain. 如果所有的東西都被檢驗正確之後,那麽每個人就都會把這塊新的區塊加到自己的區塊鏈上。 All the nodes in this network create consensus. 我們可以稱之為,網絡上的所有人達成了“共識”。 They agree about what blocks are valid and which aren’t. 他們認同網絡中那些區塊是合法的,哪些是不合法的。 Blocks that are tampered with will be rejected by other nodes in the network. 那些被篡改過的區塊將會被網絡上的其他用戶拒絕。 So to successfully tamper with a blockchain you’ll need to tamper with all blocks on the 所以,要成功篡改一個區塊鏈,你需要篡改區塊鏈上的所有區塊, chain, redo the proof-of-work for each block and take control of more than 50% of the peer-to-peer network. 重新完成每個區塊的工作量證明,並且控制區塊鏈網絡中超過50%的用戶 Only then will your tampered block become accepted by everyone else. 只有這樣,你篡改的區塊才會被所有人承認。 This is almost impossible to do! 可以說,這基本上是不可能做得到的! Blockchains are also constantly evolving. 區塊鏈技術本身也在不斷地發展。 One of the more recent developments is the creation of smart contracts. 最近的一個技術改進,叫做智能合約。 These contracts are simple programs that are stored on the blockchain and can be used to 智能合約是一些存放在區塊鏈上的簡單的程序, automatically exchange coins based on certain conditions. 並且在特定條件下可以實現自動化比特幣交易。 More on smart contracts in a later video. 我們將會在後續的視頻中講解智能合約。 The creation of blockchain technology peaked a lot of people’s interest. 區塊鏈技術的誕生吸引了很多人的目光, Soon, others realized that the technology could be used for other things like storing 在其誕生不久之後,一些人意識到區塊鏈技術可以用來 medical records, creating a digital notary or even collecting taxes. 存放病史檔案,創造數字化公證甚至還可以用來收稅。 So now you know what a blockchain is, how it works on basic level and what problems it solves. 那麽,到這裏,你應該已經明白區塊鏈基本的工作原理,以及它到底解決了哪些問題吧。 轉載:http://coin4your.info/2015/03/24/indextop2/

區塊鏈工作原理