Skip to main content

A library for generating and validating SmartHex16 identifiers

Project description

SmartHex16: A Mathematical Analysis of Hexadecimal Identifier Generation

Abstract

SmartHex16 is a deterministic hexadecimal identifier generation system implementing a 64-bit entropy space with integrated error detection capabilities. The system employs a 56-bit base identifier coupled with an 8-bit checksum, providing robust error detection while maintaining cryptographic-grade randomness in identifier generation.

Mathematical Foundations

1. System Architecture

The system architecture is defined by the following mathematical components:

  • Base Identifier Space (B):

    • Length: 14 hexadecimal characters
    • Entropy: 56 bits (14 × 4)
    • Cardinality: |B| = 2^56 ≈ 7.21 × 10^16
  • Checksum Space (C):

    • Length: 2 hexadecimal characters
    • Entropy: 8 bits (2 × 4)
    • Cardinality: |C| = 2^8 = 256
  • Total System Space (S):

    • Entropy: 64 bits
    • Cardinality: |S| = |B| × |C| = 2^64 ≈ 1.84 × 10^19

2. Checksum Algorithm

The checksum function C: B → C is defined as:

C(b₁b₂...b₁₄) = (Σ(bᵢ × (i + 1))) mod 256

where:

  • bᵢ ∈ {0,1,...,15} represents the ith hexadecimal digit
  • i ∈ {1,2,...,14} represents the position index
  • mod 256 ensures the result remains within the 8-bit checksum space

3. Error Detection Properties

The system's error detection capabilities are characterized by:

  1. Single-Digit Error Detection:

    • Detection Probability: 1
    • Mathematical Basis: Position-weighted checksum ensures unique error signatures
  2. Transposition Error Detection:

    • Detection Probability: 255/256
    • Mathematical Basis: Position-dependent weighting creates distinct checksums for transposed digits
  3. Burst Error Detection:

    • Maximum Detectable Burst Length: 8 bits
    • Detection Probability: 1 for bursts ≤ 8 bits

4. Collision Analysis

The probability of collision P(N) for N generated identifiers follows:

P(N) ≈ 1 - e^(-N(N-1)/(2×2^64))

This yields:

  • P(10^6) ≈ 2.71 × 10^-11
  • P(10^9) ≈ 2.71 × 10^-5
  • P(10^12) ≈ 0.027

Implementation

The system is implemented in Python 3.x, utilizing the secrets module for cryptographically secure random number generation. The implementation adheres to NIST SP 800-90A guidelines for random number generation.

Security Analysis

  1. Entropy Sources:

    • Base identifier: 56 bits from cryptographically secure RNG
    • Checksum: 8 bits derived from deterministic function
  2. Security Considerations:

    • Not suitable for cryptographic purposes requiring >64 bits of entropy
    • Checksum provides error detection, not cryptographic authentication
    • Collision resistance suitable for most non-cryptographic applications

References

  1. NIST Special Publication 800-90A: Recommendation for Random Number Generation Using Deterministic Random Bit Generators
  2. Peterson, W. W., & Brown, D. T. (1961). Cyclic Codes for Error Detection
  3. Shannon, C. E. (1948). A Mathematical Theory of Communication

Installation

pip install smarthex

Usage

from smarthex import SmartHex

s = SmartHex()
identity = s.generate()  # Returns 16-character hex string
is_valid = s.validate(identy)  # Returns boolean

License

This project is licensed under the MIT License. See LICENSE for details.

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

smarthex-0.2.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

smarthex-0.2.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for smarthex-0.2.0.tar.gz
Algorithm Hash digest
SHA256 36935bb385a2797506da148933370eb9bbdf749d7581d4764d5f8bd811a0160c
MD5 1cafdf10e9d7032fdb954068ae3c84bf
BLAKE2b-256 dc02b45e390aca47c04807a0ae528afc3e3059ff957b2dcca5fec3c6c3fd19cf

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for smarthex-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3df8219c2508a5fe9fbf1b8d34d86d3aaaed8e13d8fd15ee7c9d2896274f0b3d
MD5 63c78290bfdaa0ed038730e1e0ecec5c
BLAKE2b-256 e743a0e3a4f940d4e9e5bb8b2bed85b018da38a0835fdd554018a2f95716070c

See more details on using hashes here.

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