Skip to main content

CryptoTensors is an extension of safetensors that adds encryption, signing, and access control (Rego-based policy engine) while maintaining full backward compatibility with the safetensors format

Project description

CryptoTensors Python Package

CryptoTensors is a secure tensor file format that extends safetensors with encryption, signing, and access control capabilities while maintaining full backward compatibility.

Installation

pip install cryptotensors

Transparent Loading of Encrypted Models (Compatible Package)

If you want to load encrypted CryptoTensors models without modifying your code, you can use the compatible package released on GitHub Releases:

# Uninstall the original safetensors package
pip uninstall safetensors

# Install the compatible package directly from GitHub release
# Replace {tag} with the release tag (e.g., v0.1.0)
pip install https://github.com/aiyah-meloken/cryptotensors/releases/download/{tag}/safetensors-0.7.0-py3-none-any.whl

# Example for v0.1.0:
# pip install https://github.com/aiyah-meloken/cryptotensors/releases/download/v0.1.0/safetensors-0.7.0-py3-none-any.whl

After installation, your existing code using from safetensors import ... will transparently support both regular safetensors files and encrypted CryptoTensors files without any code changes. The compatible package uses the safetensors namespace but internally depends on cryptotensors, enabling seamless encryption support.

Usage

Basic Usage (Safetensors Compatible)

CryptoTensors is fully backward compatible with safetensors. You can use it as a drop-in replacement:

Numpy

from cryptotensors.numpy import save_file, load_file
import numpy as np

tensors = {
   "a": np.zeros((2, 2)),
   "b": np.zeros((2, 3), dtype=np.uint8)
}

save_file(tensors, "./model.safetensors")

# Now loading
loaded = load_file("./model.safetensors")

Torch

from cryptotensors.torch import save_file, load_file
import torch

tensors = {
   "a": torch.zeros((2, 2)),
   "b": torch.zeros((2, 3), dtype=torch.uint8)
}

save_file(tensors, "./model.safetensors")

# Now loading
loaded = load_file("./model.safetensors")

Encryption Usage

CryptoTensors adds encryption and signing capabilities:

import torch
from cryptotensors.torch import save_file, load_file

tensors = {
   "weight1": torch.zeros((1024, 1024)),
   "weight2": torch.zeros((1024, 1024))
}

# Encrypt and save
config = {
    "enc_key": enc_key,    # JWK format encryption key
    "sign_key": sign_key,  # JWK format signing key
}
save_file(tensors, "model.cryptotensors", config=config)

# Load encrypted file (keys retrieved from key provider)
tensors = load_file("model.cryptotensors")

See the documentation for detailed guides on encryption, key management, and integration examples.

Features

  • 🔐 Encryption: AES-GCM and ChaCha20-Poly1305 encryption for tensor data
  • ✍️ Signing: Ed25519 signature verification for file integrity
  • 🔑 Key Management: Flexible key provider system (environment variables, files, programmatic)
  • 🛡️ Access Policy: Rego-based policy engine for fine-grained access control
  • 🔄 Backward Compatible: Works seamlessly with existing safetensors code

Developing

# Install in development mode
pip install -e .[dev]

This should be enough to install this library locally for development.

Testing

# Install with testing dependencies
pip install -e .[dev]

# Run tests
pytest -sv tests/

Citation

This implementation is based on the following research paper:

Zhu, H., Li, S., Li, Q., & Jin, Y. (2025). CryptoTensors: A Light-Weight Large Language Model File Format for Highly-Secure Model Distribution. arXiv:2512.04580. https://arxiv.org/pdf/2512.04580

License

Apache-2.0 License

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

cryptotensors-0.1.1.tar.gz (256.5 kB view details)

Uploaded Source

Built Distributions

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

cryptotensors-0.1.1-pp310-pypy310_pp73-manylinux_2_24_s390x.whl (3.6 MB view details)

Uploaded PyPymanylinux: glibc 2.24+ s390x

cryptotensors-0.1.1-pp310-pypy310_pp73-manylinux_2_24_ppc64le.whl (3.9 MB view details)

Uploaded PyPymanylinux: glibc 2.24+ ppc64le

cryptotensors-0.1.1-pp310-pypy310_pp73-manylinux_2_24_armv7l.whl (3.3 MB view details)

