Skip to main content

A library for simulating Arbiter PUFs and other delay-based PUFs.

Project description

APUF

PyPI version CI coverage License: MIT

A Python package for simulating delay-based Physical Unclonable Functions (PUFs) using Lim's Linear Additive Delay Model (LADM). This module supports Arbiter PUFs (APUFs) and XORPUFs. Provides challenge generation, response simulation (with noise), and bit-packing utilities.

Features

  • $d$-layer Arbiter PUF (APUF): simulate $d$ layers, compute $k$-bit responses given $k$ challenges ($d$-bit binary vectors).
  • XORPUF (XORPUF): simulate multiple APUF instances, compute responses and XOR them for increased complexity.
  • Challenge generators:
    • generate_k_challenges(k, d, seed)
    • generate_n_k_challenges(n, k, d, seed)
    • generate_challenges_mp(n, k, d, seed, processes) for parallel batch generation.
  • Response data-type (Response): Both APUF and XORPUF return a $k$-bit response given $k$ challenges. Response provides a conventient interface to study PUF challenge-response behaviours.

Installation

pip install apuf

Requires Python 3.9+ and numpy.

Quick Start

Import the module and call the functions directly:

from apuf import APUF, XORPUF, generate_k_challenges

# 1) Single APUF
apuf = APUF(d=64, mean=0.0, std=0.05)

# 2) Generate 10 random challenges (phase vectors)
chals = generate_k_challenges(k=10, d=64, seed=42)  # shape (65, 10)

# 3) Measure responses twice with Gaussian noise (mean=0, std=0.005)
resp1 = apuf.get_responses(chals, nmean=0.0, nstd=0.005)
resp2 = apuf.get_responses(chals, nmean=0.0, nstd=0.005)

# 4) Due to measurement noise, resp1 and resp2 may be different
diff = resp1 - resp2
#   4.1) We can compute Hamming distance
hamming_distance = resp1.dist(resp2)
#   4.2) And fractional/normalized HD
fHD = resp1.dist(resp2)/len(resp1)

# 5) Pack responses into bytes for convenience
resp_bytes = APUF.compact_responses(resp)
print(resp, resp_bytes)

API Reference

Below you will find a short reference for the core classes and functions.

Classes

Response - Represents a PUF response vector.

  • Bitwise operations: ^, &, |, ~
  • .dist(other) returns Hamming distance.
  • .hw returns Hamming weight (number of 1s).

APUF(d: int = 128, mean: float = 0.0, std: float = 0.05) - Simulates a single APUF.

  • get_responses(chals: np.ndarray, nmean: float = 0.0, nstd: float = 0.005) -> Response
  • compact_responses(resp: Response) -> bytes

XORPUF(children: list[APUF]) - Simulates an XORPUF by XORing responses of child APUFs.

get_responses(chals: np.ndarray) -> Response

Functions

  • generate_k_challenges(k: int, d: int, seed: int = None) -> np.ndarray
  • generate_n_k_challenges(n: int, k: int, d: int, seed: int = None) -> np.ndarray
  • generate_challenges_mp(n: int, k: int, d: int, seed: int = None, processes: int = cpu_count()) -> list[np.ndarray]

Full docstrings and type hints are available in code.

Testing

Run the provided unit tests with unittest:

git clone https://github.com/nikita-tripathi-geo/APUF-simulation.git
cd APUF-simulation
pip install -r requirements.txt
python -m unittest tests/*.py

Contributing

Contributions, issues and feature requests are welcome! Please see Issues.

License

This project is licensed under the MIT License – see the LICENSE file for details.

MIT License (c) Nikita Tripathi

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apuf-0.2.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apuf-0.2.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file apuf-0.2.0.tar.gz.

File metadata

  • Download URL: apuf-0.2.0.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for apuf-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9f92847b94fbf60074f93e32f09259ae84c960bf2c6154bacebc8411e889e36a
MD5 bd156dfb0ab9aba7da5c79fbcc99a03d
BLAKE2b-256 c9c8bb122f868cd2ba43538cbdea6e7c07c1c449f06c56e5381f94cb0d023512

See more details on using hashes here.

Provenance

The following attestation bundles were made for apuf-0.2.0.tar.gz:

Publisher: python-publish.yml on nikita-tripathi-geo/APUF-simulation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file apuf-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: apuf-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for apuf-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba8af7bd49b0a5bea60766bff08fa1a13497096a59c449833c255108fcac0a21
MD5 30a9dc6639a1a5a3df8c61dd3df56841
BLAKE2b-256 5797aa9db6c11429d0a781ec926874f7d7263f6ba7c4eb08ce17a9325918af91

See more details on using hashes here.

Provenance

The following attestation bundles were made for apuf-0.2.0-py3-none-any.whl:

Publisher: python-publish.yml on nikita-tripathi-geo/APUF-simulation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page