GithubHelp home page GithubHelp logo

virtualsecureplatform / kvsp Goto Github PK

View Code? Open in Web Editor NEW
110.0 7.0 7.0 468 KB

A VSP; run your encrypted C code AS IS!

Home Page: https://virtualsecureplatform.github.io/

License: Other

Makefile 14.26% Go 67.93% Dockerfile 4.65% Shell 13.16%
cryptography secure-computation homomorphic-encryption processor compiler

kvsp's Introduction

KVSP; Kyoto Virtual Secure Platform

[Official website] [Paper on arXiv] [Brief Japanese description on KVSP]

Virtual Secure Platform (VSP) provides a toolchain to run encrypted C programs without decryption.

VSP is the first comprehensive platform that implements a multi-opcode general-purpose sequential processor over Fully Homomorphic Encryption (FHE) for Secure Multi-Party Computation (SMPC). VSP protects both the data and functions on which the data are evaluated from the adversary in a secure computation offloading situation like cloud computing.

KVSP (Kyoto Virtual Secure Platform) is the first implementation of VSP. KVSP consists of many other sub-projects. The kvsp command, which this repository serves, is a simple interface to use them easily.

Paper

We published a paper on VSP, which is accepted by USENIX Security Symposium 2021. We uploaded its full version onto arXiv.

Quick Start

Demo is on YouTube.

Demo for Kyoto Virtual Secure Platform