Uploaded PyPymanylinux: glibc 2.24+ ARMv7l

cryptotensors-0.1.1-pp310-pypy310_pp73-manylinux_2_24_aarch64.whl (3.4 MB view details)

Uploaded PyPymanylinux: glibc 2.24+ ARM64

cryptotensors-0.1.1-pp39-pypy39_pp73-manylinux_2_24_s390x.whl (3.6 MB view details)

Uploaded PyPymanylinux: glibc 2.24+ s390x

cryptotensors-0.1.1-pp39-pypy39_pp73-manylinux_2_24_ppc64le.whl (3.9 MB view details)

Uploaded PyPymanylinux: glibc 2.24+ ppc64le

cryptotensors-0.1.1-pp39-pypy39_pp73-manylinux_2_24_armv7l.whl (3.3 MB view details)

Uploaded PyPymanylinux: glibc 2.24+ ARMv7l

cryptotensors-0.1.1-pp39-pypy39_pp73-manylinux_2_24_aarch64.whl (3.4 MB view details)

Uploaded PyPymanylinux: glibc 2.24+ ARM64

cryptotensors-0.1.1-cp38-abi3-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.8+Windows x86-64

cryptotensors-0.1.1-cp38-abi3-win32.whl (2.7 MB view details)

Uploaded CPython 3.8+Windows x86

cryptotensors-0.1.1-cp38-abi3-musllinux_1_2_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ x86-64

