Code Monkey home page Code Monkey logo

aloha-he's Introduction

Aloha-HE

This repository provides the source code of Aloha-HE, a hardware accelerator for client-side operations in homomorphic encryption. Aloha-HE targets the CKKS scheme and supports all operations required during encode+encrypt and decode+decrypt in hardware. We publish the source code for the Xilinx ZYNQ-7000 and Kintex-7 FPGA platforms.

The according paper "Aloha-HE: A Low-Area Hardware Accelerator for Client-Side Operations in Homomorphic Encryption" with a detailed explanation of Aloha-HE has been accepted for the DATE'24 conference. You can find the conference paper here and the preprint here.

All content of this repo is for academic research use only. It does not come with any support, warranty, or responsibility.

Structure of this Repo

We implemented Aloha-HE using Vivado 2019.1. This repo provides these implementations for ZYNQ-7000 (PYNQ-z2 board) and Kintex-7 (Genesys2 board) in their respective directories. In addition to that, users can select between stored FFT twiddle factors and on-the-fly generated FFT twiddle factors. Optional testing functionality allows to read and write all BRAMs in the FPGA. These settings are configured using flags in Aloha-HE_Common/ComputeCore.v. We provide synthesis and implementation results for each of the possible feature combinations. The following tags refer to the corresponding commits:

Tag Name FFT Twiddle Factors Debug Functionality Instantiated
stored stored no
stored_debug stored yes
generated generated no
generated_debug generated yes

The folders Aloha-HE_Kintex and Aloha-HE_ZYNQ contain the ready-to-use Vivado 2019.1 and the SDK projects for the Kintex-7 and the ZYNQ-7000 FPGA respectively. The folder Aloha-HE_Common contains the (System-)Verilog files for Aloha-HE. The folder Scripts provides Python scripts to generate primes and constants as well as to set up ROM contents. The ROM contents are defined in .coe files stored in Aloha-HE_Common/MemoryInitializationFiles/.

Running Aloha-HE

We provide ready-to-use implementations of Aloha-HE for the PYNQ-z2 and the Genesys2 boards. Follow these steps to run Aloha-HE using Vivado 2019.1 and its SDK environment.

  1. Plug in the board and connect the serial port via a terminal. Corresponding scripts for Ubuntu are in the Scripts folder. Use e.g. Putty for Windows.
  2. Check out the desired configuration according to the table above. Use git checkout <tag name>.
  3. Open the respective Aloha-HE project for the targeted board. The bitstream file may be displayed as out-of-date. This is due to different timestamps caused by git. Just using the provided bitstream is fine, but you can re-run the implementation if you want to.
  4. Open the SDK: Go to File -> Launch SDK and click OK.
  5. The main testing software is located in ckksTest.c. Uncomment the defines according to the tests you want to run. Productive code (i.e. the code configuration with the best performance and no intermediate checks) is activated by uncommenting FAST_ENCRYPTION and FAST_DECRYPTION.
  6. Make sure the software is compiled by saving all files.
  7. For ZYNQ-7000 (PYNQ-z2 board): Click Run -> Run Configurations... Then double-click on "GDB Debugger on Local" in the opened window. For Kintex-7 (Genesys 2 board): Click on Xilinx -> Program FPGA -> Program. This flashes the FPGA and the software.
  8. We finally are able to execute the just flashed software. For ZYNQ-7000, right-click on the "Aloha-HE" application folder, select Run As..., and click on "Launch on Hardware (System Debugger)". For Kintex-7, right-click on the "Aloha-HE" application folder, select Run As..., and click on "Launch on Hardware (GDB)". This starts software execution and the board will return the results via the serial port.

Contributors

Florian Krieger - florian.krieger (at) iaik.tugraz.at

Florian Hirner - florian.hirner (at) iaik.tugraz.at

Ahmet Can Mert - ahmet.mert (at) iaik.tugraz.at

Sujoy Sinha Roy - sujoy.sinharoy (at) iaik.tugraz.at


Institute of Applied Information Processing and Communications, Graz University of Technology, Austria


If you use Aloha-HE in your research/study, please cite our work:

