intro.rst 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. About OpenFHE-rs
  2. ================
  3. OpenFHE-rs is a joint project by `Fair Math <https://fairmath.xyz/>`_ & `OpenFHE <https://www.openfhe.org/>`_
  4. .. note::
  5. 🔔 Keep in mind that the library is WIP and may contain some unpolished interfaces. If you encounter any issues or have any suggestions, feel free to ping us on our Discord server or open a new issue in the `GitHub repository <https://github.com/fairmath/openfhe-rs/tree/master>`_.
  6. OpenFHE-rs is a Rust interface for the OpenFHE library, which is renowned for its comprehensive suite of Fully Homomorphic Encryption (FHE) schemes, all implemented in C++. By providing a Rust wrapper for OpenFHE, we aim to make these advanced FHE capabilities easily accessible to Rust developers.
  7. Whether you're developing secure data processing applications or privacy-focused tools, OpenFHE-rs enables you to leverage the powerful encryption technologies of OpenFHE seamlessly within your Rust projects.
  8. Installation
  9. ============
  10. To use OpenFHE-rs, you'll need to install several dependencies and follow the installation steps for both the core OpenFHE library and the Rust crate.
  11. Prerequisites
  12. -------------
  13. Ensure you have the following dependencies installed:
  14. - `CMake >= 3.5.1`
  15. - `G++ >= 11.4`
  16. - `Rust >= 1.78`
  17. - `Git`
  18. Installation process
  19. ---------------------
  20. Core OpenFHE library installation
  21. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  22. To build and install the OpenFHE library, follow the steps below or refer to `OpenFHE's installation documentation <https://openfhe-development.readthedocs.io/en/latest/sphinx_rsts/intro/installation/installation.html>`_.
  23. 1. Clone the repository
  24. .. code-block:: bash
  25. git clone https://github.com/openfheorg/openfhe-development.git
  26. cd openfhe-development
  27. 2. Configure CMake
  28. .. code-block:: bash
  29. cmake -B ${OPENFHE_BUILD:-build} -DBUILD_SHARED=ON .
  30. 3. Build and install the C++ OpenFHE library
  31. .. code-block:: bash
  32. make -C ${OPENFHE_BUILD:-build} -j$(nproc)
  33. make -C ${OPENFHE_BUILD:-build} install
  34. 4. Update the cache for the linker
  35. .. code-block:: bash
  36. sudo ldconfig
  37. Configuring your project to use the crate
  38. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  39. To use the OpenFHE crate in your Rust project, add it as a dependency from `crates.io <https://crates.io/crates/openfhe>`_:
  40. .. code-block:: bash
  41. cargo add openfhe
  42. You also need to add a small piece of code for the core dependencies' configuration in your `build.rs` file:
  43. .. code-block:: rust
  44. fn main
  45. {
  46. // linking openFHE
  47. println!("cargo::rustc-link-arg=-L/usr/local/lib");
  48. println!("cargo::rustc-link-arg=-lOPENFHEpke");
  49. println!("cargo::rustc-link-arg=-lOPENFHEbinfhe");
  50. println!("cargo::rustc-link-arg=-lOPENFHEcore");
  51. // linking OpenMP
  52. println!("cargo::rustc-link-arg=-fopenmp");
  53. // necessary to avoid LD_LIBRARY_PATH
  54. println!("cargo::rustc-link-arg=-Wl,-rpath=/usr/local/lib");
  55. }
  56. To build and run a complete working example, go to the `crate_usage <https://github.com/fairmath/openfhe-rs/tree/master/crate_usage>`_ directory
  57. (assuming that the OpenFHE library is already installed),
  58. 1. Build the application
  59. .. code-block:: bash
  60. cargo build
  61. 2. Run
  62. .. code-block:: bash
  63. cargo run
  64. Custom crate installation from the source
  65. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  66. You can adjust the installation process by building the crate manually. In that case, you need to clone the Fair Math's `openfhe-rs <https://github.com/fairmath/openfhe-rs>`_ repo to your local machine and build it:
  67. 1. Clone the repository
  68. .. code-block:: bash
  69. git clone https://github.com/fairmath/openfhe-rs.git
  70. cd openfhe-rs
  71. 2. Build the library
  72. .. code-block:: bash
  73. cargo build
  74. 3. Run tests
  75. .. code-block:: bash
  76. cargo test -- --test-threads=1
  77. 4. Run the examples
  78. .. code-block:: bash
  79. cargo run --example function_evaluation
  80. cargo run --example polynomial_evaluation
  81. cargo run --example simple_integers
  82. cargo run --example simple_real_numbers
  83. Contributing
  84. ============
  85. Contributions are always welcome! If you find bugs, have feature requests, or want to contribute code, please open an issue or pull request on the `GitHub repository <https://github.com/fairmath/openfhe-rs/tree/master>`_.
  86. License
  87. =======
  88. `OpenFHE-rs` is licensed under the **BSD 2-Clause License**. See the `LICENSE <https://github.com/fairmath/openfhe-rs/blob/master/LICENSE>`_ file for more details.