GithubHelp home page GithubHelp logo

opencheetah's People

Contributors

vincehong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

opencheetah's Issues

关于openssl

新手小白,麻烦问下-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl是指定openssl的安装位置吗,我本地没有这个位置,但是也编译通过了,是不是也没有错误?openssl的作用是什么,谢谢

Millionaires' issue

m=4时,通信量为11L,但16选1的OT的通信复杂度至少为16L,请教下怎么得到总的通信量为11L

Windows系统上Build Dependency报错

你好,我遇到的问题与 #4 一样,区别我是在windows环境,请问要怎么解决?

HEAD is now at 44b1dde Fix silent failure in CPU seed generation (#156)
M CMakeLists.txt
M emp-tool/emp-tool.h
Reversed (or previously applied) patch detected! Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file CMakeLists.txt.rej
Reversed (or previously applied) patch detected! Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file emp-tool/emp-tool.h.rej
-- Platform: AMD64
-- Build type: Release
-- CXX Flags: /DWIN32 /D_WINDOWS /W3 /GR /EHsc /DWIN32 /D_WINDOWS /W3 -pthread -Wall -funroll-loops -Wno-ignored-attributes -Wno-unused-result -march=native -maes -mrdseed -std=c++11 -O3
-- Performing Test RDSEED_RUN_RESULT
-- Performing Test RDSEED_RUN_RESULT - Failed
-- Source of Randomness: random_device
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/yckj4361/CLionProjects/OpenCheetah2/build/deps/emp-tool
make: *** No rule to make target 'install'. Stop.
HEAD is now at 7f3d4f0 fix the bug #67 raised by @themighty1 (#68)
CMake Error at CMakeLists.txt:6 (include):
include could not find requested file:

CMAKE_FOLDER-NOTFOUND/cmake/emp-base.cmake

CMake Error at CMakeLists.txt:8 (find_package):
By not providing "Findemp-tool.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "emp-tool",
but CMake did not find one.

Could not find a package configuration file provided by "emp-tool" with any
of the following names:

emp-toolConfig.cmake
emp-tool-config.cmake

Add the installation prefix of "emp-tool" to CMAKE_PREFIX_PATH or set
"emp-tool_DIR" to a directory containing one of the above files. If
"emp-tool" provides a separate development package or SDK, be sure it has
been installed.

关于Building Dependencies

您好,我想问一下,我装了一台全新的虚拟机,下载了您的代码并安装好requirements中的内容后,运行bash scripts/build-deps.sh后出错了,最后的错误提示是emp-ot seems absent in /home/lsm/OpenCheetah/build/include/, please re-run scripts/build-deps.sh。
并且在刚开始就出现以下错误提示:
-- Build files have been written to: /home/lsm/OpenCheetah/deps/emp-tool
make: *** 没有规则可制作目标“install”。 停止。
HEAD 目前位于 7f3d4f0 fix the bug #67 raised by @themighty1 (#68)
CMake Error at CMakeLists.txt:6 (include):
include could not find load file:

CMAKE_FOLDER-NOTFOUND/cmake/emp-base.cmake

CMake Error at CMakeLists.txt:8 (find_package):
By not providing "Findemp-tool.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "emp-tool", but CMake did not find one.

Could not find a package configuration file provided by "emp-tool" with any of the following names:

emp-toolConfig.cmake
emp-tool-config.cmake

Add the installation prefix of "emp-tool" to CMAKE_PREFIX_PATH or set "emp-tool_DIR" to a directory containing one of the above files. If "emp-tool" provides a separate development package or SDK, be sure it has been installed.

-- Configuring incomplete, errors occurred!
See also "/home/lsm/OpenCheetah/build/deps/emp-ot/CMakeFiles/CMakeOutput.log".
make: *** 没有规则可制作目标“install”。 停止。
HEAD 目前位于 1f05f51 Update to version 3.3.3
-- Standard libraries to link to explicitly: none
-- Found unsuitable Qt version "" from NOTFOUND
-- Could NOT find SUPERLU (missing: SUPERLU_INCLUDES SUPERLU_LIBRARIES SUPERLU_VERSION_OK)
-- Could NOT find PASTIX (missing: PASTIX_INCLUDES PASTIX_LIBRARIES)
-- Could NOT find SCOTCH (missing: SCOTCH_INCLUDES SCOTCH_LIBRARIES)
-- Could NOT find METIS (missing: METIS_INCLUDES METIS_LIBRARIES)
-- Found unsuitable Qt version "" from NOTFOUND
-- Could NOT find Boost (missing: Boost_INCLUDE_DIR)
-- Could NOT find XSMM (missing: LIBXSMM)
-- Could NOT find GOOGLEHASH (missing: GOOGLEHASH_INCLUDES GOOGLEHASH_COMPILE)
-- Could NOT find ADOLC (missing: ADOLC_INCLUDES ADOLC_LIBRARIES)
-- Could NOT find MPFR (missing: MPFR_INCLUDES MPFR_LIBRARIES MPFR_VERSION_OK) (Required is at least version "2.3.0")
-- Could NOT find GMP (missing: GMP_INCLUDES GMP_LIBRARIES)
-- Could NOT find FFTW (missing: FFTW_INCLUDES FFTW_LIBRARIES)
-- Could NOT find OpenGL (missing: OPENGL_opengl_LIBRARY OPENGL_glx_LIBRARY OPENGL_INCLUDE_DIR)
-- Could NOT find GLUT (missing: GLUT_glut_LIBRARY GLUT_INCLUDE_DIR) CUDA_TOOLKIT_ROOT_DIR not found or specified
-- Could NOT find CUDA (missing: CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (Required is at least version "7.0")
-- Found unsuitable Qt version "" from NOTFOUND
-- Qt4 not found, so disabling the mandelbrot and opengl demos
-- Could NOT find SUPERLU (missing: SUPERLU_INCLUDES SUPERLU_LIBRARIES SUPERLU_VERSION_OK)
-- Could NOT find PASTIX (missing: PASTIX_INCLUDES PASTIX_LIBRARIES)
-- Could NOT find SCOTCH (missing: SCOTCH_INCLUDES SCOTCH_LIBRARIES)
-- Could NOT find METIS (missing: METIS_INCLUDES METIS_LIBRARIES)

请问这是为什么呢?是我少安装了什么东西吗?

Duplicate function definition in "tensor.h

typename TTypes<ScalarType, 2>::ConstTensor matrix() const {
    if (dims() != 2) {
      LOG(FATAL) << "matrix() demands 2D shape";
    }
    return typename TTypes<ScalarType, 2>::ConstTensor(data(), shape_.rows(), shape_.cols());
  }

  typename TTypes<ScalarType, 2>::ConstTensor matrix() {
    if (dims() != 2) {
      LOG(FATAL) << "matrix() demands 2D shape";
    }
    return typename TTypes<ScalarType, 2>::Tensor(data(), shape_.rows(), shape_.cols());
  }

The second definition must change to typename TTypes<ScalarType, 2>::Tensor matrix()

全连接层输入多个向量的计算

我看到有MatMul2D这样的函数,其调用里是循环调用cheetah_linear->fc(input_vector, weight_matrix, meta, out_vec)来处理多个向量的每一个,而按照论文,相同的w对应的多项式应该可以复用啊,这样是不是可以提升效率呢?还是说会有一定的安全性问题呢?

论文中的extract和remask操作

论文中是利用extract和remask完成FC和Conv等线性层的有效输出系数的搜集,但代码中的实现利用removeUnusedCoeffs去除无用系数,并解密得到输出系数。

我对extract和remask比较感兴趣,论文中是参考了Efficient Homomorphic Conversion Between (Ring) LWE Ciphertexts的工作,但我没找到这篇论文的开源实现,想请问下,cheetah是否之前实现了extract(以及LWEs到RLWE的重新打包),有的话可否分享下代码?以及Efficient Homomorphic Conversion Between (Ring) LWE Ciphertexts中只介绍了LWEs到RLWE的技术(也就是重新打包),extract部分是利用了什么技术呢?

提前感谢您的回复!

test or demo

你好!请问如果我想搭一个简单的模型的话,我应该怎么做?1)我看到在SCI里有一些test,我按照相应的结构来调用并指明USE_CHEETAH?2)或者我看到cheetah_api相关的文件,应该使用这里的函数吗?此外,我还想问下SCI里的这些test是否已经经由cheetah改过了,以及是否有构建简单网络的demo,而不是生成的几千行代码来构建?

