IoT and blockchain foundations
Investigate how a signed or anchored emissions-monitoring record can be checked by an independent auditor, and why sensor truth remains outside the ledger.
59 local laboratory notebooks. Download the file, then upload it to Colab.
Investigate how a signed or anchored emissions-monitoring record can be checked by an independent auditor, and why sensor truth remains outside the ledger.
Distinguish a digest from confidentiality and origin authentication. Observe SHA-256 and SHA-512 concepts, digest comparison and avalanche effects using actual SHA-256 computations.
Compare a consistency-first replicated store against an availability-first store during a network partition. Explore disintermediation, replication and the CAP trade-off.
Follow proposal, membership validation, hash linkage and replicated commit in public, private and consortium ledger policies.
Track a fungible balance and one unique IoT device certificate; distinguish native gas assets, token ownership and wallet control.
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.
Model a UTXO spend and bounded proof-of-work nonce search using actual SHA-256. Observe change, fee conservation and reuse rejection.
Compare observer decisions with conflicting validator messages and inspect a 3-of-4 quorum. Explore a simplified count versus stake-weighted voting rule.
Distinguish reads, transactions, gas budget and lifecycle. Calculate fees in Wei/Gwei/ETH with a user-declared gas price.
Trace owner checks, mapping writes and emitted events. Compile and deploy a real small Solidity registry using Remix VM.
Model sensor identification, gateway transport, off-chain records and ledger commitments in a farm-to-consumer cold chain.
Explore nonce, balance, gas and deterministic transition using a simplified account ledger. Separate the 2014 whitepaper from post-Merge Ethereum.
Follow identity, endorsement, ordering and validation using the whitepaper enterprise requirements and an explicitly modern Fabric-style execute-order-validate teaching abstraction.
Compare direct on-chain samples, per-sample gateway digests and gateway batch commitments using identical workloads.
Investigate the 2023 IOTA 2.0 proposal: exponential Mana decay, token-derived generation and congestion-dependent access burn.
Evaluate access, integrity, freshness and storage trade-offs across the survey’s security, privacy and trust requirements.
Construct a SHA-256-linked ledger; detect modified data and explain why hash links alone do not guarantee immutability.
Construct a four-leaf Merkle tree and verify inclusion against a trusted root.
Compare agreement, split votes and unavailable voters under a fixed four-voter teaching rule.
Compile, deploy and call a simple Solidity state variable and distinguish reads from transactions.
Use msg.sender, mappings, custom errors and events to enforce administrative authorization.
Anchor off-chain telemetry using a bytes32 digest, per-device monotonic sequence and explicit authorization.
Connect an off-chain sensor payload to a contract invocation, receipt, event and subsequent verification.
Compare raw storage and digest storage using actual transaction gas, and distinguish bytes from gas.
Demonstrate linkage risks of low-entropy hashes and design a privacy-preserving IoT commitment architecture.
Implement owner-only delegation, operator permissions and revocation with explicit custom errors.
Construct a four-record Merkle tree and verify ordered membership against an independently trusted root.
Generate stable UTF-8 telemetry, compute SHA-256 commitments and detect altered measurement bytes.
Model duplicate receipt processing, reverted transactions and missed events; reconcile with independently queried contract state.
Compare payload byte budgets and design paired EVM gas measurements without substituting byte counts for gas.
Trace a fictional sensor record into a local EVM transaction, verify receipt and event fields, and test access and replay invariants.
Encoding changes representation and is reversible without a secret. Hashing maps arbitrary bytes to a fixed-size digest; it is not encryption or sender authentication. MD5 and SHA-1 are historical, collision-broken algorithms, not suitable for new security designs. SHA-256, SHA-512 and SHA3-256 have different digest sizes and constructions. UTF-8 byte length may differ from character count. For abc, hexadecimal is 616263 and Base64 is YWJj. SHA-256 is ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad.
A collision is two distinct messages with the same digest. Preimage resistance and second-preimage resistance are different properties. For an ideal b-bit digest the approximate 50% collision threshold is sqrt(2 ln 2) × 2^(b/2). This exercise truncates SHA-256 intentionally to 4–16 bits and searches only synthetic classroom strings. It is not a collision attack on full SHA-256. An 8-bit prefix has 256 possibilities; the approximate 50% threshold is 19 samples. The first collision count depends on the selected sequence.
A controlled comparison changes one input bit while keeping message length and the hash algorithm fixed. Hamming distance counts differing digest bits; divide by digest width and multiply by 100. The bit index starts at the least significant bit of UTF-8 byte zero. Strong avalanche alone does not prove collision resistance. For a 256-bit digest, a Hamming distance of 128 corresponds to 50%. SHA-512 uses a 512-bit denominator.
A trusted reference digest can detect a modified local byte sequence. The verifier recomputes SHA-256 over received bytes and compares against that reference. A hash delivered by the same untrusted source is not independent authentication; signed firmware or a trusted authenticated manifest is required. Flipping bit zero of F (0x46) produces G (0x47), changing the firmware digest without changing length.
SHA-256 uses a 64-byte block. Normalize K to K′ by hashing keys longer than 64 bytes, then zero-padding. Compute inner=H((K′ XOR ipad)||m), tag=H((K′ XOR opad)||inner), where ipad=36 repeated and opad=5c repeated. HMAC authenticates under a shared key; it neither encrypts nor inherently prevents replay. With 20 bytes of 0b and Hi There, RFC 4231 HMAC-SHA256 is b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7.
A digital signature binds a digest to a private signing key; a trusted public key verifies it. This lab uses P-256 ECDSA with SHA-256 from a vetted library. Signatures contain r and s; Python uses ASN.1 DER while Web Crypto returns raw r||s. Validity depends on trusted keys, not simply the presence of a signature. An original synthetic firmware message verifies with its own public key. A modified message and a different public key must be rejected. Signature bytes can vary between runs.
Use a prime p, primitive root g and private x; y=g^x mod p. Choose k coprime to p−1. r=g^k mod p and s=k⁻¹(h−xr) mod (p−1). Verify g^h ≡ y^r r^s (mod p). The small example is for arithmetic only; never use these parameters or chosen signing nonces in real systems. For p=19, g=10, x=5, k=5, h=7, compute k inverse modulo 18 and both sides of the verification equation.
For this small fixed DSA fixture p=23, q=11, g=4, x=3, k=6, h=9, sign using r=(g^k mod p) mod q and s=k⁻¹(h+xr) mod q. Verify with w=s⁻¹ mod q, u1=hw mod q, u2=rw mod q, v=((g^u1 y^u2 mod p) mod q). A tiny digest domain can admit accidental verification collisions. DSA is historical and not recommended for new signature generation. The fixture is generated from h=9; verification succeeds for that representative. Other representatives must be evaluated by the actual equation, not presumed to fail.
X.509 binds a public key to subject identity via issuer signature; SAN identifies DNS names, validity limits time, key usage constrains purpose. Generate local certificates and verify the issuer signature. Signature verification alone is not full path validation.
A valid signature is insufficient: trust anchor, intermediates, validity, hostname and applicable revocation policy all matter. Revocation checking depends on client policy and infrastructure.
Freshness requires receiver state. A nonce cache rejects duplicates; a timestamp window rejects stale messages and assumes clock synchronization. The model assumes tag verification precedes freshness checks.
For positive modulus n, a=qn+r with 0≤r<n. Congruence means equal residues, not equal integers. On the GF(17) clock, 35→1, −7→10 and −11→6. Addition and multiplication reduce after the operation.
A field has additive and multiplicative identities and every nonzero element has a multiplicative inverse. Modulo a composite integer, zero divisors can exist; GF(pⁿ) is not ordinary integer arithmetic modulo pⁿ.
An inverse x satisfies ax≡1 mod n. Division a/b means a·b⁻¹, defined only when gcd(b,n)=1. The lecture includes 421 mod 1009 and 10 mod 40 (no inverse).
Forward division finds gcd; back-substitution rewrites it as ax+ny. Reduce x modulo n to obtain the inverse if gcd=1. Worked example: 20⁻¹ mod 23 = 15.
Binary exponent bits select powers a^(2^i). Repeated squaring reduces every multiplication; the number of steps grows with the exponent bit length.
The order of g is the first positive exponent giving 1. A primitive root modulo prime p has order p−1. Inversion of exponentiation is the discrete-logarithm problem.
For public prime q and generator g, Alice sends A=gˣᵃ mod q and Bob B=gˣᵇ mod q. Both compute g^(xa·xb) mod q independently. Private exponents stay local; DH alone does not authenticate peers or directly encrypt messages. q=23,g=5,xa=6,xb=15 gives A=8, B=19, B⁶ mod 23=2 and A¹⁵ mod 23=2.
Recipient publishes Y=gˣ mod q. Sender selects ephemeral k and computes C₁=gᵏ and mask K=Yᵏ mod q; C₂=mK mod q. Recipient computes K=C₁ˣ then m=C₂K⁻¹ mod q. Textbook ElGamal does not authenticate. q=19,g=10,xa=5,m=17,k=6: Y=3, K=7, C₁=11, C₂=5; inverse of 7 mod 19 is 11; recovered=17.
For prime p>3 use y²≡x³+ax+b mod p, with 4a³+27b² nonzero modulo p. Enumerate all matching y for each x. The group includes point at infinity O, which has no finite coordinate. Plot discrete points. p=17,a=b=2: (5,1) satisfies 1≡137 mod 17. There are 18 finite points plus infinity, order 19.
For distinct points with unequal x, λ=(y₂−y₁)(x₂−x₁)⁻¹ mod p, x₃=λ²−x₁−x₂ mod p, y₃=λ(x₁−x₃)−y₁ mod p. P plus its inverse gives infinity; equal noninverse points use doubling. GF(17), a=b=2, P=(5,1), Q=(6,3): numerator=2, denominator=1, inverse=1, λ=2; x₃=10,y₃=6.
For doubling λ=(3x₁²+a)(2y₁)⁻¹ mod p. Use the coordinate formulas with P=Q. If y=0, doubling gives infinity. Add P to 2P to obtain 3P. GF(17), P=(5,1): numerator=77 mod 17=9, denominator=2, inverse=9, λ=13, 2P=(6,3), 3P=(10,6). GF(23), a=b=1,P=(3,10): 2P=(7,12),3P=(19,5).
Double-and-add reads scalar bits from least significant. Start at infinity, conditionally add the current point, then double the addend. Point order is the smallest positive t with tP=O, not necessarily group order. P=(5,1) over GF(17), a=b=2. 3=11₂: add P and 2P to obtain (10,6). P has order 19.
Long-term keys authenticate identities; session keys protect one session. A KDC is a trusted intermediary. Rotation, expiration and revocation constrain use. This explicit model checks key validity and freshness before release.
Challenge-response uses a fresh nonce and proof of key possession. Mutual authentication requires two direction-bound proofs to prevent reflection; this synthetic HMAC model verifies separate labels.
Verify Kali dependencies and authorized training scope.
Verify SHA-256 and HMAC behavior for original and modified telemetry.
Minimize and pseudonymize fictional telemetry; explain residual linkage risk.