DEV Community

Loading Blocks
Loading Blocks

Posted on

Build Own Blockchain - 2 episode

We usually think of a crypto wallet as just a digital account, like a fancy version of online banking. But when you actually build one from scratch, you discover that the system under the hood is way more elegant — and way more mathematical — than it looks on the surface. The process really opened my eyes to how cryptography, math, and trust all fit together in the blockchain world.

Here are five things that really surprised me when I was developing my own wallet.


1. Your Public “Key” Isn’t Really a Key — It’s a Point on a Curve

When you first see a public key, it looks like a random string of text. But that string actually represents a point on something called an elliptic curve. In most cases, that’s the P-256 curve (some blockchains use slightly different ones).

The public key has two parts — X and Y coordinates — and the long hex string we see is basically just those two numbers stuck together. I remember seeing in the code something like:

“take hex of x, hex of y, and concatenate the two strings.”

It blew my mind that a crypto “key” isn’t just a password—it’s geometry! It’s a literal point on a mathematical curve that can be verified with pure math. That’s the backbone of ownership and verification in blockchain.


2. Your Wallet Address Is Just a Fingerprint of Your Public Key

People often mix up wallet addresses and public keys, but they’re not the same. The wallet address is actually a hash of your public key — basically a short, one-way fingerprint. In my project, we used SHA-256 to do this.

Hashing is a one-way process. You can get from a public key to an address easily, but you can’t go backward. That adds a nice privacy layer — your public key isn’t exposed until you spend funds.

And every blockchain has its own little twist. As one dev in the project said:

“address is just some hash of public key... different blockchain has different way of creating the address.”

Some chains even add custom prefixes (like “evo” for Evo chain). But in the end, the address is just a friendly alias. The real secret sauce lives one step before that…


3. The Private Key Is the Only Thing That Really Matters

If you remember one thing from this article, make it this:
The private key is everything.

Your public key and address can both be regenerated from it. But not the other way around. We built a feature in the wallet that could take a single hex string — the private key — and rebuild the entire wallet:

  • the D value (the integer form of the private key)
  • the X/Y coordinates of the public key
  • the wallet address

All perfectly derived from one piece of data. That’s why security warnings are so strict:

“Do not share your private key or recovery phrase with anyone.”

If someone gets your private key, it’s game over. They basically are you, financially speaking.


4. You Don’t Sign a Transaction — You Sign Its Hash

This part really surprised me. When you “sign” a transaction, you’re not encrypting all the transaction data. You’re just signing its hash.

Here’s roughly how it works:

  1. Bundle the transaction data (sender, receiver, amount, etc.)
  2. Hash that data with SHA-256
  3. Use your private key to sign the hash, not the data itself

This is brilliant for two reasons: it’s super fast, and it’s tamper-proof. If even one comma changes in the transaction, the hash will be totally different — and the signature won’t verify anymore. It’s like a cryptographic checksum that can’t be faked.


5. Verifying a Signature Means Pretending It Isn’t There

This part feels like a magic trick. To verify a transaction, a blockchain node doesn’t just check the signature directly. It recreates the signing process — but without the signature itself.

Here’s the simplified logic:

  1. The node receives the transaction (with signature + public key).
  2. It sets those two fields aside.
  3. It re-hashes the transaction from scratch (without the signature).
  4. Then it uses the public key to check if the signature matches that freshly computed hash.

I saw this in the source:

“we are first storing the signature and public key... then we make them empty, marshal the transaction, hash it again, and finally verify the signature.”

That means every node independently proves — mathematically — that the sender had the private key and didn’t tamper with the data. No trust, no middleman, just math.


Conclusion

Building a crypto wallet from the ground up taught me that blockchain security isn’t built on complexity — it’s built on clarity. A handful of elegant cryptographic rules form the foundation of everything:

  • the public key is a point on a curve
  • the address is its fingerprint
  • and the private key is the single root of trust

Transactions aren’t trusted — they’re verified. Every step is grounded in reproducible math.

Top comments (0)