{"id":47444070,"url":"https://github.com/hpsc-lab/OpenFHE.jl","last_synced_at":"2026-04-06T13:00:54.850Z","repository":{"id":214433411,"uuid":"735811657","full_name":"hpsc-lab/OpenFHE.jl","owner":"hpsc-lab","description":"Fully homomorphic encryption in Julia using OpenFHE","archived":false,"fork":false,"pushed_at":"2026-02-02T10:15:49.000Z","size":1338,"stargazers_count":8,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-02-23T09:38:04.950Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://hpsc-lab.github.io/OpenFHE.jl","language":"Julia","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/hpsc-lab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.bib","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":".zenodo.json","notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-12-26T06:32:12.000Z","updated_at":"2026-02-02T10:13:29.000Z","dependencies_parsed_at":"2023-12-30T08:25:26.619Z","dependency_job_id":"50057a89-9f07-461c-a297-8046acf263fc","html_url":"https://github.com/hpsc-lab/OpenFHE.jl","commit_stats":null,"previous_names":["sloede/openfhe.jl","hpsc-lab/openfhe.jl"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/hpsc-lab/OpenFHE.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hpsc-lab%2FOpenFHE.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hpsc-lab%2FOpenFHE.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hpsc-lab%2FOpenFHE.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hpsc-lab%2FOpenFHE.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hpsc-lab","download_url":"https://codeload.github.com/hpsc-lab/OpenFHE.jl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hpsc-lab%2FOpenFHE.jl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31473271,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-06T08:36:52.050Z","status":"ssl_error","status_checked_at":"2026-04-06T08:36:51.267Z","response_time":112,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2026-03-23T06:00:59.902Z","updated_at":"2026-04-06T13:00:54.842Z","avatar_url":"https://github.com/hpsc-lab.png","language":"Julia","funding_links":[],"categories":["Cryptography"],"sub_categories":["Homomorphic Encryption"],"readme":"# OpenFHE.jl\n\n[![Docs-stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://hpsc-lab.github.io/OpenFHE.jl/stable)\n[![Docs-dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://hpsc-lab.github.io/OpenFHE.jl/dev)\n[![Build Status](https://github.com/hpsc-lab/OpenFHE.jl/actions/workflows/ci.yml/badge.svg)](https://github.com/hpsc-lab/OpenFHE.jl/actions?query=workflow%3ACI)\n[![Coveralls](https://coveralls.io/repos/github/hpsc-lab/OpenFHE.jl/badge.svg)](https://coveralls.io/github/hpsc-lab/OpenFHE.jl)\n[![Codecov](https://codecov.io/gh/hpsc-lab/OpenFHE.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/hpsc-lab/OpenFHE.jl)\n[![License: MIT](https://img.shields.io/badge/License-MIT-success.svg)](https://opensource.org/license/mit/)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10460452.svg)](https://doi.org/10.5281/zenodo.10460452)\n\nOpenFHE.jl is a Julia wrapper package for\n[OpenFHE](https://github.com/openfheorg/openfhe-development), a C++ library for fully\nhomomorphic encryption. The C++ functionality is exposed in native Julia via the\n[CxxWrap.jl](https://github.com/JuliaInterop/CxxWrap.jl) package, using\n[OpenFHE-julia](https://github.com/hpsc-lab/openfhe-julia) as its backend.\n\n*Note: This package is work in progress and not all capabilities of OpenFHE have been\ntranslated to Julia yet. Community contributions are very welcome!*\n\n\n## Getting started\n\n### Prerequisites\nIf you have not yet installed Julia, please [follow the instructions for your\noperating system](https://julialang.org/downloads/platform/).\n[OpenFHE.jl](https://github.com/hpsc-lab/OpenFHE.jl) works with Julia v1.8\nand later on Linux and macOS platforms, and with Julia v1.9 or later on Windows platforms.\n\n### Installation\nSince OpenFHE.jl is a registered Julia package, you can install it by executing the\nfollowing commands in the Julia REPL:\n```julia\njulia\u003e import Pkg; Pkg.add(\"OpenFHE\")\n```\nInternally, OpenFHE.jl relies on [OpenFHE-julia](https://github.com/hpsc-lab/openfhe-julia) to\nprovide bindings for the C++ library\n[OpenFHE](https://github.com/openfheorg/openfhe-development). Precompiled binaries for\nOpenFHE-julia and OpenFHE are automatically for your platform when you install OpenFHE.jl,\nthus there is no need to compile anything manually.\n\n### Usage\nThe easiest way to get started is to run one of the examples from the\n[`examples`](https://github.com/hpsc-lab/OpenFHE.jl/tree/main/examples) directory by\n`include`ing them in Julia, e.g.,\n```julia\njulia\u003e using OpenFHE\n\njulia\u003e include(joinpath(pkgdir(OpenFHE), \"examples\", \"simple_real_numbers.jl\"))\nCKKS scheme is using ring dimension 16384\n\nInput x1: (0.25, 0.5, 0.75, 1, 2, 3, 4, 5,  ... ); Estimated precision: 50 bits\n\nInput x2: (5, 4, 3, 2, 1, 0.75, 0.5, 0.25,  ... ); Estimated precision: 50 bits\n\n\nResults of homomorphic computations:\nx1 = (0.25, 0.5, 0.75, 1, 2, 3, 4, 5,  ... ); Estimated precision: 43 bits\nEstimated precision in bits: 43.0\nx1 + x2 = (5.25, 4.5, 3.75, 3, 3, 3.75, 4.5, 5.25,  ... ); Estimated precision: 43 bits\nEstimated precision in bits: 43.0\nx1 - x2 = (-4.75, -3.5, -2.25, -1, 1, 2.25, 3.5, 4.75,  ... ); Estimated precision: 43 bits\n\n4 * x1 = (1, 2, 3, 4, 8, 12, 16, 20,  ... ); Estimated precision: 41 bits\n\nx1 * x2 = (1.25, 2, 2.25, 2, 2, 2.25, 2, 1.25,  ... ); Estimated precision: 41 bits\n\n\nIn rotations, very small outputs (~10^-10 here) correspond to 0's:\nx1 rotate by 1 = (0.5, 0.75, 1, 2, 3, 4, 5, 0.25,  ... ); Estimated precision: 43 bits\n\nx1 rotate by -2 = (4, 5, 0.25, 0.5, 0.75, 1, 2, 3,  ... ); Estimated precision: 43 bits\n```\n\n### Memory issues\nOpenFHE is a memory-optimized C++ library, but these optimizations can cause\nmemory issues when transitioning to Julia.\n\nIn OpenFHE, large objects like `Ciphertext`, `Plaintext`, and `CryptoContext` are managed\nusing `std::shared_ptr`. These objects are not freed until all associated `std::shared_ptr`s\nare destroyed. Since the Julia objects that hold a reference to these shared pointers are relatively small, Julia's garbage collector\ndoes not always free them automatically, as they are not considered a high priority for garbage collection. This is because Julia's garbage collector primarily\nfocuses on \"young\" objects during its incremental collections, leaving some `std::shared_ptr`s\nin memory even when they are no longer in use. This may result in a significant increase in memory consumption over time,\nas a single `Ciphertext` object can occupy over 60 MB. Consequently, complex operations may lead\nto gigabytes of memory being occupied without being freed until the Julia session is terminated.\nOne possible solution is to manually trigger Julia's garbage collector\nto perform a full collection, which will also clean up these \"small\" objects:\n```julia\nGC.gc()\n```\n\nAdditionally, OpenFHE optimizes memory usage in C++ by storing evaluation keys and `CryptoContext`s\nin static objects. These objects, being quite large, remain in memory until the Julia REPL is\nclosed. To release them while the REPL is still running, you can execute the following functions:\n```julia\nClearEvalMultKeys()\nClearEvalSumKeys()\nClearEvalAutomorphismKeys()\nReleaseAllContexts()\n```\nNote that this will invalidate all currently existing contexts, even those which are\nstill in use. Thus you should only call these functions once you are done with a given\nFHE setup and want to start a new one.\nFor more details, please refer to the documentation for [`ClearEvalMultKeys`](@ref),\n[`ClearEvalSumKeys`](@ref), [`ClearEvalAutomorphismKeys`](@ref), and [`ReleaseAllContexts`](@ref).\n\nTherefore, for a full cleanup of all OpenFHE-occupied memory, first ensure that all variables holding references to OpenFHE objects are out of scope and then execute\n```julia\nClearEvalMultKeys()\nClearEvalSumKeys()\nClearEvalAutomorphismKeys()\nReleaseAllContexts()\nGC.gc()\n```\nBy running these commands at appropriate points in your code, you can prevent excessive memory\nusage and ensure efficient memory management when using OpenFHE.jl.\n\n### Using 128-bit integers\nBy default, OpenFHE uses 64-bit integers, but for CKKS, 128-bit integers are also available\nto increase precision at the cost of additional computational overhead. You can switch between\n64 and 128 bits by using the `OpenFHE.set_native_int!` function, i.e., by running\n```julia-repl\njulia\u003e using OpenFHE\n\njulia\u003e OpenFHE.set_native_int!(128)\n[ Info: Please restart Julia and reload OpenFHE.jl for the library changes to take effect\n```\nThis will create a `LocalPreferences.toml` file in your current project directory with the\n`native_int` preference set accordingly. As advised, you need to restart Julia for\nthe change to take effect. By calling `OpenFHE.set_native_int!()` without an argument, you revert to\nusing 64-bit integers again.\nWith `OpenFHE.get_native_int()` you can query the native integer size of the\ncurrently loaded OpenFHE library.\n\n### Using a custom OpenFHE-julia library\nBy default, OpenFHE.jl uses the [OpenFHE-julia](https://github.com/hpsc-lab/openfhe-julia)\nlibrary provided by the openfhe\\_julia\\_jll.jl package, which is automatically obtained when\ninstalling OpenFHE.jl. Someimtes, however, it might be beneficial to instead use a\nsystem-provided OpenFHE-julia library, e.g., for development or performance purposes. You\ncan change the default by providing a different library with the `OpenFHE.set_library!`\nfunction, i.e., by running\n```julia\njulia\u003e using OpenFHE\n\njulia\u003e OpenFHE.set_library!(\"/abs/path/to/library.so\")\n[ Info: Please restart Julia and reload OpenFHE.jl for the library changes to take effect\n```\nThis will create a `LocalPreferences.toml` file in your current project directory with the\n`libopenfhe_julia` preference set accordingly. As advised, you need to restart Julia for\nthe change to take effect. By calling `OpenFHE.set_library!()` without an argument, you revert to\nusing JLL-provided library again.\n\nIn case the custom library has been deleted, loading OpenFHE.jl will fail. In that case,\neither remove the `LocalPreferences.toml` file or manually reset the preferences by\nexecuting\n```julia\njulia\u003e using UUIDs, Preferences\n\njulia\u003e delete_preferences!(UUID(\"77ce9b8e-ecf5-45d1-bd8a-d31f384f2f95\"), # UUID of OpenFHE.jl\n                           \"libopenfhe_julia\"; force = true)\n```\n\n### Transitioning between OpenFHE and OpenFHE.jl\nOpenFHE.jl using CxxWrap.jl to wrap the C++ library OpenFHE for use in Julia. In general, we\ntry to stick as close to the original library's names and conentions as possible. Since some\nconcepts of C++ do not directly translate to Julia, however, some differences are\nunavoidable. The most notable one is likely that Julia does not know the concept of class\nmember functions. CxxWrap.jl (and OpenFHE.jl) translates this to Julia functions that expect\nthe object as its first argument. Thus, a C++ member function call\n```c++\nmy_object.member_function(arg1, arg2);\n```\nwill look like\n```julia\nmember_function(my_object, arg1, arg2)\n```\nin Julia.\n\nTo simplify switching back and forth between OpenFHE.jl and the C++ library OpenFHE,\nOpenFHE.jl tries to use the same type and function names as OpenFHE. Since `PascalCase` is\nused for types and functions in OpenFHE, the same style is used in OpenFHE.jl, even though\nthis is contrary to typical Julia best practices (where `PascalCase` is only used for types\nand `snake_case` is used for functions).\n\nFurthermore, all OpenFHE types are wrapped by corresponding CxxWrap.jl types, which can\nsometimes be very verbose. To reduce clutter in the Julia REPL, OpenFHE.jl thus often uses a\nsimpler canonical output when printing an object. For example, the output of\n`GenCryptoContext(parameters)` is an object of type\n`CxxWrap.StdLib.SharedPtrAllocated{CryptoContextImpl{DCRTPoly}}`, but when `show`ing the\nobject we just print `SharedPtr{CryptoContext{DCRTPoly}}()`. To find out the actual\nunderlying type, use `typeof`.\n\n\n## Referencing\nIf you use OpenFHE.jl in your own research, please cite this repository as follows:\n```bibtex\n@misc{schlottkelakemper2024openfhejulia,\n  title={{O}pen{FHE}.jl: {F}ully homomorphic encryption in {J}ulia using {O}pen{FHE}},\n  author={Schlottke-Lakemper, Michael},\n  year={2024},\n  howpublished={\\url{https://github.com/hpsc-lab/OpenFHE.jl}},\n  doi={10.5281/zenodo.10460452}\n}\n```\n\n\n## Authors\nOpenFHE.jl was initiated by [Michael Schlottke-Lakemper](https://www.uni-augsburg.de/fakultaet/mntf/math/prof/hpsc)\n(University of Augsburg, Germany), who is also its principal maintainer.\n\nFurther contributions to OpenFHE.jl have been made by the following people:\n* [Arseniy Kholod](https://www.github.com/ArseniyKholod) (RWTH Aachen University, Germany)\n* [Max Grübmeyer](https://www.github.com/MaxGruebmeyer) (University of Augsburg, Germany)\n\n\n## License and contributing\nOpenFHE.jl is available under the MIT license (see [LICENSE.md](LICENSE.md)).\n[OpenFHE](https://github.com/openfheorg/openfhe-development) itself is available under\nthe BSD 2-Clause license.\n\nContributions by the community are very welcome! A good start would be to compare the\n`examples` folder in OpenFHE.jl\n([link](https://github.com/hpsc-lab/OpenFHE.jl/tree/main/examples))\nand in OpenFHE\n([link](https://github.com/openfheorg/openfhe-development/tree/main/src/pke/examples)) and to\nport a missing example file to OpenFHE.jl. In case some OpenFHE functionality is not yet\nexposed by [OpenFHE-julia](https://github.com/hpsc-lab/openfhe-julia), it would have to be\nadded there first.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhpsc-lab%2FOpenFHE.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhpsc-lab%2FOpenFHE.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhpsc-lab%2FOpenFHE.jl/lists"}