So I like metaphors and I like cryptography, so why not throw together a guide of what's what in Cryptocurrencies to help people understand it batter?
Source code style, means terms of cryptocurrencies and bold are what my metaphors to Real Life and stuff I pull out.
I think to understand everything and to establish a "lore" in this I am creating this story/guide with the very basics of crypto currencies skip the chapters you already know, but maybe keep a note of the metaphors as I will use them later on too.
Chapter 1: Cryptocurrencies, Blockchains, and the Network
so for a start somehwere between most and all (I cannot know everything) run on something called the
blockchain. which you can think of a public ongoing list of all transactions ever occured, basically an accounting book, but in public and containing everyone using that currency.
so the question is who manages these books?
That is the
Mining Network. Which is a fully automated central bank compromised of a network of computers. This bank is so central (to the currency) that ALL transactions have to go through it, you cannot really do a "cash transaction" like in real life that easily on crypto, on the other hand, this bank of sorts is very decentral as in that EVERYONE can just download a copy of the accouting books and declare to take part in the network.
and while everyone can be part of the bank, doing malicious stuff is prevented by a few methods:
transaction, aka Bob declaring "I am sending 20 coins to Alice", is signed (more on that Later)
- the blockchain is not called "chain" without reason. it is split into (obviously)
blocks, which are basically pages of the Accounting book. and every page contains a
cryptographic hash, a kind of very specific summary ALL THE WAY to the very first page, known as the
Genesis Block. Therefore replacing a past page requires replacing ALL future pages as well, which might sound simple, but it is not due to the next few points.
- it is intentionally very hard for one player to influence which transactions are written next (to keep it simple we are focusing on one way to do that). Basically every machine on the network selects transactions it wants to and builds a page, but in order to be a valid page for the accounting book its summary has to meet a specific requirement, and to meet that there is an extra field on the page for a
nonce, which is a counter of how many times one tried to make a summary, just added to meet that requirement of the summary as the summary is heavily affected by even small changes. so one has to try out a lot of summaries before generating a valid page to add to the book, on the other hand, once the value has been found, it's trivial to confirm that the page is valid.
- the book with the most pages (or the chain with the most blocks respectively) counts.
difficultyof the hashes, or exactly how specifiy your summary needs to be, is always determined automatically every set amount of blocks, based on how long it took to make them (the time of making the block is also recorded), so basically you cannot just go and fake blocks with large time intervals to lower the difficulty as you will not get enough blocks to create a longer chain once you reached the present time.
- There is a merit for actually filling out the book.
- at first there are
Block Rewards, basically you can say "I made this page so I can claim x amount of currency" (which has been pre-determined by the block chain and is generaly adjusted by the design automatically to get lower when the chain gets longer and eventually drops to zero), which is a very controlled inflation, or slow release of the currency to the public (depending on which way you prefer to think of it)
- and then there are
transaction fees, which are basically the same as in the fees for doing bank transactions in real life. but with a catch. they are not exactly fixed or maybe not even mandatory, but unlike a bank, the network can choose when to do which transaction and obviously the network will take the transactions with the highest fees first.
This creates competition, because everyone wants to get the rewards and/or fees, so any player in the network has as much power in the decision making (probability to create the next page) as their calculation power in the network. Think of a every unit of computing power being a person standing in a long line randomly, and the first one gets to write the next page. so if you have 51% of the people you are 51% likely to create the next page, which allows you to single handedly have more power than everyone else, and potentially create pages faster than the others, which would allow you to create a larger and DIFFERENT chain than currently existing, and "
double spend" your coins.
This basically means that you send one request "Bob pays Alice 2 coins" into the network, you do not actually work on putting that into the block, but rather you create a "
side-chain", an extra set of new pages, which instead says "Bob pays Eve 2 coins" (or even just leave out this transaction completely), and due to you having more power than the rest of the network you are likely to create more pages faster than the rest of the network. This would result in for example Alice selling you a car or whatever after seeing the blocks being in the big book, but after you drive off, you just reveal that you have more pages, where you instead sent your coins to Eve instead or kept them, and Alice now has no coins and no car. And due to Rule 4, your book prevails
but that is VERY hard to achieve and hopefully will never happen, on the other Hand, to make such an attack much harder in practice, a transaction usually has to be a few pages old to count as confirmed (I often have seen 6 as the magic number) as it gets increasingly harder to replace more pages at once.
Chapter 2: Transactions, Keys and how your coins cannot be just stolen
so the first chapter was around how the cryptocurrency as a whole is secure against people frauding each other using legitimate transactions, even though (or because of) it not being one single person/company controlling all, let's get to the security of your individual cryptocurrency assets and how it is secured against being just stolen by others.
I did mention the Network of the Cryptocurrency being essentially a big automated currency-central mandatory bank, with ANY AND ALL amounts of currency in that bank being managed by the big accounting book. no assets can leave or enter the accounting book in any way (excluding the rewards, which are part of the design how the currency itself works and are specifically defined), you cannot just randomly print or destroy cryptocurrency assets (if anything you can only make it unspendable, more on that later), so EVERY asset in existance is assigned to an account of that currency in that bank.
so what is an account and what allows you to actually transfer money into or away from an account?
basically every account is determined by a
public/private key-pair. with the two being linked mathematically, if you have a private key you can just create the public one for it, but not the other way around (in theory you could just try out private keys and check whether they can fit, but let's be real that is SO NOT FEASIBLE),
basically think of your
public key as a Handwriting analysis, and the
private key as the hand that is actually doing the writing. just because someone has an analysis of your Handwriting, does not mean that anyone can just easily forge your Handwriting, provided it is deeply checked.
address of your account, is in fact just your
public key, and also you cannot just send arbitrary amounts like in real Banks, but to simplify verification, the only unit you can spend is the
unspent transaction. It would be very annyoing to keep track of every account completely (as in the network would have to check every transaction on the account to make sure enough assets are available.
so to summarize
- you can only spend the entire amount of any past transaction you recieved
- every transaction can only be spent once
- every transaction must give away the exact same amount of coins as it has taken in
- you do not send to a person/company etc. but to "whoever can create the same handwriting as this analysis shows"
- every transaction consists of as many past unspent transactions as you want, and as many targets for the money as you want where you can choose arbitrary amounts where they go (including yourself to get change), think of it like handling Gold. You always recieve all gold you get sent in one piece, and you cannot just melt it down, but your bank can and you can say into how large pieces of gold the gold you enter is melted into and where these go.
- Every transaction is signed by the private key associated with the public key that holds the assets, and thereby can be confirmed by the network as being legitimate (this part is important)
so any transaction does in fact not say "Bob sends 20 coins to Alice", but more, like "I got 10 coins on page 970 and another 14 on page 1005 (so 24 in total) , send 20 of them to Bob, 3 to me and 1 as fee for whoever adds it to the Book (yet again, 24 in total)".
Any Transaction not abiding all these conditions will just be discarded as invalid.
But depending on the chain addresses are not just keys, but also
scripts, so instead of saying "send 20 coins to whoever can write like this", you can say:
"I have here a summary of some statement and whoever can bring both this and the data needed to make it be correct.", this is a mouthful so let's break this up.
- make a kind of script, ideally with some variables inside. like for example 2+x+[the amount of coins sent in the transaction]=50
(this is VERY simplified, no one in their right mind would do this)
- summarize that statement using a
hash, which then can be made into an address. (remember. a hash is one-way, so you cannot re-create the original content, and any changes to the content will significantly change it)
- have someone do a transaction to that address to get your coins, let's say 20 coins
- get your script out and if needed, insert data to have that script become true
in this case we have "2+x+[amount of coins recieved in input tranasction]=50" so you add "x=28" as the data as 2+28+20=50 is a true statement.
- send that along with where you want your coins to go, be happy.
so I did say before you cannot actually burn cryptocurrency, but only make it
unspendable (it is often called burning, which in my opinion is not overly fitting as the coins still exist, but cannot be used in any way, similar to marked bills when you break into certain money safes with anti-theft marking systems. the bills still exist, but there's no way you can actually use them.
So the process of marking coins as unspendable consists of the idea to make a script that NEVER CAN BE TRUE, for example by a fixed script with no data which just says "2+2=5", you cannot make that statement true as there is no data you can add in to make it true, because as said, you do not only need the script itself, you also need it to evaluate as true.
Chapter 3:Wallets, and how to keep your Keys safe
so we had the cryptocurrency itself and how a transaction works and a basic crash course in public/private keys and how the network does not only keep the cryptocurrency as a whole but also your coins safe from general fraud and stealing. so now we get to the part of how each individual keeps their keys safe so their coins cannot be stolen.
As explained, you do not own coins, in fact you as a person do not own ANYTHING. Every asset, every transaction is in the accounting book but not assigned to you but your
public/private keys, your ability to make the correct signatures. So the question is obviously how to keep these safe from others.
It might be obvious to some but as all of the cryptocurrency is governed by math, so are your Keys. and while you can just generate new random keys and store all of them, that is tedious as hell and not very practical, so a method was made to instead of one "master Key" which can be used for a process called
Key derivation. to keep it simple let's just say math is powerful and you can command: "I have Master Key 'ABC' and want the first account for bitcoin, now give me the private key, and along with that also the public one I can use as address" and get exactly that. in fact you can create as many keys as you want with your master Key, by instead saying that you want the second or third or one-millionth account for Bitcoin, or Ethereum, or whatever. as that master key can used to grow many keys for cryptocurrencies and stuff it can also be known as the
seed, (probably because a seed can grow a tree which can create A LOT OF fruits).
well now that we have a modern way to keep track of our keys let's discuss on how we actually store that seed. there are basically 3 methods:
- (the least secure, but most convienient): a
full software walleton an online computer (or in general, digital storage), as in you let your computer store the seed. very vulnerable as malware can literally just steal and copy off the seed and steal all your cryptocurrency. similar to a debit card with a magnet stripe, it can just be skimmed and read out which is bad.
- (very secure, but not overly safe against just being destroyed or dying etc, but still convenient for active use). a
hardware walletlike a Ledger, Trezor, Keepkey or whatever in combination with a
watch-only wallet, (basically a software that just knows your addresses and can read whatever happed with them in the accounting book) the seed is stored on a device that will NEVER actively reveal it to anyone (including you) after you set it up, but instead just read the transactions from whatever and send back the signed result, like a blackbox. you only put something in and take something out without actually seeing what it does. Think of it like a debit card with a chip. It will also only give out an authorization for a specific transaction, and nothing else. This means you can NOT clone directly from a working hardware wallet.
- (how secure or safe it is, is entirely up to you)
Cold Storage. As in not in an directly usable form (ideally offline and not on an electronic device of any kind), generally in the form of 12-24 words (the more, the safer) selected mostly at random from a standardized list of 2048 words (the last word acts partly as a kind of checksum for the rest and in part itself).
you ALWAYS should have one (or more) of these. computers and hardware wallets can easily be destroyed or simply stop working, and especially as hardware wallets have no export function. So in case that happens you need this kind of Key Template for your Master Key to restore to a wallet to actually get access your assets.
Usually with a hardware wallet you get one or more pieces of paper where you can write them down, and your Hardware wallet will show you this phrase ONCE during setup, and usually confirm you have actually written it down by having you enter your words directly after you get to see them during the setup process, but paper is not overly durable so there are also cold storage options made out of metal (usually steel or titanium) where you can ether stamp in your words into a sheet of the metal or use plates which you insert into a kind of holder and close that to have a more permanent storage which can resist the forces of nature a bit better.
for optimal security make sure to NOT interact with your words when cameras or people are close and try not to read them out loud while writing them down or restoring them into a device for use.
So that's what I have for now, anything else you wanna have explained in more real-world terms to compare it with, or any other feedback? leave it in the comments or contact me using any other way.
Hope you read me again someday.
Update: added script addresses and making coins unspendable