@INPROCEEDINGS{aloha_he,
  author={Krieger, Florian and Hirner, Florian and Mert, Ahmet Can and Roy, Sujoy Sinha},
  booktitle={2024 Design, Automation & Test in Europe Conference & Exhibition (DATE)}, 
  title={Aloha-HE: A Low-Area Hardware Accelerator for Client-Side Operations in Homomorphic Encryption}, 
  year={2024},
  volume={},
  number={},
  pages={1-6},
  doi={},
  url = {https://ieeexplore.ieee.org/document/10546608}
}

aloha-he's People

Contributors

flokrieger avatar

Stargazers

 avatar  avatar Welson Liu avatar  avatar Sam Vervaeck avatar Jaganath Prasad Mohanty avatar Ahmet Can Mert avatar Cheng Guan avatar

Watchers

 avatar  avatar  avatar

aloha-he's Issues

The fast_encryption test case does not check the correct return addresses

The fast_encryption stores the resulting ciphertexts in one big array:

#if defined(FAST_ENCRYPTION)
uint64_t result_fft[2*poly_size] ALIGN;
XTime_GetTime(&tStart);
ckks_encrypt(result_c0, input, poly_size, error_polys_seed, pk1_seeds, num_moduli, constants_select, modulus_select, pk0, scale, qm, current_k);
XTime_GetTime(&tEnd);
for(uint32_t modulus_index = 0; modulus_index < num_moduli; ++modulus_index)
{
error |= checkPoly(result_c1[modulus_index], expected_c1[modulus_index], poly_size, "C1", modulus_index, 0);
error |= checkPoly(result_c0[modulus_index], expected_c0[modulus_index], poly_size, "C0", modulus_index, 0);
}
#endif

uint64_t data[6*8192] __attribute__((aligned(8192)));
uint64_t* result_c0_mod0 = data;
uint64_t* result_c1_mod0 = data + 8192 * 1;
uint64_t* result_c0_mod1 = data + 8192 * 2;
uint64_t* result_c1_mod1 = data + 8192 * 3;
uint64_t* result_c0_mod2 = data + 8192 * 4;
uint64_t* result_c1_mod2 = data + 8192 * 5;
uint64_t* result_c0[] = {data, data + 8192 * 2, data + 8192 * 4, NULL};

However, the test line 1247 checks result_c1[modulus_index] which is not used by the ckks_encrypt function. I assume this should be changed to something like result_c0[modulus_index] + 8192

Remove "for testing purposes only" documentation

In the send64 function description it mentions sending data with this function is for testing only:

// Sending data via this function is for testing purpose only. The hardware must
// have the PROVIDE_DEBUG_IO set to 1 (ComputeCore.v).
void send64(uint64_t *p, uint32_t num_words, uint32_t INS_flag, uint32_t bram_sel)

However, in the decrypt function it is used to transfer the instructions to be executed:

void ckks_decrypt(uint64_t* c0_c1_sk, uint64_t* plaintext, uint32_t poly_size, uint32_t qm, uint8_t log_q,
uint8_t ntt_modulus_rom_index, int32_t log_scale)
{
cdmaDDRtoBRAM(NTT_MSG_BRAM_ID, (size_t)c0_c1_sk, 3*poly_size*sizeof(uint64_t));
instructions_decrypt[1] = getPWMInstructionWord(log_q, qm);
instructions_decrypt[2] = getNTTTransformationInstructionWord(1,log_q,ntt_modulus_rom_index,qm);
instructions_decrypt[3] = getI2FInstructionWord(log_scale,log_q,qm);
send64(instructions_decrypt, INS_BUFFER_SIZE, 1, 0);
cdmaWaitForIdle();

It seems to me that the "for testing only" comments for send64 and receive64 functions should be removed.

Assert typos in instruction.c

In the instruction.c file some of the asserts have a typo. Instead of asserting on log_scale, they make use of the non-existing variable scale?

uint64_t getRNSInstructionWord(uint16_t log_scale, uint8_t log_q, uint8_t modulus_rom_index, uint32_t qm)
{
assert(scale < (1<<12));

uint64_t getI2FInstructionWord(int16_t log_scale, uint8_t log_q, uint32_t qm)
{
assert(!(scale < -(1<<8) || scale >= (1<<8)));

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.