mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 20:25:34 -05:00
For now what it works are only levelled ops with user parameters. (take a look to the tests) Done: - Add parameters to the fhe parameters to support CRT-based large integers - Add command line options and tests options to allows the user to give those new parameters - Update the dialects and pipeline to handle new fhe parameters for CRT-based large integers - Update the client parameters and the client library to handle the CRT-based large integers Todo: - Plug the optimizer to compute the CRT-based large interger parameters - Plug the pbs for the CRT-based large integer
47 lines
1.4 KiB
C++
47 lines
1.4 KiB
C++
// Part of the Concrete Compiler Project, under the BSD3 License with Zama
|
|
// Exceptions. See
|
|
// https://github.com/zama-ai/concrete-compiler-internal/blob/main/LICENSE.txt
|
|
// for license information.
|
|
|
|
#ifndef CONCRETELANG_CLIENTLIB_CRT_H_
|
|
#define CONCRETELANG_CLIENTLIB_CRT_H_
|
|
|
|
#include <cstdint>
|
|
#include <vector>
|
|
|
|
namespace concretelang {
|
|
namespace clientlib {
|
|
namespace crt {
|
|
|
|
/// Compute the product of the moduli of the crt decomposition.
|
|
///
|
|
/// \param moduli The moduli of the crt decomposition
|
|
/// \returns The product of moduli
|
|
uint64_t productOfModuli(std::vector<int64_t> moduli);
|
|
|
|
/// Compute the crt decomposition of a `val` according the given `moduli`.
|
|
///
|
|
/// \param moduli The moduli to compute the decomposition.
|
|
/// \param val The value to decompose.
|
|
/// \returns The remainders.
|
|
std::vector<int64_t> crt(std::vector<int64_t> moduli, uint64_t val);
|
|
|
|
/// Compute the inverse of the crt decomposition.
|
|
///
|
|
/// \param moduli The moduli used to compute the inverse decomposition.
|
|
/// \param remainders The remainders of the decomposition.
|
|
uint64_t iCrt(std::vector<int64_t> moduli, std::vector<int64_t> remainders);
|
|
|
|
/// Encode the plaintext with the given modulus and the product of moduli of the
|
|
/// crt decomposition
|
|
uint64_t encode(int64_t plaintext, uint64_t modulus, uint64_t product);
|
|
|
|
/// Decode follow the crt encoding
|
|
uint64_t decode(uint64_t val, uint64_t modulus);
|
|
|
|
} // namespace crt
|
|
} // namespace clientlib
|
|
} // namespace concretelang
|
|
|
|
#endif
|