Live data from Hacker News

Bitcoin From Scratch – Part 1

monokh.com

21–30 of 77 posts

Re: Bitcoin From Scratch – Part 1

#21
post #2

> The PoW is suffice if the hash begins with a certain number of 0s This is a common explanation of PoW, but is actually incorrect. If you think about it, this would mean that the PoW difficulty could only increase (or decrease) by a factor of two. In reality, the block hash is simply interpreted as a (very large) number, and this number must be less than some other very large number (the "target"). So you do end up…

That doesn't seem like a simplification that misrepresents a relevant, core dynamic of Bitcoin. The exact details of how you ramp up difficulty are a pretty low-level technical issue.

Re: Bitcoin From Scratch – Part 1

#24

Clear, concise and to the point. Looking forward to reading the rest. If you finish the whole series and fix/improve the posts in this sequence using the feedback from here, I think it might serve as one of the go-to pages for technically inclined people who are interested to learn about Bitcoin and blockchains.

Except they’re polarising as hell. Expect someone to chime in and state how they are a complete waste of time and energy.

those people are just mad that they are poor, disregard

Re: Bitcoin From Scratch – Part 1

#25
post #6

Earlier quoted context omitted.

TIL. I wonder why that myth is so commonly perpetuated.

It used to work this way, but got changed to a less-than check for performance reasons. The Bitcoin whitepaper [0] even has the original approach: > The proof-of-work involves scanning for a value that when hashed, such as with SHA-256, the hash begins with a number of zero bits. [0] https://bitcoin.org/bitcoin.pdf

There’s a difference between mining bitcoins, and mining for network fees.

Re: Bitcoin From Scratch – Part 1

#26

Clear, concise and to the point. Looking forward to reading the rest. If you finish the whole series and fix/improve the posts in this sequence using the feedback from here, I think it might serve as one of the go-to pages for technically inclined people who are interested to learn about Bitcoin and blockchains.

Except they’re polarising as hell. Expect someone to chime in and state how they are a complete waste of time and energy.

Of course people who try to profit from alternative currencies are pure cancer to this planet, but that doesn't diminish the value or interestingness of applied cryptography or consensus algorithms.

Re: Bitcoin From Scratch – Part 1

#27
post #19
post #14

Earlier quoted context omitted.

> It used to work this way, but got changed to a less-than check for performance reasons. I don't know who told you that, but they were weirdly confused. It not unlikely the case that sometime early in development (long before publication) that it was bits-based, not only is this how the standard hashcash code works-- but the Bitcoin code calls the relevant field that encods the difficulty "bits". But Bitcoin itself…

I did not read the sentence you are responding to as implying it was changed after final network launch, only that it was changed.

Well there is no evidence of that other than "bits" and that's how hashcash worked. Sounds like an invitation on the meaning of the word "changed".

No bitcoin software was ever released that worked another way.

Re: Bitcoin From Scratch – Part 1

#28
For people that need or want to know (really understand) in depth about Bitcoin without any previous background in Computer Science (for example, in Finance, investors, journalists, historians, curious people in general) I have to recommend Ted Nelson's "How Bitcoin actually works" (2014) from his series "Computers for Cynics" [0]. I enjoyed it. (+)

[0] https://youtu.be/3CMucDjJQ4E

(+) For the people with background in CS: it might be that the video at some point talks about the number of zeros instead of the comparison, but really, it does not detract a 'bit' from its value.

edit: formatting

Re: Bitcoin From Scratch – Part 1

#29
post #6

Earlier quoted context omitted.

It used to work this way, but got changed to a less-than check for performance reasons. The Bitcoin whitepaper [0] even has the original approach: > The proof-of-work involves scanning for a value that when hashed, such as with SHA-256, the hash begins with a number of zero bits. [0] https://bitcoin.org/bitcoin.pdf

There’s a difference between mining bitcoins, and mining for network fees.

What difference would that be? Both the fees and the block reward go to the miner who first published a valid block with hash lower than the current difficulty. The only difference is where those bitcoins came from, but that has no impact on how easy it was to mine.

Re: Bitcoin From Scratch – Part 1

#30
I wrote a toy (but working) implementation of the Bitcoin algorithm here: https://github.com/tlrobinson/tomcoin

The main logic is a few hundred lines of code: https://github.com/tlrobinson/tomcoin/blob/master/src/node.j...

A somewhat unique aspect is since it's written in JavaScript a node can run on the server or the browser, which makes for easy demos:

1. Open https://tomcoin.herokuapp.com/ and https://tomcoin1.herokuapp.com/ in two browser windows (the private key is stored in localStorage so using different domains ensures each gets a different wallet)

2. Click "Start Mining" on one or both nodes

3. Once you've mined some TomCoin (should just take a few seconds unless more people start mining) copy the public key from one node to the other's "publicKey" field, enter an amount, and click "Transfer"

4. Wait for another block to be mined and you should see the balances transfer

(There's no persistence so the chain will reset when all the Heroku nodes idle out and other nodes close)

(It also just uses WebSockets to connect to the instances on Heroku, or in theory other server instances people are running. I meant to implement WebRTC for P2P between browser nodes but never got around to it)

Post reply on HN