Download a KVSP release from here and unzip it. (It has been compiled on Ubuntu 20.04 LTS and CUDA 11.1.1. If it doesn't work in the following steps, please read Build section and try to build KVSP on your own. It may be time-consuming, but not so hard.)

$ wget 'https://github.com/virtualsecureplatform/kvsp/releases/latest/download/kvsp.tar.gz'
$ tar xf kvsp.tar.gz
$ cd kvsp_v29/bin    # The directory's name depends on the file you download.

Write some C code...

$ vim fib.c

$ cat fib.c
static int fib(int n) {
  int a = 0, b = 1;
  for (int i = 0; i < n; i++) {
    int tmp = a + b;
    a = b;
    b = tmp;
  }
  return a;
}

int main(int argc, char **argv) {
  // Calculate n-th Fibonacci number.
  // n is a 1-digit number and given as command-line argument.
  return fib(argv[1][0] - '0');
}

...like so. This program (fib.c) returns the n-th term of Fibonacci sequence, as its comment says.

Compile fib.c to an executable file fib.

$ ./kvsp cc fib.c -o fib

Let's encrypt it. First, we'll generate a secret key (secret.key):

$ ./kvsp genkey -o secret.key

Then encrypt fib with secret.key to get an encrypted executable fib.enc. We have to pass its command-line arguments here. I chose 5, so the result of this program will be fib(5)=5.

$ ./kvsp enc -k secret.key -i fib -o fib.enc 5

Okay. Now we will run fib.enc without secret.key. To do this, first we have to make a bootstrapping key, which doesn't reveal the secret key at all but only enables the computation:

$ ./kvsp genbkey -i secret.key -o bootstrapping.key

Then we will execute the program, but here is a problem: once it starts running we can't know if it is still running or has already halted, because everything about the code is totally encrypted!

So, we have to decide how many clock cycles to run fib.enc at our choice. It is, say, 30.

# If you have GPUs use '-g NUM-OF-GPUS' option.
$ ./kvsp run -bkey bootstrapping.key -i fib.enc -o result.enc -c 30

Let's check the result. We'll decrypt result.enc:

$ ./kvsp dec -k secret.key -i result.enc
...
f0      false
...

f0 is 'finish flag', which is true iff the program ends. So, 30 cycles were not enough. Let's try another 30; We can resume from the point where we stopped using 'snapshot' file (its filename depends on your environment):

$ ./kvsp resume -c 30 -i kvsp_20200517002413.snapshot -o result.enc -bkey bootstrapping.key

Check the result again:

$ ./kvsp dec -k secret.key -i result.enc
...
f0      true
...
x8      5
...

Finished! x8 register has the returned value from main() and it is the correct answer 5. We could get the correct answer using secure computation!

More examples?

See the directory examples/.

System Requirements

We ensure that KVSP works on the following cloud services:

If you run KVSP locally, prepare a machine with the following devices:

  • Intel CPU with AVX2 support (e.g. Intel Core i7-8700)
  • 16GB RAM
  • NVIDIA GPU (not required but highly recommended)
    • Only NVIDIA V100 and A100 are supported.
    • Other GPUs may work but are not supported.

Dependencies

We are using Ubuntu 20.04 LTS in the development of v30 and later. Following commands setup the AWS instances. If you use AWS p3 instances, we highly recommend to increase EBS (Storage) size to 12 GB because intermediate files will be some GBs orders.

p3 instances (This includes reboot at last to enable a GPU driver.)

sudo apt update&&sudo apt upgrade -y&&sudo apt install -y libgoogle-perftools-dev libomp-dev nvidia-driver-460&&sudo reboot

c5.metal

sudo apt update&&sudo apt upgrade -y&&sudo apt install -y libgoogle-perftools-dev libomp-dev

Build

Clone this repository:

$ git clone https://github.com/virtualsecureplatform/kvsp.git

Clone submodules recursively:

$ git submodule update --init --recursive

Build KVSP:

$ make -j$(nproc) # It may take a while.

Use option ENABLE_CUDA if you build KVSP with GPU support:

$ make -j$(nproc) ENABLE_CUDA=1 CUDACXX="/usr/local/cuda/bin/nvcc" CUDAHOSTCXX="/usr/bin/clang-8"

Build KVSP Using Docker

Based on Ubuntu 20.04 LTS with NVIDIA CUDA 11.1.1. Note that NVIDIA GPU is NOT necessary to build KVSP.

$ docker build -t kvsp-build .
$ docker run -it -v $PWD:/build -w /build kvsp-build:latest

Code Owners

kvsp's People

Contributors

naoki9911 avatar nindanaoto avatar ushitora-anqou 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  avatar

kvsp's Issues

fib.c doesn't finish

Hi all,

I built kvsp on almost clean Ubuntu 20.04 (WSL2) without GPU, and tried to run the fib.c example.

I executed fib.enc executable for 90 cycles in total, but decrypted result.enc shows that the execution doesn't finish as the following:

    $ ./kvsp dec -k secret.key -i result.enc
    [2021-05-12 20:59:36.636] [iyokan-packet] [info] Starting dec...
    [2021-05-12 20:59:37.218] [iyokan-packet] [info] dec done. (0 seconds)
    [2021-05-12 20:59:37.308] [iyokan-packet] [info] Starting packet2toml...
    [2021-05-12 20:59:37.314] [iyokan-packet] [info] packet2toml done. (0 seconds)
    #cycle  90
    
    f0      false
    
    x0      14
    x1      498
    x2      0
    x3      0
    x4      0
    x5      0
    x6      0
    x7      0
    x8      5
    x9      500
    x10     0
    x11     0
    x12     0
    x13     0
    x14     0
    x15     0
    
             0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    000000  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    000010  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    000020  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    000030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    000040  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    000050  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    000060  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    000070  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    000080  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    000090  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0000a0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0000b0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0000c0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0000d0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0000e0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0000f0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    000100  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    000110  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    000120  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    000130  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    000140  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    000150  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    000160  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    000170  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    000180  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    000190  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0001a0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0001b0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0001c0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0001d0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0001e0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0001f0  00 00 02 00 fb 01 fc 01 00 00 00 00 35 00 f2 01

Do you have any ideas of what causes this problem?

Build error

I have tried to build the kvsp project directly from sources and I've got the following error when trying to compile the c file:
2020/07/15 09:00:47 CAHP_RT not found at /home/cris/projects/kvsp/build/share/kvsp/cahp-rt

The build was done with success, I have tried also the build with docker, it has finished with success but still can not execute the compile. (Secret key generation, bootstrapping key generation was possible)

Running directly from archive didn't work:
/home/cris/projects/kvsp_v28/bin/clang: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
2020/07/15 08:58:42 exit status 127

What can I do to be able to run it? I am using Ubuntu 19.10 and without CUDA options.

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.