Skip to content

Commit 3e4e757

Browse files
philsipplrw0x0
andauthored
make comparison <= threshold (#669)
* make comparison <= threshold * fix makng the comparison <= threshold * add default case * fix --------- Co-authored-by: Roman Walch <9820846+rw0x0@users.noreply.github.com>
1 parent 5197f01 commit 3e4e757

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

iris-mpc-gpu/src/threshold_ring/cuda/kernel.cu

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ __device__ void u16_transpose_pack_u64(U64 *out_a, U64 *out_b, U16 *in_a,
132132

133133
// Performs the transpose for a and b in parallel
134134
__device__ void u32_transpose_pack_u64(U64 *out_a, U64 *out_b, U32 *in_a,
135-
U32 *in_b, size_t in_len, size_t out_len) {
135+
U32 *in_b, size_t in_len,
136+
size_t out_len) {
136137
// in has size in_len = 64 * n
137138
// out has size out_len, where each element is an array of n elements
138139
// Thus out itslef has n * out_len elements (split into n arrays)
@@ -168,10 +169,10 @@ __device__ void lift_mul_sub(U32 *mask, U16 *mask_corr1, U16 *mask_corr2,
168169
*mask -= (U32)(*mask_corr1) << 16;
169170
*mask -= (U32)(*mask_corr2) << 17;
170171

171-
U32 a;
172-
mul_lift_b(&a, code);
172+
U32 lifted;
173+
mul_lift_b(&lifted, code);
173174
*mask *= A;
174-
*mask -= a;
175+
*mask -= lifted;
175176
}
176177

177178
__device__ void split_inner(U64 *x1_a, U64 *x1_b, U64 *x2_a, U64 *x2_b,
@@ -322,11 +323,21 @@ extern "C" __global__ void lift_split(U16 *in_a, U16 *in_b, U32 *lifted_a,
322323
extern "C" __global__ void shared_lift_mul_sub(U32 *mask_a, U32 *mask_b,
323324
U16 *mask_corr_a,
324325
U16 *mask_corr_b, U16 *code_a,
325-
U16 *code_b, size_t n) {
326+
U16 *code_b, int id, size_t n) {
326327
size_t i = blockIdx.x * blockDim.x + threadIdx.x;
327328
if (i < n) {
328329
lift_mul_sub(&mask_a[i], &mask_corr_a[i], &mask_corr_a[i + n], &code_a[i]);
329330
lift_mul_sub(&mask_b[i], &mask_corr_b[i], &mask_corr_b[i + n], &code_b[i]);
331+
switch (id) {
332+
case 0:
333+
mask_a[i] += 1; // Transforms the <= into <
334+
break;
335+
case 1:
336+
mask_b[i] += 1; // Transforms the <= into <
337+
break;
338+
default:
339+
break;
340+
}
330341
}
331342
}
332343

iris-mpc-gpu/src/threshold_ring/protocol.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,8 @@ impl Circuits {
14661466
&mc.b,
14671467
&c.a,
14681468
&c.b,
1469-
self.chunk_size as u32 * 64,
1469+
self.peer_id as u32,
1470+
self.chunk_size * 64,
14701471
),
14711472
)
14721473
.unwrap();

0 commit comments

Comments
 (0)