A block header commits the previous block and Merkle root. Inclusion proofs verify an ordered leaf against a trusted root.
Before operating the equipment or executing the program, derive the expected outcome using the required theoretical work in Experiment. Use the diagram to identify the variables and system boundaries.
BC-M06 · Academic orientation
Scope and objectives
Scope of the experiment
Build the eight-transaction binary hash tree shown in the module. Inspect ordered hash inputs, root and logarithmic inclusion proof with a trusted header root.
The focus of this experiment is to construct a Merkle root from ordered leaf digests. Students then trace an inclusion proof and sibling ordering, and verify the trusted root and explain what inclusion does not prove. The Concepts view explains the operation before the practical work; the Simulation view is used to examine reference and changed inputs, not to substitute for actual measurements.
Learning objectives
Construct a Merkle root from ordered leaf digests.
Trace an inclusion proof and sibling ordering.
Verify the trusted root and explain what inclusion does not prove.
Identify the configured inputs (Ordered transactions (semicolon separated); Leaf index (zero based); Candidate transaction; Proof modification; Previous block hash (teaching header)) and record the corresponding observed outputs with units where applicable.
Compare the reference calculation or decision with an independent implementation or authorized observation; state any discrepancy and the applicable model boundary.
Expected learning outcomes
On completion, students can construct a Merkle root from ordered leaf digests, trace an inclusion proof and sibling ordering, and verify the trusted root and explain what inclusion does not prove.
Required deliverables
Submit the derivation or state trace for the named operation, the exact reference and changed configurations, the associated simulator or practical evidence, and a short validation statement addressing verify the trusted root and explain what inclusion does not prove. Separate predicted values from observations.
Prerequisite knowledge and related learning
Review the foundational terminology in Concepts and confirm readiness using the existing setup instructions. After completion, continue to Mining, nonce search and double spending.
Environment and experimental methodology
The listed browser model and experiment-specific local Python, Solidity or EVM workflow, where provided. Do not treat a model as a deployed ledger.
Begin with a manual prediction, record the baseline, change one independent condition at a time, and compare the resulting trace or measurements with the original prediction. Record observations and uncertainty separately from reference values. Follow the experiment’s specific procedure, safety limits, and acceptance checks.
Scientific theory · Header commitment and inclusion
A block header links to the previous header and commits transactions through a Merkle root. A light client verifies inclusion using sibling hashes and orientation against a trusted header; it does not download every transaction in this model. Header authenticity and consensus are additional checks.
Worked example and engineering interpretation
A balanced four-leaf Merkle tree requires two sibling hashes for an inclusion proof. Modify one leaf, recompute its ancestor hashes and compare against the original trusted root. A locally recomputed root is not the same as a proof against the original commitment.
Engineering principles · additional worked teaching example
A Merkle proof contains sibling hashes and left/right ordering. In a four-leaf tree with h0…h3, leaf2 proof uses h3 then H(h0‖h1); compute H(h2‖h3), then combine with left subtree. The trusted root is essential.
From theory to experiment
Predict the reference result before operating the workbench; check the actual intermediate state, units and constraints. The existing simulation, implementation and procedure below are distinct sources of evidence.
Worked engineering reasoning and boundary conditions
Engineering reference configuration: Ordered transactions (semicolon separated) = T1;T2;T3;T4;T5;T6;T7;T8; Leaf index (zero based) = 2; Candidate transaction = T3; Proof modification = none; Previous block hash (teaching header) = 0000000000000000000000000000000000000000000000000000000000000000; Header nonce = 0. In the classroom model, Verified = Yes; Tree hash operations = 15; Proof bytes = 96 B; Full leaf hashes = 256 B. The original tree and header trust anchor are calculated from the editable transaction set; the independent candidate and sibling order are then verified. Actual SHA-256 with explicit domain-separated UTF-8 teaching encoding. Not Bitcoin wire serialization or Ethereum Keccak.
Use the diagram to follow the calculation or state progression. Keep the teaching configuration separate from the independent exercise values; compare observations with the actual model and implementation.
Mathematical representation and interpretation
Merkle parent construction
The child digests are concatenated in the defined order using the same byte representation; membership depends on the independently trusted root.
\[h_{i,j}=H(h_i\parallel h_j)\]
Concept animation · independent state notebook
Explore the teaching example independently of the simulator. Each step reveals an operation, data relationship or calculated state. The Simulation view has separate editable inputs.
Teaching example only; inspect live calculations or real practical evidence separately.
How to investigate Blockchain elements: Merkle trees and light clients
Build the eight-transaction binary hash tree shown in the module. Inspect ordered hash inputs, root and logarithmic inclusion proof with a trusted header root.
Analytical investigation means collecting an observation, identifying the mechanism, using a calculation or state trace to explain it, and checking your conclusion against evidence. Controlled comparison means changing one independent variable, holding the remaining relevant conditions constant, and measuring a dependent variable against a baseline. Experimental validation means comparing a predicted result to a reproducible observation or assertion; agreement inside a model does not certify hardware. Evidence-based reasoning connects a specific observation to a theoretical rule and states uncertainty, not merely an opinion. Performance characterization records a named metric and its units across conditions; sensitivity analysis changes one parameter across several values. A threat assessment links an asset, threat, consequence and evidence to a mitigation.
Experiment-specific guided practice
Objective: Build the eight-transaction binary hash tree shown in the module. Inspect ordered hash inputs, root and logarithmic inclusion proof with a trusted header root.
Use T1 through T8, zero-based leaf index 2, candidate T3. Inspect all eight leaf hashes, four first parents, two second parents and one root. Confirm 15 tree hashes.
Inspect each exact hash input: leaf: followed by the JSON-encoded record; node: followed by two ordered 64-hex digests. Explain why left/right order matters.
Change only candidate to T3 modified; trusted root must stay fixed and computed root must change. Restore candidate and modify one sibling or its order.
Use four records and leaf 2. Calculate 7 hashes and 64 raw proof bytes; compare with 8 records (15 hashes, 96 bytes).
Reference check: Four leaves require 7 digests and 2 proof siblings; eight require 15 digests and 3 siblings. Modified candidate fails against the original root.
Model boundary: Domain-separated UTF-8 encoding matches the existing teaching labs; not Bitcoin double-SHA256 byte serialization or Ethereum Keccak. Inclusion does not establish finality or source truth.
Independent task and submission evidence
2. Inspect each exact hash input: leaf: followed by the JSON-encoded record; node: followed by two ordered 64-hex digests. Explain why left/right order matters. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat.
Before execution write the independent variable and its levels, dependent observation with units where applicable, baseline, controlled variables, measurement method and expected result. For a state machine use state/event/output rather than inventing a numeric metric. Record failures and repeat the baseline. A weak conclusion is “it works”; a supported conclusion names the changed setting, observed value/state, corresponding rule and one limitation.
Trial
Changed setting
Fixed settings
Predicted result
Actual observation / units
Evidence / uncertainty
A: baseline
Reference
Record
Predict
Record
Record
B: one change
Record
Same as A
Predict
Record
Record
A: repeat
Restore
Same as A
Predict
Record
Record
Completion: submit the filled table, relevant simulator screenshot or terminal/notebook output, reasoning with units/assumptions, and one limitation. Preserve the independent assessment questions; this guide does not fill their answers.
Build the eight-transaction binary hash tree shown in the module. Inspect ordered hash inputs, root and logarithmic inclusion proof with a trusted header root.
Learning goals
Explain the mechanism using the actual intermediate states in this experiment.
Predict and verify the reference and modified conditions described below.
Interpret the acceptance criteria and identify the limits of the model.
Module flashcards · 12 questions
Browse all 12 questions and explanationsWhat is a leaf hash?
The digest of one encoded record.
How are internal hashes constructed here?
SHA-256 of the node prefix and ordered hexadecimal child digests.
How many siblings prove membership in an eight-leaf complete tree?
Three 32-byte sibling digests plus ordering/index information.
What happens if the verifier replaces the trusted root after tampering?
The comparison no longer checks against the original commitment.
Why is child order important?
H(left || right) generally differs from H(right || left).
How many total hashes for four leaves?
Seven: four leaves, two parents and the root.
How many total hashes for eight leaves?
Fifteen: eight leaves, four first-level parents, two next-level parents and the root.
What changes when one of eight leaves is edited?
Its leaf and three ancestor digests change; unrelated subtree hashes remain unchanged.
How many total digests are computed for four leaves?
Seven: four leaf digests and three internal digests.
How many total digests are computed for eight leaves?
Fifteen: eight leaf digests and seven internal digests.
How many sibling hashes are needed in the eight-leaf membership proof?
Three, one per level.
Why must the original root remain trusted during the tampering trial?
Replacing the trusted root with a new root would invalidate the integrity comparison.
Engineering diagram · BC-M06. Use the interactive workstation to investigate the calculated state.Loading experiment-specific apparatus…Previous model / additional reference tools
Loading computational workbench…
Independent theoretical exercises
Before the simulation or practical, solve both experiment-specific tasks. List the given inputs, show the intermediate calculation or state trace, identify the expected observation, and state a limitation. Show formulas and intermediate calculations where relevant, or draw the requested state/sequence diagram. These are independent classroom fixtures; where they differ from the reference configuration below, do not treat them as measured values. Compare your predictions with the corresponding experiment afterwards.
01 · Predict and derive using the given inputs
Draw an eight-leaf tree T1…T8 and calculate the sibling indices/levels for leaf 2. Write root hash expressions.
Engineering method — A Merkle proof contains sibling hashes and left/right ordering. In a four-leaf tree with h0…h3, leaf2 proof uses h3 then H(h0‖h1); compute H(h2‖h3), then combine with left subtree. The trusted root is essential. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
02 · Compare or justify using evidence
Change T3, recalculate affected ancestors symbolically and identify which next-block pointer becomes invalid when the header is rebuilt.
Engineering method — A Merkle proof contains sibling hashes and left/right ordering. In a four-leaf tree with h0…h3, leaf2 proof uses h3 then H(h0‖h1); compute H(h2‖h3), then combine with left subtree. The trusted root is essential. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
03 · Diagram tracing
Diagram tracing · Independent work
In an eight-leaf binary tree, give the sibling subtrees and order for leaf5 (zero-based), assuming no odd-leaf padding. How many hashes are supplied?
Diagram tracing — A Merkle proof contains sibling hashes and left/right ordering. In a four-leaf tree with h0…h3, leaf2 proof uses h3 then H(h0‖h1); compute H(h2‖h3), then combine with left subtree. The trusted root is essential. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
Work is saved locally when browser storage is available. Export it for submission; no remote upload or automatic grade is assigned.
Expanded independent theoretical exercise bank
Progress from calculation and interpretation to diagnosis and controlled engineering design. Complete the questions without opening the simulation first; show intermediate steps.
Intermediate · Explain a changed-input result
Independent theoretical exercise · BC-M06-01
Use the reference configuration (Ordered transactions (semicolon separated) = T1;T2;T3;T4;T5;T6;T7;T8; Leaf index (zero based) = 2; Candidate transaction = T3; Proof modification = none; Previous block hash (teaching header) = 0000000000000000000000000000000000000000000000000000000000000000; Header nonce = 0), but change Leaf index (zero based) = 4. The model reports Verified = No. Explain the governing rule and assumptions that make this output plausible; identify an independent verification method.
Intermediate · Interpret a state transition
Independent theoretical exercise · BC-M06-02
The reference model reports Verified: Yes. Under Leaf index (zero based) = 4 it reports No. Explain which configured condition changed and what the two outputs establish, and what they do not establish.
Intermediate · Interpret a technical trace
Independent theoretical exercise · BC-M06-03
For Proof modification = modified sibling, the model supplies this excerpt from Independent inclusion proof:
Step · Sibling side · Exact input · Computed digest
Candidate leaf · — · leaf:"T3" · 50de762b8fd96e8569a78309bf140d660cb5abe719615cd93bd9d2c025f1d957
Level 1 · right · node:50de762b8fd96e8569a78309bf140d660cb5abe719615cd93bd9d2c025f1d957b9becbef22beacf… · 2d8be19583b71f7f8ef312ebf694fe9303835e74a740f12f019b4b0b6ae29025
Level 2 · left · node:f120b2acb5b3c7259422689fc72779eb1c95e09ea6cbdc9338935b2908d1b7c92d8be19583b71f7… · 052201e250d81a9252b1f1ab2f689e85094e20c40bf99511710fb19eedd13971
Level 3 · right · node:052201e250d81a9252b1f1ab2f689e85094e20c40bf99511710fb19eedd13971e0c251566b9b6c7… · 724960061f141656e7a1532c4191da309eb822ff04a802b480286f551134da1a
Count rows whose Sibling side value is exactly “right”, and identify the displayed row numbers. Explain what the count describes.
Advanced · Reverse reasoning
Independent theoretical exercise · BC-M06-04
An observation is Verified = No. Candidate A uses Ordered transactions (semicolon separated) = T1;T2;T3;T4;T5;T6;T7;T8; Leaf index (zero based) = 2; Candidate transaction = T3; Proof modification = none; Previous block hash (teaching header) = 0000000000000000000000000000000000000000000000000000000000000000; Header nonce = 0. Candidate B changes the listed settings (Proof modification = modified sibling) and keeps the remaining settings fixed. Which is consistent with the observation? If both can explain it, say what additional evidence is required.
Advanced · Diagnose a reported mismatch
Independent theoretical exercise · BC-M06-05
A student configures Candidate transaction = T3 modified while preserving all other reference settings, but copies the reference report of Verified = Yes. Evaluate whether the report is justified. Identify the first configuration/output check to perform.
Challenging · Design a controlled verification
Independent theoretical exercise · BC-M06-06
Design a controlled comparison for Blockchain elements: Merkle trees and light clients using reference Ordered transactions (semicolon separated) = T1;T2;T3;T4;T5;T6;T7;T8; Leaf index (zero based) = 2; Candidate transaction = T3; Proof modification = none; Previous block hash (teaching header) = 0000000000000000000000000000000000000000000000000000000000000000; Header nonce = 0 and test Leaf index (zero based) = 4. Specify the changed setting(s), measured metric Verified, controls, repetitions, an acceptance check and what evidence can distinguish an actual implementation from the model.
Step-by-step experimental procedure
Construct and independently verify the ordered binary hash tree that supports resource-constrained light clients.
1 · Reference workbench configuration
Use the named reference workbench and its reference inputs. Additional live instruments may have different controls; use the matching instrument. Record virtual and practical results separately.
Use T1 through T8, zero-based leaf index 2, candidate T3. Inspect all eight leaf hashes, four first parents, two second parents and one root. Confirm 15 tree hashes.
Inspect each exact hash input: leaf: followed by the JSON-encoded record; node: followed by two ordered 64-hex digests. Explain why left/right order matters.
Change only candidate to T3 modified; trusted root must stay fixed and computed root must change. Restore candidate and modify one sibling or its order.
Use four records and leaf 2. Calculate 7 hashes and 64 raw proof bytes; compare with 8 records (15 hashes, 96 bytes).
Change the header nonce while preserving the transaction list. Compare the block-header digest and unchanged Merkle root.
Explain the bandwidth benefit of a proof plus trusted header, versus downloading all transactions; calculate proof bytes for a 64-leaf tree.
3 · Compare controlled trials
Trial
Independent change
Expected check
Observation
Eight leaves
Use reference inputs above
Verified: Yes; Tree hash operations: 15; Proof bytes: 96
Model boundary: Actual SHA-256 with explicit domain-separated UTF-8 teaching encoding. Not Bitcoin wire serialization or Ethereum Keccak.
Controlled investigation · reproducible evidence
Method. Use the existing reference workbench configuration and the named controlled changes below. A controlled variable stays fixed while the independent variable is intentionally changed; the dependent variable is the resulting observed output. First predict each trial from the Concepts page. Run the baseline, then change only the specified setting and record the outcome. For deterministic traces one execution per case and a repeated verification are sufficient; for timing or stochastic measurements repeat at least five times, recording each run, median and range. Reset to the reference state between independent comparisons.
Evidence: attach the completed comparison table, one trace or screenshot per condition, and actual practical terminal/hardware evidence where applicable. Explain any prediction mismatch and distinguish modeled behavior from measured results.
Loading laboratory-specific procedure…
Python / Google Colab notebook
Original module reference toolkit; genuine SHA-256 and bounded search. Validated locally in a fresh Jupyter kernel. Download, then upload to Google Colab.
Download this notebook and open Google Colab. Select File → Upload notebook and choose the downloaded .ipynb.
Read the Markdown instructions before each executable cell. Use a Python runtime, run cells from top to bottom, and resolve imports if necessary.
Perform the baseline and controlled changes. Save the notebook with actual outputs and your written interpretation.
Execution scope: Domain-separated UTF-8 encoding matches the existing teaching labs; not Bitcoin double-SHA256 byte serialization or Ethereum Keccak. Inclusion does not establish finality or source truth. Default computational cells passed isolated local Python execution; physical equipment and live services require separate verification.
01Instructions · Markdown
# BC-M06 · Blockchain elements: Merkle trees and light clients
**PSUT IoT Engineering Studio — Dr. Mohammad Alja’afreh**
## Introduction
Build the eight-transaction binary hash tree shown in the module. Inspect ordered hash inputs, root and logarithmic inclusion proof with a trusted header root.
## How to run
1. Download this notebook from the laboratory page. Open Google Colab → File → Upload notebook.
2. Select a Python CPU runtime. Run cells from top to bottom using Shift+Enter, or Runtime → Run all.
3. Read the printed observations and assertions. Change one parameter at a time and rerun the relevant cell.
4. Save your own outputs and compare them to the portal Experiment tab.
**Execution boundary:** Original module reference toolkit; genuine SHA-256 and bounded search. Do not run the hardware or service commands in Colab. No real credentials are needed. The notebook is self-contained.
02Instructions · Markdown
## Experiment-specific preparation
Build the eight-transaction binary hash tree shown in the module. Inspect ordered hash inputs, root and logarithmic inclusion proof with a trusted header root.
**Reference procedure (use the matching simulator/WSL tool where named, not an unrelated service):**
1. Use T1 through T8, zero-based leaf index 2, candidate T3. Inspect all eight leaf hashes, four first parents, two second parents and one root. Confirm 15 tree hashes.
2. Inspect each exact hash input: leaf: followed by the JSON-encoded record; node: followed by two ordered 64-hex digests. Explain why left/right order matters.
3. Change only candidate to T3 modified; trusted root must stay fixed and computed root must change. Restore candidate and modify one sibling or its order.
4. Use four records and leaf 2. Calculate 7 hashes and 64 raw proof bytes; compare with 8 records (15 hashes, 96 bytes).
5. Change the header nonce while preserving the transaction list. Compare the block-header digest and unchanged Merkle root.
**Evidence:** Four leaves require 7 digests and 2 proof siblings; eight require 15 digests and 3 siblings. Modified candidate fails against the original root.
**Boundary:** Domain-separated UTF-8 encoding matches the existing teaching labs; not Bitcoin double-SHA256 byte serialization or Ethereum Keccak. Inclusion does not establish finality or source truth.
03Instructions · Markdown
## 1. Objectives and reference condition
- Reproduce the specific computational mechanism in this laboratory.
- Inspect the output, compare the reference condition with a changed or rejected condition where implemented, and explain any discrepancy.
- Distinguish actual local Python execution from mock, physical and external-service observations.
## 2. Environment check
04Python · executable cell
PYTHON · Code cell
# =====================================================================
# BC-M06 | Code cell 01 | Blockchain elements: Merkle trees and light clients
# Purpose: 1. Objectives and reference condition - Reproduce the specific computational mechanism in this laboratory. - Inspect the output, compare the reference condition with a changed or rejected condition where implem
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
import sys
print("Python",sys.version.split()[0])
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert sys.version_info >= (3,10)
## 3. Implementation
Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
06Python · executable cell
PYTHON · Code cell
# =====================================================================
# BC-M06 | Code cell 02 | Blockchain elements: Merkle trees and light clients
# Purpose: implement only the mechanism named in this laboratory.
# Inputs: the explicit fictional fixture and reference parameters below.
# Output: printed observations and assertions for the controlled trial.
# =====================================================================
import hashlib,json
def serialize(obj):
return json.dumps(obj, ensure_ascii=False, separators=(',', ':'))
def sha(text):
return hashlib.sha256(text.encode('utf-8')).hexdigest()
def tree(values):
if len(values) not in (4,8): raise ValueError('Use 4 or 8 leaves')
levels = [[sha('leaf:' + serialize(v)) for v in values]]
while len(levels[-1]) > 1:
a=levels[-1]; levels.append([sha('node:' + a[i] + a[i+1]) for i in range(0,len(a),2)])
return levels
def prove(levels,index,candidate):
current=sha('leaf:'+serialize(candidate)); steps=[dict(input='leaf:'+serialize(candidate),digest=current)]
for row in levels[:-1]:
sibling=row[index^1]; text='node:'+(sibling+current if index&1 else current+sibling);current=sha(text)
steps.append(dict(input=text,digest=current,sibling=sibling,side='left' if index&1 else 'right'));index//=2
return dict(valid=current==levels[-1][0],steps=steps,computedRoot=current,trustedRoot=levels[-1][0])
values=[f'sensor-{i+1}:temp={25+i}' for i in range(8)]
levels=tree(values);proof=prove(levels,0,values[0]);tampered=prove(levels,0,'changed')
print('root',levels[-1][0],'proof',proof,'tampered valid',tampered['valid'])
assert proof['valid'] and not tampered['valid']
## Original portal implementation (reference only)
These are the actual laboratory snippets. They are retained for comparison; follow the portal setup for WSL, hardware or services. They are **not** executed by Run all.
```bash
python3 reference.py merkle --count 8 --leaf 0
```
08Instructions · Markdown
## 4. Results and analysis
Record the actual output and whether the assertions pass. Identify a parameter to vary, state your prediction, repeat the reference calculation, then explain the changed result.
| Trial | Configuration | Observation | Interpretation |
|---|---|---|---|
| A | Reference | | |
| B | One controlled change | | |
| C | Reference repeat | | |
**Limitations:** Original module reference toolkit; genuine SHA-256 and bounded search. Notebook success does not certify external equipment or services.
09Instructions · Markdown
## Guided reasoning and evidence
A controlled comparison changes one independent input while keeping the other relevant inputs fixed; the dependent variable is the recorded output. Use this lab’s reference condition above.
**Independent task:** 2. Inspect each exact hash input: leaf: followed by the JSON-encoded record; node: followed by two ordered 64-hex digests. Explain why left/right order matters. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat.
| Trial | Input/configuration | Prediction | Observation | Evidence / limitation |
|---|---|---|---|---|
| A | Reference | | | |
| B | Changed input | | | |
| A repeat | Reference | | | |
A conclusion is supported only when it cites the recorded values or observed states and explains them with the experiment theory.
Formative assessment
Explain the following without looking at the simulation output, then reveal the reference response.
What is a leaf hash?
The digest of one encoded record.
How are internal hashes constructed here?
SHA-256 of the node prefix and ordered hexadecimal child digests.
How many siblings prove membership in an eight-leaf complete tree?
Three 32-byte sibling digests plus ordering/index information.
What happens if the verifier replaces the trusted root after tampering?
The comparison no longer checks against the original commitment.
Applied task
Select a leaf, lock the reference root and verify the unmodified record. Inspect the three sibling hashes and their order.
Submit your reference and modified observations with a justification.
The original tutor and adaptive examination retain their existing 102-lab catalogue. Use the module-specific study questions above and copy this contextual prompt into your chosen AI assistant if needed.
Explain the engineering mechanism in BC-M06 · Blockchain elements: Merkle trees and light clients. My task: Build the eight-transaction binary hash tree shown in the module. Inspect ordered hash inputs, root and logarithmic inclusion proof with a trusted header root.. Acceptance: Four leaves require 7 digests and 2 proof siblings; eight require 15 digests and 3 siblings. Modified candidate fails against the original root.. Model boundary: Domain-separated UTF-8 encoding matches the existing teaching labs; not Bitcoin double-SHA256 byte serialization or Ethereum Keccak. Inclusion does not establish finality or source truth.. Ask me for my actual observations and distinguish model predictions from real measurements.
Shared research workbenches · network designer & advanced studiesConcurrent-device simulation & Monte Carlo research