learn-blockchain-with-phoebe / Leader session 1 of 6
Learn Blockchain with Phoebe · Leader session 1 of 6

What a chain actually is

Harbourgate is a port authority. It keeps a custody register for consignments moving through its cold store, and the sixth entry in that register reads "Consignment 42 inspected, seal broken". Somebody would prefer it did not. The register is arranged so that changing that line is not difficult but is impossible to do quietly, and the arrangement is two ideas deep. A fingerprint that changes completely when its input changes at all, and a list in which every entry carries the fingerprint of the one before it. Tonight is those two ideas and the six real hashes they produce.

🟡 Foundations Anyone being sold a chain Anyone who has to sign off on one 45 min
0-3 · Welcome 3-17 · A fingerprint 17-25 · A list of them 25-45 · Build-along and Q&A
Part 0

Harbourgate, and what its register has to survive

A custody register records who held what, and when. Its value is entirely in whether anyone can trust the old lines, because the old lines are what a dispute is argued over. Harbourgate's register holds six entries: the register opening, two consignments signed over to named buyers, two inspections, and one release. Nothing in it is money. It is provenance, which is the plainest thing a chain is good for and the easiest place to see the mechanism working.

Live = presented in the 45 minutes Self-study = the full depth, after class 🔍 Every diagram zooms

★ What you walk out with tonight. A one sentence account of the mechanism that you can say out loud without hedging: each block contains the previous block's hash. The Harbourgate register with its six real hashes, so the structure is a thing you have seen rather than a thing described to you. And the reason the fingerprint has to change completely rather than a little, which is the part that does the actual work.

LiveWithout the hype4 min▶

A chain is a data structure. It is a list, with one unusual rule about what each element has to contain, and the rule is enforced by arithmetic rather than by permissions. That is genuinely clever, and it is also completely mundane once seen, in the way that double entry bookkeeping is clever and mundane. Nothing in it is magic, nothing in it is new mathematics, and nothing in it knows whether the entry it is protecting is true.

The claim worth making about it is narrow and strong: you can hand the whole register to someone who does not trust you, and they can check for themselves that it has not been altered since it was written. The claims worth refusing are the wide ones, and refusing them is easier once the structure fits in one diagram.

Real world

Harbourgate's register runs at difficulty 0, which means no work was done to produce any of the six hashes beyond computing them. It is still fully tamper evident. Every property in tonight's session holds with no mining at all, which is worth knowing before mining is introduced, because mining is often described as the thing that makes a chain trustworthy and it is not.

Self-studyThe words that will keep coming back4 min▶
  • Hash. A function taking any input and returning a fixed length output. Also called a digest or a fingerprint. Part 1 tonight, and practitioner session 1.
  • SHA-256. One particular hash function, the one Harbourgate uses. It returns 64 hexadecimal characters no matter what goes in.
  • Block. One entry in the register, packaged with its position, its timestamp, the previous block's hash, and a number called a nonce.
  • Genesis block. The first block, which has no predecessor to point at. Part 2 tonight.
  • Avalanche. The property that a tiny change to the input produces an unrecognisably different digest. Without it the rest does not work.
  • Nonce. A number a block carries that can be varied freely without changing what the block says. Idle at difficulty 0, and the whole subject of session 3.
  • Merkle root. One hash standing for a whole set of records. Practitioner session 6.
  • Key management. Who holds which secret, and how it is rotated and revoked. A discipline of its own, covered in the security courses rather than here.
Part 1 · covers the hash

A fingerprint, and why it has to change completely

14 min live

A hash takes an input of any size and returns an output of one fixed size. Three characters in, 64 hexadecimal characters out. Three million characters in, 64 hexadecimal characters out. The three inputs below are the published test vectors, and Harbourgate's own implementation is checked against them before any register hash is believed.

Any input. One fixed size output. Every time. Any input Three characters or three million SHA-256 A function, not a store One fingerprint Always 64 hexadecimal characters INPUT DIGEST, CHECKED BEFORE ANY REGISTER HASH IS USED abc ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad the empty string e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 abcdbcdecdefdefgefghfghi jhijkijkljklmklmnlmnomnopnopq 248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1 Fixed length is the easy half. The hard half is that neighbouring inputs do not get neighbouring digests. Change one character and the output has no visible relationship to the one before it, which is what makes a near miss impossible to fake.
🔍 Click to zoom - the three inputs have lengths 3, 0 and 56. The three digests have length 64, 64 and 64.
Live Real SHA-256, running in this page. Change one character in either line.

