mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 03:55:04 -05:00
fix(compiler/runtime): decode with integers
This commit is contained in:
@@ -267,11 +267,10 @@ llvm::Error KeySet::decrypt_lwe(size_t argPos, LweCiphertext_u64 *ciphertext,
|
||||
decrypt_lwe_u64(&err, std::get<2>(outputSk), ciphertext, &plaintext),
|
||||
"cannot decrypt");
|
||||
// Decode
|
||||
double divisor = std::pow(
|
||||
2, 64 - (std::get<0>(outputSk).encryption->encoding.precision + 1));
|
||||
output = std::round(((double)plaintext._0) / divisor);
|
||||
output %= (1 << (std::get<0>(outputSk).encryption->encoding.precision + 1));
|
||||
|
||||
size_t precision = std::get<0>(outputSk).encryption->encoding.precision;
|
||||
output = plaintext._0 >> (64 - precision - 2);
|
||||
size_t carry = output % 2;
|
||||
output = ((output >> 1) + carry) % (1 << (precision + 1));
|
||||
return llvm::Error::success();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user