mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-09 14:47:56 -05:00
fix: fix the atomic pattern used to cast in trivium and a test in shortint
- parameters are optimized for a clean ciphertext, the ciphertext being keyswitched was noisy
This commit is contained in:
@@ -48,6 +48,8 @@ fn transcipher_from_1_1_stream(
|
||||
) -> FheUint64 {
|
||||
assert_eq!(stream.len(), 64);
|
||||
|
||||
let id_lut = internal_server_key.generate_lookup_table(|x| x);
|
||||
|
||||
let pairs = (0..32)
|
||||
.into_par_iter()
|
||||
.map(|i| {
|
||||
@@ -57,10 +59,11 @@ fn transcipher_from_1_1_stream(
|
||||
let b0 = &stream[8 * byte_idx + 2 * pair_idx];
|
||||
let b1 = &stream[8 * byte_idx + 2 * pair_idx + 1];
|
||||
|
||||
casting_key.cast(
|
||||
&internal_server_key
|
||||
.unchecked_add(b0, &internal_server_key.unchecked_scalar_mul(b1, 2)),
|
||||
)
|
||||
let mut combined = internal_server_key
|
||||
.unchecked_add(b0, &internal_server_key.unchecked_scalar_mul(b1, 2));
|
||||
internal_server_key.apply_lookup_table_assign(&mut combined, &id_lut);
|
||||
|
||||
casting_key.cast(&combined)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
|
||||
@@ -129,7 +129,12 @@ fn gen_multi_keys_test_add_with_overflow_ci_run_filter() {
|
||||
let c3 = sk1.unchecked_scalar_mul(&c1, 2);
|
||||
let c4 = sk1.unchecked_add(&c3, &c2);
|
||||
|
||||
let output_of_cast = ksk.cast(&c4);
|
||||
// The optimized atomic pattern requires a ciphertext with NoiseLevel::NOMINAL, i.e. a
|
||||
// ciphertext fresh out of a bootstrap
|
||||
let id_lut = sk1.generate_lookup_table(|x| x);
|
||||
let c5 = sk1.apply_lookup_table(&c4, &id_lut);
|
||||
|
||||
let output_of_cast = ksk.cast(&c5);
|
||||
let clear = ck2.decrypt(&output_of_cast);
|
||||
assert_eq!(clear, 3);
|
||||
let ct_carry = sk2.carry_extract(&output_of_cast);
|
||||
|
||||
Reference in New Issue
Block a user