...

...

...

...
LiveWhy a small change cannot make a small difference4 min▶

Imagine a fingerprint that behaved sensibly: similar inputs, similar outputs. Anyone wanting to alter an entry would simply nudge it until the digest landed back where it started, in the way you close in on a target by getting warmer. The whole structure would be worthless, because the attacker would have a gradient to climb.

The avalanche property removes the gradient. Every attempt is a fresh draw with no information carried over from the last one, so there is no warmer and no colder, only right or wrong. That is why a hash function is described as one way. Running it forwards is instant. Running it backwards has no method better than trying inputs.

LiveWhat the hash covers3 min▶

A block is hashed as a whole, not as a line of text. Its position in the register, its timestamp, its entry, the previous block's hash and its nonce all go in together. Change any one of those five and the digest changes, which means the digest is a statement about all of them at once.

This matters for what you are allowed to claim. A matching hash says the block is byte for byte what it was when the hash was taken. It says nothing about whether the inspector actually looked at the seal.

Self-studyWhere the disagreement really is4 min▶

There is a long running argument about whether a chain is a new idea at all. One side points out that hash linked records were published in the late 1970s and used in practice through the 1990s, that a list in which each element carries its predecessor's digest is a textbook structure, and that calling it a breakthrough is a sales pitch attached to a linked list.

The other side says the structure was never the contribution. The contribution was the packaging: a way for parties who do not trust each other to hold copies of the same register and agree on which one is current, with no administrator in the middle. On that view the data structure is old and the system around it is not.

Both readings are held by serious people and they lead to different purchasing decisions, so it is worth knowing which one the person opposite you holds. This session is deliberately about the part nobody disputes.

Part 2 · covers the chain

Six entries, and the link that runs through them

8 min live

Here is the register in full. The column on the right is the only structural idea in it: each block records the hash of the block before it, so the same sixteen characters appear twice, once as a block's own fingerprint and once as the next block's record of what it was built on.

The Harbourgate custody register, difficulty 0, timestamps 600 seconds apart BLOCK ENTRY THIS BLOCK'S HASH BEGINS PREVIOUS HASH IT RECORDS 0 Harbourgate opens the register 608eba0870199b95 none, this is the genesis block 1 Consignment 41 signed over to Pell and Sons 86202a0bab83df26 608eba0870199b95 2 Consignment 41 inspected, seal intact f325e5d96bee6a1d 86202a0bab83df26 3 Consignment 42 signed over to Ardwick Cold Store fc189d9dba7c4311 f325e5d96bee6a1d 4 Consignment 41 released to the buyer e5526e6e0bbc1aed fc189d9dba7c4311 5 Consignment 42 inspected, seal broken 1e9fa1742f98715d e5526e6e0bbc1aed Each block contains the previous block's hash. Edit any entry and its own fingerprint changes, while the block after it still records the fingerprint it had before.
🔍 Click to zoom - the right hand column is a copy of the column to its left, shifted down one row. That shift is the entire structure.
LiveThe genesis block has nothing to point at3 min▶

Block 0 is the exception that shows what the rule is for. Every other block inherits its credibility from the one before it, and block 0 has no predecessor, so its previous hash field is filled with a row of zeros standing in for a block that does not exist.

The consequence is worth saying plainly. The structure carries confidence forward from the start of the register, and it cannot manufacture any at the start. Whoever wrote block 0 and whoever was watching are the foundation, and no amount of hashing afterwards improves that.

LiveWhat the chain actually promises3 min▶

Hand a copy of the Harbourgate register to a buyer who thinks the port authority is covering something up. They recompute all six hashes themselves and compare each block's previous hash field with the hash of the block above it. If everything matches, they know the six entries are exactly the six entries that were written, in that order.

That is a real promise and it is narrower than it sounds. It covers the entries as written, not the events they describe, and it says nothing about entries that were never written down at all.

Self-studyTimestamps, nonces and the rest of the block4 min▶

Harbourgate's blocks carry fixed timestamps starting at 1758000000 and advancing 600 seconds per block, which makes the register reproducible: anyone rebuilding it from the six entries gets the same six hashes rather than six new ones. A real register takes its timestamps from a clock, and whose clock that is turns out to be a harder question than it looks.

