Hi community!

I am trying to play with the bootstrap function of ZAMA. I am not always getting the correct result while trying to implement the User defined function on x. Can you help me understand what is happening? Here is my code snippet.

let sk_rlwe = RLWESecretKey::new(&RLWE128_1024_1);

let sk_lwe = sk_rlwe.to_lwe_secret_key();

let base_log = 7;

let level = 3;

let bsk = LWEBSK::new(&sk_lwe, &sk_rlwe, base_log, level);

let (min, max) = (-3., 3.);

let precision = 4;

let padding = 2;

let compare = |x:f64|

if x == 0.{

1.

}

else{

0.

};

let encoder_input = Encoder::new(min, max, precision, padding).unwrap();

let encoder_output = Encoder::new(0., 1., precision, padding).unwrap();

let messages: Vec = vec![-3., -2., -1., 0., 1., 2., 3];

for i in 0…7{

let ct_b = LWE::encode_encrypt(&sk_lwe, messages[i], &encoder_input).unwrap();

let ct_o = ct_b.bootstrap_with_function(&bsk, compare, &encoder_output).unwrap();

let res = ct_o.decode_decrypt(&sk_lwe).unwrap();

}

I ran three different instances of code, the outputs I received were:

Instance1: 0.005 0 0.023 1 0.007 0.001 0

Instance2: 0.002 0 0.001 1 0 0.98 0.025

Instance3: 0.007 0 0.006 0.019 0 0.004 0.012

Ideally only the 4th value should be 1 and all other should be zero with some error. But here only instance 1 is giving results same as the expected results. What am I missing here?