polynomial_evaluation.rst 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 :doc:`intro` section.
  23. 2. Go to the `openfhe-rs` directory.
  24. 3. Compile and run the `polynomial_evaluation.rs` example:
  25. .. code-block:: sh
  26. cargo run --example polynomial_evaluation
  27. This should output the results of the homomorphic computations to the console.