Skip to content

Latest commit

Β 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

APUF Model Decoder: Parameter Recovery from XOR-APUF Weights

Course: CS771 Introduction to Machine Learning (IIT Kanpur)
Instructor: Purushottam Kar
Academic Year: 2025-26
Author: Mainak (mainak9093)


Problem Statement

Implement an Arbiter PUF (Physically Unclonable Function) Model Decoder using machine learning techniques. The goal is to:

  1. Decode embedded APUF model parameters from XOR-APUF weight vectors
  2. Reconstruct the original APUF models from decoded parameters
  3. Minimize the reconstruction error between original and decoded models

Background

  • 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

Key Objectives

  1. Implement APUF model representation and generation
  2. Develop decoding algorithm to extract parameters from weights
  3. Compute reconstruction quality metrics
  4. Evaluate performance across multiple models
  5. Optimize decoding efficiency

Project Structure

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

Approach

1. APUF Model Representation

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

2. XOR-APUF Model

For XOR-APUF combining two APUFs:

w_xor = kronecker(w_apuf1, w_apuf2)

This creates the combined weight vector from two independent APUF models.

3. Decoding Algorithm

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

4. Reconstruction & Evaluation

# 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

5. Performance Metrics

  • Average Decoding Time (per model)
  • Average Reconstruction Error (L2 norm)
  • Error Distribution across models
  • Robustness Analysis

πŸš€ Quick Start

Prerequisites

  • Python 3.8+
  • pip or conda

Installation

# Clone the repository
git clone https://github.com/mainak9093/apuf-model-decoder.git
cd apuf-model-decoder

# Install dependencies
pip install -r requirements.txt

Running the Solution

# 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

Running the Notebook

# Start Jupyter
jupyter notebook

# Open notebooks/analysis.ipynb for detailed step-by-step analysis

Results Summary

Performance Metrics

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

Execution Timing

Phase Time
Model Loading ~0.1s
Decoding (all models) ~0.5s-2s
Reconstruction ~0.1s
Evaluation ~0.2s
Total ~1-3s

Error Statistics

Reconstruction Error Statistics:
  Mean: 0.0158
  Min:  0.0001
  Max:  0.0425
  Std:  0.0052

Technical Details

APUF Model Generation

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 w

XOR-APUF Generation

def 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)

Decoding Process

The decoding function reverse-engineers APUF parameters from the weight vector structure, exploiting:

  1. Kronecker product factorization
  2. Parameter relationships (Ξ±, Ξ² from p, q, r, s)
  3. Weight distribution pattern

Validation & Testing

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)

Key Insights

  1. Kronecker Product Structure: XOR-APUF inherits the Kronecker structure, enabling factorization-based decoding
  2. Parameter Constraints: ReLU constraints on parameters provide implicit regularization
  3. Scalability: Decoding time scales with weight vector dimension
  4. Reconstruction Quality: Average error~0.016 indicates high parameter recovery accuracy

Data Format

Input: Models File (secret_mod.txt)

Format: Binary matrix of shape (n_models, vector_dimension)
- Each row: weight vector from learned XOR-APUF model
- Values: Real numbers representing delay differences

Output Files

  • decoding_results.txt: Summary statistics and timing
  • reconstruction_errors.txt: Per-model errors
  • timing_analysis.txt: Detailed timing breakdown

Contributing

This is an assignment submission. For improvements or questions, feel free to open an issue.


References

PUF Literature

  • "Arbiter PUFs: Delay Characteristics, Modeling and Attacks" - Suh & Devadas
  • "Hardware Security Primitives" - Tehranipoor & Koushanfar
  • "Reliable APUF Design" - Lim & Verbauwhede

Key Concepts

  • Kronecker Products in ML
  • Hardware Security & PUF Design
  • Parameter Estimation from Composite Models

License

Academic use only. Part of CS771 course at IIT Kanpur.


Author

Mainak (mainak9093)
IIT Kanpur, CS771 - Introduction to Machine Learning


Support

For issues or questions:

  • Check docs/approach.md for detailed explanations
  • Review docs/puf_theory.md for PUF background
  • See notebooks/analysis.ipynb for step-by-step walkthrough
  • Ensure dependencies: pip install -r requirements.txt

About

APUF model parameter extraction and reconstruction

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages