Negative subtraction is not possible.
ranjan241991 opened this issue · comments
ranjan241991 commented
Hello,
I tried subtracting 3 with 6 and I got a result as 4294967293 rather than -3 . Can you please tell me whether subtraction between two numbers is possible that results in a negative number ? Thanks.
Code :
const int minimum_lambda = 110;
auto params = new_default_gate_bootstrapping_parameters(minimum_lambda);
uint32_t seed[] = { 314, 1592, 657 };
tfhe_random_generator_setSeed(seed, 3);
auto key = new_random_gate_bootstrapping_secret_keyset(params);
mdl::TFHEEncryptor encryptor(key);
mdl::TFHEDecryptor decryptor(key->lwe_key);
Integer<TFHECtxt> a(32), b(32);
a.encrypt(3, &encryptor);
b.encrypt(6, &encryptor);
a.sub(b);
std::cout << "Final answer: " << a.decrypt(&decryptor) << "\n";
delete_gate_bootstrapping_secret_keyset(key);
delete_gate_bootstrapping_parameters(params);
lwj commented
Because we decrypt it to 'uint32_t' type.