polynomial_evaluation.rst 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. Polynomial evaluation in CKKS via OpenFHE-rs
  2. =============================================
  3. Overview
  4. --------
  5. This document describes how to call polynomial evaluation on a ciphertext in CKKS.
  6. Polynomial evaluation refers to the computation of the value of a polynomial when its indeterminates are substituted for some values, see more `on Wiki <https://en.wikipedia.org/wiki/Polynomial_evaluation>`_.
  7. Rust example
  8. ------------
  9. The example for this code is located in `examples/polynomial_evaluation.rs <https://github.com/fairmath/openfhe-rs/blob/master/examples/polynomial_evaluation.rs>`_.
  10. This code gives an example of how to run `EvalPoly` function and outputs in the log input parameters, the result of evaluation and the evaluation time.
  11. Input parameters
  12. ----------------
  13. Our Rust wrapper is based on the original OpenFHE interface; `EvalPoly` function requires the following input parameters:
  14. - `ciphertext`: the ciphertext we wish to operate on.
  15. - `coefficients`: the coefficients to run polynomial evaluation upon, a vector array of doubles.
  16. In this example, we run the evaluation upon two sets of coefficients:
  17. 1. {0.15, 0.75, 0, 1.25, 0, 0, 1, 0, 1, 2, 0, 1, 0, 0, 0, 0, 1}
  18. 2. {1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 0.1, 0.2, 0.3, 0.4, 0.5, -0.1, -0.2, -0.3, -0.4, -0.5, 0.1, 0.2, 0.3, 0.4, 0.5, -0.1, -0.2, -0.3, -0.4, -0.5}.
  19. For this example, we set the multiplicative depth at 6 and the scaling mod size at 50.
  20. Running the example
  21. -------------------
  22. 1. Ensure the `openfhe-rs` library is installed and properly configured, see the `Installation guide <../getting-started/installation.md>`.
  23. 2. Go to the `examples` directory and make sure that the needed example is there - `polynomial_evaluation.rs`.
  24. 3. Compile and run the Rust file:
  25. .. code-block:: sh
  26. rustc polynomial_evaluation.rs -o polynomial_evaluation
  27. ./polynomial_evaluation
  28. This should output the results of the homomorphic computations to the console.