Live data from Hacker News

Show HN: An educational blockchain implementation in Python

github.com

1–10 of 44 posts

Re: Show HN: An educational blockchain implementation in Python

#2
For the last couple of months, there have been many educational, simple implementations that explains blockchain technology, I guess thanks to crypto bubble. I wish these were around when we were doing our senior design project on blockchains in 2014. Back then, I only could find basiccoin[0], which was purely minified to just fit in 1000 loc.

After that, I decided to re-implement everything from scratch. My foremost constraint was to write readable code so that anyone could read the codebase and have an idea of how blockchain works.

My current draft of implementation can be found on https://github.com/halilozercan/halocoin , which currently lacks detailed README and documentation. However, you can still experiment with it by using API or CLI. I'm running a dedicated server to have an always online peer you can connect to.

[0]: https://github.com/zack-bitcoin/basiccoin

Edit: a word

Re: Show HN: An educational blockchain implementation in Python

#3
Very good writeup that shows all the steps.

Note it uses MD5 hash instead of SHA256 so not exactly bitcoin. I wonder how much more work would be to make the code fully implement bitcoin. Will it still be readable? Or Etherium? Would be great value for understanding even if Python would be inefficient to run in prod.

Re: Show HN: An educational blockchain implementation in Python

#4
> It is NOT secure neither a real blockchain and you should NOT use this for anything else than educational purposes.

It would be nice if non-secure parts of implementation or design were clearly marked.

What's the point of education article, if bad examples aren't clearly marked as bad? If MD5 usage is the only issue, author could easily replace it with SHA and get rid of the warning at the start. If there are other issues, how can a reader know which parts to trust?

Even if fixing bad/insecure parts are "left as an exercise for the reader", learning value of the article would be much greater if those parts would be at least pointed at.

Re: Show HN: An educational blockchain implementation in Python

#5
post #3

Very good writeup that shows all the steps. Note it uses MD5 hash instead of SHA256 so not exactly bitcoin. I wonder how much more work would be to make the code fully implement bitcoin. Will it still be readable? Or Etherium? Would be great value for understanding even if Python would be inefficient to run in prod.

Fully implementing Bitcoin white paper would require moderate amount of work if you do not consider every little detail related to security of your client code. However, current Bitcoin protocol added many features such as scripting.

I think one can maintain code readability in a python implementation but documentation is the key here. Developer needs to clearly state the objective of each function.

For ethereum, you need one external element called: Ethereum Virtual Machine. Smart Contracts are basically byte code that runs on EVM. Without it, blockchain cannot function. So, ethereum development may require extra knowledge on top of blockchain technology.

Re: Show HN: An educational blockchain implementation in Python

#6
Thanks! Simplest explanation I've seen.

Here's an nbviewer link (which, like base58, works on/over a phone): https://nbviewer.jupyter.org/github/julienr/ipynb_playground...

Note that Bitcoin does two rounds of SHA256 rather than one round of MD5. There's also a "P2P DHT" (peer-to-peer distributed hash table) for storing and retrieving blocks from the blockchain; instead of traditional database multi-master replication and secured offline backups.

> ERROR:root:Invalid transaction signature, trying to spend someone else's money ?

This could be more specific. Where would these types of error messages log to?

Re: Show HN: An educational blockchain implementation in Python

#7
post #5
post #3

Very good writeup that shows all the steps. Note it uses MD5 hash instead of SHA256 so not exactly bitcoin. I wonder how much more work would be to make the code fully implement bitcoin. Will it still be readable? Or Etherium? Would be great value for understanding even if Python would be inefficient to run in prod.

Fully implementing Bitcoin white paper would require moderate amount of work if you do not consider every little detail related to security of your client code. However, current Bitcoin protocol added many features such as scripting. I think one can maintain code readability in a python implementation but documentation is the key here. Developer needs to clearly state the objective of each function. For ethereum, you…

I've been ignoring bitcoin for a while. Do the devs still maintain the official implementation is the only implementation possible since it contains quirks the spec doesn't specify?

Re: Show HN: An educational blockchain implementation in Python

#9
post #4

> It is NOT secure neither a real blockchain and you should NOT use this for anything else than educational purposes. It would be nice if non-secure parts of implementation or design were clearly marked. What's the point of education article, if bad examples aren't clearly marked as bad? If MD5 usage is the only issue, author could easily replace it with SHA and get rid of the warning at the start. If there are other…

Being secure is the lack of attack surface. So it's really hard to say. Often what hits you is something you haven't considered.

So what the author is saying he doesn't take responsibility for when you use the result of his work and get problems. If you want to act responsibly build a team of different experts, have tests for security scenarios, have automated tests, from time to time pay people to attack your system and show the weaknesses you have.

Or, do it like 99.9% of people and just accept that there are risks but don't try to put resulting failures on people who provide free solutions for you online.

PS: Incorporation is a good way to protect yourself. Then having even ineffective due diligence processes is enough to protect your personal life from the risks of doing business.

Post reply on HN