Skip to main content

ModelLock - AI 模型加密保护与授权系统

ModelLock 是一个用于加密和授权机器学习模型的工具。它提供了基于密码的文件加密功能,以及基于设备指纹的许可证管理系统,确保只有授权设备才能解密和使用加密的模型。

功能特性

  • 基于密码的文件加密(使用 AES-GCM 算法)
  • 设备指纹识别(跨平台支持)
  • 许可证管理(带有效期控制)
  • 命令行界面(CLI)便于集成和使用
  • 安全的密钥派生(使用 PBKDF2)
  • Python API 接口便于程序集成
  • 支持直接提供主密钥进行解密(适用于特殊场景)
  • 支持创建无设备绑定的许可证
  • 增加from model.lock import lock 支持,用于程序快速加密

快速开始

安装

pip install modellock

或从源码安装:

git clone https://github.com/yaqiangsun/modellock.git
cd modellock
pip install -e .

使用流程示例

  1. 准备阶段

    # 生成服务器密钥(**必须妥善保管生成文件且不能分享给他人**)
    bash ./scripts/run0_generate_server_secret.sh
    
    # 生成密钥文件与master_key文件(**必须妥善保管生成文件且不能分享给他人**)
    bash ./scripts/run1_generate_keyfile.sh
    
    # 加密模型文件(**加密后的文件可以分享给授权使用**)
    bash ./scripts/run2_encrypt_file.sh
    
    # 收集目标设备信息 (**不限制使用**)
    bash ./scripts/run3_collect_device.sh
    
    # 为目标设备创建许可证(**生成文件可分享给授权使用**)
    bash ./scripts/run4_create_license.sh
    

    上述生成的文件 只将 加密后的模型文件、许可证文件分发给授权使用。

  2. 部署和使用

    # 在目标设备上解密模型 (**为保证模型安全,只能在内存中解密,且解密代码需编译以保证源码不可见**)
    ./scripts/run5_decrypt_file.sh
    

    解密形式包含两种:1.提供密钥文件与密码,自动生成master_key内容解密;2.直接提供master_key解密

所有中间文件和输出文件都会保存在 tmp/ 目录下。

重要安全提示

在使用 ModelLock 过程中会生成多个敏感文件,这些文件或内容必须妥善保管且不能分享给他人:

  • password - 密码,用户自定义的密码
  • server_secret.key - 服务器密钥文件,用于许可证加密(步骤0生成服务密钥中生成的内容)
  • keyfile.json - 密钥文件,包含加密相关信息(步骤1生成密钥种子中生成的内容)

这些文件或内容能够授权使用可分享给授权的使用者:

请务必遵循此安全提示,防止未授权访问。

Metadata

Release files for modellock 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for modellock 0.2.2
File Actions
modellock-0.2.2-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for modellock-0.2.2-cp313-cp313-win_amd64.whl
modellock-0.2.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for modellock-0.2.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
modellock-0.2.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details for modellock-0.2.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
modellock-0.2.2-cp313-cp313-macosx_11_0_universal2.whl CPython 3.13 CPython 3.13 macOS 11.0+ universal2 (ARM64, x86-64) Details for modellock-0.2.2-cp313-cp313-macosx_11_0_universal2.whl
modellock-0.2.2-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for modellock-0.2.2-cp312-cp312-win_amd64.whl
modellock-0.2.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for modellock-0.2.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
modellock-0.2.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details for modellock-0.2.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
modellock-0.2.2-cp312-cp312-macosx_11_0_universal2.whl CPython 3.12 CPython 3.12 macOS 11.0+ universal2 (ARM64, x86-64) Details for modellock-0.2.2-cp312-cp312-macosx_11_0_universal2.whl
modellock-0.2.2-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for modellock-0.2.2-cp311-cp311-win_amd64.whl
modellock-0.2.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for modellock-0.2.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
modellock-0.2.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details for modellock-0.2.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
modellock-0.2.2-cp311-cp311-macosx_11_0_universal2.whl CPython 3.11 CPython 3.11 macOS 11.0+ universal2 (ARM64, x86-64) Details for modellock-0.2.2-cp311-cp311-macosx_11_0_universal2.whl
modellock-0.2.2-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for modellock-0.2.2-cp310-cp310-win_amd64.whl
modellock-0.2.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for modellock-0.2.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
modellock-0.2.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details for modellock-0.2.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
modellock-0.2.2-cp310-cp310-macosx_11_0_universal2.whl CPython 3.10 CPython 3.10 macOS 11.0+ universal2 (ARM64, x86-64) Details for modellock-0.2.2-cp310-cp310-macosx_11_0_universal2.whl

Total release size: 26.5 MB

Release files / modellock-0.2.2-cp313-cp313-win_amd64.whl

Download URL modellock-0.2.2-cp313-cp313-win_amd64.whl
Size 1.5 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
67617a9ece39378c363eeb286ff6729237f958bc81a484615f093004bc3ca504
BLAKE2b-256 checksum
How to use checksums
3186395992359d4e39df1b08cfbdfab4830daa8090d6f45260d1240306546cb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / modellock-0.2.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL modellock-0.2.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 3.0 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
2dcb156488beab339dc148222ecaf20dac057fc29f77cfd32f2612c573ee22c4
BLAKE2b-256 checksum
How to use checksums
2544813cedb0424ccaef7c81fb3fbc894c3169efb4693c1a59fee58d495cba69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / modellock-0.2.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL modellock-0.2.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 2.8 MB
Tags CPython 3.13 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
3ece4290687c44cad24f5f13003d881d5df20a7357bc21494241fcf1d08b1b4a
BLAKE2b-256 checksum
How to use checksums
da854d633769253ad4ca36cc96cb598499f5994ffc3865bca5ef8c61941ff3b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / modellock-0.2.2-cp313-cp313-macosx_11_0_universal2.whl

