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.1.tar.gz (4.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.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for smarthex-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a3cb50c5651387bd201803f4748ab43d9d602d8f960ccf53ad5e58320b3f0441
MD5 6bcb82c7e2be1b6529ee1022e2872b66
BLAKE2b-256 f6a7f2b6e324956b175395d5badf9ee96807a79781dc50e4baace95bc6fa649e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for smarthex-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fb2d903b08f91a28d567c70305902911b67fd8667158c7cc6d4a0fcdbfadc622
MD5 521dd931451fa9f3246ed1ff2e6a5853
BLAKE2b-256 98cdd94a386bd4844ded5eb57a21c040a3ebb1533c93c5e2f2eb482fadbef0dd

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