2 Star 3 Fork 0

隐语SecretFlow / heu

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

HEU

CircleCI PyPI version

HEU(Homomorphic Encryption processing Unit)是一个低门槛、高性能的同态加密库,支持多类型、可扩展的硬件加速生态。

文档

https://www.secretflow.org.cn/docs/heu/

开发状态

同态加密算法主要分为半同态(PHE)和全同态(FHE)两大类,目前 HEU 已支持大部分 PHE 算法,而 FHE 仍需要一段时间的开发

支持的算法:

  • 加法同态加密
    • Paillier (推荐)
    • Okamoto–Uchiyama (推荐)
    • EC ElGamal
    • Damgard-Jurik
    • Damgard-Geisler-Krøigaard (DGK)
  • 全同态加密
    • 正在开发中,并且是当前 HEU 的工作重心

其中每一类算法又包含多种不同的实现,部分实现支持硬件加速器,详见文档

目录结构

.
├── .circleci  # 存放 circleci 的 CI/CD 配置文件
├── .github    # 存放 github 配置文件
├── docs       # 存放 HEU 文档,sphinx 格式
├── heu        # 存放 HEU 所有实现代码
│   ├── algorithms     # 存放所有算法实现,包括 PHE 和 FHE
│   ├── experimental   # 存放一些独立的实验性代码
│   ├── library        # HE Library 应用层功能实现
│   │   ├── algorithms # 未迁移至 SPI 下的存量算法,迁移完成后该目录废弃
│   │   ├── benchmark  # 存放基准测试代码
│   │   ├── numpy      # 实现一套 Numpy-like 接口
│   │   └── phe        # PHE Dispatcher 实现(即将废弃,功能由 SPI 代替)
│   ├── pylib          # 实现 Python binding
│   └── spi            # 定义 HEU 软硬件接入层接口(SPI)
│       ├── he         # 存放 HE SPI,以及相关的 Sketches
│       └── poly       # 定义多项式接口,以及相关的 Sketches
└── third_party        # 存放编译所需的第三方库链接,库本身会在编译时自动下载

目前 HEU 正在从老的 Dispatcher 架构切换成基于 SPI 的架构,两套架构主要的模块及其代码路径的映射关系如下:

基于 Dispatcher 的架构:

     Python APIs (Python binding)
          PATH: heu/pylib

                  ├───────────────────┐
                  │                   ▼
                  │    Tensor Lib with Numpy-like API
                  │        PATH: heu/library/numpy
                  │                   │
                  │     ┌─────────────┘
                  │     │
                  ▼     ▼
     PHE Dispatcher & PHE C++ API
        PATH: heu/library/phe



 Various PHE algorithm implementations
     PATH: heu/library/algorithms

基于 SPI 的架构:

    Python APIs (Python binding)
         PATH: heu/pylib

                 ├───────────────────┐
                 │                   ▼
                 │    Tensor Lib with Numpy-like API
                 │           PATH: heu/numpy
                 │                   │
                 │ ┌─────────────────┘
                 │ │
                 ▼ ▼
         HE SPI (C++ APIs)
         PATH: heu/spi/he



 Various HE algorithm implementations
        PATH: heu/algorithms

关于 SPI 更详细的介绍请 点击此处

2024 工作计划

架构切换里程碑:

  • HE SPI:设计一套大一统接口,同时支持所有的 PHE/FHE 算法
  • 实现 SPI Sketches (in progress)
  • 存量算法迁移至 SPI (in progress)
  • HE 算法自动化测试框架 (in progress)
  • Tensor Lib 底层从 Dispatcher 切到 SPI
  • PyLib 底层从 Dispatcher 切到 SPI

FHE 里程碑

  • 集成 SEAL,提供 BFV/BGV/CKKS 算法功能
  • 集成 OpenFHE
  • 支持 GPU 加速的 CKKS 算法
  • Tensor Lib 开放 FHE 接口
  • PyLib 开放 FHE 接口

编译和安装

环境要求

  • CPU
    • x86_64: 至少支持 AVX 指令集
    • AArch64: ARMv8
  • OS
    • Ubuntu 18.04+
    • Centos 7
    • macOS 12.0+ (macOS Monterey+)
  • Python
    • Python 3.9+

通过 Pip 安装

pip install sf-heu

从源码安装

以下命令将自动编译并安装 HEU 到默认 Python 环境:

git clone git@github.com:secretflow/heu.git
cd heu
sh build_wheel_entrypoint.sh

运行单元测试(可选)

# just compile, do not run any UT (optional)
bazel build heu/...

# compile and run all UTs
bazel test heu/...

贡献指南

隐语是一个非常包容和开放的社区,我们欢迎任何形式的贡献,如果您想要改进 HEU,请参考贡献指南

header: # <1> license: spdx-id: Apache-2.0 # <2> copyright-owner: Ant Group Co., Ltd. # <3> copyright-year: '2024' # <25> software-name: secretflow # <4> pattern: | # <6> Licensed under the Apache License, Version 2.0 \(the "License"\); you may not use this file except in compliance with the License. You may obtain a copy of the License at http[s]?://www\.apache\.org/licenses/LICENSE-2\.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. paths: # <7> - '**' paths-ignore: # <8> - '.circleci' - '.github' - '**/*.md' - '**/*.yaml' - '**/*.yml' - '**/*.txt' - '**/*.po' - '**/*.rst' - '**/*.lds' - '**/*.patch' - '**/*.bat' - 'LICENSE' - 'NOTICE' - '.bazelversion' - '.clang-format' - '.gitattributes' - '.gitignore' - '.gitmodules' - 'pyproject.toml' - 'third_party/bazel_rust/**/*.bazel' # Generated - 'third_party/bazel_rust/**/*.bzl' # Generated comment: never # <9> license-location-threshold: 80 # <10> language: # <11> Starlark: # <12> extensions: #<13> - ".bazel" - ".bazelrc" - "BUILD" - ".bzl" - "WORKSPACE" comment_style_id: PythonStyle # <15> Cpp: extensions: - ".cc" - ".h" - ".cu" comment_style_id: DoubleSlash

简介

Homomorphic Encryption processing Unit (HEU) is a subproject of Secretflow that implements high-performance homomorphic encryption algorithms. 展开 收起
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C++
1
https://gitee.com/secretflow/heu.git
git@gitee.com:secretflow/heu.git
secretflow
heu
heu
main

搜索帮助