Making the rewrite expensive on purpose
Nothing in the Harbourgate register stopped the attacker. Four hashes were recomputed, verification came back clean, and the whole rewrite cost four computations. Difficulty is the deliberate answer to that: a rule saying a block's hash is only acceptable if it begins with a required number of zero characters. The rule adds no security to the hash itself. It adds price, and price is the only thing that was missing.
★ What you walk out with tonight. A plain account of what mining is: trying nonces until a block's hash begins with the required zeros, with no method better than trying. The four measured means, 16, 277, 4,115 and 74,190 attempts at difficulties 1 to 4, each with its trial count. And a habit that outlives the subject: a cost quoted without a trial count beside it is not a cost, it is an anecdote.
LiveThe one field a block will let you change4 min▶
A block's hash is taken over its position, its timestamp, its entry, the previous block's hash and its nonce. The first four are what the block is for and cannot be altered without altering the record. The nonce is different. It says nothing, carries no meaning, and exists so that the hash can be moved without the record being touched.
That is why the nonce looked like a flaw when it was introduced. It is the handle the whole mechanism turns on. Set a rule about what an acceptable hash must look like, and the nonce becomes the only thing anyone can turn while looking for one.
Harbourgate's six entries were built at difficulty 0, which imposes no rule at all, so every nonce stayed at zero and every block was accepted on its first computation. Everything about tamper evidence held anyway. Difficulty was never about detection.
Self-studyThe words that will keep coming back4 min▶
- Nonce. A number in every block that can be set to anything without changing what the block says.
- Difficulty. How many leading zero characters a block's hash is required to have before the block is accepted.
- Mining. Trying nonce values until the block's hash meets that requirement.
- Attempt. One nonce tried and one hash computed. The unit every cost figure here is counted in.
- Expected attempts. 16 to the power of the difficulty, because each hexadecimal character takes one of 16 values and the leading ones must all land on zero.
- Mean. The average over many independent blocks. The only honest way to state a mining cost.
- Spread. How far individual runs sit from that mean. At difficulty 4 the measured runs went from 149 attempts to 339,789.
- Reforge. Redoing a block and every block after it, now at a price per block. Practitioner session 5.
Guessing is not a weakness of the method, it is the method
15 min liveThe requirement is arbitrary and that is the point: a valid block is one whose hash begins with a given number of zeros. Nobody can compute a nonce that produces such a hash, because the avalanche property means the digest for nonce 1 carries no information about the digest for nonce 2. So the nonce is counted upwards and the hash is computed again, until one lands.
...
...
LiveWhy sixteen to the power of the difficulty4 min▶
A digest is written in hexadecimal, so each character is one of sixteen. A hash function with no gradient scatters its output evenly across every possible digest, which means the first character lands on zero about one time in sixteen. Requiring two leading zeros asks for two independent one in sixteen events at once, and so on upwards.
That gives the expected attempt counts directly: 16, 256, 4,096 and 65,536 for difficulties 1 to 4. It is worth noticing what this expectation is not. It is not a limit, not a guarantee, and not a schedule. It is the average of a process whose individual outcomes are wild.
LiveWhat difficulty does to the attacker's four blocks3 min▶
Session 2 left the attacker needing to redo blocks 2, 3, 4 and 5. At difficulty 0 each of those cost one computation. At difficulty 3 each one costs a mean of 4,115 attempts, measured over 120 trials, and the attacker has to pay that four times over rather than once.
There is a second cost that is easy to miss. While the attacker is redoing four blocks, an honest register is still adding new ones, and every new block is another block the attacker must also redo before the rewritten version can be as long as the real one. The work is not a fixed bill, it is a race against a register that keeps moving.
Self-studyWhere the disagreement really is4 min▶
One camp treats proof of work as a security mechanism in the full sense. There is no administrator to appeal to, so the only thing that can deter a rewrite is making it cost more than it is worth, and a cost that anybody can verify from the data alone is exactly the right shape for a system with nobody in charge.
The other camp says calling cost security mislabels a deterrent as a guarantee. A cryptographic property holds regardless of who is attacking. A cost only holds while the attacker's budget is smaller than the honest work being done, which is a claim about economics, not about mathematics, and it can change without anything in the code changing.
Both positions are held by people who understand the mechanism perfectly well, and the disagreement is about what kind of assurance has been bought rather than about how the mechanism works. It matters in a procurement conversation because the two camps write very different warranties.
The mean is known. Any single run is not.
9 min liveEvery figure below was measured by mining many independent blocks and counting attempts. The means sit close to the expectation, which is reassuring and mostly uninteresting. The columns worth looking at are the last two, because they are the ones that decide whether a number somebody quotes you means anything.
The first time this measurement was taken it was taken once, and once is what produced the two numbers below. Both are real results from the real engine. Both would have been quoted with a straight face, and both would have been wrong, in opposite directions.
LiveA lottery with a known ticket count4 min▶
Mining behaves like drawing until a rare event happens. The average wait is exactly what the arithmetic predicts, and a single wait can be almost anything. At difficulty 1 the measured runs went from 1 attempt to 101 around a mean of 16. At difficulty 4 they went from 149 to 339,789 around a mean of 74,190, all over 150 trials.
The practical consequence is that a lucky attacker exists, always, and does not need to be clever. Difficulty does not promise that a rewrite is slow. It promises that rewriting a long stretch of register, block after block, is slow on average, and averages only assert themselves over many blocks.
LiveWhat to ask when somebody quotes you a cost3 min▶
Three questions, in order. How many runs is that averaged over. What were the smallest and largest results. And was the measurement taken on the same configuration you are being sold. A supplier who has the first two answers has measured something. A supplier who has only a single impressive figure has run the thing once.
This generalises well past mining. Any figure produced by a process with a long tail behaves the same way, and a benchmark quoted from one run of a model, one load test or one query plan carries exactly the same defect.
Self-studyWhy difficulty protects a public register better than a private one4 min▶
Difficulty raises the cost of producing a block for everybody, honest or not. On a register maintained by many independent parties, the honest total is large and an attacker has to outspend it, so the price is paid by the attacker and inherited by everyone else as protection.
On a register where one organisation runs all the machines, the same rule raises that organisation's own running cost and raises nothing for an insider, because the insider is the one with the capacity. Adding difficulty to a single operator register buys a slower system and very little else, which is an awkward result for a lot of internal chain projects.
Take the draws yourself
18 min hands onNo code. Six steps using the live box above, which mines real blocks with the real hash. The aim is to leave with a number you would defend and a refusal you would hold.
Predict, then take one draw
At difficulty 2, write down how many attempts you expect before you press anything. Take one draw. Write down what you got. Resist the temptation to explain the gap, because there is nothing to explain.
Take four more single draws
Say out loud, after each one, whether you would be comfortable quoting it as the cost. By the fourth you should be able to say why the question is badly formed.
Run a batch and watch which number moves
Add twenty five draws. The mean walks towards 256 and settles. The smallest and largest keep moving apart. Name which of those two behaviours a cost estimate depends on.
Step up one difficulty and estimate first
Before switching to difficulty 3, say what you expect the mean to become. Then run a batch and compare against 4,115 over 120 trials. Being close is less interesting than knowing why you were able to predict it at all.
Price the attacker's rewrite in blocks
The rewrite from session 2 is 4 blocks. State its cost as a sentence a sceptic could not pull apart, using the mean per block and its trial count, and without multiplying anything you have not measured.
Write the refusal
One sentence you will say when somebody quotes a single benchmark figure as a cost. Keep it short enough to use in a meeting without sounding like an accusation.
The habit to keep. A mean without a trial count is an anecdote wearing a decimal point. Ask how many runs, ask for the smallest and largest, and treat a refusal to answer as the answer.
Three questions
What does a machine actually do when it mines a block at difficulty 3?
There is no method for computing a suitable nonce, because neighbouring nonces do not produce neighbouring digests. The expected number of tries at difficulty 3 is 4,096 and the measured mean over 120 trials is 4,115, which is what trying rather than solving looks like.
A single mining run at difficulty 3 comes back at 12,462 attempts. What have you learned?
12,462 was a real first run and it sits inside the measured range. A draw that far from the mean is unremarkable in a process with this spread, and treating it as evidence about the cost is the exact mistake the trial counts exist to prevent.
Why does raising difficulty change what an attacker faces, when session 2 showed the rewrite succeeding at difficulty 0?
Difficulty changes price, not detectability and not reversibility. The edit is still possible and still visible; what changes is that the attacker now pays per block, four times over, against a target that keeps moving.
Homework
Twenty minutes, on a number somebody in your organisation is already relying on.
Find a single run being quoted as a cost
A latency figure, a training time, a batch duration, a price per request. Find out how many runs it came from. Write down the answer, including when the answer is that nobody knows.
Name who holds the other copy
For the register you have been tracking since session 1, list every party outside your own team that holds an independent copy. Session 4 is about what that list does and what happens when it is empty.