{"id":13654901,"url":"https://github.com/vernamlab/cuHE","last_synced_at":"2025-04-23T10:31:38.415Z","repository":{"id":37743083,"uuid":"49899380","full_name":"vernamlab/cuHE","owner":"vernamlab","description":"CUDA Homomorphic Encryption Library","archived":false,"fork":false,"pushed_at":"2017-06-08T20:26:33.000Z","size":27060,"stargazers_count":193,"open_issues_count":4,"forks_count":41,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-10T06:34:14.491Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Cuda","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vernamlab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-18T19:21:35.000Z","updated_at":"2024-11-05T07:55:13.000Z","dependencies_parsed_at":"2022-09-01T06:12:18.971Z","dependency_job_id":null,"html_url":"https://github.com/vernamlab/cuHE","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vernamlab%2FcuHE","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vernamlab%2FcuHE/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vernamlab%2FcuHE/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vernamlab%2FcuHE/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vernamlab","download_url":"https://codeload.github.com/vernamlab/cuHE/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250416408,"owners_count":21426984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T03:00:52.499Z","updated_at":"2025-04-23T10:31:38.036Z","avatar_url":"https://github.com/vernamlab.png","language":"Cuda","funding_links":[],"categories":["Libraries"],"sub_categories":["[Sunscreen](https://sunscreen.tech/)"],"readme":"cuHE: Homomorphic and fast\n==========================\nCUDA Homomorphic Encryption Library (cuHE) is a GPU-accelerated library for [homomorphic encryption][6] (HE) schemes and homomorphic algorithms defined over polynomial rings. cuHE yields an astonishing performance while providing a simple interface that greatly enhances programmer **productivity**. It features both algebraic techniques for homomorphic evalution of circuits and highly optimized code for single-GPU or multi-GPU machines. Develop **high-performance** applications rapidly with cuHE!\n\nThe cuHE library is distributed under the terms of the The MIT License (MIT). It is currently created for research purpose only. Several algorithms are implemented as examples and more will follow. Feedback and collaboration of any kind are welcomed.\n\nFeatures\n--------\nThe library pushes performance to a limit. A number of optimizations such as algebraic techniques for efficient evaluation, memory minimization techniques, memory and stream scheduling and low level CUDA hand-tuned assembly optimizations are included to take full advantage of the mass parallelism and high memory bandwidth GPUs offer. The arithmetic functions constructed to handle very large polynomial operands adopt the Chinese remainder theorem (CRT), the number-theoretic transform (NTT) and Barrett reduction based methods. A few algorithms and routines of the library is described in [this paper][3], along with a performance analysis. More details on arithmetic methods and optimizations regarding HE are explained in our previous papers listed below.\n\n1. Dai, Wei, and Berk Sunar. \"cuHE: A Homomorphic Encryption Accelerator Library.\" Cryptography and Information Security in the Balkans. Springer International Publishing, 2015. 169-186. [[draft][3]] [[Springer][15]]\n\n2. Dai, Wei, Yarkın Doröz, and Berk Sunar. \"Accelerating NTRU based homomorphic encryption using GPUs.\" High Performance Extreme Computing Conference (HPEC), 2014 IEEE. IEEE, 2014. [[draft][4]] [[IEEE Xplore][16]]\n\n3. Dai, Wei, Yarkın Doröz, and Berk Sunar. \"Accelerating SWHE Based PIRs Using GPUs.\" Financial Cryptography and Data Security: FC 2015 International Workshops, BITCOIN, WAHC, and Wearable, San Juan, Puerto Rico, January 30, 2015, Revised Selected Papers. Vol. 8976. Springer, 2015. [[draft][5]] [[Springer][17]]\n\nExamples\n--------\nCurrently available is an implementation of the [Doröz-Hu-Sunar][1] (DHS) somewhat homomorphic encryption (SHE) scheme based on the [Lopez-Tromer-Vaikuntanathan][2] (LTV) scheme.\nSeveral homomorphic applications built on DHS are implemented on GPUs and are included as examples, such as the Prince block cipher and a sorting algorithm.\nThese examples give an idea of how to program with the cuHE library.\n\nSystem Requirements\n-------------------\n1. NVIDIA [CUDA-Enabled GPUs][7] with computation compability 3.0 or higher\n2. [NTL][8]: A Library for doing Number Theory 9.3.0 (requires C++11) **NOTE:** to avoid random crashes compile it running ```./configure NTL_EXCEPTIONS=on```\n3. The [OpenMP][9] API\n\nCompile\n-------\n\n\tcd cuhe\n\tcmake ./\n\tmake\n\noptions to cmake command defaults are:\n\n\t-DGPU_ARCH:STRING=50\n\t-DGCC_CUDA_VERSION:STRING=gcc-4.9\n\nNotes for Mac OS X\n------------------\nOn Mac you must use clang instead of gcc. You need to install a version compatible with OpenMP. With brew you can\n\n\tbrew install clang-omp\n\nThen you must tell Cmake and Cuda that you are using clang-omp\n\n\tcd cuhe\n\tCC=clang-omp CXX=clang-omp++ cmake -DGCC_CUDA_VERSION=clang-omp ./\n\tmake\n\nA Short Tutorial\n----------------\nTo design/implement a homomorphic application/circuit, e.x. the AND of 8 bits. First of all, we need to decide which homomorphic encryption scheme to adopt and set parameters (polynomial ring degree, coefficient sizes in each level of circuit, relinearization strategy) according to some noise analysis process. Let's say we decide to adopt the DHS HE scheme.\n```c++\n#include \"cuHE.h\"\nvoid setParameters(int d, int p, int w, int min, int cut, int m);//in \"CuHE.h\", set parameters\nvoid initCuHE(ZZ *coeffMod_, ZZX modulus); //in \"CuHE.h\", start pre-computation on GPUs\n```\n\nThen we may process some pre-computation of the circuit. When it is time to run the circuit, we suggest to turn on our virtual allocator. Do not turn it off until the circuit is completely done.\n```c++\nvoid startAllocator(); //in \"CuHE.h\", start virtual allocator\nvoid stopAllocator(); //in \"CuHE.h\", stop virtual allocator\n```\n\nThe program by default uses a single GPU (device ID 0). To adopt multiple devices, call the function below.\n```c++\nvoid multiGPUs(int num); //adopt 'num' GPUs\n```\n\nThose are all the initialization steps. To implement any HE scheme or circuit, please check out the provided examples.\n\nDeveloper\n---------\nThe cuHE library is developed and maintained by [Wei Dai][13] from the [Vernam Group][14] at Worcester Polytechnic Institute.\n\nAcknowledgment\n--------------\nFunding for this research was in part provided by the US National Science Foundation\nCNS Award #1117590 and #1319130.\n\nWe want to acknowledge [Andrea Peruffo][18] for improving and debugging the code.\n\n[1]: http://eprint.iacr.org/2014/233/ \"DHS14\"\n[2]: http://eprint.iacr.org/2013/094/ \"LTV13\"\n[3]: http://eprint.iacr.org/2015/818/ \"cuHEePrint\"\n[4]: http://eprint.iacr.org/2014/389/ \"Dai2014ePrint\"\n[5]: http://eprint.iacr.org/2015/462/ \"Dai2015ePrint\"\n[6]: http://en.wikipedia.org/wiki/Homomorphic_encryption \"HE\"\n[7]: http://developer.nvidia.com/cuda-gpus/ \"CUDAGPUs\"\n[8]: http://www.shoup.net/ntl/ \"NTL\"\n[9]: http://openmp.org/wp/ \"OpenMP\"\n[10]: http://en.wikipedia.org/wiki/Chinese_remainder_theorem/ \"CRT\"\n[11]: http://en.wikipedia.org/wiki/Discrete_Fourier_transform_(general)/ \"NTT\"\n[12]: http://en.wikipedia.org/wiki/Barrett_reduction/ \"Barrett\"\n[13]: http://github.com/Veirday \"WeiDaiGitHub\"\n[14]: http://v.wpi.edu/ \"VernamGroup\"\n[15]: http://link.springer.com/chapter/10.1007%2F978-3-319-29172-7_11 \"cuHESpringer\"\n[16]: http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=7041001\u0026tag=1 \"Dai2014IEEE\"\n[17]: http://link.springer.com/chapter/10.1007%2F978-3-662-48051-9_12 \"Dai2015aSpringer\"\n[18]: https://github.com/andreaTP \"AndreaPeruffoGitHub\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvernamlab%2FcuHE","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvernamlab%2FcuHE","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvernamlab%2FcuHE/lists"}