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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cryptotensors-0.2.0.tar.gz.
File metadata
- Download URL: cryptotensors-0.2.0.tar.gz
- Upload date:
- Size: 273.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6228ce43f3b858cc0ed01335fff8b4d12aef6b4122a954321f2aafe8eba963c8
|
|
| MD5 |
a1c6fe1e65d56a250833d54a7f3ad5a2
|
|
| BLAKE2b-256 |
deb58e6892d2d77d71a8ffb7b94389eacb1eb3df5736a6a2c1987b65ba5440cc
|
File details
Details for the file cryptotensors-0.2.0-pp310-pypy310_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl.
File metadata
- Download URL: cryptotensors-0.2.0-pp310-pypy310_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 3.6 MB
- Tags: PyPy, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
880165fb103965c8a9746df8505fa685d85cf0fe12b4fa151be86ea76cf65514
|
|
| MD5 |
7ea34b47b9b829fffb1a8b635d2a8a95
|
|
| BLAKE2b-256 |
cc7b19ca103df8c2340ea697f7fd4d09230d0dcf1622e1525a0e6a93cf0f121b
|
File details
Details for the file cryptotensors-0.2.0-pp310-pypy310_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.
File metadata
- Download URL: cryptotensors-0.2.0-pp310-pypy310_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 3.9 MB
- Tags: PyPy, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92fc4ec63be946c5fa3961847e1e31292b5f0d41575ed4f01c8ec921ff022aa3
|
|
| MD5 |
c8cd2630cbab069f897c33ae7b451f47
|
|
| BLAKE2b-256 |
66f3e7162a8cd7302778b5ab0b2a486a7832a740b76af7cc3f740be036ab7481
|
File details
Details for the file cryptotensors-0.2.0-pp310-pypy310_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: cryptotensors-0.2.0-pp310-pypy310_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 3.3 MB
- Tags: PyPy, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a62f9ff8f84a9e704d3dc4d843f5040adaee19e95a18618f7629c85a70ae5723
|
|
| MD5 |
0e7f2bda2cfa53c4694a6e8e04b219e2
|
|
| BLAKE2b-256 |
e8e92ed384e9987a77c5eb45664d9e2e02b70f82355fc7264e109bea294a6b0c
|
File details
Details for the file cryptotensors-0.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: cryptotensors-0.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.4 MB
- Tags: PyPy, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e590eca6ad9b953031a9ba8dc4ccec4cf7340c17f302360f8ef3f6d2f6791282
|
|
| MD5 |
49bbf26105db82b226b0f6e889d857d1
|
|
| BLAKE2b-256 |
9bd7575cd79fa3b4ec9aed81ce99d48a52fe46d35220003e4354b3e3f06e8ecb
|
File details
Details for the file cryptotensors-0.2.0-pp39-pypy39_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl.
File metadata
- Download URL: cryptotensors-0.2.0-pp39-pypy39_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 3.6 MB
- Tags: PyPy, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9d503288fdf41d9ff86540247dc74a6b359af72af99a78577080174d5599a23
|
|
| MD5 |
406dfb522419881a3abfef1d259889be
|
|
| BLAKE2b-256 |
79c8853eaaa9656270bac245829c56eb6113c0f24a56f4a0e9c3c26e185742de
|
File details
Details for the file cryptotensors-0.2.0-pp39-pypy39_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.
File metadata
- Download URL: cryptotensors-0.2.0-pp39-pypy39_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 3.9 MB
- Tags: PyPy, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3a4bf87d2e3043befae1b9915e6db9367ce044df92b3331238534cae09f5161
|
|
| MD5 |
c9a0b9de092da0532ab72f0b7017beeb
|
|
| BLAKE2b-256 |
01f0543a886029160870bacb2e0b744f85429cf715f11de57b567a781e92ac14
|
File details
Details for the file cryptotensors-0.2.0-pp39-pypy39_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: cryptotensors-0.2.0-pp39-pypy39_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 3.3 MB
- Tags: PyPy, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee27d6ff0fe521deee28e4153f72b4553dd8f928817296c4ebb70656ab1bf413
|
|
| MD5 |
f3052b00a39bebeab8baaf37087a6a4b
|
|
| BLAKE2b-256 |
dfc683076096e13a3629d1b146d821cd10e9b9277baab2edaf3b1e44ddec6aac
|
File details
Details for the file cryptotensors-0.2.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: cryptotensors-0.2.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.4 MB
- Tags: PyPy, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15af913e155b79775d9a971d634309d2a6e928daf98648ea6416033e90162744
|
|
| MD5 |
6bf0bd1314ad60f13ffec6ea1d90ed77
|
|
| BLAKE2b-256 |
1c73448614e8dca7eff8710bc53ce5c74888cab54085b115b9abab7311a308e5
|
File details
Details for the file cryptotensors-0.2.0-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: cryptotensors-0.2.0-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 3.2 MB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5054c7dd87b86ce1951543ed7552dab14d695599f44389dfdb1a5aeef5efc488
|
|
| MD5 |
e1de5d32b4d212f3a9990d06f54a25f4
|
|
| BLAKE2b-256 |
a6d0a5122c332a93bb09ee4455365ab836c9c29666e511847739909c0316bc67
|
File details
Details for the file cryptotensors-0.2.0-cp38-abi3-win32.whl.
File metadata
- Download URL: cryptotensors-0.2.0-cp38-abi3-win32.whl
- Upload date:
- Size: 2.7 MB
- Tags: CPython 3.8+, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5a2213b86c484cc6950d60dbca018fa1e311041ba0abb5b8a03c8207ea0bfd2
|
|
| MD5 |
125b9a3ecc76e93f174233d21dfa8889
|
|
| BLAKE2b-256 |
a2f1f8c3fa9289e352956225bd8ddc15592959b97e9d4abba5dfa1aa53996e41
|
File details
Details for the file cryptotensors-0.2.0-cp38-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: cryptotensors-0.2.0-cp38-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 3.8 MB
- Tags: CPython 3.8+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b75855acb25c2a8045c946d6b0017092c78ac2f848dc5c03356b1c8977e222b
|
|
| MD5 |
dd85d315ba74ffd42620a003e65a5e6a
|
|
| BLAKE2b-256 |
d9d0e807a413c61e4db8fd0eb1e86520c0ec764d5f31bb9db01c2fe208f36d9a
|
File details
Details for the file cryptotensors-0.2.0-cp38-abi3-musllinux_1_2_i686.whl.
File metadata
- Download URL: cryptotensors-0.2.0-cp38-abi3-musllinux_1_2_i686.whl
- Upload date:
- Size: 3.7 MB
- Tags: CPython 3.8+, musllinux: musl 1.2+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12c39f33801b570ad5ca0518e4028f65cd776de167a82d3593720b728cef90b1
|
|
| MD5 |
6881e477ac707c5a3c265b47a8714a4e
|
|
| BLAKE2b-256 |
39f0456e2644a374847ccccb73103f22ef7653a722d12f0420d44aa51351f18d
|
File details
Details for the file cryptotensors-0.2.0-cp38-abi3-musllinux_1_2_armv7l.whl.
File metadata
- Download URL: cryptotensors-0.2.0-cp38-abi3-musllinux_1_2_armv7l.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.8+, musllinux: musl 1.2+ ARMv7l
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6412d6b765e123ec6bd3356691ee2a8d0e72e6478c40ac6e3c1e1978264481b6
|
|
| MD5 |
fe35782081b9ebe69622f61d22f13bfc
|
|
| BLAKE2b-256 |
26ee891cedf09b6c24b7f5f2bd31d2b3b1cc43c834cf5f42851897203f1af6e6
|
File details
Details for the file cryptotensors-0.2.0-cp38-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: cryptotensors-0.2.0-cp38-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.8+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f1d634c1f1dd8fc51c423bf2726ed8b76d842efadd0ef5d19f59e621ca72263
|
|
| MD5 |
78f57b1555123113e47fa56844278a65
|
|
| BLAKE2b-256 |
ab54b14b06a1587170ff84bdaa7804d86a5b00965e1c0d61f53aa11c78f2b665
|
File details
Details for the file cryptotensors-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: cryptotensors-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.5 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c25d551f00b7c41a013e432b2f6b5f65fa4936f2aaa56a8bc4c101be29f757c
|
|
| MD5 |
fcd54cd368b64f56fc757705cf1d67cd
|
|
| BLAKE2b-256 |
c072798b49f534f28135f2c0a4ee5ee6f9dbffc63139fb6ac67fed56cedf942f
|
File details
Details for the file cryptotensors-0.2.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.
File metadata
- Download URL: cryptotensors-0.2.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bff7960e6140bc93c0fa058817f163ce7ece33d63b5df07299e72d22ae6e6ddc
|
|
| MD5 |
a62bd690632d15ad8996ac592e5d0f16
|
|
| BLAKE2b-256 |
e0d0c35c59be5f9afca821f998aba4dd92ce7c8d0d3ce7889b006aa7d9d47635
|
File details
Details for the file cryptotensors-0.2.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.
File metadata
- Download URL: cryptotensors-0.2.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 3.9 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5816044dae4e8e0c7d02e628796c3b4223396bb07d0962cd3cf0a2b2577d6334
|
|
| MD5 |
c98f089df7786de4bc950d0a5532c989
|
|
| BLAKE2b-256 |
dcc1b72acfa47fa754f5cc975bbdbf6f8fafd98ccd493489faaed3564cd37828
|
File details
Details for the file cryptotensors-0.2.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: cryptotensors-0.2.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 3.3 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a447573f1461b51603c9e098f2a9fe8e473c675693d9e9269272bc42519c74d2
|
|
| MD5 |
e6f214096a97cc523f3a99f704b1c731
|
|
| BLAKE2b-256 |
5f35b84b4a62df182a93ce9f45ce956df90ff93ae2c70458310e7fb2093a5c75
|
File details
Details for the file cryptotensors-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: cryptotensors-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.4 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2c8f0cf25f8c966ffc3ac1bd68a88d993392ac0c74e102f483a72f81fa13b4d
|
|
| MD5 |
9e94dac4150e585ceb367ba7f6fd8477
|
|
| BLAKE2b-256 |
5c0942b2ad897246409c7cec0cf8ab602c47bd6badd0e69f4b0ac8d105efcabb
|
File details
Details for the file cryptotensors-0.2.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl.
File metadata
- Download URL: cryptotensors-0.2.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.8+, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cdd9c33ee59c366c1f610c0ae0bf4e196edd23b22abf431d71285fe28e5dc9b
|
|
| MD5 |
3b60882e2c8364d955207522e80ca0fd
|
|
| BLAKE2b-256 |
a96820b3f61f9b8473a653f93c2feabe0e726c2dd78e70a514e89ac964d06b38
|
File details
Details for the file cryptotensors-0.2.0-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: cryptotensors-0.2.0-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.1 MB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5de55bc91c7b3ae4f02f2c1d4a03a38ff39a5240d47d74ba2eb520c1ec8850e
|
|
| MD5 |
b9bb457ebe98baa6266c40149228fa8b
|
|
| BLAKE2b-256 |
ff0bd5b180b7611ee67e94cfee33803ea0c63f577585656f7c8b8caa312054d3
|
File details
Details for the file cryptotensors-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: cryptotensors-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 3.3 MB
- Tags: CPython 3.8+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cdb974cc908917433ae7d8aba6d60a4561fbcb5ba480887bb9f79208f4e09b4
|
|
| MD5 |
d301e90c660068c9ec427d884f3eea07
|
|
| BLAKE2b-256 |
393a5966dda52426b0ba86293fd2a53607710c2dc8f8c47c2ad54be86f50fc80
|