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.2.tar.gz (256.8 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.2-pp310-pypy310_pp73-manylinux_2_24_s390x.whl (3.6 MB view details)

Uploaded PyPymanylinux: glibc 2.24+ s390x

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

Uploaded PyPymanylinux: glibc 2.24+ ppc64le

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

Uploaded PyPymanylinux: glibc 2.24+ ARMv7l

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

Uploaded PyPymanylinux: glibc 2.24+ ARM64

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

Uploaded PyPymanylinux: glibc 2.24+ s390x

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

Uploaded PyPymanylinux: glibc 2.24+ ppc64le

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

Uploaded PyPymanylinux: glibc 2.24+ ARMv7l

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

Uploaded PyPymanylinux: glibc 2.24+ ARM64

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

Uploaded CPython 3.8+Windows x86-64

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

Uploaded CPython 3.8+Windows x86

cryptotensors-0.1.2-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.2-cp38-abi3-musllinux_1_2_i686.whl (3.7 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ i686

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

Uploaded CPython 3.8+musllinux: musl 1.2+ ARMv7l

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

Uploaded CPython 3.8+musllinux: musl 1.2+ ARM64

cryptotensors-0.1.2-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.2-cp38-abi3-manylinux_2_24_s390x.whl (3.6 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.24+ s390x

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

Uploaded CPython 3.8+manylinux: glibc 2.24+ ppc64le

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

Uploaded CPython 3.8+manylinux: glibc 2.24+ i686

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

Uploaded CPython 3.8+manylinux: glibc 2.24+ ARMv7l

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

Uploaded CPython 3.8+manylinux: glibc 2.24+ ARM64

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

Uploaded CPython 3.8+macOS 11.0+ ARM64

cryptotensors-0.1.2-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.2.tar.gz.

File metadata

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

File hashes

Hashes for cryptotensors-0.1.2.tar.gz
Algorithm Hash digest
SHA256 eb7c1d01350ac5644e83a355bbc0138a1dfaaedb14a7ceb62b1fd5c6aaa5a786
MD5 30710eb89dfd0a1b5245cba50c8689af
BLAKE2b-256 82eb800c71f9797f184188ea228520ca52bba7413c3ff1aaae31c8deb761b728

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-pp310-pypy310_pp73-manylinux_2_24_s390x.whl
Algorithm Hash digest
SHA256 fb393530eb6818185fcfd75a75c2b81db37720f0798306165777e77a6db25ab6
MD5 e65a6286b26b283dc06cbe3d3134c770
BLAKE2b-256 781ca8a6f96bb60daae1e6c9fc763eeb57d41d9c1da276669e025b8832fbdd67

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-pp310-pypy310_pp73-manylinux_2_24_ppc64le.whl
Algorithm Hash digest
SHA256 3596e57dcc46d449cd48a45a23502b77c1d2f9f94439fc2276b3e743b6aafc5e
MD5 ff3152bac76b77387948f10c043fc98c
BLAKE2b-256 6e769558f23b3786ee88521ab5d72e9243676d7b0139de4a0889fc096c443c09

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-pp310-pypy310_pp73-manylinux_2_24_armv7l.whl
Algorithm Hash digest
SHA256 8ebaf3da96d9a0ebd75cbd9f8319f9918f3bfb7e4bd41d5716ca5394374de5c8
MD5 55d8d44f17fe1eac966fa1dfe228012d
BLAKE2b-256 ef207a06de1e13705f66678f99d2127df7fec43b4cdd42cf379ba4b2e031f826

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-pp310-pypy310_pp73-manylinux_2_24_aarch64.whl
Algorithm Hash digest
SHA256 7db91d224f6c22d139cd65009b09e371fdc8da6b8ba388a80c9060a92413b006
MD5 d8527f957d4dbfab3c969639f6a4a1e7
BLAKE2b-256 63c643c852fdec3a5f354b31146f3f4817143ea5d85df7be3020e8d0966e5d12

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-pp39-pypy39_pp73-manylinux_2_24_s390x.whl
Algorithm Hash digest
SHA256 66ca244edf18a9828395b91f071cfaa3fba7082192e892144e0655c1d024935b
MD5 96fa71e68d4ded23eea95229ddc6f329
BLAKE2b-256 ad5eafa41c4e87f998a3d197a7aae51bd9c20d4b983556e0114cf3dd8f83da62

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-pp39-pypy39_pp73-manylinux_2_24_ppc64le.whl
Algorithm Hash digest
SHA256 97c8b0d410fc1a147786717de06581d871d2de923fcb149168f7536f45766455
MD5 7f44d0a784c4a7c4776b869f2c40843d
BLAKE2b-256 1dbe9f40e2691630687fd4b62c996c31629c1b866cad86b3d811533cad500223

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-pp39-pypy39_pp73-manylinux_2_24_armv7l.whl
Algorithm Hash digest
SHA256 b74fb5f77c143068f3a95b8c977dfb4663893dbc42436087e9e368362f8425e9
MD5 aa67a356dd0b71955e459e28880d5f6b
BLAKE2b-256 ab218cbc699b345e072c7d73f1dbf85a99abd427de10be40449e72d243e6e0e2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-pp39-pypy39_pp73-manylinux_2_24_aarch64.whl
Algorithm Hash digest
SHA256 87e5bfb8bae5f5cbfa52925a4ae60dbfdc66f6329c81b9103e5225b0e3f3923e
MD5 a91298c15db2795b6190c9ddbce78ee8
BLAKE2b-256 1ee3a41b9ada9a64552ecd0386014855c6acb333cd36917a2c7a882b252e2aa3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5f48e03aeb1ec0ea7de1731a571a35addcf666e5bb207eb6fc5a87c7f6ad89e9
MD5 c15fc9463b05928a828bfb8728788dfb
BLAKE2b-256 f4e04f0278b2765b252d7554c99425e65a0f346973bba21a55c85b1e6625bcbb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 9b7502c7d3498cd4ee35426fa452ffb9d2988d343230947511d7d6dfb352d349
MD5 739bccdcfd271a0c34e09f8f333853d2
BLAKE2b-256 3dc8c9178a09605b696dca5d56516d53dfc0592bff71bff35aa74ee5aca21e63

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a949777189cd77c7208728860906cf6fdc436f059e7ba9203dee4a6071206893
MD5 dd8a02a9b167e0317c4ea869c8005d54
BLAKE2b-256 346fb16c7f5cd50b7b6f03021a0fed25ee4919375f8f9fdc543265a275487148

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-cp38-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 c079cb782a6c2d2cc72a2b2dbd521f301f32845fca5881472e86653ffad59cdd
MD5 c60491ecfc95006589db1434828b6f01
BLAKE2b-256 bb0d130ed34fbe09cb781afe9faf8701a8120cf7bcefdba1de562d524be31aea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-cp38-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 717421f7276f8699dc9da501b28bad3b108c63e5a8b6026cb6112589efb25303
MD5 2446837d591bf37c368defd3a0d68990
BLAKE2b-256 7d47d3d50104027c1f7b633ae8b418df594d8eacf7c36cb84cccad9a2b80af00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 9b2830a5adca39138d2b524c72873a5eb5cd634aef55819c652bf3801f0c264f
MD5 063a75e6277c9674612dc1da80ff7dec
BLAKE2b-256 822f653bda5030115d50e6e5a93a20cad6eb3aa386f240c10c3ce32b9abfb4f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-cp38-abi3-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 53669cd7c9232efc1cf11999c41914c26291768f1130000bf237c09d576c6bd2
MD5 2f64f9dcb2882e7e9d87a1c9d010c884
BLAKE2b-256 1078342d8f0110168e36d37356d208910393a076e67604700ce418483348b744

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-cp38-abi3-manylinux_2_24_s390x.whl
Algorithm Hash digest
SHA256 5d558b52485e911d4a0f60587ce9a3683ff4afd838fbcbc4f0db36dfd2d4af6b
MD5 09e93e36f76da878ddb6536127af7405
BLAKE2b-256 fa55cfb44553a862d46ef35163f5c2f7e79bbd9f4cb1a69fa8612c9a4ac3b51b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-cp38-abi3-manylinux_2_24_ppc64le.whl
Algorithm Hash digest
SHA256 049e2970c5ea582fab7008b6cc577cf8b1759731a7e487aaec79f085bd5de104
MD5 c043490097bb3ee77d89cae7b3ac31f5
BLAKE2b-256 c828415296bb2f24d57f0379db262120728b14715f46a305b56c962dc8242ab0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-cp38-abi3-manylinux_2_24_i686.whl
Algorithm Hash digest
SHA256 6d1d791c0a079bc81f89c47f5a8376bba4c2598c53bfcf3a262f137a1cb55dab
MD5 7726be3fe7f0320702b74a956ee1f33c
BLAKE2b-256 3aef2f5548fee7d624fa4cf45a1a7a421f5a618c49dbbb9a01e297d99eaadc04

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-cp38-abi3-manylinux_2_24_armv7l.whl
Algorithm Hash digest
SHA256 9761daa59a4154e644d955b37adcfd18eaf3c650cf7aa0e2443db4ce1113e462
MD5 55d06e5a27f44d1114bcf319d074bd52
BLAKE2b-256 d67559e352a4deb226f5c798e10f5b2e0a6e1b1691c64fe3b68159bbc2e696e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-cp38-abi3-manylinux_2_24_aarch64.whl
Algorithm Hash digest
SHA256 5b5c2ff945f294aba530c0c054704cda2182c6ae87b28cc807229d4844d4a266
MD5 86c60e2f7d2803eaed0acc0f977ae01b
BLAKE2b-256 a33c130fd47725d4baa6e2e33cdc7d97f04495ee61ab1fa9595560678ea25379

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 01d01d8d5896b623c8dd937c09d4da9ae26ec0d8458d0ac124f88712bc34987d
MD5 6c43cb36a400ce2f63d43b8bb74c0932
BLAKE2b-256 b6f521f525b0638858c543bfec0c1075ae3fe246b4b4ae906c5b57ebac8c71f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptotensors-0.1.2-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6b4939c3fbe4617f21bfb826cf2b6da0fc9a6ae931e1c51616f34ceeb446161a
MD5 5f6413305a8e69e846fa53ba51329887
BLAKE2b-256 9d2f11cb434c2015029863dce6225a91354710562aeb4ac715b5cae099068eff

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