Noding a Blockchain

Noding a Blockchain

Blockchains and cryptocurrency are all the hot rage these days. But if you're like me, it all seems like a bunch of voodoo magic math and super complicated algorithms.

So I decided the best way to de-mystify and learn it was to build my own blockchain and cryptocurrency. And of course, I started with Node! I'm going to walk you through some of my code and show a few bits of intermediate-to-advanced Node that I had to tackle to build my blockchain.

Topics covered will include: efficient asynchronous logic, SHA256 hashing and RSA cryptography, mesh communications via UDP and TCP messages, streams, offloading work to child processes, and persisting data in Git.

35761e3936deba2f8189c2d20982c771?s=128

Kyle Simpson

April 19, 2018
Tweet

Transcript

  1. 3.
  2. 4.

    • Read/write access is private • Data is (usually) mutated

    • Sharing and backups:
 replication • All stakeholders are trusted
  3. 5.

    • Private/sensitive data • "Single" point of failure (SPOF) •

    Target for hacking • Load balancing, eventual
 consistency
  4. 7.
  5. 9.

    • Public data • Trust based on math • Essentially

    zero failure • "50% + 1" weakness • Never consistent, consensus
 complications
  6. 17.

    { index: 1, prevHash: "B22D1D8...89E2B87", data: ... , timestamp: 1524029051480,

    } data: [ { hash: "C37AF10...0040A18", data: ... , timestamp: ... , ... }, { hash: "B9DC4FC...91F59BD", data: ... , timestamp: ... , ... }, ... , ], { index: 1, prevHash: "B22D1D8...89E2B87", timestamp: 1524029051480, }
  7. 19.
  8. 20.
  9. 21.
  10. 22.
  11. 23.
  12. 24.
  13. 25.
  14. 27.
  15. 32.
  16. 37.

    Private Key Public
 Key "some secret text" Encrypt Decrypt "some

    secret text" "jn4ra...bBH3/sKn" What I always thought...
  17. 38.

    Private Key Public
 Key "some secret text" Encrypt Decrypt "some

    secret text" "jn4ra...bBH3/sKn" How it actually works...
  18. 40.
  19. 41.
  20. 43.
  21. 44.
  22. 45.
  23. 47.
  24. 48.
  25. 49.
  26. 50.