怎么读懂代码实现的细节?

我阅读了Cheetah的论文,并理解了这些MPC协议的**和技术,但我对理解这些代码的复现细节依然毫无头绪。
我的问题包括:
1)如果我想用Cheetah在其他的CNN模型上进行安全推理,应该从哪里入手改动代码?
2)如果我想调试Cheetah的线性层和非线性层协议,应该从哪里入手?

cmake时出现了问题

您好,当我cmake时提示SEAL包找不到,和 #6 类似,OpenCheetah/build/deps/SEAL目录下没有SEALConfig.cmake文件,但是OpenCheetah/deps/SEAL下不为空,请问这应该怎么解决?
20220629213256

hexl与SEAL的版本冲突

build-deps.sh中拉下来的hexl是1.2.2版本的,SEAL是3.7.2版本的。但是在SEAL3.7.2版本的CMakeList的226行中,约束了hexl的版本为1.2.3。

Inquiry about Modifying codes for Cheetah Compatibility

Hi,

I wanted to express my interest in your work and seek your guidance. Recently, I have been experimenting with Cheetah using different sized neural networks. I successfully compiled the model and generated the ‘.cpp file’ using the script provided by Athos. I placed the ‘.cpp’ file in this directory: OpenCheetah/networks. However, I am aware that you manually modified the auto generated ‘.cpp file’, and I’m curious about the specific modifications required to ensure compatibility with Cheetah.

