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.1.1.tar.gz (9.9 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.1.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for apuf-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f53cbff2679778599ac641325abfccc3749cb802eb1e5e41fa2be592404b55ca
MD5 aa2243a7f82c456841dbc11689e1c065
BLAKE2b-256 ed6934e989d245bd3459094afffafa0657d9fc26a787e8e96950eeedc0ff6ac9

See more details on using hashes here.

Provenance

The following attestation bundles were made for apuf-0.1.1.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.1.1-py3-none-any.whl.

File metadata

  • Download URL: apuf-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.6 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d34242eeb83051d14eac222a958382a5b01ac3c6b2d5fb63f3a9073b8309760b
MD5 59c4d64199cbae19bba8b96850a145a7
BLAKE2b-256 4f99941e0937b07777cf47434afd17863e325ca0a6465086ce29c2854b9771a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for apuf-0.1.1-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