Skip to main content

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

Project description

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生成密钥种子中生成的内容)

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

modellock-0.2.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

modellock-0.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

modellock-0.2.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

modellock-0.2.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (731.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file modellock-0.2.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for modellock-0.2.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c2dbd86dc3391811c85b7509736dffee4f86b01789251b21d2b49efe2b60e929
MD5 7718c64f348fa6cdb91fa82ae244d4b4
BLAKE2b-256 2f5b284aba91f1cfe99b5a99aaf0bf78e6b4d83082e1afd5887c4f5eb99c3335

See more details on using hashes here.

File details

Details for the file modellock-0.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for modellock-0.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8fe229fe63bb570f37c637e573c271abb9733172216127054173d01bd9d0d1fc
MD5 d1b11e2005210f36a1dafb70468beef0
BLAKE2b-256 e19d20698854aba52aa80f542a0a1b85d4e69e92e2fbfd6a15e49bb3d6323b5f

See more details on using hashes here.

File details

Details for the file modellock-0.2.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for modellock-0.2.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4cebf75f72e9f7137a3ebbc66a5642b79ef1ea06c2273d74d64659addcd90152
MD5 541ace23943e5e563fc129f251e62617
BLAKE2b-256 9a4e1fa2083145a376f17415d859582a64170cb90bc49ccea0c956475ccbb42d

See more details on using hashes here.

File details

Details for the file modellock-0.2.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for modellock-0.2.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d6cf064b18acae45001459d0920f87e15ac8aa66f017fd2153f06e14dc977c94
MD5 5b20ff66960bd514392f502671c25d0c
BLAKE2b-256 d2cbac9d34796a50675855ef0850fb33ed68218e00a8a658a9a07321e8dabbb8

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