For instance, if I want to compile and run models like ResNet50 using Cheetah as the backend, what are the necessary adjustments I should make? I greatly appreciate your kind assistance in this matter.

Thank you in advance for your time and help.

How to compile TensorFlow code with our desired protocols?

Hi, I am very interested in your work!
Recently, I have a question about compiling TensorFlow code to cpp code. If I directly generate cpp code with the method provided by "Athos", I will get the cpp code that invokes protocols in "SCI/src/library_fixed_uniform.cpp" by default.
So, I wonder how I can compile TF code to cpp code with invoking protocols in "SCI/src/library_fixed_uniform_cheetah.cpp" that you've added for Cheetah. Which part of the code should I modify when I convert the code.
I would appreciate it very much if you could help me with this question! Thanks a lot!

'class seal::EncryptionParameters' has no member named 'set_n_special_primes'

I installed the dependencies and tried to buid OpenCheetah, and it reported

[build] /root/OpenCheetah/SCI/src/cheetah/cheetah-api.cpp: In constructor 'gemini::CheetahLinear::CheetahLinear(int, sci::NetIO*, uint64_t, size_t)':
[build] /root/OpenCheetah/SCI/src/cheetah/cheetah-api.cpp:97:14: error: 'class seal::EncryptionParameters' has no member named 'set_n_special_primes'
[build]    97 |   seal_parms.set_n_special_primes(0);
[build]       |              ^~~~~~~~~~~~~~~~~~~~
[build] /root/OpenCheetah/SCI/src/cheetah/cheetah-api.cpp: In member function 'void gemini::CheetahLinear::setUpForBN()':
[build] /root/OpenCheetah/SCI/src/cheetah/cheetah-api.cpp:181:14: error: 'class seal::EncryptionParameters' has no member named 'set_n_special_primes'
[build]   181 |   seal_parms.set_n_special_primes(0);
[build]       |              ^~~~~~~~~~~~~~~~~~~~
[build] gmake[2]: *** [SCI/src/cheetah/CMakeFiles/Cheetah-Linear.dir/build.make:76: SCI/src/cheetah/CMakeFiles/Cheetah-Linear.dir/cheetah-api.cpp.o] Error 1
[build] gmake[1]: *** [CMakeFiles/Makefile2:664: SCI/src/cheetah/CMakeFiles/Cheetah-Linear.dir/all] Error 2
[build] gmake[1]: *** Waiting for unfinished jobs....
[build] [ 50%] Linking CXX static library ../../lib/libSCI-HE.a
[build] [ 50%] Built target SCI-HE
[build] gmake: *** [Makefile:91: all] Error 2
[build] Build finished with exit code 2

Slow linear layer compared to non-linear layer

Hello! Thank you for your outstanding work. I have been running the ResNet50 model following the instructions provided in the ReadMe file. While doing so, I noticed that the linear layer's latency is longer than that of the non-linear layer, which seems to contradict the expectation that linear layers would require fewer rounds and less data for communication.

Upon running the model, I obtained the following log data:

Total time in Conv = 175.196 seconds.
Total time in MatMul = 0.253 seconds.
Total time in BatchNorm = 8.453 seconds.
Total time in Truncation = 32.28 seconds.
Total time in Relu = 46.977 seconds.
Total time in MaxPool = 7.566 seconds.
Total time in AvgPool = 0.042 seconds.
Total time in ArgMax = 0.021 seconds.
Total time in MatAdd = 0 seconds.
Total time in MatAddBroadCast = 0 seconds.
Total time in MulCir = 0 seconds.
Total time in ScalarMul = 0 seconds.
Total time in Sigmoid = 0 seconds.
Total time in Tanh = 0 seconds.
Total time in Sqrt = 0 seconds.
Total time in NormaliseL2 = 0 seconds.

