Metadata-Version: 2.4
Name: BHPAICrypto
Version: 1.0.0
Summary: BHPAI Standalone Zero-Knowledge & E2EE Cryptographic SDK Library
Home-page: https://github.com/BHPAI/BHPAICrypto
Author: BHPAI Team
Author-email: support@bhpai.io
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Security :: Cryptography
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cryptography>=41.0.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# `lib_bhpai_crypto` - BHPAI Standalone Cryptographic Library

Portable, high-performance Zero-Knowledge & End-to-End Encryption (E2EE) Python Library extracted from BHPAI Vault architecture.

## Features

- **Key Derivation**: Argon2id & PBKDF2-HMAC-SHA256 derivation + HKDF domain separation (`K_master`, `K_unlock`, `K_wrap_files`, `K_wrap_meta`).
- **AEAD Encryption**: AES-256-GCM authenticated encryption with CSPRNG 96-bit nonces.
- **Binary Canonical AAD**: 6-field length-prefixed AAD for C++/Python cross-platform binary compatibility.
- **Bucket Size Padding**: Application-level padding to obfuscate exact file sizes.
- **Envelope Encryption**: DEK envelope + file payload envelope wrapping.

## Installation / Requirements

- Python 3.8+
- `cryptography` package (`pip install cryptography`)

## Usage Example

```python
from lib_bhpai_crypto import BHPAICryptoLib

# 1. Initialize Crypto SDK
client = BHPAICryptoLib(vault_id="user-vault-123")

# 2. Derive Key Tree from Master Password
keys = client.derive_keys(password="UserSecretPassword123!")
k_unlock = keys["k_unlock"]
k_wrap_files = keys["k_wrap_files"]

# 3. Encrypt Arbitrary Data / JSON Payload
sensitive_data = {"account_no": "1234-5678", "token": "abc.xyz"}
envelope = client.encrypt_data(data=sensitive_data, key=k_unlock)
print("Encrypted Envelope:", envelope)

# 4. Decrypt Data Payload
decrypted_bytes = client.decrypt_data(envelope=envelope, key=k_unlock)
print("Decrypted Data:", decrypted_bytes.decode('utf-8'))

# 5. Encrypt Raw File Bytes (with DEK envelope + bucket size padding)
sample_file_bytes = b"Secret PDF content or image bytes..."
dek_envelope, file_envelope = client.encrypt_file(
    file_bytes=sample_file_bytes,
    k_wrap_files=k_wrap_files
)

# 6. Decrypt File Bytes
original_bytes = client.decrypt_file(
    dek_envelope=dek_envelope,
    file_envelope=file_envelope,
    k_wrap_files=k_wrap_files
)
assert original_bytes == sample_file_bytes
print("File decryption successful!")
```
