Files
concrete/compiler/tests/unit_tests/concretelang/ClientLib/ClientParameters.cpp
Quentin Bourgerie 8cd3a3a599 feat(compiler): First draft to support FHE.eint up to 16bits
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
2022-08-12 16:35:11 +02:00

66 lines
2.1 KiB
C++

#include <gtest/gtest.h>
#include "concretelang/ClientLib/ClientParameters.h"
#include "concretelang/ClientLib/EncryptedArguments.h"
#include "tests_tools/assert.h"
namespace clientlib = concretelang::clientlib;
TEST(Support, client_parameters_json_serde) {
clientlib::ClientParameters params0;
params0.secretKeys = {
{clientlib::SMALL_KEY, {/*.size = */ 12}},
{clientlib::BIG_KEY, {/*.size = */ 14}},
};
params0.bootstrapKeys = {
{"bsk_v0",
{/*.inputSecretKeyID = */ clientlib::SMALL_KEY,
/*.outputSecretKeyID = */ clientlib::BIG_KEY,
/*.level = */ 1,
/*.baseLog = */ 2,
/*.glweDimension = */ 3,
/*.variance = */ 0.001}},
{"wtf_bsk_v0",
{
/*.inputSecretKeyID = */ clientlib::BIG_KEY,
/*.outputSecretKeyID = */ clientlib::SMALL_KEY,
/*.level = */ 3,
/*.baseLog = */ 2,
/*.glweDimension = */ 1,
/*.variance = */ 0.0001,
}},
};
params0.keyswitchKeys = {{"ksk_v0",
{
/*.inputSecretKeyID = */
clientlib::BIG_KEY,
/*.outputSecretKeyID = */
clientlib::SMALL_KEY,
/*.level = */ 1,
/*.baseLog = */ 2,
/*.variance = */ 3,
}}};
params0.inputs = {
{
/*.encryption = */ {{clientlib::SMALL_KEY, 0.00, {4, {1, 2, 3, 4}}}},
/*.shape = */ {32, {1, 2, 3, 4}, 1 * 2 * 3 * 4},
},
{
/*.encryption = */ {{clientlib::SMALL_KEY, 0.00, {5}}},
/*.shape = */ {8, {4, 4, 4, 4}, 4 * 4 * 4 * 4},
},
};
params0.outputs = {
{
/*.encryption = */ {{clientlib::SMALL_KEY, 0.00, {5}}},
/*.shape = */ {8, {4, 4, 4, 4}, 4 * 4 * 4 * 4},
},
};
auto json = clientlib::toJSON(params0);
std::string jsonStr;
llvm::raw_string_ostream os(jsonStr);
os << json;
auto parseResult = llvm::json::parse<clientlib::ClientParameters>(jsonStr);
ASSERT_EXPECTED_VALUE(parseResult, params0);
}