Based on these results, it appears that the linear layer is slower than the ReLU layer. However, I am unsure as to why this is the case. I suspect that the 4-thread CPU setting may be running slow for the linear layer and it is bottlenecked on the computation. Could you kindly provide some insight on this matter?

Thank you for your time and attention to this issue.

- Extract a LWE from RLWE under the X^N + 1 (N is 2-power) ring is a trivial task.

  • Extract a LWE from RLWE under the X^N + 1 (N is 2-power) ring is a trivial task.
    • For example, RLWE(m(X)) is given as two polynomial (b(X), a(X)) which is decrypted as b(X) + a(X) * s(X) mod X^N + 1
    • To extract the k-th coefficient of this RLWE to obtain LWE(m_k) (i.e, LWE encryption of the k-th coefficient) is simply doing coefficient re-ordering.
      Suppose LWE(m_k) is given as (c, \vec{d}) then we have c = b[k] (ie the k-th coefficient of b(X)) and
      \vec{d} = [a[k], a[k-1], ...., a[0], -a[N-1], -a[N-2], ...., -a[k+1]] (ie. reverse the first k coefficients of a(X) and reverse-then-flip-sign of the remaining N-k coefficients
  • This is simply a reverse computation of Section 3.3 in Efficient Homomorphic Conversion Between (Ring) LWE Ciphertexts without using the Trace function.
  • For the RLWE-to-LWE extraction implementation, check out here
  • We have plan to open the PackLWEs codes in the near future (see our GBDT paper)

Originally posted by @fionser in #30 (comment)

Hi,the first link is not accessable, thanks!

编译cheetah-api.cpp:97发生error

你好,在使用script/build.sh进行编译的时候出现了错误,错误如下

/root/.vs/Cheetah/1644abe3-27db-4b0a-b392-b4265d7c6c23/src/SCI/src/cheetah/cheetah-api.cpp: In constructor ‘gemini::CheetahLinear::CheetahLinear(int, sci::NetIO*, uint64_t, size_t)’:
/root/.vs/Cheetah/1644abe3-27db-4b0a-b392-b4265d7c6c23/src/SCI/src/cheetah/cheetah-api.cpp:97:14: error: ‘class seal::EncryptionParameters’ has no member named ‘set_n_special_primes’
   97 |   seal_parms.set_n_special_primes(0);
      |              ^~~~~~~~~~~~~~~~~~~~
/root/.vs/Cheetah/1644abe3-27db-4b0a-b392-b4265d7c6c23/src/SCI/src/cheetah/cheetah-api.cpp: In member function ‘void gemini::CheetahLinear::setUpForBN()’:
/root/.vs/Cheetah/1644abe3-27db-4b0a-b392-b4265d7c6c23/src/SCI/src/cheetah/cheetah-api.cpp:181:14: error: ‘class seal::EncryptionParameters’ has no member named ‘set_n_special_primes’
  181 |   seal_parms.set_n_special_primes(0);

且编译后build/bin只有densenet121-SCI_HE resnet50-SCI_HE sqnet-SCI_HE,没有cheetah结尾的可执行文件

How to support new models?

Under the directory /networks, the model definition seems to be auto-generated. How can I add new models?😀

Regaring log file

After running the local demo it's showing that check in the log file (cheetah-sqnet_server.log)
for more details but I can't find any log file where it is created.

Another question I would like to ask what is the input for the local demo program.

是否支持conv1d?

我想要使用conv1d,但没有找到相应的函数,当我想借用conv2d来实现conv1d时,即在数据和卷积核上均增加一个维度,shape(n)->shape(n,1),出现关于slice的报错[OpenCheetah/include/gemini/cheetah/sliced_3d_tensor.h:152] Conv2DSliceHelper: invalid paddings,想问下是否能够解决?

Question about removeUnusedCoeffs

Hi,

removeUnusedCoeffs is the function to remove the un-used plaintext polynomial coefficients by masking the ciphertext. Honestly, I cannot understand it princeple. Could you help me how did you do that? Masking the ciphertext to operate its corresponing plaintext?

Thanks in advance for your reply!

关于AuxProtocols::multiplexer() 函数无法使用

尊敬的阿里大佬:
我在使用猎豹框架的AuxProtocols::multiplexer() 函数时遇到了些困难,希望能得到大佬的帮助。
具体情况是这样的,之前一直在用微软的CF2做一些应用,在移植代码到cheetah后,我的drule函数与multiplexer函数无法使用,并且报bus error (core dumped)、segmentation fault (core dumped)等错误,我把代码贴上来,在CF2上测试是没有问题的,在猎豹上就不行了,同时我也测试了OpenCheetah/SCI/tests/test_ring_aux_protocols.cpp这个文件,也是同样的错误,希望能够得到大佬们的指点。
同时,悄悄的问一下,为啥在建立一个slient OT Pack的时间要几秒钟,搞多几个OT Pack调试代码时就让人着急[dog],期待大佬早日回复,也盼望隐语框架早日开源。

图片

图片

#include "BuildingBlocks/aux-protocols.h"
#include "stdio.h"
using namespace sci;
using namespace std;
#define MAX_THREADS 4

int party, port = 31000;
int num_threads = 1;
string address = "127.0.0.1";
bool six_comparison = true;
int dim = 2ULL;
int32_t bitlength = 32;
uint64_t mask_x = (bitlength == 64 ? -1 : ((1ULL << bitlength) - 1));
uint64_t ring_mod = (1ULL << bitlength);
int64_t getSignedVal(uint64_t x) {
  int64_t sx = x%ring_mod;
  if (sx >= ring_mod/2)
    sx = sx - ring_mod;
  return sx;
}
uint64_t getRingElt(int64_t x) { return ((uint64_t)x) & mask_x; }

int main(int argc, char **argv) {
    /************* Argument Parsing  ************/
    /********************************************/
    ArgMapping amap;
    amap.arg("r", party, "Role of party: ALICE = 1; BOB = 2");
    amap.arg("p", port, "Port Number");
    amap.arg("N", dim, "Number of ReLU operations");
    amap.arg("nt", num_threads, "Number of threads");
    amap.arg("ip", address, "IP Address of server (ALICE)");
    amap.parse(argc, argv);

    sci::NetIO *ioArr[4];
    OTPack<sci::NetIO> *otpackArr[3];
    ioArr[0] = new sci::NetIO(party == 1 ? nullptr : address.c_str(), port);
    ioArr[1] = new sci::NetIO(party == 1 ? nullptr : address.c_str(), port+1);
    otpackArr[0] = new OTPack<sci::NetIO>(ioArr[0], party);

    //双方布尔共享的值
    uint8_t *sel_alice = new uint8_t[8];
    uint8_t *sel_bob = new uint8_t[8];
    //双方算数共享的值
    uint64_t *x_alice = new uint64_t[8];
    uint64_t *x_bob = new uint64_t[8];
    //密码共享的output值
    uint64_t *y_alice = new uint64_t[8];
    uint64_t *y_bob = new uint64_t[8];

    for (int i = 0; i < 8; i++) {
        sel_alice[i] = i%2;
        sel_bob[i] = 0;
        x_alice[i] = i;
        x_bob[i] = i;
    }
    for (int i = 0; i < 8; i++) {
        printf("x_alice[%d]=%ld,x_bob[%d]=%ld,sel_alice[%d]=%d,sel_bob[%d]=%d\n",
                i,x_alice[i],i,x_bob[i],i,sel_alice[i],i,sel_bob[i]);
    }

    AuxProtocols *aux = new AuxProtocols(party, ioArr[0],otpackArr[0]);

    if (party == sci::ALICE) {
        aux->multiplexer(sel_alice, x_alice, y_alice, 8, 32, 32);
        ioArr[1]->send_data(y_alice, 8 * sizeof(uint64_t));
    } else {
        aux->multiplexer(sel_bob, x_bob, y_bob, 8, 32, 32);
        //验证
        uint64_t *y_from_alice = new uint64_t[8];
        ioArr[1]->recv_data(y_from_alice, 8 * sizeof(uint64_t));
        for (size_t i = 0; i < 8; i++)  {
          printf("AilceShare = %ld\tBobShare = %ld\tbool_x = %d\tbool_y = %d\nx1+x2 = %ld\tBool = %d\tOutPut = %ld\n\n", 
                x_alice[i], x_bob[i], sel_alice[i], sel_bob[i], (x_alice[i]+x_bob[i])&mask_x,
                 !(sel_alice[i]^sel_bob[i]),getSignedVal(y_from_alice[i]+y_bob[i])); 
        }
    }
    return 0;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.