UTXO inputs are consumed once; outputs plus fee equal input value. Proof of work searches header nonces against a target.
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-M07 · Academic orientation
Scope and objectives
Scope of the experiment
Model a UTXO spend and bounded proof-of-work nonce search using actual SHA-256. Observe change, fee conservation and reuse rejection.
The focus of this experiment is to trace nonce search and synthetic proof-of-work acceptance. Students then compare transaction ordering and conflicting-spend scenarios, and explain confirmation assumptions without claiming absolute finality. 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 nonce search and synthetic proof-of-work acceptance.
Compare transaction ordering and conflicting-spend scenarios.
Explain confirmation assumptions without claiming absolute finality.
Identify the configured inputs (Available input (sat); Payment (sat); Fee (sat); Subsidy (sat); Attempt repeated spend) 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 nonce search and synthetic proof-of-work acceptance, compare transaction ordering and conflicting-spend scenarios, and explain confirmation assumptions without claiming absolute finality.
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 explain confirmation assumptions without claiming absolute finality. 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 Consensus algorithms and Byzantine disagreement.
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 · UTXO accounting and proof of work
An unspent transaction output is consumed as an input and new outputs are created. Sum(inputs)=sum(outputs)+fee; the same output cannot be spent twice in an accepted history. Proof of work searches candidate header values against a numeric target; each uniformly distributed hash has a corresponding success probability.
Worked example and engineering interpretation
An input of 10 units paying 6 with fee 1 requires change 3. A toy target of two leading hexadecimal zero digits has probability 1/256 per independent hash, with expected 256 attempts. A target match alone does not validate transactions or establish consensus.
Engineering principles · additional worked teaching example
A UTXO is an unspent output referenced by a transaction. Inputs equal outputs plus fee. With 9000 sat input, 5000 payment and 300 fee, change=3700 sat. A conflicting transaction cannot consume the same output in the same valid history.
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: Available input (sat) = 10000; Payment (sat) = 6000; Fee (sat) = 500; Subsidy (sat) = 312500; Attempt repeated spend = true; Required leading hex zeroes = 2; Maximum nonce attempts = 4096; Change mined block payload = false. In the classroom model, Spend accepted = Yes; Change output = 3500 sat; Repeat spend = Rejected: spent; Coinbase output = 313000 sat; Nonce attempts = 6; Target found = Yes. Transaction conservation and proof-of-work search are separate calculations. A valid-looking hash alone does not prove a ledger is canonical. Actual bounded SHA-256 search and simplified UTXO ledger; no cryptocurrency mining, real reward schedule or network consensus.
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.
Step 1 of 5 · Calculated state 1
Calculated state 1
Output / state
Input
Before
10000
After
STXO
Calculated state 2
Output / state
Recipient
Before
0
After
6000
Calculated state 3
Output / state
Change
Before
0
After
3500
Calculated state 4
Output / state
Fee
Before
0
After
500
Calculated state 5
Output / state
Coinbase
Before
0
After
313000
Teaching example only; inspect live calculations or real practical evidence separately.
How to investigate Mining, nonce search and double spending
Model a UTXO spend and bounded proof-of-work nonce search using actual SHA-256. Observe change, fee conservation and reuse rejection.
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: Model a UTXO spend and bounded proof-of-work nonce search using actual SHA-256. Observe change, fee conservation and reuse rejection.
Enter 10,000 sat input, 6,000 sat payment and 500 sat fee. Verify change 3,500 sat and coinbase 313,000 sat in this example.
Inspect the UTXO→STXO transition and repeat-spend rejection. Raise payment to 10,000; no new outputs should appear.
Restore the spend. Use difficulty two leading hex zeroes and search bound 4096. Inspect attempted nonces and first qualifying hash (or bounded failure).
Raise difficulty to three and reduce attempts to one. A search failure is not evidence that no valid nonce exists.
Reference check: Input equals recipient + change + fee on accepted spend; spent input cannot be reused. A nonce is accepted only if its hash meets the toy target.
Model boundary: Bounded single-miner SHA-256 search (max 25,000 attempts); no real mining or Bitcoin serialization; a valid nonce does not guarantee network acceptance.
Independent task and submission evidence
2. Inspect the UTXO→STXO transition and repeat-spend rejection. Raise payment to 10,000; no new outputs should appear. 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.
Model a UTXO spend and bounded proof-of-work nonce search using actual SHA-256. Observe change, fee conservation and reuse rejection.
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 UTXO?
An unspent transaction output available under its spending rules.
How is change computed?
Input value minus recipient amount and fee.
What does the nonce search test?
Whether the actual candidate digest satisfies the chosen target condition.
Why is reuse rejected?
A successfully spent UTXO is removed from the available set.
What makes a mined block valid in this toy target check?
Its SHA-256 hexadecimal digest starts with the configured number of zeroes.
Is the nonce necessarily random?
No; it can be varied sequentially to search the input space.
Why bound the search?
It prevents unbounded computation in a browser while allowing a no-solution outcome.
What distinguishes a block reward from a transaction fee?
A reward may include new issuance; fees are allocated from transaction values according to protocol rules.
What must the recipient, change and fee sum to on an accepted spend?
The input value.
What happens when a previously spent input is submitted again?
It is rejected as already spent.
What does a difficulty of two leading hexadecimal zeroes require?
The candidate header digest must start with 00.
Does finding a valid nonce establish that all transactions are valid?
No. Transaction validation and proof-of-work target checking are separate checks.
Engineering diagram · BC-M07. 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
For 10000 sat input, 6000 payment and 500 fee, compute change and miner reward including subsidy 312500. Evaluate repeat spend.
Engineering method — A UTXO is an unspent output referenced by a transaction. Inputs equal outputs plus fee. With 9000 sat input, 5000 payment and 300 fee, change=3700 sat. A conflicting transaction cannot consume the same output in the same valid history. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
02 · Compare or justify using evidence
For two leading hex zeros, derive single-attempt success probability and expected attempts under independent uniform hashes. Explain why the actual nonce may differ.
Engineering method — A UTXO is an unspent output referenced by a transaction. Inputs equal outputs plus fee. With 9000 sat input, 5000 payment and 300 fee, change=3700 sat. A conflicting transaction cannot consume the same output in the same valid history. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
03 · Calculation
Calculation · Independent work
Input 12000 sat; payment 7200; fee 450. Calculate change and explain whether a second transaction referencing the same input can also be valid in the same chain.
Calculation — A UTXO is an unspent output referenced by a transaction. Inputs equal outputs plus fee. With 9000 sat input, 5000 payment and 300 fee, change=3700 sat. A conflicting transaction cannot consume the same output in the same valid history. 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-M07-01
Use the reference configuration (Available input (sat) = 10000; Payment (sat) = 6000; Fee (sat) = 500; Subsidy (sat) = 312500; Attempt repeated spend = true; Required leading hex zeroes = 2; Maximum nonce attempts = 4096; Change mined block payload = false), but change Available input (sat) = 10002. The model reports Change output = 3502 sat. Explain the governing rule and assumptions that make this output plausible; identify an independent verification method.
Intermediate · Quantitative comparison
Independent theoretical exercise · BC-M07-02
Two model observations of Change output are 3500 sat (reference) and 3502 sat (changed condition). Compute signed change and, when the reference is nonzero, percentage change. Explain why units matter.
Intermediate · Interpret a technical trace
Independent theoretical exercise · BC-M07-03
For Payment (sat) = 6002, the model supplies this excerpt from UTXO accounting:
Output / state · Before · After
Input · 10000 · STXO
Recipient · 0 · 6002
Change · 0 · 3498
Fee · 0 · 500
Coinbase · 0 · 313000
Compute the range (maximum minus minimum) of the Before column in these rows. Identify the maximum observation. Do not extrapolate beyond these rows.
Advanced · Reverse reasoning
Independent theoretical exercise · BC-M07-04
An observation is Change output = 3498 sat. Candidate A uses Available input (sat) = 10000; Payment (sat) = 6000; Fee (sat) = 500; Subsidy (sat) = 312500; Attempt repeated spend = true; Required leading hex zeroes = 2; Maximum nonce attempts = 4096; Change mined block payload = false. Candidate B changes the listed settings (Payment (sat) = 6002) 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-M07-05
A student configures Fee (sat) = 502 while preserving all other reference settings, but copies the reference report of Change output = 3500 sat. Evaluate whether the report is justified. Identify the first configuration/output check to perform.
Challenging · Design a controlled verification
Independent theoretical exercise · BC-M07-06
Design a controlled comparison for Mining, nonce search and double spending using reference Available input (sat) = 10000; Payment (sat) = 6000; Fee (sat) = 500; Subsidy (sat) = 312500; Attempt repeated spend = true; Required leading hex zeroes = 2; Maximum nonce attempts = 4096; Change mined block payload = false and test Available input (sat) = 10002. Specify the changed setting(s), measured metric Change output, controls, repetitions, an acceptance check and what evidence can distinguish an actual implementation from the model.
Step-by-step experimental procedure
Analyze input/output conservation, coinbase accounting and proof-of-work search with actual SHA-256.
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.
Available input (sat)10000
Payment (sat)6000
Fee (sat)500
Subsidy (sat)312500
Attempt repeated spendYes
Required leading hex zeroes2
Maximum nonce attempts4096
Change mined block payloadNo
2 · Perform the investigation in order
Enter 10,000 sat input, 6,000 sat payment and 500 sat fee. Verify change 3,500 sat and coinbase 313,000 sat in this example.
Inspect the UTXO→STXO transition and repeat-spend rejection. Raise payment to 10,000; no new outputs should appear.
Restore the spend. Use difficulty two leading hex zeroes and search bound 4096. Inspect attempted nonces and first qualifying hash (or bounded failure).
Raise difficulty to three and reduce attempts to one. A search failure is not evidence that no valid nonce exists.
Toggle tamper after mining; recompute the header with the same nonce and compare with the original mined digest.
Relate these modeled transactions to Bitcoin input/output accounting and compare Ethereum accounts and Fabric state in later modules.
Required leading hex zeroes = 3; Maximum nonce attempts = 1
Nonce attempts: 1
Record actual result
Modified mined payload
Change mined block payload = Yes
Header unchanged: No
Record actual result
4 · Analyze and report
Explain why mining validates a candidate header against a target and why merely rehashing a modified block is not enough to establish canonical history.
Required evidence: Transaction accounting, nonce trace, tamper comparison and model limitations.
Model boundary: Actual bounded SHA-256 search and simplified UTXO ledger; no cryptocurrency mining, real reward schedule or network consensus.
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 spend
Use reference inputs above
Record actual outcome and units
Overspend
Payment (sat) = 10000
Record actual outcome and units
Higher difficulty
Required leading hex zeroes = 3; Maximum nonce attempts = 1
Record actual outcome and units
Modified mined payload
Change mined block payload = Yes
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.
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: Bounded single-miner SHA-256 search (max 25,000 attempts); no real mining or Bitcoin serialization; a valid nonce does not guarantee network acceptance. Default computational cells passed isolated local Python execution; physical equipment and live services require separate verification.
01Instructions · Markdown
# BC-M07 · Mining, nonce search and double spending
**PSUT IoT Engineering Studio — Dr. Mohammad Alja’afreh**
## Introduction
Model a UTXO spend and bounded proof-of-work nonce search using actual SHA-256. Observe change, fee conservation and reuse rejection.
## 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
Model a UTXO spend and bounded proof-of-work nonce search using actual SHA-256. Observe change, fee conservation and reuse rejection.
**Reference procedure (use the matching simulator/WSL tool where named, not an unrelated service):**
1. Enter 10,000 sat input, 6,000 sat payment and 500 sat fee. Verify change 3,500 sat and coinbase 313,000 sat in this example.
2. Inspect the UTXO→STXO transition and repeat-spend rejection. Raise payment to 10,000; no new outputs should appear.
3. Restore the spend. Use difficulty two leading hex zeroes and search bound 4096. Inspect attempted nonces and first qualifying hash (or bounded failure).
4. Raise difficulty to three and reduce attempts to one. A search failure is not evidence that no valid nonce exists.
5. Toggle tamper after mining; recompute the header with the same nonce and compare with the original mined digest.
**Evidence:** Input equals recipient + change + fee on accepted spend; spent input cannot be reused. A nonce is accepted only if its hash meets the toy target.
**Boundary:** Bounded single-miner SHA-256 search (max 25,000 attempts); no real mining or Bitcoin serialization; a valid nonce does not guarantee network acceptance.
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-M07 | Code cell 01 | Mining, nonce search and double spending
# 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-M07 | Code cell 02 | Mining, nonce search and double spending
# 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 mine(amount,difficulty,seed):
if not 1<=amount<=110 or not 1<=difficulty<=3 or not 1<=seed<=50: raise ValueError('Parameters outside teaching range')
fee=2; change=100-amount-fee
if change<0:return dict(committed=False,attempts=0,reason='Insufficient input')
for nonce in range(25000):
inp=serialize(['iot-block',seed,amount,change,fee,nonce]);d=sha(inp)
if d.startswith('0'*difficulty):return dict(committed=True,nonce=nonce,digest=d,input=inp,attempts=nonce+1,recipient=amount,change=change,fee=fee,reuseRejected=True)
return dict(committed=False,attempts=25000,reason='Bounded search exhausted')
for difficulty in (1,2,3):
result=mine(60,difficulty,1);print(difficulty,result)
if result['committed']:assert result['digest'].startswith('0'*difficulty)
assert not mine(110,2,1)['committed']
## 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 mining --amount 60 --difficulty 2 --seed 1
```
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 the UTXO→STXO transition and repeat-spend rejection. Raise payment to 10,000; no new outputs should appear. 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 UTXO?
An unspent transaction output available under its spending rules.
How is change computed?
Input value minus recipient amount and fee.
What does the nonce search test?
Whether the actual candidate digest satisfies the chosen target condition.
Why is reuse rejected?
A successfully spent UTXO is removed from the available set.
Applied task
Observe actual nonce attempts and verify the successful digest begins with the chosen number of zeros, if found within the bound.
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-M07 · Mining, nonce search and double spending. My task: Model a UTXO spend and bounded proof-of-work nonce search using actual SHA-256. Observe change, fee conservation and reuse rejection.. Acceptance: Input equals recipient + change + fee on accepted spend; spent input cannot be reused. A nonce is accepted only if its hash meets the toy target.. Model boundary: Bounded single-miner SHA-256 search (max 25,000 attempts); no real mining or Bitcoin serialization; a valid nonce does not guarantee network acceptance.. 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