Live data from Hacker News

Building a tiny blockchain

medium.com

21–30 of 60 posts

Re: Building a tiny blockchain

#21
post #9

Earlier quoted context omitted.

What? A blockchain isn’t a distributed ledger. A blockchain IS a chain of linked documents - whereas these documents are usually hash trees including the “transactions” per block. They ensure integrity by hashing the previous blocks. The proof of work is just a way to ensure a self regulating growth of virtual currencies and to prevent double spending.

This is a really twisted take on blockchains. The whole point behind a blockchain is that cryptoeconomic incentives serve as an additional security function which is better than relying on generosity alone to contribute hashing power. So while it is true that a blockchain can exist without any kind of currency - the real genius behind blockchains is how they are designed as a new kind of corporation - one which requi…

> The whole point behind a blockchain is that cryptoeconomic incentives serve as an additional security function which is better than relying on generosity alone to contribute hashing power.

This has nothing to do with blockchains. What you're describing is proof of work with a payout system, and you could implement that without a blockchain at all.

>So while it is true that a blockchain can exist without any kind of currency

It has always been true. This was, in fact, exclusively the case before the first cryptocurrencies - blockchains are data structures, not a concept exclusive to currency.

>Your other point is that a blockchain is simply a linked chain of documents. This is incorrect.

It is exactly correct. The use of blockchains in cryptocurrencies is irrelevant to what they are. If I build the next great money machine tomorrow using a doubly-linked list, it doesn't change what a doubly-linked list fundamentally is. The fact that many people have been introduced to the idea of a blockchain through cryptocurrencies doesn't alter the basic facts.

>The whole point behind a blockchain is that it serves as a way to get people to agree on an ordered list of events.

This is not what the blockchain does. The blockchain helps to ensure that Proof of Work is effective for maintaining consensus after blocks are made - it's the role of PoW to produce the agreement. A blockchain without PoW would allow members to produce new combinations of blocks at will to edit the history.

Re: Building a tiny blockchain

#22
post #11

This worries me. Bitcoin solved the double spend problem by using the LCR with PoW. That is the novel aspect which allowed cryptocurrencies to come into existence. If you remove the LCR and PoW, all you are left with is a toy example which cannot work in practice. What is needed is education about censensus design and bitcoin's implementation of the solution, rather than a 'how to guide' for building a basic linked l…

As for proof of work, am I right in assuming it works like this :- Add a field to store a random number. Keep generating values for this field until the hash of the structure has 'n' leading zeros. Is that more or less correct?

Yes, that's more or less it.

It's worth adding to that description that the hash must be secure in that it does not allow determining what random number to use to get a particular output (I'm sure you already recognized this detail - it just guarantees you have to keep trying actually random numbers to find a result).

Also worth adding is that the 'n' (Basically the difficulty) is generally going to need some way of scaling based on how quickly correct hashes were found in the past. This is important to prevent problems that would happen with people being able to generate correct results too quickly (Or even just significantly faster then previously).

In particular, Bitcoin's difficulty factor scales such that a new block is found aprox. every 10 minutes, so 'n' is adjusted every so many blocks depending on how fast the hashes were found. Because in the case of Bitcoin, a found block means more coins in the market, it is important that when more hashing power is added, it doesn't result in blocks now being found 1 minute apart. If that were to happen, then you'd have 10 times the number of coins entering the market.

Re: Building a tiny blockchain

#23
post #2

So ah... where's the part where you implement a working blockchain, again? There's no proof-of-work, consensus logic, currency logic, accounting logic, peer-to-peer networking code, etc. Instead this is just a list of hashed-linked documents... Not that much different from a Git repo or a basic file system with integrity checks. Hashing != blockchains.

The only real blockchain is CBC mode. (Cipher Block Chaining)

What you're describing is a cryptocurrency, or some other form of cryptographically assured distributed ledger with a proof of work.

If you think I'm wrong, look in the original Bitcoin paper and search for "blockchain".

Re: Building a tiny blockchain

#24

Earlier quoted context omitted.

Again, that's how it works, but not why it works. It bitcoin it is used as an unforgeable proxy for elapsed time.

>"It bitcoin it is used as an unforgeable proxy for elapsed time" This sounds pretty interesting, can you elaborate on how exactly its proxy model for the passage of time?

In a p2p environment, timestamps are totally useless at proving when I sent you bitcoins. However, when I sent you bitcoins is fundamentally important when it comes to ordering transactions, because I can send you bitcoins, but also send them to myself after you accept them. If I can forge timestamps then this attack is trivial to pull off.

You need an analogue to elapsed time to solve this problem. Hashes in bitcoin are probabilistic, there is an expected number of hashes required to solve the PoW (on average). Each hash takes an amount of time that cannot be made faster, so you suddenly have an unforgeable, easily provable analogue to elapsed time.

Re: Building a tiny blockchain

#25

Earlier quoted context omitted.

Longest Chain Rule, that the network honors the longest chain as the correct chain.

Bitcoin has moved away from the Longest Chain Rule to the blockchain with the most cumulative Proof of Work as what the nodes recognize as valid blockchain.

I hear a lot about hash rates. How are aggregate hash rates confirmed/reported? Does a miner submit every single attempted hash to the network as a potential solution or do miners self-report their total hash rates?

Re: Building a tiny blockchain

#26

Earlier quoted context omitted.

>"It bitcoin it is used as an unforgeable proxy for elapsed time" This sounds pretty interesting, can you elaborate on how exactly its proxy model for the passage of time?

In a p2p environment, timestamps are totally useless at proving when I sent you bitcoins. However, when I sent you bitcoins is fundamentally important when it comes to ordering transactions, because I can send you bitcoins, but also send them to myself after you accept them. If I can forge timestamps then this attack is trivial to pull off. You need an analogue to elapsed time to solve this problem. Hashes in bitcoin…

That makes perfect sense. Thanks.

Re: Building a tiny blockchain

#28
Regardless of the semantic discussion on what exactly a 'blockchain' is and whether or not this qualifies, I found the article interesting by taking a tiny piece of the whole monster and demystifying it a bit.

I don't see this any differently than a tutorial that makes a static image move around the screen with key presses. Is it a full game? Not at all. But can it teach you how to build a tiny piece of it, and you can look at other tutorials to figure out how to build other tiny pieces of it, and eventually synthesize that knowledge and make a full game? Yes.

Re: Building a tiny blockchain

#29

I wanted to try re-writing in Ruby to warm up today. Can someone confirm this is correct? https://gist.github.com/chrisallick/cb196b13555c86f9193f3ec4...

Looks good to me.

You might want to keep track of the blocks as you create them, or you will find it hard to verify the integrity of a block.

(Do I know the hash of the previous block? Do I know about the next block, if it is not the last block?)

Post reply on HN