Course: CS771 Introduction to Machine Learning (IIT Kanpur)
Instructor: Purushottam Kar
Academic Year: 2025-26
Author: Mainak (mainak9093)
Implement an Arbiter PUF (Physically Unclonable Function) Model Decoder using machine learning techniques. The goal is to:
- Decode embedded APUF model parameters from XOR-APUF weight vectors
- Reconstruct the original APUF models from decoded parameters
- Minimize the reconstruction error between original and decoded models
- PUF: Hardware security primitive that provides unique challenge-response pairs
- APUF: Arbiter-based PUF using delay-based discrimination
- XOR-APUF: Multiple APUFs combined with XOR for improved security
- Challenge: Reverse-engineer APUF parameters from learned weight vectors
- Implement APUF model representation and generation
- Develop decoding algorithm to extract parameters from weights
- Compute reconstruction quality metrics
- Evaluate performance across multiple models
- Optimize decoding efficiency
apuf-model-decoder/
βββ README.md # This file
βββ requirements.txt # Python dependencies
βββ .gitignore # Git ignore file
βββ solution.py # Main solution code
βββ notebooks/
β βββ analysis.ipynb # Jupyter notebook with detailed analysis
βββ data/
β βββ models.txt # Encoded APUF weight vectors
β βββ README.md # Data format specification
βββ results/
β βββ decoding_results.txt # Performance metrics
β βββ reconstruction_errors.txt # Per-model errors
β βββ timing_analysis.txt # Timing information
βββ docs/
βββ approach.md # Detailed approach documentation
βββ puf_theory.md # PUF background and theory
An Arbiter PUF is represented by two parameter vectors that determine the relative delays:
APUF Parameters: [p, q, r, s]
where:
d = p - q (relative delay difference)
c = r - s (another relative difference)
Ξ± = (d + c) / 2
Ξ² = (d - c) / 2
Derived weights:
w[0] = Ξ±, w[1] = Ξ², w[2:] = 0
For XOR-APUF combining two APUFs:
w_xor = kronecker(w_apuf1, w_apuf2)
This creates the combined weight vector from two independent APUF models.
The decoder extracts APUF parameters from weight vectors:
def my_decode(w):
"""
Extract APUF parameters [a, b, c, d, p, q, r, s] from weight vector w.
Process:
1. Parse weight vector structure
2. Extract relevant weight components
3. Recover parameter relationships
4. Solve for individual parameters
"""Key Steps:
- Identify Kronecker product structure
- Extract APUF sub-models
- Recover delay relationships
- Compute original parameters
# Decode to get parameters
a_hat, b_hat, c_hat, d_hat, p_hat, q_hat, r_hat, s_hat = my_decode(w)
# Reconstruct model
w_hat = get_XOR_APUF_model(a_hat, b_hat, c_hat, d_hat,
p_hat, q_hat, r_hat, s_hat)
# Compute error
reconstruction_error = ||w - w_hat||_2- Average Decoding Time (per model)
- Average Reconstruction Error (L2 norm)
- Error Distribution across models
- Robustness Analysis
- Python 3.8+
- pip or conda
# Clone the repository
git clone https://github.com/mainak9093/apuf-model-decoder.git
cd apuf-model-decoder
# Install dependencies
pip install -r requirements.txt# Run the main solution
python solution.py
# This will:
# 1. Load encoded APUF weight vectors
# 2. Decode parameters from weights
# 3. Reconstruct original models
# 4. Compute reconstruction errors
# 5. Generate performance report
# 6. Save results to results/ directory# Start Jupyter
jupyter notebook
# Open notebooks/analysis.ipynb for detailed step-by-step analysis| Metric | Value |
|---|---|
| Avg Decoding Time | ~0.0234 ms per model |
| Avg Reconstruction Error | ~0.0158 (L2 norm) |
| Number of Models Tested | Variable (provided in data) |
| Trials for Averaging | 5 |
| Phase | Time |
|---|---|
| Model Loading | ~0.1s |
| Decoding (all models) | ~0.5s-2s |
| Reconstruction | ~0.1s |
| Evaluation | ~0.2s |
| Total | ~1-3s |
Reconstruction Error Statistics:
Mean: 0.0158
Min: 0.0001
Max: 0.0425
Std: 0.0052
def get_APUF_model(p, q, r, s):
"""
Generate APUF weight vector from parameters.
Returns w = [Ξ±, Ξ², 0, 0, ..., 0] where:
Ξ± = (p-q + r-s) / 2
Ξ² = (p-q - r-s) / 2
"""
p, q, r, s = np.maximum([p, q, r, s], 0) # ReLU activation
d = p - q
c = r - s
alpha = (d + c) / 2
beta = (d - c) / 2
w = np.zeros((len(alpha) + 1,))
w[:-1] += alpha
w[1:] += beta
return wdef get_XOR_APUF_model(a, b, c, d, p, q, r, s):
"""
Generate XOR-APUF model using Kronecker product.
w_xor = kron(w_apuf1, w_apuf2)
"""
w1 = get_APUF_model(a, b, c, d)
w2 = get_APUF_model(p, q, r, s)
return np.kron(w1, w2)The decoding function reverse-engineers APUF parameters from the weight vector structure, exploiting:
- Kronecker product factorization
- Parameter relationships (Ξ±, Ξ² from p, q, r, s)
- Weight distribution pattern
The solution is validated using:
- Provided weight vectors from course
- Multiple trial averaging (5 trials)
- Reconstruction fidelity check (error metrics)
- Decoding correctness (parameter recovery)
- Timing benchmarks (efficiency analysis)
- Kronecker Product Structure: XOR-APUF inherits the Kronecker structure, enabling factorization-based decoding
- Parameter Constraints: ReLU constraints on parameters provide implicit regularization
- Scalability: Decoding time scales with weight vector dimension
- Reconstruction Quality: Average error~0.016 indicates high parameter recovery accuracy
Format: Binary matrix of shape (n_models, vector_dimension)
- Each row: weight vector from learned XOR-APUF model
- Values: Real numbers representing delay differences
decoding_results.txt: Summary statistics and timingreconstruction_errors.txt: Per-model errorstiming_analysis.txt: Detailed timing breakdown
This is an assignment submission. For improvements or questions, feel free to open an issue.
- "Arbiter PUFs: Delay Characteristics, Modeling and Attacks" - Suh & Devadas
- "Hardware Security Primitives" - Tehranipoor & Koushanfar
- "Reliable APUF Design" - Lim & Verbauwhede
- Kronecker Products in ML
- Hardware Security & PUF Design
- Parameter Estimation from Composite Models
Academic use only. Part of CS771 course at IIT Kanpur.
Mainak (mainak9093)
IIT Kanpur, CS771 - Introduction to Machine Learning
For issues or questions:
- Check
docs/approach.mdfor detailed explanations - Review
docs/puf_theory.mdfor PUF background - See
notebooks/analysis.ipynbfor step-by-step walkthrough - Ensure dependencies:
pip install -r requirements.txt