cryptotensors-0.1.1-cp38-abi3-musllinux_1_2_i686.whl (3.7 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ i686

cryptotensors-0.1.1-cp38-abi3-musllinux_1_2_armv7l.whl (3.6 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARMv7l

cryptotensors-0.1.1-cp38-abi3-musllinux_1_2_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARM64

cryptotensors-0.1.1-cp38-abi3-manylinux_2_24_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.24+ x86-64

cryptotensors-0.1.1-cp38-abi3-manylinux_2_24_s390x.whl (3.6 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.24+ s390x

cryptotensors-0.1.1-cp38-abi3-manylinux_2_24_ppc64le.whl (3.9 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.24+ ppc64le

cryptotensors-0.1.1-cp38-abi3-manylinux_2_24_i686.whl (3.6 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.24+ i686

cryptotensors-0.1.1-cp38-abi3-manylinux_2_24_armv7l.whl (3.3 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.24+ ARMv7l

cryptotensors-0.1.1-cp38-abi3-manylinux_2_24_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.24+ ARM64

cryptotensors-0.1.1-cp38-abi3-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

cryptotensors-0.1.1-cp38-abi3-macosx_10_12_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: cryptotensors-0.1.1.tar.gz
  • Upload date:
  • Size: 256.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.11.2

File hashes

Hashes for cryptotensors-0.1.1.tar.gz
Algorithm Hash digest
SHA256 984de32c2a9646c4766716cc3de96bcef9d1ce8e02ab564d476b7eb7b5648aa7
MD5 67620eb2203b16efd6bd7ba3660a4b83
BLAKE2b-256 4083bbc5875ae5cfe03199f407c1a3ee049827dedc55c3394bf1347f0ea8b259

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-pp310-pypy310_pp73-manylinux_2_24_s390x.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-pp310-pypy310_pp73-manylinux_2_24_s390x.whl
Algorithm Hash digest
SHA256 15c8f1463e69f2c4b44f6e4197cffdd9731c72665b4135fde2918a7452764415
MD5 bf04ecd29d17e0ac622b78aff933a779
BLAKE2b-256 b4b9a3378ef55b986fc8095985bdf62379ef498e6a1a8c3cdcfe6cf3f7a3d0a8

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-pp310-pypy310_pp73-manylinux_2_24_ppc64le.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-pp310-pypy310_pp73-manylinux_2_24_ppc64le.whl
Algorithm Hash digest
SHA256 3ab65f7e447703ef7102730b32e96c5840496ab298b4b8bfb2538692a2e7fe13
MD5 22932c655f32187df830b8f1c3f0f5da
BLAKE2b-256 d05fb3f1a79fe03066548ded254a3801e1b5360594254d6ed162c66af419f6cd

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-pp310-pypy310_pp73-manylinux_2_24_armv7l.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-pp310-pypy310_pp73-manylinux_2_24_armv7l.whl
Algorithm Hash digest
SHA256 c6c0e8bc266fc36bcc1a839ae6a71e35e61a601759c68c7a1261af49c38d62bb
MD5 c3e46f98872ee229727d06415eb88211
BLAKE2b-256 8f13f9b496e4f503723c4584977327870e24b430237359f15f907713a86ed64a

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-pp310-pypy310_pp73-manylinux_2_24_aarch64.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-pp310-pypy310_pp73-manylinux_2_24_aarch64.whl
Algorithm Hash digest
SHA256 5ed7e07cbd957e522420ef65f80b5f692f1ea64000f911bc4f8f92b0d2019edd
MD5 5e4ef2a2dc5366d58badf70ed7996bad
BLAKE2b-256 a307f6f41092af4e8db04f30b3dcdd06e3dedb6832262905280cbdfaddd9b58c

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-pp39-pypy39_pp73-manylinux_2_24_s390x.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-pp39-pypy39_pp73-manylinux_2_24_s390x.whl
Algorithm Hash digest
SHA256 044b14c6e65b3c464b280b69ebd56fb1b6d2196d77a522c0e01091340757f9dc
MD5 057cc9e5c2d36ec4d59d2f704460e7e6
BLAKE2b-256 1e6c771527cb82d030ce1d855a2c5cb9ca9360be2a99e5943c68c04b521e7ae7

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-pp39-pypy39_pp73-manylinux_2_24_ppc64le.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-pp39-pypy39_pp73-manylinux_2_24_ppc64le.whl
Algorithm Hash digest
SHA256 6cd79a34da0ecf82975654ed060a1e902f57778c6e70bc8e1ea6a9cc9d61b56a
MD5 5db956fbd79452ad9b902310a78ca5d1
BLAKE2b-256 bb9a99fed7179407a36622db19a0f380ab90439b8b59bda8686275dde9dc4edc

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-pp39-pypy39_pp73-manylinux_2_24_armv7l.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-pp39-pypy39_pp73-manylinux_2_24_armv7l.whl
Algorithm Hash digest
SHA256 3d4d4d9d86f15197b3b0ceb8954f9d70cad4f1b03e7ac2e85a2355a49aa4762b
MD5 9ae2e76411187a88b59881c508849235
BLAKE2b-256 7c4cced9ef1fa81cde5e6a3773551d0b3ab5695e6eeab463edafd42610c2c522

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-pp39-pypy39_pp73-manylinux_2_24_aarch64.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-pp39-pypy39_pp73-manylinux_2_24_aarch64.whl
Algorithm Hash digest
SHA256 a23f561a53eebdf557de68fe059bebe07ba372d142b770af1b04302484a354a7
MD5 4a66c77cc2b98beef2001c2afa44be1a
BLAKE2b-256 ae2700af6fde3535fbce1c334049e55c6cbcf45494d86666ffea0ea535d22d93

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5cf694fd1adcc20974568831171d7ae7d9beb6eb7ec3d9c369e717c41c1f6707
MD5 ea01d7aea83dba4d06a67a8e46cb1549
BLAKE2b-256 0901878bd88760fa3e09843de0985efb7e8b9524e566c938e06a2863bfa7d0c3

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-cp38-abi3-win32.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 febbf82c5698a4c8c8db353f5f58c2598a2ebc06f36b907a4a8ffeb775688b36
MD5 adf862325b14ba9f9c12c403e45882cb
BLAKE2b-256 2cb991986eac37f324d4b38e96ea6ec05a22f59c4f9809bb91c8e666e6f8b7c9

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-cp38-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 47aee654c874a5b712104b68cdef252d5738d8cac9852a550a9265d0b1d08a7f
MD5 80f7daf308365c5c6dc82d1774807234
BLAKE2b-256 32fd28ef4db41b83b1667e835a796160da2ef16f201f846c503b24b5833bd9a4

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-cp38-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-cp38-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 444bc9e2c8c355e9ab1e9abce4e891e173632e87cb49d3fb3f72d03b509003a6
MD5 145da29c7548c40a08cb87a1b651cc1f
BLAKE2b-256 aac6d3d4044aaaddf64c55cf913ab1198ae341339efb3b9ac289d1a9382e4e23

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-cp38-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-cp38-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 123be7661e03f1f614ce8f40e212df4effb2f9bb247cca3d28a52f39d5c0d141
MD5 657ff12246f7528284be263e3c4e0ff4
BLAKE2b-256 bcb8207c2d7449ee1d695c0a386179fabf9873ae2ac3158be546c5aaeb6ae556

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-cp38-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 65443b4ec246385aef68df626099e17a11d70cf75fc877f9817778e1d934f224
MD5 197cc0daf52c6a1f2317ddcea83422c8
BLAKE2b-256 5ec8207dab7e99fbfbafedc261d65615aef4f0f6179be617e486bd72dc81e891

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-cp38-abi3-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-cp38-abi3-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 0404ae2246ae8ce00a86efd8c2ab6318b98964d9cbee33d4168d180f8b4e54aa
MD5 21f3c5ada24ad557f6bafbcead9123e1
BLAKE2b-256 41d9b448f818ac7e34f0264da9168c0c921bcb172f328db95e1ca4d0a9d2a7ed

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-cp38-abi3-manylinux_2_24_s390x.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-cp38-abi3-manylinux_2_24_s390x.whl
Algorithm Hash digest
SHA256 6b99772153df29a59a9922cf28148b1b572976795de28540475b2055b169dc31
MD5 21282194300d9f7fe5620d09255e0847
BLAKE2b-256 97d356cec50a17808ba900232c42d1c7ac81f1ba02bf9ce37753782338b74b8d

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-cp38-abi3-manylinux_2_24_ppc64le.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-cp38-abi3-manylinux_2_24_ppc64le.whl
Algorithm Hash digest
SHA256 1c3eda871764937272401e4e912b0357e740a6ba6ac0ec0707a12549589c029b
MD5 af661095f7083e3ad4784e4c10c4a8ec
BLAKE2b-256 2d52cec6d9d4b5cc33ffa21f7cbc9a5596f8ac272a0ef5f55fe93deca64d5ae9

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-cp38-abi3-manylinux_2_24_i686.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-cp38-abi3-manylinux_2_24_i686.whl
Algorithm Hash digest
SHA256 4f22e29441eee1de425f3ac434cf96b32b781d55aa4c0b5a09ae168e6a48b393
MD5 753fc016050b50066d0c7b969ce4042c
BLAKE2b-256 7f8d96109c9e43463f29a8fcb9eb115f9e7f96c8c14e0b83abbb2946879e3f24

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-cp38-abi3-manylinux_2_24_armv7l.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-cp38-abi3-manylinux_2_24_armv7l.whl
Algorithm Hash digest
SHA256 28175bc8d9bfede4d51bf9bc31ee4b9870abc8bc1082560f3b271b188756d30c
MD5 5e7c204cba550bd57d789af7d78f4510
BLAKE2b-256 76c965268c0c7eb468f905a1669adf025cb4d7bf318189b30a92551f819a22b3

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-cp38-abi3-manylinux_2_24_aarch64.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-cp38-abi3-manylinux_2_24_aarch64.whl
Algorithm Hash digest
SHA256 a5093361db53bac258c24869d0e653c4585e0393cd2c70ec03bd060299b60bb4
MD5 a076e013a8458fa443a915da21943e21
BLAKE2b-256 fdf60e7de4d56906e484172b8f45800a6b6805efbed6986db850ee410ec0e2a7

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cb7fc3a134d34624c10f6fcc847b7663f4493e59e4d2ce64d135e32f369beb11
MD5 935fae72d6fe239ff593de0e467e92db
BLAKE2b-256 0094cc9adbdc26a7eb08fbc5761c6845a6109b419e87f3e8614778e1adfdfd1b

See more details on using hashes here.

File details

Details for the file cryptotensors-0.1.1-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for cryptotensors-0.1.1-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5f464b6eab54201bc2016efaad833cd361f03206c2e08236a68ccd8eaba6cb76
MD5 4b0238f4e286a0c1b34148ef5688414d
BLAKE2b-256 2f902b07eb38d3d34c7d8c1e4fda439ea04f2360ad98ccdfef088596202949f7

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