中文版 · Blockchain learning guide · Previous article
Blockchain learning · Extension BCX009

A trusted content identifier is a starting point for checking a file, not proof that a download contains every block needed to produce it. A root can be authentic while a required child is missing. Every supplied block can hash correctly while the file’s declared layout is invalid. A container can arrive intact while describing a different root from the one you intended to retrieve.
This lesson works through those distinctions with actual locally generated CIDv1 identifiers and inert bytes. The root uses DAG-JSON, but its teaching-file manifest is an explicitly fictional application format. It is not UnixFS, and the block collections are not claimed to be serialized CAR archives. Nothing is uploaded, fetched from a gateway or executed as content.
The reader’s job is to issue a precise reconstruction verdict: which requested bytes were verified, which required block or rule remains unresolved, and which wider claims the result does not establish.
Choose your reading route
In this guide
- 1. Decide which root is expected before opening the packet
- 2. Read a CID as a typed content address
- 3. Define the actual blocks and fictional file rules
- 4. Case A: verify the complete required graph
- 5. Case B: the root matches but B is absent
- 6. Case C: altered bytes retain the old claimed CID
- 7. Case D: extra blocks and arrival order
- 8. Case E: authentic blocks, invalid file semantics
- 9. Case F: the same file under a different root
- 10. Why a CAR header does not settle reconstruction
- 11. Completeness depends on the requested range
- 12. Keep the decoder’s authority bounded
- Exercise and model verdicts
- Sources and further reading
Sections 1–3 fix the trusted root, identifiers and application rules. Sections 4–9 examine complete, missing, altered and differently arranged packets. Sections 10–12 separate container claims, range requests and semantic acceptance. The final exercise supplies exact answers. For ownership and permission questions, use the existing metadata, files and permission lesson.
Back to contents · Next section
1. Decide which root is expected before opening the packet
Our fictional archive request identifies expected root R through an authenticated project record. The authority and authenticity of that record are supplied assumptions; this lesson does not prove them from a file’s hash. The requested task is initially to reconstruct the entire file under the declared teaching-file rules.
A transport header may advertise roots, but it cannot replace that external expected-root decision. If a sender provides a different internally consistent object, it may be a valid object for another request while still failing this one.
We distinguish three questions throughout: do the bytes match their claimed identifiers; do the necessary linked blocks exist; and does the declared application decode them into the requested file? Success on the first question alone does not answer the other two.
For every case except the expressly independent invalid-layout fixture, R remains the expected root. The independent fixture will authenticate its own root Q so that its failure can be attributed to layout rather than mistaken root identity.
Back to contents · Next section
2. Read a CID as a typed content address
The maintained CID specification describes version, codec and multihash information. In our fixture, every identifier uses CIDv1 with SHA-256 and a 32-byte digest. Children use raw codec 0x55; the root uses DAG-JSON codec 0x0129. The textual strings use unpadded lowercase base32 with prefix b.
Verification must respect the expected codec as well as the digest. A root expected to decode as DAG-JSON cannot simply be treated as raw file content because its bytes were successfully hashed. The CID’s interpretation information is part of the requested object identity.
The DAG-JSON specification represents a link with a single-key object whose key is a slash and whose value is the encoded CID. Its encoding rules sort keys by UTF-8 bytes and remove whitespace. Our root is hashed in exactly that compact serialization, without a trailing newline.
Do not pretty-print the root and hash the prettified bytes as though they were the original block. Decoding can reveal the same logical fields while reserialization changes the byte sequence being checked. Hash the received bytes first, then decode under the expected format.
Back to contents · Next section
3. Define the actual blocks and fictional file rules
Raw block A contains five bytes: hex 424c55450a, the text BLUE followed by a line feed. Its CID is bafkreihgnpiozg2kencb7bpzz45batt2qeltqkotudxmj2ddtsqi6vm7xi.
Raw block B contains eight bytes: hex 415243484956450a, the text ARCHIVE followed by a line feed. Its CID is bafkreic4d4yol4bxxzrrx5kpbnjbgbghpo2dtp7jb54dtoefug2qthdsjq.
The root has four fields. Chunks is an ordered list of DAG-JSON links to A and then B. Lengths is the list [5,8]. Size is 13. Type is the string teaching-file. In the serialized object the actual field names are lowercase: chunks, lengths, size and type.
The application rule requires the teaching-file type, one nonnegative integer length per link, raw children, each child’s actual length equal to its declared length, and size equal to the sum. The full file is the children concatenated in link order. These are our application rules, not requirements imposed on every DAG-JSON object or every IPFS file.
R is baguqeeramvml7dhzojpngspl4cgqbes7lkzct3xizbksadixd7cxyenyatfq. Its exact 197-byte UTF-8 root serialization is:
{“chunks”:[{“/”:”bafkreihgnpiozg2kencb7bpzz45batt2qeltqkotudxmj2ddtsqi6vm7xi”},{“/”:”bafkreic4d4yol4bxxzrrx5kpbnjbgbghpo2dtp7jb54dtoefug2qthdsjq”}],”lengths”:[5,8],”size”:13,”type”:”teaching-file”}
These identifiers were generated from the specified bytes locally. The small fixture lets a reviewer reproduce both encoding and arithmetic; it is not evidence that the blocks are hosted anywhere.
Back to contents · Next section
4. Case A: verify the complete required graph
The complete packet supplies R’s root block, A and B. First compare the root’s exact bytes against the expected DAG-JSON CID. Decode its links and fields only after that check. Then verify A and B against their respective raw CIDs and inspect the declared application lengths.
A has five bytes and B has eight, so both child lengths pass. The sum is thirteen, matching size. The accepted output is hex 424c55450a415243484956450a: BLUE, line feed, ARCHIVE, line feed. Both line feeds are part of the file.
The whole-file SHA-256 is 3a43669f79ee0079317aa00068471d1c0e7c518a8d2db3ad6b04d80463c34bd0. This checksum describes the reconstructed thirteen bytes. It is a different calculation from hashing the 197-byte root block.
A useful result is “the full thirteen-byte file was reconstructed under the supplied teaching-file rules from the authenticated expected root and its required verified children.” It does not need the vague claim that every possible object in the packet was meaningful or that all future copies will remain available.
Back to contents · Next section
5. Case B: the root matches but B is absent
The packet now supplies the correct root and A, but no block for B’s CID. Root verification succeeds. A’s verification succeeds. The full-file task remains incomplete because the second linked block is required and unavailable in this packet.
Report the missing CID and its expected role: the eight-byte second chunk. Do not silently return only BLUE and label it the complete file. Do not insert eight zero bytes to satisfy the declared size. Neither action follows the application rule.
This is not evidence that B never existed or can never be retrieved. It establishes a bounded absence from the supplied collection. Availability elsewhere is outside the present exercise, and no external retrieval is attempted.
The case distinguishes authentic structure from available payload. A verified link tells the reviewer what to request or look for, but the link is not a substitute for the linked bytes.
Back to contents · Next section
6. Case C: altered bytes retain the old claimed CID
Restore a claimed B entry, but supply the eight bytes for ARCHIVE followed by an exclamation mark instead of a line feed. Its hex is 4152434849564521. The entry still claims B’s original CID.
The length is still eight, so a length-only check would miss the alteration. SHA-256 verification against the claimed CID fails. Reject that entry as a source of the required B bytes and leave the full-file task unfulfilled.
If the sender computes a new CID for the altered bytes, that would accurately identify another block. It would not make the new block the child linked by the already authenticated R. Replacing the root link would in turn change the root block and its expected identity.
The lesson does not require identifying who caused the discrepancy or whether it was intentional. The evidence supports a byte-identity failure, not an accusation about the sender’s motives.
Back to contents · Next section
7. Case D: extra blocks and arrival order
A separate packet contains all required blocks plus raw X, whose bytes are UNUSED followed by a line feed. X is seven bytes and has a valid CID, bafkreieifnz4q6bl3xhkam5cendvm42vfsdgfzy4ohetdadz5szlwcronm. Nothing in R links to X.
Under this lesson’s policy allowing unrelated extras, X does not prevent the requested file from being reconstructed. It also does not add seven bytes to the output. Report that it is outside the required graph. An application with a different strict packet policy would need to declare that policy separately.
Now let the required blocks arrive in order B, root, A. After collecting and validating them by identifier, reconstruction still follows R’s link order A then B. It does not follow arrival order or alphabetical order of the CID strings.
Appending B then A would produce ARCHIVE, line feed, BLUE, line feed. That has the same total length thirteen but different bytes. Matching a size alone therefore cannot validate reconstruction order.
Back to contents · Next section
8. Case E: authentic blocks, invalid file semantics
This case has a different independently authenticated expected root Q: baguqeerai6pgtxgnnwkjhlpwgmnu2u4qjjjah3x2nln4ohxvf5gwn2keolhq. Q links to the same A and B but declares lengths [5,7] and size 12. Its own compact bytes are correctly hashed, and both children still verify under their CIDs.
The declared lengths sum to twelve, so that internal arithmetic passes. But the second child actually has eight bytes, not seven. The full-file teaching format therefore rejects this layout at the child-length rule.
No hash failure is needed for this rejection. Hashes bind bytes; they do not make arbitrary application fields mutually consistent. It would be wrong to truncate B to seven bytes merely to make the declared value true, because our rules require exact child length rather than an implicit truncation operation.
Q must not be confused with a substituted R. For this independent test, Q is the requested root on purpose. That lets us isolate the semantic failure after successful identity verification. If the request still named R, receiving Q would first fail the root-selection requirement.
Back to contents · Next section
9. Case F: the same file under a different root
The thirteen output bytes can also be represented as one raw block. Its CID is bafkreib2intj66poab4tc6vaabueohi4bz6fdcunfwz222ye3acghq2l2a. This identifier is different from R because it identifies the raw file bytes rather than our linked DAG-JSON manifest.
For an independently authorized raw-file request naming that CID, the single block reconstructs the same thirteen-byte output directly. It does not require the two-child manifest. Conversely, supplying only that raw block does not satisfy a request to validate R’s particular manifest and linked representation.
IPFS’s content-addressing guide distinguishes representation choices from the file bytes they reconstruct. It also acknowledges the single raw-block case where the digest is directly the file’s hash. Therefore “a CID digest can never equal a file checksum” is too broad.
Changing the textual base used to display the same binary CID is another, separate matter. Do not infer a new file merely because an equivalent identifier is printed differently. In this fixture, however, the manifest root and raw-file root genuinely identify different representations.
Back to contents · Next section
10. Why a CAR header does not settle reconstruction
The CARv1 specification is marked Final. It defines a container with a header and CID-associated block data, but does not require every advertised root to describe a complete graph of all necessary descendants. It also allows blocks unrelated to the header’s root graphs.
Thus container framing, per-block identity, requested-root selection and application reconstruction are separate checks. A syntactically valid container is not a certificate that the requested file is complete. A header’s root list is not authority to replace the root supplied by the user’s authenticated request.
In a hypothetical container advertising Q while the authenticated request names R, retain R as the target. If R and its required children are present, assess them under the declared policy; if R is absent, report that the requested object is unavailable in the packet. Do not quietly reconstruct Q and call the request satisfied.
Our worked packets are simple supplied collections of blocks, not generated CAR binaries. We use the specification to explain what a container would and would not add. No CAR parser conformance, transport download or archive upload is claimed.
Back to contents · Next section
11. Completeness depends on the requested range
Change the task explicitly: request only byte positions 0 through 4, written as range [0,5), under R’s teaching-file policy. The first endpoint is included and the second excluded. The verified manifest assigns these five bytes entirely to A.
For this range-only policy, the correct root and verified A suffice to return BLUE followed by its line feed. B may remain absent. The result must say that the requested range was verified from the manifest and available child; it must not certify the whole file or the actual length of the unseen B block.
A request for [4,7) crosses the chunk boundary. It needs A’s last byte and B’s first two bytes: hex 0a4152. Under this fixture’s block-level verification policy, both complete child blocks are verified before extracting those three output bytes.
A broad “complete” label without a task definition is therefore misleading. Record whether the request concerns the full file, a range, a directory or another traversal. Different tasks can require different subsets even when they begin from the same root.
Back to contents · Next section
12. Keep the decoder’s authority bounded
The checked UnixFS specification page is dated 17 September 2026 and marked draft. UnixFS has its own file-node and layout rules. Our DAG-JSON teaching-file schema is not a substitute implementation and should not be accepted by a decoder that only promises UnixFS support.
Likewise, a valid CID with an unsupported codec is not permission to guess a decoder from a filename. The verifier should identify that limitation and stop the unsupported reconstruction. The allowed codecs here are explicitly raw for children and DAG-JSON for our root.
Practical parsers also need declared limits on input sizes, block counts, nesting and output allocation before processing untrusted collections. Our tiny fixed fixture does not implement a general hardened parser. The local calculations only inspect inert bytes and do not execute retrieved content.
A successful reconstruction establishes byte correspondence under the supplied root and rules. It does not establish authorship, licence, factual truth, permanent hosting or blockchain finality. Those wider questions remain separate even when every required block is present.
Back to contents · Next section
Exercise and model verdicts
- Root R and A verify, but B is missing. Is the full file complete? No; identify B’s CID as the missing eight-byte second child.
- Altered B is still eight bytes. Does that make it acceptable? No. Its digest must match the CID linked by R.
- Does unrelated valid X enlarge the file to twenty bytes? No. It is not in the requested graph; the accepted full output remains thirteen bytes.
- Does arrival order B, root, A reverse the file? No. The manifest’s link order remains A then B.
- Q and its children all hash correctly. Why does the full task reject? The declared second length is seven but B contains eight bytes.
- Is the raw whole-file CID the same as R? No. The output bytes can agree while their representations and roots differ.
- What does range [4,7) return? Hex 0a4152: line feed, A, R. It needs both children under the stated verification policy.
- Does a container header naming Q change an authenticated request for R? No. Root authority is not supplied by the untrusted header.
A concise full-file verdict is: “R and both required raw children verify. The application lengths are 5 and 8, the total is 13, and link-order reconstruction produces the stated thirteen bytes. Extra X is unrelated. This result concerns the requested file under the teaching-file schema, not UnixFS conformance or permission to use the content.”
Back to contents · Next section
Sources and further reading
- CID specification: Permanent, page dated 26 June 2026; typed identifiers and binary/text encoding, checked 12 October 2026.
- DAG-JSON specification: Descriptive–Final; ordered encoding and link representation, checked 12 October 2026.
- CARv1 specification: Final; container scope and graph-completeness limits, checked 12 October 2026.
- IPFS content addressing: representation and raw single-block distinctions, checked 12 October 2026.
- UnixFS specification: draft dated 17 September 2026, checked 12 October 2026; referenced to distinguish its rules from our fictional manifest.
The practical achievement is a bounded answer about the requested bytes, supported by the exact root, required blocks, decoder and failed or satisfied conditions.
