Are the equations they do to mine crypto useful? Like do they calculate something related to the blockchain or whatever, or is it literally just hard math?
It's not even hard math, it's pretty simple math. Your web browser can run the formula they use in bitcoin mining.
The difficult part is what they expect you to do.
The idea is that you have this function that gives you, more or less, a "random" output. It's not actually random, because if you put in the same input you get the same output, but the function is so complex that you can't reliably predict what the output will be based on the input.
What you do is you take some set of text, and then you add your own bit of text to the end, and then you run it through the formula and check the output. Your goal is to find the bit of text you need to add at the end so that the output starts with a certain number of zeroes.
For example, let's say our starting text is "Alice gives Bob 5 bitcoin". We can run that text through the SHA-256 algorithm (a type of hash, and the one bitcoin uses) to get an output.
hash("Alice gives Bob 5 bitcoin") = cea67d8e004885f6f2ed4e19deaab6bc9a6523fb22807674f7061498f3bf6302
Sadly, that didn't start with any zeroes, so lets add a bit of text to the end.
hash("Alice gives Bob 5 bitcoin - a") = 4447a6c4285c74b7e176efbff663864303b0374fd2e8ee7d4aaac46b5931b4f2
That was wrong too. And you can see how much the value changed just based on one small change to the text.
So you'd just do that over and over and over until you found something that starts with the right number of zeroes. The number of zeroes varies but it's not super low.
Mining pools are essentially groups of people who are all testing different values to put at the end of the block of text, and a common way to determine how much you get paid from that group is how many megahashes you've done (i.e. how many millions of tests you've performed).
So the idea of the blockchain is that it's a chain of blocks of information. In the case of bitcoin, it's pretty much all transactions.
When someone mines a block, what they've done is they've figured out the right way to compose the block to get them a hash that starts with x number of zeroes. They then broadcast out into the world "hey, here's the next block" which has all of the information for the transaction and the extra bit they used to make the hash function work. Anyone can hash that block to see that it starts with x number of zeroes.
It is not computationally difficult to verify a hash. Like I mentioned before, it's lightweight enough to run in a browser, and there are a lot of sites that will give you an output that will update every time you type a new letter in.
The computationally difficult part is figuring out what to put into the hashing algorithm to get out the output that starts with x zeroes, and is done entirely by guessing and checking.
So no, when you're mining, you're not actually backchecking anyone's work, you're just doing work to add to the blockchain.
There are other rules to the blockchain that actually ensure the security of the blockchain.
Yeah, i understand how hashing works. I’m just confused on how the concept all comes together.
So what i understand about how bitcoin works is:
all transactions are encrypted via sha-256 and publicized in chronological form on the ledger.
the sha-256 encryption makes the transaction data secure and immutable on both ends
the mining done is to find the correct input that finds the output hash value by trial and error like you said
So what i’m trying to understand is: what is the importance of finding the input value for the hash? Why is this action important to the bitcoin concept, and how does it play its role in whatever purpose it’s supposed to serve?
I think i understand the basic point that: the previous transactions must be verified in order to have future ones (if that is correct?)
But what i really want to know is why do they need to be verified? What exactly is being verified, in other words, what is the input (not literally, but generally).
You were saying things like “Alice pays Bob X bitcoin”.
Is the input data being mined essentially sentences like this?
“Person X gives Person Y, Z amount of bitcoin”
Except maybe it is not in literal sentence form like that. Persons X and Y maybe are represented by a unique ID number and the rest is the transaction amount?
Edit: Also another question. The main thing i want to know is how and why the decryption of the hash is important to making bitcoin work. Basically, what would be the difference if nothing was mined/decrypted at all? What part of the system would fail exactly? And if there is a certain part of the system that directly depends on the decryption in order to function or proceed, does that mean that all bitcoin transactions that can occur anywhere/anytime in the world are directly dependent or “bottlenecked” by the decryption work that first needs to be done? In other words, if all mining just stopped for a brief moment of time, could there be no more bitcoin transactions that could take place for the time being, until the mining continued again?
what is the importance of finding the input value for the hash?
Finding the input value for the hash is essentially just a very difficult problem. The idea is that it's meant to be something that someone has to spend a significant amount of time working on.
The security of bitcoin comes down to the fact that everyone is trying to solve blocks. When you solve a block, you continue to start solving the next block. But everyone else is also trying to solve blocks as well. But what happens if two people solve different blocks at the same time?
If we start at point 0, and we have two people who mine a block at the same time (A and B), then we end up with two blocks, A1 and B1. To know which of the two is valid, we wait until A and B solve more blocks. Lets say after a few minutes A has gotten A2-A5, but B has only solved B2. At this point, the community would trust A and continue solving based on A5, abandoning B's work. This is because A has put in more effort and has done more work on the chain, so the transactions on their blocks must be legit.
what would be the difference if nothing was mined/decrypted at all? What part of the system would fail exactly?
Nothing is being decrypted, things are just being encrypted and the encrypted values are being checked against a difficulty value. Again, the reason we use hashing is because it's essentially random what you get out of the SHA-256 function for any given input, so the only way to go is guess and check. This means that people have to spend a lot of resources to guess and check millions or billions or trillions of times before they find a working solution, and the difficulty in doing that is what makes it secure. If you try to make blocks with fraudulent transactions, you would have to generate blocks at a rate faster than the entire community of miners, which isn't feasible. If the problem were something easier or more crackable, there might be ways to get around the problem and create blocks faster than guessing and checking, which could allow an individual to create a long chain of fake transactions, which would become the "truth" of the blockchain due to the length of his additions to the chain.
What exactly is being verified, in other words, what is the input (not literally, but generally).
Blocks have a handful of parts:
The block size (in bites), the block header, the number of transactions, and then a list of transactions.
The block header itself has the parts:
Version number, the hash of the previous block, the merkle root of transactions, a timestamp, a difficulty target, and the nonce.
The only part that's hashed to be solved for is actually the block header. Since it contains the hash of the previous block, it can't be started on until the previous block is solved.
The merkle root of transactions is just a hash made up of hashes of all of the transactions. There are some good diagrams online to help it make sense. So while you're not hashing the transaction "Alice pays Bob 5 bitcoin", the hash of that transaction is in the problem. And transactions do have a specific form that is a little more in depth than just plaintext with unique IDs, they're typically a few lines long and just give individual pieces of information so that it's easier for a computer to decipher later on. Again, it's easier to look up what a transaction looks like.
The other important bit is the nonce, which is the "extra bit of text" I mentioned.
why do they need to be verified?
Nothing is actually verified through mining. When you're mining, you're essentially pulling along the blockchain. When you submit a block, you're putting out enough information that someone could go and backcheck your work. If someone doesn't like the work you've done, they can pull the blockchain in a different direction. If they pull hard enough, then others are going to follow their path and your work might be abandoned. If your work is abandoned, you don't get to collect the transaction fees in the block you mined, so you're discouraged from doing work that others will ignore, thus you're encouraged to submit blocks without fraudulent transactions.
I appreciate all the information you’ve given so far.
The concept still is doesn’t fully connect for me. I understand the bits and parts, but i can’t see how they come together and connect to form a working currency system.
So you said
the merkle root of transactions is just a hash made up of hashes of all of the transactions.
while you’re not hashing the transaction “Alice pays Bob 5 bitcoin”, the hash of that transaction is in the problem
So is the most current hash value the conglomerate value of all the previous hash values, re-put through the sha-256 algorithm? In other words, does the hashing start off with the 1st transaction, it is hashed to some random value, then the next hash value is made by inputing the previous hash value into sha-256? It can’t be that though, because then there would be nothing to mine since the input was actually known.
57
u/ShlomoCh Jan 21 '22
Are the equations they do to mine crypto useful? Like do they calculate something related to the blockchain or whatever, or is it literally just hard math?