Giter Club home page Giter Club logo

cloud-zk's Introduction

cloud-ZK

A toolkit for developing ZKP acceleration in the cloud

Follow the instructions below in order to use AWS EC2 F1 FPGA instance in your code to get accelerated MSM.

Note: Before continuing, please prepare an AFI according to our guide. Alternatively, you can use Ingonyama AFI.

Install the MSM Client

  • Install and run the MSM client on the F1 instance :

  • Clone ingonyama-zk/cloud-zk client design github:

    NOTE: the Ingonyama client code is written in Rust.
    

Instructions to install Rust can be found here.

  • Create a dir for the Ingonyama client in your project
mkdir -p  <ingonyama-zk-client-folder-name>
  • Clone the Ingonyama client
$ cd <ingonyama-zk-client-folder-name>
$ git clone https://github.com/ingonyama-zk/cloud-zk.git  (TBD)
$ cd <ingonyama-zk-client-folder-name>/rust-rw-device/

Install the linux xdma drivers

  • Go to xdma dir and run make
$ cd <ingonyama-zk-client-folder-name>/xdma
$ make
  • To install drivers, run the following as root
$ sudo make install
$ sudo modprobe xdma
  • Allow driver access
sudo chmod 77 /dev/xdma0_user
sudo chmod 77 /dev/xdma0_c2h_0
sudo chmod 77 /dev/xdma0_c2h_1
sudo chmod 77 /dev/xdma0_h2c_0

Once successful, drivers are

MSM client functionality

In order to run the MSM core on a custom input, one can use rust-rw-device as follows, using the function ''msm_calc'' in rw_msm_to_dram.rs file.

msm_calc_biguint(points: &Vec, scalars: &Vec, size: usize) -> ([BigUint; 3],Duration,u8)

This function receives 3 parameters:

  1. points: Vec<BigUint>
  2. scalars: Vec<BigUint>
  3. size: <usize>

msm_calc_u32(points: &Vec, scalars: &Vec, size: usize) -> ([Vec ;3],Duration,u8)

This function receives 3 parameters:

  1. points: Vec<u32>
  2. scalars: Vec<u32>
  3. size: <usize> This function is built to run with bytestreams of points scalars, all data should be represented as little endian.

The MSM we want to compute is with points given in affine coordinates: x_1, y_1,...,x_n, y_n, and scalars s_1,...,s_n.

  • The points input will be a 2n size vector that contains the values: [(x_1,y_1),...,(x_n,y_n)] (i.e., the points one after the other).
  • The scalar vector will be an n size vector containing [s_1,...,s_n].

Each BigUint element in these vectors is expected to be an unsigned big integer of size at most 48 bytes (1152 bits). The output of the function is a vector containing the result in projective coordinates and therefore contains a 48-byte BigUint vector with 3 elements (i.e., (x,y,z) of the resulting point).

the functions return single point in Projective representation and task duration -> (x, y, z, duration).

Using the MSM client

Add to your (rust) code the appropriate “use directive”:

use rust_rw_device::rw_msm_to_dram;

Calling the MSM function: Call the function msm_calc_biguint(&points, &scalars, size) or msm_calc_u32(&points, &scalars, size) in rw_msm_to_dram.rs file, when the MSM calculation is needed.

License

The code is released under the GNU General Public License v3.0 license. See LICENSE.md for more information.

cloud-zk's People

Contributors

omershlo avatar

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.