@@ -277,6 +277,18 @@ bool dkg_get_group_public_key(mpc_poc_group_info_t *group_info,
277277 for (int _ = 0 ; _ < signed_pub_key_list_count ; ++ _ ) {
278278 mpc_poc_signed_public_key_t signed_pub_key = signed_pub_key_list [_ ];
279279
280+ bool already_added = false;
281+ for (int i = 0 ; i < ind ; ++ i ) {
282+ if (xcords [i ] == signed_pub_key .index ) {
283+ already_added = true;
284+ break ;
285+ }
286+ }
287+
288+ if (already_added ) {
289+ continue ;
290+ }
291+
280292 xcords [ind ] = signed_pub_key .index ;
281293
282294 if (index_to_pub_key (group_info , signed_pub_key .index , participant_pub_key ) == false) {
@@ -311,17 +323,30 @@ bool dkg_get_group_public_key(mpc_poc_group_info_t *group_info,
311323 return false;
312324 }
313325
314- points [ind ] = & Qi_point ;
315- xcords [ind ] = my_index ;
316- ind ++ ;
326+ int malloc_counter = ind ;
327+
328+ // check if my point is already there
329+ bool already_added = false;
330+ for (int i = 0 ; i < ind ; ++ i ) {
331+ if (xcords [i ] == my_index ) {
332+ already_added = true;
333+ break ;
334+ }
335+ }
336+
337+ if (already_added == false) {
338+ xcords [ind ] = my_index ;
339+ points [ind ] = & Qi_point ;
340+ ind ++ ;
341+ }
317342
318343 if (ind < group_info -> threshold ) {
319344 mpc_send_error (ERROR_COMMON_ERROR_CORRUPT_DATA_TAG ,
320345 ERROR_DATA_FLOW_INVALID_REQUEST );
321346 return false;
322347 }
323348
324- lagarange_exp_interpolate (curve , (const curve_point * * )points , xcords , my_index , signed_pub_key_list_count + 1 , & Qj );
349+ lagarange_exp_interpolate (curve , (const curve_point * * )points , xcords , my_index , ind , & Qj );
325350
326351 if (!point_is_equal (& Qj , & Qi_point )) {
327352 mpc_send_error (ERROR_COMMON_ERROR_CORRUPT_DATA_TAG ,
@@ -330,10 +355,10 @@ bool dkg_get_group_public_key(mpc_poc_group_info_t *group_info,
330355 }
331356
332357 curve_point Q ;
333- lagarange_exp_interpolate (curve , (const curve_point * * )points , xcords , 0 , signed_pub_key_list_count + 1 , & Q );
358+ lagarange_exp_interpolate (curve , (const curve_point * * )points , xcords , 0 , ind , & Q );
334359
335360 // free all points except Q
336- for (int i = 0 ; i < signed_pub_key_list_count ; ++ i ) {
361+ for (int i = 0 ; i < malloc_counter ; ++ i ) {
337362 free (points [i ]);
338363 }
339364
0 commit comments