The focus of this experiment is to trace deterministic gateway serialization into integrity commitments. Students then identify field ordering, encoding and canonicalization issues, and verify equivalent and modified records using the specified representation. 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
Trace deterministic gateway serialization into integrity commitments.
Identify field ordering, encoding and canonicalization issues.
Verify equivalent and modified records using the specified representation.
Identify the configured inputs (Fictional device; Sequence; Temperature (centi-°C); Received bytes) 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 trace deterministic gateway serialization into integrity commitments, identify field ordering, encoding and canonicalization issues, and verify equivalent and modified records using the specified representation.
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 equivalent and modified records using the specified representation. Separate predicted values from observations.
Prerequisite knowledge and related learning
Review the following catalogue prerequisites before starting. After completion, continue to Transaction receipts and event reconciliation.
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.
Canonical serialization ensures identical bytes for equivalent intended records; field order, whitespace, encoding and units can change hashes.
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.
Scientific theory · Canonical bytes and hash integrity
Hash inputs are byte strings, not abstract objects. JSON field order, whitespace, Unicode encoding, numeric representation and units can affect byte equality. Canonical serialization is a shared deterministic rule; authentication and freshness must still be checked separately.
Worked example and engineering interpretation
The records {"t":25,"id":1} and {"id":1,"t":25} may describe the same object but have different raw bytes. Serialize both using the lab's defined canonical format and compare hashes. Do not assume arbitrary JSON stringify implementations are a universal canonicalization standard.
Engineering principles · additional worked teaching example
Canonical serialization defines field order, representation and encoding. Integer centi-degrees avoids float representation ambiguity: 2537 represents 25.37 °C. A digest commits to bytes, not semantically similar JSON.
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.
How to investigate IoT gateway serialization & integrity
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.
Run baseline; copy original UTF-8 string and digest. Change only received bytes and check mismatch. Restore and compare.
From extracted portal root inside Linux run python3 verification/advanced_dapp.py gateway --output gateway-evidence.json . Expected seven passing controls and fixture text/hash identical to the model. Choose a new filename if it already exists.
In a real gateway, validate schema before hashing; retain private measurements off-chain; transmit digest and monotonic sequence to an authorized contract caller. Never store credentials or real identifiers in this demo.
Reference check: Identical strings yield the same digest and zero changed bits. A changed sample yields a different digest; bit distance is measured, not prescribed.
Model boundary: An unkeyed hash is not a MAC, signature or encryption. SHA-512 and signature examples remain conceptual unless separately executed.
Independent task and submission evidence
2. From extracted portal root inside Linux run python3 verification/advanced_dapp.py gateway --output gateway-evidence.json . Expected seven passing controls and fixture text/hash identical to the model. Choose a new filename if it already exists. 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.
Fixed field order and integer temperature are this lab schema, not a universal JSON canonicalization standard. No actual ESP32 acquisition.
Worked engineering reasoning and boundary conditions
Engineering reference configuration: Fictional device = node-1; Sequence = 1; Temperature (centi-°C) = 2500; Received bytes = none. In the classroom model, Digest match = Yes; Raw UTF-8 bytes = 57; Digest bytes = 32. Integers in centi-degrees and fixed key order make this specific schema reproducible. A matching digest does not establish sensor truth or confidentiality. Fixed field order and integer temperature are this lab schema, not a universal JSON canonicalization standard. No actual ESP32 acquisition.
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.
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.
B12 · 03 / 08Which layer authenticates the caller?Reveal explanation
Engineering explanation
The smart contract checks the sending account; a hash alone does not authenticate the measurement source.
B12 · 04 / 08Why does whitespace or field order matter in a serialized record?Reveal explanation
Engineering reasoning
Cryptographic hashes operate on bytes; different serialization choices can change the digest.
B12 · 05 / 08What must be retained to reproduce a commitment?Reveal explanation
Engineering reasoning
The exact UTF-8 bytes, serialization convention, hash algorithm and trusted expected digest.
B12 · 06 / 08Telemetry serialization changes whitespace. Select every technically valid statement.
A. Hash the agreed serialized byte sequence.
B. Different encodings can change a digest even when semantic fields agree.
C. SHA-256 hashes only the semantic meaning of JSON.
D. UTF-8 byte length always equals character count.Reveal explanation
Applied scenario
Correct: A. Hash the agreed serialized byte sequence.; B. Different encodings can change a digest even when semantic fields agree.
B12 · 07 / 08In IoT gateway serialization & integrity, which reference and changed settings are prescribed for Received bytes?Reveal explanation
Controlled configuration
Received bytes: none → alter; hold the remaining settings fixed.
B12 · 08 / 08What expected result distinguishes the reference and changed trials in IoT gateway serialization & integrity?Reveal explanation
Expected observation
Baseline SHA-256 6147100b4d09fc59a44777e831a3e026f8f0456f1f32087e6d3fe27e6f2f4ba7; altered temperature does not match.
Loading experiment-specific apparatus…Previous model / additional reference tools
Explore the model using its own controls. Record a prediction before changing a condition. Compare the reference with a changed condition, then use the Experiment tab for the procedure, acceptance criteria and notebook. Model outputs and physical observations must remain separate.
Interactive engineering workbenchB12 · Existing model
Readout from the original computational model; not physical measurements.
Loading instrument…
Awaiting model display.
Experimental instrumentation · A/B
Compare two model conditions
Capture a baseline, change one experimental condition, run the model if required and capture the comparison. Snapshots contain visible controls and display text, not physical sensor readings. Review before exporting.
Ask Dr. Mohammad locally, or prepare an experiment-aware prompt for ChatGPT, Gemini or Claude. The external providers open in their own tabs; nothing is automatically submitted.
Public course objective, displayed commands, source excerpts and procedure. Private assessment content is not collected.
Prepare a contextual AI prompt
0 characters
Common secret and email patterns are redacted on preparation; this is not a comprehensive privacy filter. Review the entire editable prompt, including student work and unpublished research, before sharing. The providers apply their own accounts, privacy settings and limits.
Prepare → review → copy & open your selected provider → paste and submit there.
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
Write a canonical fictional record for node-1, seq1, temperature 2500 centi-°C and convert to °C. Compare with a record using 25.0 as a numeric field.
Engineering method — Canonical serialization defines field order, representation and encoding. Integer centi-degrees avoids float representation ambiguity: 2537 represents 25.37 °C. A digest commits to bytes, not semantically similar JSON. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
02 · Compare or justify using evidence
Explain why JSON whitespace changes a raw-byte hash and why a stable encoding must be agreed before committing.
Engineering method — Canonical serialization defines field order, representation and encoding. Integer centi-degrees avoids float representation ambiguity: 2537 represents 25.37 °C. A digest commits to bytes, not semantically similar JSON. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
03 · Encoding analysis
Encoding analysis · Independent work
Record temperature 18.25 °C and seq12 using integer centi-degrees. Explain why changing field order may change a digest even if parsed objects match.
Encoding analysis — Canonical serialization defines field order, representation and encoding. Integer centi-degrees avoids float representation ambiguity: 2537 represents 25.37 °C. A digest commits to bytes, not semantically similar JSON. 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 · B12-01
Use the reference configuration (Fictional device = node-1; Sequence = 1; Temperature (centi-°C) = 2500; Received bytes = none), but change Temperature (centi-°C) = -4000. The model reports Raw UTF-8 bytes = 58. Explain the governing rule and assumptions that make this output plausible; identify an independent verification method.
Intermediate · Interpret a state transition
Independent theoretical exercise · B12-02
The reference model reports Raw UTF-8 bytes: 57. Under Temperature (centi-°C) = -4000 it reports 58. 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 · B12-03
For Received bytes = alter, the model supplies this excerpt from Calculated trace:
Item · Value · Explanation
Original bytes · {"device":"node-1","sequence":1,"temperature_centi":2500} ·
Original SHA-256 · 6147100b4d09fc59a44777e831a3e026f8f0456f1f32087e6d3fe27e6f2f4ba7 ·
Received bytes · {"device":"node-1","sequence":1,"temperature_centi":2501} ·
Received SHA-256 · 142dae881a7f85eb13e50bb5350a9e6060a6db057f84b2e3a4ea8617ab6c45ce ·
Count rows whose Value value is exactly “{"device":"node-1","sequence":1,"temperature_centi":2500}”, and identify the displayed row numbers. Explain what the count describes.
Advanced · Reverse reasoning
Independent theoretical exercise · B12-04
An observation is Digest match = No. Candidate A uses Fictional device = node-1; Sequence = 1; Temperature (centi-°C) = 2500; Received bytes = none. Candidate B changes the listed settings (Received bytes = alter) 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 · B12-05
A student configures Received bytes = alter while preserving all other reference settings, but copies the reference report of Digest match = Yes. Evaluate whether the report is justified. Identify the first configuration/output check to perform.
Challenging · Design a controlled verification
Independent theoretical exercise · B12-06
Design a controlled comparison for IoT gateway serialization & integrity using reference Fictional device = node-1; Sequence = 1; Temperature (centi-°C) = 2500; Received bytes = none and test Temperature (centi-°C) = -4000. Specify the changed setting(s), measured metric Raw UTF-8 bytes, controls, repetitions, an acceptance check and what evidence can distinguish an actual implementation from the model.
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.
Fictional devicenode-1
Sequence1
Temperature (centi-°C)2500
Received bytesnone
2 · Perform the investigation in order
Run baseline; copy original UTF-8 string and digest. Change only received bytes and check mismatch. Restore and compare.
From extracted portal root inside Linux run python3 verification/advanced_dapp.py gateway --output gateway-evidence.json. Expected seven passing controls and fixture text/hash identical to the model. Choose a new filename if it already exists.
In a real gateway, validate schema before hashing; retain private measurements off-chain; transmit digest and monotonic sequence to an authorized contract caller. Never store credentials or real identifiers in this demo.
3 · Compare controlled trials
Trial
Independent change
Expected check
Observation
Reference
Use reference inputs above
Baseline SHA-256 6147100b4d09fc59a44777e831a3e026f8f0456f1f32087e6d3fe27e6f2f4ba7; altered temperature does not match.
Record actual result
Controlled change
Received bytes = alter
Baseline SHA-256 6147100b4d09fc59a44777e831a3e026f8f0456f1f32087e6d3fe27e6f2f4ba7; altered temperature does not match.
Record actual result
4 · Analyze and report
Fixed field order and integer temperature are this lab schema, not a universal JSON canonicalization standard. No actual ESP32 acquisition.
Required evidence: Record the iot gateway serialization & integrity comparison and justify the changed outcome from the calculated trace.
Model boundary: Fixed field order and integer temperature are this lab schema, not a universal JSON canonicalization standard. No actual ESP32 acquisition.
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.
Trial
Independent change
Dependent observation
Reference
Use reference inputs above
Record actual outcome and units
Controlled change
Received bytes = alter
Record actual outcome and units
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.
✓ Expected baseline and controlled change: Baseline SHA-256 6147100b4d09fc59a44777e831a3e026f8f0456f1f32087e6d3fe27e6f2f4ba7; altered temperature does not match.
Run baseline; copy original UTF-8 string and digest. Change only received bytes and check mismatch. Restore and compare.
From extracted portal root inside Linux run python3 verification/advanced_dapp.py gateway --output gateway-evidence.json. Expected seven passing controls and fixture text/hash identical to the model. Choose a new filename if it already exists.
In a real gateway, validate schema before hashing; retain private measurements off-chain; transmit digest and monotonic sequence to an authorized contract caller. Never store credentials or real identifiers in this demo.
Export observed evidence, restore baseline and record limitations. Do not treat browser-model output as actual hardware or EVM evidence.
Experimental notebook
Record your own results. Values are not prefilled or independently verified.
Record & discuss
Notebook exports use related core lab B06; the supplementary ID is retained in the evidence. Technical reference.
Learning progress
Mark complete only after documenting your observations. This is not a verified result or official grade.
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: An unkeyed hash is not a MAC, signature or encryption. SHA-512 and signature examples remain conceptual unless separately executed. Default computational cells passed isolated local Python execution; physical equipment and live services require separate verification.
01Instructions · Markdown
# B12 · IoT gateway serialization & integrity
**PSUT IoT Engineering Studio — Dr. Mohammad Alja’afreh**
## 1. Scientific objective
Generate stable UTF-8 telemetry, compute SHA-256 commitments and detect altered measurement bytes.
Complete the analytical worksheet in the portal first. Record your predictions before running this notebook. This notebook is a bounded local computational investigation; use the portal’s separate WSL, hardware or Remix procedure for real interfaces.
02Instructions · Markdown
## Experiment-specific preparation
Generate stable UTF-8 telemetry, compute SHA-256 commitments and detect altered measurement bytes.
**Reference procedure (use the matching simulator/WSL tool where named, not an unrelated service):**
1. Run baseline; copy original UTF-8 string and digest. Change only received bytes and check mismatch. Restore and compare.
2. From extracted portal root inside Linux run python3 verification/advanced_dapp.py gateway --output gateway-evidence.json . Expected seven passing controls and fixture text/hash identical to the model. Choose a new filename if it already exists.
3. In a real gateway, validate schema before hashing; retain private measurements off-chain; transmit digest and monotonic sequence to an authorized contract caller. Never store credentials or real identifiers in this demo.
**Evidence:** Identical strings yield the same digest and zero changed bits. A changed sample yields a different digest; bit distance is measured, not prescribed.
**Boundary:** An unkeyed hash is not a MAC, signature or encryption. SHA-512 and signature examples remain conceptual unless separately executed.
03Instructions · Markdown
## 2. Reference configuration and investigation
1. Run baseline; copy original UTF-8 string and digest. Change only received bytes and check mismatch. Restore and compare.
2. From extracted portal root inside Linux run python3 verification/advanced_dapp.py gateway --output gateway-evidence.json . Expected seven passing controls and fixture text/hash identical to the model. Choose a new filename if it already exists.
3. In a real gateway, validate schema before hashing; retain private measurements off-chain; transmit digest and monotonic sequence to an authorized contract caller. Never store credentials or real identifiers in this demo.
Run cells in order; do not substitute model results for physical measurements.
04Instructions · Markdown
## 3. Construct a stable telemetry byte representation and commitment.
05Python · executable cell
PYTHON · Code cell
# =====================================================================
# B12 | Code cell 01 | IoT gateway serialization & integrity
# Purpose: 3. Construct a stable telemetry byte representation and commitment.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
import json,hashlib,hmac
# Set record for the next computation or reference condition.
record={"device":"A","seq":4,"temperature":25}
# Set raw for the next computation or reference condition.
raw=json.dumps(record,sort_keys=True,separators=(",",":" )).encode()
# Prepare key; retain only the scope required for this trial.
key=b"fictional-lab-key"
# Set tag for the next computation or reference condition.
tag=hmac.digest(key,raw,"sha256")
print(raw,hashlib.sha256(raw).hexdigest())
## 4. Check authentication, authorization and sequence independently.
07Python · executable cell
PYTHON · Code cell
# =====================================================================
# B12 | Code cell 02 | IoT gateway serialization & integrity
# Purpose: 4. Check authentication, authorization and sequence independently.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
# Define the reusable operation accept; keep its logic separate from the trial.
def accept(payload,tag,previous,authorized):
if not authorized or not hmac.compare_digest(hmac.digest(key,payload,"sha256"),tag):return False
return json.loads(payload)["seq"]>previous
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert accept(raw,tag,3,True)
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert not accept(raw,tag,4,True)
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert not accept(raw.replace(b"25",b"26"),tag,3,True)
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert not accept(raw,tag,3,False)
## Experimental analysis and submission
1. Record the reference input, predicted output and actual result.
2. Modify one independent variable and run the relevant cells again.
3. Explain the result using the theory and identify model limitations.
4. Save the notebook with outputs and retain the separate theoretical worksheet.
**Your derivation and conclusion:**
(Complete independently.)
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. From extracted portal root inside Linux run python3 verification/advanced_dapp.py gateway --output gateway-evidence.json . Expected seven passing controls and fixture text/hash identical to the model. Choose a new filename if it already exists. 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.
Shared research workbenches · network designer & advanced studiesConcurrent-device simulation & Monte Carlo research