mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-11 15:48:20 -05:00
Compare commits
1 Commits
go/chore/t
...
al/debug_l
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de710cb2fb |
@@ -17,39 +17,39 @@ where
|
||||
P: Into<TestParameters> + Clone,
|
||||
{
|
||||
// Binary Ops Executors
|
||||
let add_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::add);
|
||||
let sub_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::sub);
|
||||
//let add_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::add);
|
||||
//let sub_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::sub);
|
||||
let bitwise_and_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::bitand);
|
||||
let bitwise_or_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::bitor);
|
||||
let bitwise_xor_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::bitxor);
|
||||
let mul_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::mul);
|
||||
let rotate_left_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::rotate_left);
|
||||
let left_shift_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::left_shift);
|
||||
let rotate_right_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::rotate_right);
|
||||
let right_shift_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::right_shift);
|
||||
let max_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::max);
|
||||
let min_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::min);
|
||||
//let rotate_left_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::rotate_left);
|
||||
//let left_shift_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::left_shift);
|
||||
//let rotate_right_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::rotate_right);
|
||||
//let right_shift_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::right_shift);
|
||||
//let max_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::max);
|
||||
//let min_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::min);
|
||||
|
||||
// Binary Ops Clear functions
|
||||
let clear_add = |x, y| x + y;
|
||||
let clear_sub = |x, y| x - y;
|
||||
//let clear_add = |x, y| x + y;
|
||||
//let clear_sub = |x, y| x - y;
|
||||
let clear_bitwise_and = |x, y| x & y;
|
||||
let clear_bitwise_or = |x, y| x | y;
|
||||
let clear_bitwise_xor = |x, y| x ^ y;
|
||||
let clear_mul = |x, y| x * y;
|
||||
// Warning this rotate definition only works with 64-bit ciphertexts
|
||||
let clear_rotate_left = |x: u64, y: u64| x.rotate_left(y as u32);
|
||||
let clear_left_shift = |x, y| x << y;
|
||||
// Warning this rotate definition only works with 64-bit ciphertexts
|
||||
let clear_rotate_right = |x: u64, y: u64| x.rotate_right(y as u32);
|
||||
let clear_right_shift = |x, y| x >> y;
|
||||
let clear_max = |x: u64, y: u64| max(x, y);
|
||||
let clear_min = |x: u64, y: u64| min(x, y);
|
||||
//let clear_rotate_left = |x: u64, y: u64| x.rotate_left(y as u32);
|
||||
//let clear_left_shift = |x, y| x << y;
|
||||
//// Warning this rotate definition only works with 64-bit ciphertexts
|
||||
//let clear_rotate_right = |x: u64, y: u64| x.rotate_right(y as u32);
|
||||
//let clear_right_shift = |x, y| x >> y;
|
||||
//let clear_max = |x: u64, y: u64| max(x, y);
|
||||
//let clear_min = |x: u64, y: u64| min(x, y);
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
let mut binary_ops: Vec<(BinaryOpExecutor, &dyn Fn(u64, u64) -> u64, String)> = vec![
|
||||
(Box::new(add_executor), &clear_add, "add".to_string()),
|
||||
(Box::new(sub_executor), &clear_sub, "sub".to_string()),
|
||||
//(Box::new(add_executor), &clear_add, "add".to_string()),
|
||||
//(Box::new(sub_executor), &clear_sub, "sub".to_string()),
|
||||
(
|
||||
Box::new(bitwise_and_executor),
|
||||
&clear_bitwise_and,
|
||||
@@ -66,28 +66,28 @@ where
|
||||
"bitxor".to_string(),
|
||||
),
|
||||
(Box::new(mul_executor), &clear_mul, "mul".to_string()),
|
||||
(
|
||||
Box::new(rotate_left_executor),
|
||||
&clear_rotate_left,
|
||||
"rotate left".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(left_shift_executor),
|
||||
&clear_left_shift,
|
||||
"left shift".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(rotate_right_executor),
|
||||
&clear_rotate_right,
|
||||
"rotate right".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(right_shift_executor),
|
||||
&clear_right_shift,
|
||||
"right shift".to_string(),
|
||||
),
|
||||
(Box::new(max_executor), &clear_max, "max".to_string()),
|
||||
(Box::new(min_executor), &clear_min, "min".to_string()),
|
||||
//(
|
||||
// Box::new(rotate_left_executor),
|
||||
// &clear_rotate_left,
|
||||
// "rotate left".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(left_shift_executor),
|
||||
// &clear_left_shift,
|
||||
// "left shift".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(rotate_right_executor),
|
||||
// &clear_rotate_right,
|
||||
// "rotate right".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(right_shift_executor),
|
||||
// &clear_right_shift,
|
||||
// "right shift".to_string(),
|
||||
//),
|
||||
//(Box::new(max_executor), &clear_max, "max".to_string()),
|
||||
//(Box::new(min_executor), &clear_min, "min".to_string()),
|
||||
];
|
||||
|
||||
// Unary Ops Executors
|
||||
@@ -115,8 +115,8 @@ where
|
||||
];
|
||||
|
||||
// Scalar binary Ops Executors
|
||||
let scalar_add_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_add);
|
||||
let scalar_sub_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_sub);
|
||||
//let scalar_add_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_add);
|
||||
//let scalar_sub_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_sub);
|
||||
let scalar_bitwise_and_executor =
|
||||
GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_bitand);
|
||||
let scalar_bitwise_or_executor =
|
||||
@@ -124,27 +124,27 @@ where
|
||||
let scalar_bitwise_xor_executor =
|
||||
GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_bitxor);
|
||||
let scalar_mul_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_mul);
|
||||
let scalar_rotate_left_executor =
|
||||
GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_rotate_left);
|
||||
let scalar_left_shift_executor =
|
||||
GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_left_shift);
|
||||
let scalar_rotate_right_executor =
|
||||
GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_rotate_right);
|
||||
let scalar_right_shift_executor =
|
||||
GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_right_shift);
|
||||
//let scalar_rotate_left_executor =
|
||||
// GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_rotate_left);
|
||||
//let scalar_left_shift_executor =
|
||||
// GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_left_shift);
|
||||
//let scalar_rotate_right_executor =
|
||||
// GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_rotate_right);
|
||||
//let scalar_right_shift_executor =
|
||||
// GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_right_shift);
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
let mut scalar_binary_ops: Vec<(ScalarBinaryOpExecutor, &dyn Fn(u64, u64) -> u64, String)> = vec![
|
||||
(
|
||||
Box::new(scalar_add_executor),
|
||||
&clear_add,
|
||||
"scalar add".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(scalar_sub_executor),
|
||||
&clear_sub,
|
||||
"scalar sub".to_string(),
|
||||
),
|
||||
//(
|
||||
// Box::new(scalar_add_executor),
|
||||
// &clear_add,
|
||||
// "scalar add".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(scalar_sub_executor),
|
||||
// &clear_sub,
|
||||
// "scalar sub".to_string(),
|
||||
//),
|
||||
(
|
||||
Box::new(scalar_bitwise_and_executor),
|
||||
&clear_bitwise_and,
|
||||
@@ -165,26 +165,26 @@ where
|
||||
&clear_mul,
|
||||
"scalar mul".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(scalar_rotate_left_executor),
|
||||
&clear_rotate_left,
|
||||
"scalar rotate left".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(scalar_left_shift_executor),
|
||||
&clear_left_shift,
|
||||
"scalar left shift".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(scalar_rotate_right_executor),
|
||||
&clear_rotate_right,
|
||||
"scalar rotate right".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(scalar_right_shift_executor),
|
||||
&clear_right_shift,
|
||||
"scalar right shift".to_string(),
|
||||
),
|
||||
//(
|
||||
// Box::new(scalar_rotate_left_executor),
|
||||
// &clear_rotate_left,
|
||||
// "scalar rotate left".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(scalar_left_shift_executor),
|
||||
// &clear_left_shift,
|
||||
// "scalar left shift".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(scalar_rotate_right_executor),
|
||||
// &clear_rotate_right,
|
||||
// "scalar rotate right".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(scalar_right_shift_executor),
|
||||
// &clear_right_shift,
|
||||
// "scalar right shift".to_string(),
|
||||
//),
|
||||
];
|
||||
|
||||
// Overflowing Ops Executors
|
||||
@@ -249,37 +249,37 @@ where
|
||||
|
||||
// Comparison Ops Executors
|
||||
let gt_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::gt);
|
||||
let ge_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::ge);
|
||||
let lt_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::lt);
|
||||
let le_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::le);
|
||||
let eq_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::eq);
|
||||
let ne_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::ne);
|
||||
//let ge_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::ge);
|
||||
//let lt_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::lt);
|
||||
//let le_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::le);
|
||||
//let eq_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::eq);
|
||||
//let ne_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::ne);
|
||||
|
||||
// Comparison Ops Clear functions
|
||||
let clear_gt = |x: u64, y: u64| -> bool { x > y };
|
||||
let clear_ge = |x: u64, y: u64| -> bool { x >= y };
|
||||
let clear_lt = |x: u64, y: u64| -> bool { x < y };
|
||||
let clear_le = |x: u64, y: u64| -> bool { x <= y };
|
||||
let clear_eq = |x: u64, y: u64| -> bool { x == y };
|
||||
let clear_ne = |x: u64, y: u64| -> bool { x != y };
|
||||
//let clear_ge = |x: u64, y: u64| -> bool { x >= y };
|
||||
//let clear_lt = |x: u64, y: u64| -> bool { x < y };
|
||||
//let clear_le = |x: u64, y: u64| -> bool { x <= y };
|
||||
//let clear_eq = |x: u64, y: u64| -> bool { x == y };
|
||||
//let clear_ne = |x: u64, y: u64| -> bool { x != y };
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
let mut comparison_ops: Vec<(ComparisonOpExecutor, &dyn Fn(u64, u64) -> bool, String)> = vec![
|
||||
(Box::new(gt_executor), &clear_gt, "gt".to_string()),
|
||||
(Box::new(ge_executor), &clear_ge, "ge".to_string()),
|
||||
(Box::new(lt_executor), &clear_lt, "lt".to_string()),
|
||||
(Box::new(le_executor), &clear_le, "le".to_string()),
|
||||
(Box::new(eq_executor), &clear_eq, "eq".to_string()),
|
||||
(Box::new(ne_executor), &clear_ne, "ne".to_string()),
|
||||
//(Box::new(ge_executor), &clear_ge, "ge".to_string()),
|
||||
//(Box::new(lt_executor), &clear_lt, "lt".to_string()),
|
||||
//(Box::new(le_executor), &clear_le, "le".to_string()),
|
||||
//(Box::new(eq_executor), &clear_eq, "eq".to_string()),
|
||||
//(Box::new(ne_executor), &clear_ne, "ne".to_string()),
|
||||
];
|
||||
|
||||
// Scalar Comparison Ops Executors
|
||||
let scalar_gt_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_gt);
|
||||
let scalar_ge_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_ge);
|
||||
let scalar_lt_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_lt);
|
||||
let scalar_le_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_le);
|
||||
let scalar_eq_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_eq);
|
||||
let scalar_ne_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_ne);
|
||||
//let scalar_ge_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_ge);
|
||||
//let scalar_lt_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_lt);
|
||||
//let scalar_le_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_le);
|
||||
//let scalar_eq_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_eq);
|
||||
//let scalar_ne_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_ne);
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
let mut scalar_comparison_ops: Vec<(
|
||||
@@ -292,31 +292,31 @@ where
|
||||
&clear_gt,
|
||||
"scalar gt".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(scalar_ge_executor),
|
||||
&clear_ge,
|
||||
"scalar ge".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(scalar_lt_executor),
|
||||
&clear_lt,
|
||||
"scalar lt".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(scalar_le_executor),
|
||||
&clear_le,
|
||||
"scalar le".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(scalar_eq_executor),
|
||||
&clear_eq,
|
||||
"scalar eq".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(scalar_ne_executor),
|
||||
&clear_ne,
|
||||
"scalar ne".to_string(),
|
||||
),
|
||||
//(
|
||||
// Box::new(scalar_ge_executor),
|
||||
// &clear_ge,
|
||||
// "scalar ge".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(scalar_lt_executor),
|
||||
// &clear_lt,
|
||||
// "scalar lt".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(scalar_le_executor),
|
||||
// &clear_le,
|
||||
// "scalar le".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(scalar_eq_executor),
|
||||
// &clear_eq,
|
||||
// "scalar eq".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(scalar_ne_executor),
|
||||
// &clear_ne,
|
||||
// "scalar ne".to_string(),
|
||||
//),
|
||||
];
|
||||
|
||||
// Select Executor
|
||||
|
||||
@@ -19,29 +19,29 @@ where
|
||||
P: Into<TestParameters> + Clone,
|
||||
{
|
||||
// Binary Ops Executors
|
||||
let add_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::add);
|
||||
let sub_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::sub);
|
||||
//let add_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::add);
|
||||
//let sub_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::sub);
|
||||
let bitwise_and_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::bitand);
|
||||
let bitwise_or_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::bitor);
|
||||
let bitwise_xor_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::bitxor);
|
||||
let mul_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::mul);
|
||||
let max_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::max);
|
||||
let min_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::min);
|
||||
//let max_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::max);
|
||||
//let min_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::min);
|
||||
|
||||
// Binary Ops Clear functions
|
||||
let clear_add = |x, y| x + y;
|
||||
let clear_sub = |x, y| x - y;
|
||||
//let clear_add = |x, y| x + y;
|
||||
//let clear_sub = |x, y| x - y;
|
||||
let clear_bitwise_and = |x, y| x & y;
|
||||
let clear_bitwise_or = |x, y| x | y;
|
||||
let clear_bitwise_xor = |x, y| x ^ y;
|
||||
let clear_mul = |x, y| x * y;
|
||||
let clear_max = |x: i64, y: i64| max(x, y);
|
||||
let clear_min = |x: i64, y: i64| min(x, y);
|
||||
//let clear_max = |x: i64, y: i64| max(x, y);
|
||||
//let clear_min = |x: i64, y: i64| min(x, y);
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
let mut binary_ops: Vec<(SignedBinaryOpExecutor, &dyn Fn(i64, i64) -> i64, String)> = vec![
|
||||
(Box::new(add_executor), &clear_add, "add".to_string()),
|
||||
(Box::new(sub_executor), &clear_sub, "sub".to_string()),
|
||||
//(Box::new(add_executor), &clear_add, "add".to_string()),
|
||||
//(Box::new(sub_executor), &clear_sub, "sub".to_string()),
|
||||
(
|
||||
Box::new(bitwise_and_executor),
|
||||
&clear_bitwise_and,
|
||||
@@ -58,14 +58,14 @@ where
|
||||
"bitxor".to_string(),
|
||||
),
|
||||
(Box::new(mul_executor), &clear_mul, "mul".to_string()),
|
||||
(Box::new(max_executor), &clear_max, "max".to_string()),
|
||||
(Box::new(min_executor), &clear_min, "min".to_string()),
|
||||
//(Box::new(max_executor), &clear_max, "max".to_string()),
|
||||
//(Box::new(min_executor), &clear_min, "min".to_string()),
|
||||
];
|
||||
|
||||
let rotate_left_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::rotate_left);
|
||||
let left_shift_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::left_shift);
|
||||
let rotate_right_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::rotate_right);
|
||||
let right_shift_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::right_shift);
|
||||
//let left_shift_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::left_shift);
|
||||
//let rotate_right_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::rotate_right);
|
||||
//let right_shift_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::right_shift);
|
||||
// Warning this rotate definition only works with 64-bit ciphertexts
|
||||
let clear_rotate_left = |x: i64, y: u64| x.rotate_left(y as u32);
|
||||
let clear_left_shift = |x: i64, y: u64| x << y;
|
||||
@@ -83,21 +83,21 @@ where
|
||||
&clear_rotate_left,
|
||||
"rotate left".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(left_shift_executor),
|
||||
&clear_left_shift,
|
||||
"left shift".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(rotate_right_executor),
|
||||
&clear_rotate_right,
|
||||
"rotate right".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(right_shift_executor),
|
||||
&clear_right_shift,
|
||||
"right shift".to_string(),
|
||||
),
|
||||
//(
|
||||
// Box::new(left_shift_executor),
|
||||
// &clear_left_shift,
|
||||
// "left shift".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(rotate_right_executor),
|
||||
// &clear_rotate_right,
|
||||
// "rotate right".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(right_shift_executor),
|
||||
// &clear_right_shift,
|
||||
// "right shift".to_string(),
|
||||
//),
|
||||
];
|
||||
|
||||
// Unary Ops Executors
|
||||
@@ -125,8 +125,8 @@ where
|
||||
];
|
||||
|
||||
// Scalar binary Ops Executors
|
||||
let scalar_add_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_add);
|
||||
let scalar_sub_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_sub);
|
||||
//let scalar_add_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_add);
|
||||
//let scalar_sub_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_sub);
|
||||
let scalar_bitwise_and_executor =
|
||||
GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_bitand);
|
||||
let scalar_bitwise_or_executor =
|
||||
@@ -141,16 +141,16 @@ where
|
||||
&dyn Fn(i64, i64) -> i64,
|
||||
String,
|
||||
)> = vec![
|
||||
(
|
||||
Box::new(scalar_add_executor),
|
||||
&clear_add,
|
||||
"scalar add".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(scalar_sub_executor),
|
||||
&clear_sub,
|
||||
"scalar sub".to_string(),
|
||||
),
|
||||
//(
|
||||
// Box::new(scalar_add_executor),
|
||||
// &clear_add,
|
||||
// "scalar add".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(scalar_sub_executor),
|
||||
// &clear_sub,
|
||||
// "scalar sub".to_string(),
|
||||
//),
|
||||
(
|
||||
Box::new(scalar_bitwise_and_executor),
|
||||
&clear_bitwise_and,
|
||||
@@ -175,12 +175,12 @@ where
|
||||
|
||||
let scalar_rotate_left_executor =
|
||||
GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_rotate_left);
|
||||
let scalar_left_shift_executor =
|
||||
GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_left_shift);
|
||||
let scalar_rotate_right_executor =
|
||||
GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_rotate_right);
|
||||
let scalar_right_shift_executor =
|
||||
GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_right_shift);
|
||||
//let scalar_left_shift_executor =
|
||||
// GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_left_shift);
|
||||
//let scalar_rotate_right_executor =
|
||||
// GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_rotate_right);
|
||||
//let scalar_right_shift_executor =
|
||||
// GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_right_shift);
|
||||
#[allow(clippy::type_complexity)]
|
||||
let mut scalar_shift_rotate_ops: Vec<(
|
||||
SignedScalarShiftRotateExecutor,
|
||||
@@ -192,21 +192,21 @@ where
|
||||
&clear_rotate_left,
|
||||
"scalar rotate left".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(scalar_left_shift_executor),
|
||||
&clear_left_shift,
|
||||
"scalar left shift".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(scalar_rotate_right_executor),
|
||||
&clear_rotate_right,
|
||||
"scalar rotate right".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(scalar_right_shift_executor),
|
||||
&clear_right_shift,
|
||||
"scalar right shift".to_string(),
|
||||
),
|
||||
//(
|
||||
// Box::new(scalar_left_shift_executor),
|
||||
// &clear_left_shift,
|
||||
// "scalar left shift".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(scalar_rotate_right_executor),
|
||||
// &clear_rotate_right,
|
||||
// "scalar rotate right".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(scalar_right_shift_executor),
|
||||
// &clear_right_shift,
|
||||
// "scalar right shift".to_string(),
|
||||
//),
|
||||
];
|
||||
|
||||
// Overflowing Ops Executors
|
||||
@@ -271,11 +271,11 @@ where
|
||||
|
||||
// Comparison Ops Executors
|
||||
let gt_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::gt);
|
||||
let ge_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::ge);
|
||||
let lt_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::lt);
|
||||
let le_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::le);
|
||||
let eq_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::eq);
|
||||
let ne_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::ne);
|
||||
//let ge_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::ge);
|
||||
//let lt_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::lt);
|
||||
//let le_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::le);
|
||||
//let eq_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::eq);
|
||||
//let ne_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::ne);
|
||||
|
||||
// Comparison Ops Clear functions
|
||||
let clear_gt = |x: i64, y: i64| -> bool { x > y };
|
||||
@@ -292,20 +292,20 @@ where
|
||||
String,
|
||||
)> = vec![
|
||||
(Box::new(gt_executor), &clear_gt, "gt".to_string()),
|
||||
(Box::new(ge_executor), &clear_ge, "ge".to_string()),
|
||||
(Box::new(lt_executor), &clear_lt, "lt".to_string()),
|
||||
(Box::new(le_executor), &clear_le, "le".to_string()),
|
||||
(Box::new(eq_executor), &clear_eq, "eq".to_string()),
|
||||
(Box::new(ne_executor), &clear_ne, "ne".to_string()),
|
||||
//(Box::new(ge_executor), &clear_ge, "ge".to_string()),
|
||||
//(Box::new(lt_executor), &clear_lt, "lt".to_string()),
|
||||
//(Box::new(le_executor), &clear_le, "le".to_string()),
|
||||
//(Box::new(eq_executor), &clear_eq, "eq".to_string()),
|
||||
//(Box::new(ne_executor), &clear_ne, "ne".to_string()),
|
||||
];
|
||||
|
||||
// Scalar Comparison Ops Executors
|
||||
let scalar_gt_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_gt);
|
||||
let scalar_ge_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_ge);
|
||||
let scalar_lt_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_lt);
|
||||
let scalar_le_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_le);
|
||||
let scalar_eq_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_eq);
|
||||
let scalar_ne_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_ne);
|
||||
//let scalar_ge_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_ge);
|
||||
//let scalar_lt_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_lt);
|
||||
//let scalar_le_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_le);
|
||||
//let scalar_eq_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_eq);
|
||||
//let scalar_ne_executor = GpuMultiDeviceFunctionExecutor::new(&CudaServerKey::scalar_ne);
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
let mut scalar_comparison_ops: Vec<(
|
||||
@@ -318,31 +318,31 @@ where
|
||||
&clear_gt,
|
||||
"scalar gt".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(scalar_ge_executor),
|
||||
&clear_ge,
|
||||
"scalar ge".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(scalar_lt_executor),
|
||||
&clear_lt,
|
||||
"scalar lt".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(scalar_le_executor),
|
||||
&clear_le,
|
||||
"scalar le".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(scalar_eq_executor),
|
||||
&clear_eq,
|
||||
"scalar eq".to_string(),
|
||||
),
|
||||
(
|
||||
Box::new(scalar_ne_executor),
|
||||
&clear_ne,
|
||||
"scalar ne".to_string(),
|
||||
),
|
||||
//(
|
||||
// Box::new(scalar_ge_executor),
|
||||
// &clear_ge,
|
||||
// "scalar ge".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(scalar_lt_executor),
|
||||
// &clear_lt,
|
||||
// "scalar lt".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(scalar_le_executor),
|
||||
// &clear_le,
|
||||
// "scalar le".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(scalar_eq_executor),
|
||||
// &clear_eq,
|
||||
// "scalar eq".to_string(),
|
||||
//),
|
||||
//(
|
||||
// Box::new(scalar_ne_executor),
|
||||
// &clear_ne,
|
||||
// "scalar ne".to_string(),
|
||||
//),
|
||||
];
|
||||
|
||||
// Select Executor
|
||||
|
||||
@@ -3,4 +3,4 @@ pub(crate) mod test_random_op_sequence;
|
||||
pub(crate) mod test_signed_erc20;
|
||||
pub(crate) mod test_signed_random_op_sequence;
|
||||
pub(crate) const NB_CTXT_LONG_RUN: usize = 32;
|
||||
pub(crate) const NB_TESTS_LONG_RUN: usize = 20000;
|
||||
pub(crate) const NB_TESTS_LONG_RUN: usize = 200;
|
||||
|
||||
@@ -588,6 +588,9 @@ pub(crate) fn random_op_sequence_test<P>(
|
||||
left_vec[i].blocks.iter().map(|b| b.degree.0).collect();
|
||||
let input_degrees_right: Vec<u64> =
|
||||
right_vec[i].blocks.iter().map(|b| b.degree.0).collect();
|
||||
let output_degrees: Vec<u64> =
|
||||
res.blocks.iter().map(|b| b.degree.0).collect();
|
||||
println!("Input degrees left: {input_degrees_left:?}, right {input_degrees_right:?}, Output degrees {:?}", output_degrees);
|
||||
let decrypted_res: u64 = cks.decrypt(&res);
|
||||
let expected_res: u64 = clear_fn(clear_left, clear_right);
|
||||
|
||||
|
||||
@@ -680,6 +680,9 @@ pub(crate) fn signed_random_op_sequence_test<P>(
|
||||
left_vec[i].blocks.iter().map(|b| b.degree.0).collect();
|
||||
let input_degrees_right: Vec<u64> =
|
||||
right_vec[i].blocks.iter().map(|b| b.degree.0).collect();
|
||||
let output_degrees: Vec<u64> =
|
||||
res.blocks.iter().map(|b| b.degree.0).collect();
|
||||
println!("Input degrees left: {input_degrees_left:?}, right {input_degrees_right:?}, Output degrees {:?}", output_degrees);
|
||||
let decrypt_signed_res: i64 = cks.decrypt_signed(&res);
|
||||
let expected_res: i64 = clear_fn(clear_left, clear_right);
|
||||
|
||||
@@ -731,6 +734,9 @@ pub(crate) fn signed_random_op_sequence_test<P>(
|
||||
"Determinism check failed on unary op {fn_name} with clear input {clear_input}.",
|
||||
);
|
||||
let input_degrees: Vec<u64> = input.blocks.iter().map(|b| b.degree.0).collect();
|
||||
let output_degrees: Vec<u64> =
|
||||
res.blocks.iter().map(|b| b.degree.0).collect();
|
||||
println!("Output degrees {:?}", output_degrees);
|
||||
let decrypt_signed_res: i64 = cks.decrypt_signed(&res);
|
||||
let expected_res: i64 = clear_fn(clear_input);
|
||||
if i % 2 == 0 {
|
||||
@@ -774,6 +780,9 @@ pub(crate) fn signed_random_op_sequence_test<P>(
|
||||
);
|
||||
let input_degrees_left: Vec<u64> =
|
||||
left_vec[i].blocks.iter().map(|b| b.degree.0).collect();
|
||||
let output_degrees: Vec<u64> =
|
||||
res.blocks.iter().map(|b| b.degree.0).collect();
|
||||
println!("Output degrees {:?}", output_degrees);
|
||||
let decrypt_signed_res: i64 = cks.decrypt_signed(&res);
|
||||
let expected_res: i64 = clear_fn(clear_left, clear_right);
|
||||
|
||||
@@ -829,6 +838,9 @@ pub(crate) fn signed_random_op_sequence_test<P>(
|
||||
left_vec[i].blocks.iter().map(|b| b.degree.0).collect();
|
||||
let input_degrees_right: Vec<u64> =
|
||||
right_vec[i].blocks.iter().map(|b| b.degree.0).collect();
|
||||
let output_degrees: Vec<u64> =
|
||||
res.blocks.iter().map(|b| b.degree.0).collect();
|
||||
println!("Output degrees {:?}", output_degrees);
|
||||
let decrypt_signed_res: i64 = cks.decrypt_signed(&res);
|
||||
let decrypt_signed_overflow = cks.decrypt_bool(&overflow);
|
||||
let (expected_res, expected_overflow) = clear_fn(clear_left, clear_right);
|
||||
@@ -889,6 +901,9 @@ pub(crate) fn signed_random_op_sequence_test<P>(
|
||||
);
|
||||
let input_degrees_left: Vec<u64> =
|
||||
left_vec[i].blocks.iter().map(|b| b.degree.0).collect();
|
||||
let output_degrees: Vec<u64> =
|
||||
res.blocks.iter().map(|b| b.degree.0).collect();
|
||||
println!("Output degrees {:?}", output_degrees);
|
||||
let decrypt_signed_res: i64 = cks.decrypt_signed(&res);
|
||||
let decrypt_signed_overflow = cks.decrypt_bool(&overflow);
|
||||
let (expected_res, expected_overflow) = clear_fn(clear_left, clear_right);
|
||||
@@ -1020,6 +1035,9 @@ pub(crate) fn signed_random_op_sequence_test<P>(
|
||||
left_vec[i].blocks.iter().map(|b| b.degree.0).collect();
|
||||
let input_degrees_right: Vec<u64> =
|
||||
right_vec[i].blocks.iter().map(|b| b.degree.0).collect();
|
||||
let output_degrees: Vec<u64> =
|
||||
res.blocks.iter().map(|b| b.degree.0).collect();
|
||||
println!("Output degrees {:?}", output_degrees);
|
||||
let decrypt_signed_res: i64 = cks.decrypt_signed(&res);
|
||||
let expected_res = clear_fn(clear_bool, clear_left, clear_right);
|
||||
|
||||
@@ -1081,6 +1099,12 @@ pub(crate) fn signed_random_op_sequence_test<P>(
|
||||
left_vec[i].blocks.iter().map(|b| b.degree.0).collect();
|
||||
let input_degrees_right: Vec<u64> =
|
||||
right_vec[i].blocks.iter().map(|b| b.degree.0).collect();
|
||||
let output_degrees_q: Vec<u64> =
|
||||
res_q.blocks.iter().map(|b| b.degree.0).collect();
|
||||
let output_degrees_r: Vec<u64> =
|
||||
res_r.blocks.iter().map(|b| b.degree.0).collect();
|
||||
println!("Output degrees {:?}", output_degrees_q);
|
||||
println!("Output degrees {:?}", output_degrees_r);
|
||||
let decrypt_signed_res_q: i64 = cks.decrypt_signed(&res_q);
|
||||
let decrypt_signed_res_r: i64 = cks.decrypt_signed(&res_r);
|
||||
let (expected_res_q, expected_res_r) = clear_fn(clear_left, clear_right);
|
||||
@@ -1147,6 +1171,12 @@ pub(crate) fn signed_random_op_sequence_test<P>(
|
||||
);
|
||||
let input_degrees_left: Vec<u64> =
|
||||
left_vec[i].blocks.iter().map(|b| b.degree.0).collect();
|
||||
let output_q_degrees: Vec<u64> =
|
||||
res_r.blocks.iter().map(|b| b.degree.0).collect();
|
||||
let output_r_degrees: Vec<u64> =
|
||||
res_r.blocks.iter().map(|b| b.degree.0).collect();
|
||||
println!("Output r degrees {:?}", output_r_degrees);
|
||||
println!("Output q degrees {:?}", output_q_degrees);
|
||||
let decrypt_signed_res_q: i64 = cks.decrypt_signed(&res_q);
|
||||
let decrypt_signed_res_r: i64 = cks.decrypt_signed(&res_r);
|
||||
let (expected_res_q, expected_res_r) = clear_fn(clear_left, clear_right);
|
||||
@@ -1205,6 +1235,9 @@ pub(crate) fn signed_random_op_sequence_test<P>(
|
||||
"Determinism check failed on op {fn_name} with clear input {clear_input}.",
|
||||
);
|
||||
let input_degrees: Vec<u64> = input.blocks.iter().map(|b| b.degree.0).collect();
|
||||
let output_degrees: Vec<u64> =
|
||||
res.blocks.iter().map(|b| b.degree.0).collect();
|
||||
println!("Output degrees {:?}", output_degrees);
|
||||
let cast_res = sks.cast_to_signed(res, NB_CTXT_LONG_RUN);
|
||||
let decrypt_signed_res: i64 = cks.decrypt_signed(&cast_res);
|
||||
let expected_res = clear_fn(clear_input) as i64;
|
||||
@@ -1252,6 +1285,9 @@ pub(crate) fn signed_random_op_sequence_test<P>(
|
||||
left_vec[i].blocks.iter().map(|b| b.degree.0).collect();
|
||||
let input_degrees_right: Vec<u64> =
|
||||
unsigned_right.blocks.iter().map(|b| b.degree.0).collect();
|
||||
let output_degrees: Vec<u64> =
|
||||
res.blocks.iter().map(|b| b.degree.0).collect();
|
||||
println!("Output degrees {:?}", output_degrees);
|
||||
let decrypt_signed_res: i64 = cks.decrypt_signed(&res);
|
||||
let expected_res: i64 = clear_fn(clear_left, clear_right as u64);
|
||||
|
||||
@@ -1297,6 +1333,9 @@ pub(crate) fn signed_random_op_sequence_test<P>(
|
||||
);
|
||||
let input_degrees_left: Vec<u64> =
|
||||
left_vec[i].blocks.iter().map(|b| b.degree.0).collect();
|
||||
let output_degrees: Vec<u64> =
|
||||
res.blocks.iter().map(|b| b.degree.0).collect();
|
||||
println!("Output degrees {:?}", output_degrees);
|
||||
let decrypt_signed_res: i64 = cks.decrypt_signed(&res);
|
||||
let expected_res: i64 = clear_fn(clear_left, clear_right as u64);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user