The nonce field sits in every block doing nothing at difficulty 0. It exists so that a block's hash can be changed without changing what the block says, which sounds like a flaw and is the foundation of session 3.

Part 3 · build-along

Read the register the way a sceptic would

20 min hands on

No code. Six steps on the six entries above, done out loud. The aim is to be able to say what a matching hash proves and what it does not, without reaching for a metaphor.

Say the sentence

Out loud, without notes: each block contains the previous block's hash. Then say what that buys, in your own words, in one more sentence. If the second sentence needs the word "secure", replace it with something you could defend.

Find the same hash twice

Locate f325e5d96bee6a1d in two places in the register and say what each occurrence means. One of them is a fingerprint of a block. The other is a claim made by a different block about what it was built on.

Count what a digest depends on

Name the five things that go into a block's hash. Then say which of them an inspector in a cold store has any control over, and which of them are set by the register itself.

Try the two lines in the live box

Change a single character in either entry above and watch how many of the 64 output characters move. Then predict, before you press anything, whether changing a different character changes a different number of them.

Ask what block 0 rests on

Block 0 has no predecessor. Say who or what has to be trusted for the register to mean anything, and where that trust comes from, given that the structure cannot supply it.

Write the honest claim

In one sentence, write what you could tell a buyer about the Harbourgate register without overstating it. Keep the sentence. Session 2 tests whether it survives an attacker who is willing to do arithmetic.

The habit to keep. When somebody says a record is on a chain, the useful follow up is what the hash covers. It covers the bytes of the entry from the moment they were hashed. It does not cover whether the entry was accurate, whether anything was left out, or who was allowed to write it.

Check yourself

Three questions

Why does a hash function have to produce a completely different digest for a nearly identical input?

A gradient is a ladder. If getting closer to the original input produced a digest closer to the original digest, forging an entry would be a search with feedback rather than a blind one. The avalanche property removes the feedback, which is why every attempt is independent of the last.

Harbourgate's register runs at difficulty 0, so no mining was done. What does that mean for tamper evidence?

Detection and cost are separate. The six hashes in the register were computed with no mining and they check out exactly as they would at any difficulty. Mining changes what a rewrite costs, which is session 3, not whether a rewrite is visible.

A buyer recomputes every hash in the register and every link matches. What have they established?

The hash covers the bytes it was taken over. It has no access to the cold store, the inspector or the entries nobody wrote. An accurate chain of inaccurate entries verifies perfectly, which is the failure mode session 5 is built around.

Before session 2

Homework

Twenty minutes, on a record your own organisation keeps and would be embarrassed to have altered.

Find your block 0

Pick one register, log or audit trail you rely on. Write down who could change an old row in it today, and how anybody downstream would find out. If the answer is that nobody would, write that down too, because that is the finding.

Write the claim you would want to make

One sentence about that record, of the form you would be willing to put in front of a regulator or a customer. Bring it to session 2, which puts an attacker against it.

Covered tonight

What this session covers

✓A hash as a fixed length fingerprintAny input, 64 hexadecimal characters out, checked against the three published test vectors.
✓The avalanche propertyWhy a small change cannot make a small difference, and why that removes the attacker's gradient.
✓The link, and the genesis blockEach block contains the previous block's hash; block 0 has nothing to point at.
✓The Harbourgate register in fullSix entries and six real hashes, from 608eba0870199b95 to 1e9fa1742f98715d.
◐What an attacker does about a broken linkNamed tonight, worked through in session 2.
◐The nonce and what mining costsSitting idle at difficulty 0. Session 3.
○Key management, rotation and certificate hygieneA discipline of its own, covered in the security and access control courses.
○Named commercial chains and their roadmapsThey move faster than a course can, and none of the mechanism depends on which one.
Take this with you

Cheat sheet

The one sentence. Each block contains the previous block's hash.
A hash. Any input in, 64 hexadecimal characters out, every time.
Avalanche. One character different, an unrecognisable digest. No gradient to climb.
One way. Forwards is instant. Backwards has no method better than trying inputs.
What a block hashes. Position, timestamp, entry, previous hash, nonce, all together.
Genesis. Block 0 points at nothing, so the structure cannot supply trust at the start.
Harbourgate. Six entries, difficulty 0, first hash 608eba0870199b95, last 1e9fa1742f98715d.
The honest claim. The entries are as written. Not that they are true, and not that none are missing.