Download URL modellock-0.2.2-cp313-cp313-macosx_11_0_universal2.whl
Size 3.4 MB
Tags CPython 3.13 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
80d2d59fc72671f64d6095548f92a05c4c7958706a0cea55efd4f92d19e89098
BLAKE2b-256 checksum
How to use checksums
bc41a8b0e3933f927c0e946194ca4fd5edccc90b230c1bb490e43e3538d63a24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / modellock-0.2.2-cp312-cp312-win_amd64.whl

Download URL modellock-0.2.2-cp312-cp312-win_amd64.whl
Size 1.1 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
a94fc585c452df40fc3d4d1c7a7999fb3e12ba3413812b0db7e34cc14326931e
BLAKE2b-256 checksum
How to use checksums
c14759d2a7e4feab58505355c2b207f1bd8b2441c523b0457c6dcc7e1a8274e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / modellock-0.2.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL modellock-0.2.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 2.2 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
820cab8c2a18b2f5b9a94377566463af421bed3f8a907e9a26273085054127df
BLAKE2b-256 checksum
How to use checksums
a37c07bc11c24575cf48809601a1e09f4f73fbc1476b7c7708f01f2568a5ac00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / modellock-0.2.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL modellock-0.2.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 2.0 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
ad2e9be55c92ddaccc4fbdc1c6fda62db0484a1374964b2eccfba041ef9c0f77
BLAKE2b-256 checksum
How to use checksums
37ee9630976c2b04072a8fc168150ff65ac21deb156b964561ba2e55f2dda9fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / modellock-0.2.2-cp312-cp312-macosx_11_0_universal2.whl

Download URL modellock-0.2.2-cp312-cp312-macosx_11_0_universal2.whl
Size 2.5 MB
Tags CPython 3.12 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
45e52a9aa1bec1a2a85cef2ae11f3bc90b18bcfd570bc72adbd2892fec4c6bec
BLAKE2b-256 checksum
How to use checksums
ab0d6b4ed3714d1a78c996a86a50b7cb6900bcc1aa88d41b5e67c3c6a3a55ef9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / modellock-0.2.2-cp311-cp311-win_amd64.whl

Download URL modellock-0.2.2-cp311-cp311-win_amd64.whl
Size 759.3 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
38ff5e0406202a42f9d93792c5cb5fc3aed54119b9278d0b7739bf309e05d63b
BLAKE2b-256 checksum
How to use checksums
2411e2f1aa63e8f113c993a70d0640b33d186a593005e48fa2629c7a27f686c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / modellock-0.2.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL modellock-0.2.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 1.5 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
fb098213b18713d551cf06c0a6f77ec76e1de5b8466aa9fa0771307625b5715d
BLAKE2b-256 checksum
How to use checksums
f4439e5a59ce38f3555ef6acc66951aee4ee63747bd91d84210c5d27f5455339
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / modellock-0.2.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL modellock-0.2.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 1.3 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
b1de96a37aab9cbdd7d105286c189c098da1962045f02bf7e1b47878f6987336
BLAKE2b-256 checksum
How to use checksums
b474871a54c5a686d986cdaeb2ea68dc18bdf8b71e33c6d9675488420e628751
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / modellock-0.2.2-cp311-cp311-macosx_11_0_universal2.whl

Download URL modellock-0.2.2-cp311-cp311-macosx_11_0_universal2.whl
Size 1.7 MB
Tags CPython 3.11 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
703424237309fb33f6d2285e4daa493118705958b5936460cc2606ab49fd561e
BLAKE2b-256 checksum
How to use checksums
52c9c5d7e6e3401dfb5cf29ccbab4eec3c887d5ec9dd12bfb788b510cdf3525f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / modellock-0.2.2-cp310-cp310-win_amd64.whl

Download URL modellock-0.2.2-cp310-cp310-win_amd64.whl
Size 380.2 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
95ef0d69a6a723a4a4c6bbff4bee5691f5758dc4604045cf41dce46e2b207541
BLAKE2b-256 checksum
How to use checksums
0c9b8f8223e5cfc5ca38630fcf08883a168c9ab634e97e96f1d35bb72bea1700
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / modellock-0.2.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL modellock-0.2.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 731.2 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
129847b86a90693573bf1b509b73c8d4b49ba1f0cc33cf2ae6cb45d1a5c9abc8
BLAKE2b-256 checksum
How to use checksums
26502e88d09178134a29f94bf2b3b17b809ca2ee1a97068448e46dc1ef2ec106
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / modellock-0.2.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL modellock-0.2.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 677.9 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
230cc3693ba6514357455e2fc46774a30db5b6bdb5cade7a12f411fb13b38919
BLAKE2b-256 checksum
How to use checksums
7fe9e0a8ceb37def655cffd4a71d1b75c79f524e2c31f324ca6751fa19d82b9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / modellock-0.2.2-cp310-cp310-macosx_11_0_universal2.whl

Download URL modellock-0.2.2-cp310-cp310-macosx_11_0_universal2.whl
Size 838.1 kB
Tags CPython 3.10 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
1f2abbe38118c7cf05e03850474b7103455fca4ae8159461ec6829212f8588ef
BLAKE2b-256 checksum
How to use checksums
adc74ac6a77addeb8c07f61bac1c01f4e1b51c207779c7cc0bfb40a7e8159ead
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for modellock 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page