{"id":13654937,"url":"https://github.com/bogdan-kulynych/libshe","last_synced_at":"2025-12-30T17:23:52.162Z","repository":{"id":30984371,"uuid":"34542679","full_name":"bogdan-kulynych/libshe","owner":"bogdan-kulynych","description":"Symmetric somewhat homomorphic encryption library based on DGHV","archived":false,"fork":false,"pushed_at":"2017-08-08T23:34:25.000Z","size":109,"stargazers_count":27,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-10T06:34:15.319Z","etag":null,"topics":["c-plus-plus","ciphertext-compression","cryptography","homomorphic-encryption","homomorphic-encryption-library"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bogdan-kulynych.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":"2015-04-24T21:26:16.000Z","updated_at":"2024-09-27T14:43:17.000Z","dependencies_parsed_at":"2022-08-26T15:41:52.588Z","dependency_job_id":null,"html_url":"https://github.com/bogdan-kulynych/libshe","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/bogdan-kulynych%2Flibshe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bogdan-kulynych%2Flibshe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bogdan-kulynych%2Flibshe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bogdan-kulynych%2Flibshe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bogdan-kulynych","download_url":"https://codeload.github.com/bogdan-kulynych/libshe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250416407,"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":["c-plus-plus","ciphertext-compression","cryptography","homomorphic-encryption","homomorphic-encryption-library"],"created_at":"2024-08-02T03:00:52.921Z","updated_at":"2025-12-30T17:23:52.118Z","avatar_url":"https://github.com/bogdan-kulynych.png","language":"C++","funding_links":[],"categories":["Libraries"],"sub_categories":["[Sunscreen](https://sunscreen.tech/)"],"readme":"# libshe\n\n[![Build Status](https://travis-ci.org/bogdan-kulynych/libshe.svg?branch=master)](https://travis-ci.org/bogdan-kulynych/libshe) [![Coverage Status](https://coveralls.io/repos/bogdan-kulynych/libshe/badge.svg?branch=master)](https://coveralls.io/r/bogdan-kulynych/libshe?branch=master)\n\nSymmetric somewhat homomorphic encryption library based on DGHV scheme.\n\n\n## Introduction\n\nHomomorphic encryption is a kind of encryption that allows to execute functions over the ciphertexts without decrypting them. This library implements a symmetric variant of originally asymmetric somewhat homomorphic encryption scheme over the integers by van Dijk et al. [DGHV10][DGHV10] using ciphertext compression techniques from [CNT11][CNT11]. The symmetricity of the scheme means that only the private key is used to encrypt and decrypt ciphertexts. A relatively small public element, however, is used in homomorphic operations, but it is not a real public key.\n\nSuch scheme is useful in secure function evaluation setting, where a client encrypts an input to an algorithm using their private key, sends it to a server which executes an algorithm homorphically, and sends the output back to the client. The client then obtains the output of the algorithm by decrypting server response using the private key.\n\nSee the following diagram for visual explanation.\n\n- Let _f_ be an algorithm to be evaluated on a server.\n- Let _a[1], a[2], ... a[n]_ be inputs of _f_ that client provides to the server.\n- Let _b[1], b[2], ... b[n]_ be inputs of _f_ that server possesses.\n- Let _p_ be the client's private key, and _x[0]_ be the corresponding public element\n\n![SFE](misc/sfe.png)\n\n\n## Status\n\n_Warning_. This is experimental software. **It is not to be used in mission-critical applications.** Since the time this software was written, parameters of the underlying scheme were broken many times.\n\n## Installation\n\nYou can consult the `.travis.yml` for concrete installation commands on Debian-based systems.\n\n### Requirements\n\n- gcc \u003e= 4.8\n- [boost](http://www.boost.org/) \u003e= 1.55\n- [GMP](https://gmplib.org/) \u003e= 6.0.0\n- [lcov](http://ltp.sourceforge.net/coverage/lcov/readme.php) \u003e= 1.11 (optional)\n\n### Building and installation\n\nBuild and install `libshe.so` library and headers:\n\n```\nmake\nsudo make install\n```\n\nYou can also uninstall with\n\n```\nsudo make uninstall\n```\n\n## Usage\n\n### Tests and benchmarks\n\nRun tests:\n\n```\nmake tests\n```\n\n_Note_. Running tests will compile sources with debug options. Do `make clean` before installing if tests were run previously.\n\nRun benchmarks:\n\n```\nmake benchmarks\n```\n\n### Building your program\n\nUse C++11 and link against _GMP_ and _Boost Serialization_ when building your program:\n\n```\n-std=c++11 -lgmp -lboost_serialization -lshe\n```\n\nInclude libshe in your sources:\n\n```cpp\n#include \u003cshe.hpp\u003e\n\nusing she::ParameterSet;\nusing she::PrivateKey;\n// ...\n```\n\n### Example\n\nThe following example assumes a client and a server that are engaged in a two-party secure function evaluation protocol.\n\nClient generates a parameter set:\n\n```cpp\nconst ParameterSet params = ParameterSet::generate_parameter_set(62, 1, 42);\n```\n\nGiven these parameters, the encryption scheme exhibits following properties:\n\n   - Security level is **(62-bit)**\n   - At least 1 multiplication can be evaluated on every bit in the ciphertext\n   - The non-secure random number generator used in ciphertext compression is seeded with number 42\n\nClient then constructs a private key object from generated parameters:\n\n```cpp\nconst PrivateKey sk(params);\n```\n\nEncrypts the plaintext:\n\n```cpp\nconst vector\u003cbool\u003e plaintext = {1, 0, 1, 0, 1, 0, 1, 0};\nconst auto compressed_ciphertext = sk.encrypt(plaintext);\n```\n\nSerializes and sends compressed ciphertext to server.\n\nUpon obtaining the compressed ciphertext, Server expands it to perform operations:\n\n```cpp\nconst auto ciphertext = compressed_ciphertext.expand();\n```\n\nExecutes the algorithm (here negation of an 8-bit input)\n\n```cpp\nconst vector\u003cbool\u003e another_plaintext = {1, 1, 1, 1, 1, 1, 1, 1};\nconst auto response = ciphertext ^ another_plaintext;\n```\n\nSerializes the output and sends it back to the client.\n\nClient decrypts the response and obtains the algorithm output in plaintext:\n\n```cpp\nconst auto decrypted_response = sk.decrypt(response);\nconst vector\u003cbool\u003e expected_result = {0, 1, 0, 1, 0, 1, 0, 1};\nassert(decrypted_response == expected_result);\n```\n\nNote that ciphertext can be compressed only during encryption on the client side, so cost for Server → Client communication is significantly higher than that of Client → Server communication.\n\n### Available homomorphic operations\n\n- Bitwise addition (XOR): `c1 ^ c2`\n- Bitwise multiplication (AND): `c1 \u0026 c2`\n- Equality comparison: `c0.equal({c1, c2, ..., cn})`..\n- Selection of _i_-th ciphertext: `c0.select({c1, c2, ..., cn})`.\n\n## License\n\nThe code is released under the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.html).\n\nCopyright © 2015 Bogdan Kulynych. `hello [at] bogdankulynych.me`\n\n\n\n[DGHV10]: http://eprint.iacr.org/2009/616.pdf\n[CNT11]: http://eprint.iacr.org/2011/440.pdf\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbogdan-kulynych%2Flibshe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbogdan-kulynych%2Flibshe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbogdan-kulynych%2Flibshe/lists"}