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.1.0.tar.gz (4.6 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.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for smarthex-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7a46727f75ece1b1e126f00e93ae4cfd6bbf76a3c8afb3e863e3b4284f3c6640
MD5 db5b364dd29465c765ba5b1d198875eb
BLAKE2b-256 f53f4a1f61a32bd45982c943decf14b1cabfe67ed99d13ca5364b4ba8b7efca0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: smarthex-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 55359bcb49a088dfdaa37717614e4aac8bd5559ced945bebed9c8d0ab8e00da6
MD5 b817a33801e0730a003efefcedb46fc0
BLAKE2b-256 0e68b12d5df146cb34d00fb75f3475fda8ffbccc703aa4bf366f362fdb2d0b7e

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