@@ -7,7 +7,8 @@ use crate::network::{MeshNetworkClient, NetworkTaskChannel};
77use crate :: primitives:: { ParticipantId , UniqueId } ;
88use crate :: protocol:: run_protocol;
99use crate :: providers:: robust_ecdsa:: {
10- KeygenOutput , RobustEcdsaSignatureProvider , RobustEcdsaTaskId ,
10+ get_number_of_signers, translate_threshold, KeygenOutput , RobustEcdsaSignatureProvider ,
11+ RobustEcdsaTaskId ,
1112} ;
1213use crate :: providers:: HasParticipants ;
1314use crate :: tracking:: AutoAbortTaskCollection ;
@@ -92,9 +93,9 @@ impl RobustEcdsaSignatureProvider {
9293 . collect ( ) ;
9394
9495 let threshold = mpc_config. participants . threshold as usize ;
95-
96- // TODO: we need to guarantee this is less than the total number of participants in the contract
97- anyhow:: ensure!( running_participants . len ( ) >= 2 * threshold + 1 ) ;
96+ let num_signers = get_number_of_signers ( threshold , running_participants . len ( ) ) ;
97+ let robust_ecdsa_threshold = translate_threshold ( threshold , running_participants . len ( ) ) ;
98+ anyhow:: ensure!( robust_ecdsa_threshold * 2 + 1 <= num_signers ) ;
9899
99100 loop {
100101 progress_tracker. update_progress ( ) ;
@@ -114,13 +115,13 @@ impl RobustEcdsaSignatureProvider {
114115 {
115116 let id = presignature_store. generate_and_reserve_id ( ) ;
116117 let participants = match client. select_random_active_participants_including_me (
117- 2 * threshold + 1 ,
118+ num_signers ,
118119 & running_participants,
119120 ) {
120121 Ok ( participants) => participants,
121122 Err ( e) => {
122123 tracing:: warn!(
123- "Can't choose active participants for a triple : {}. Sleeping." ,
124+ "Can't choose active participants for a robust-ecdsa presignature : {}. Sleeping." ,
124125 e
125126 ) ;
126127 // that should not happen often, so sleeping here is okay
@@ -139,7 +140,7 @@ impl RobustEcdsaSignatureProvider {
139140 let _in_flight = in_flight;
140141 let _semaphore_guard = parallelism_limiter. acquire ( ) . await ?;
141142 let presignature = PresignComputation {
142- threshold,
143+ threshold : robust_ecdsa_threshold ,
143144 keygen_out,
144145 }
145146 . perform_leader_centric_computation (
@@ -177,8 +178,12 @@ impl RobustEcdsaSignatureProvider {
177178 ) -> anyhow:: Result < ( ) > {
178179 let domain_data = self . domain_data ( domain_id) ?;
179180
181+ let number_of_participants = self . mpc_config . participants . participants . len ( ) ;
182+ let threshold = self . mpc_config . participants . threshold as usize ;
183+ let robust_ecdsa_threshold = translate_threshold ( threshold, number_of_participants) ;
184+
180185 FollowerPresignComputation {
181- threshold : self . mpc_config . participants . threshold as usize ,
186+ threshold : robust_ecdsa_threshold ,
182187 keygen_out : domain_data. keyshare ,
183188 out_presignature_store : domain_data. presignature_store ,
184189 out_presignature_id : id,
@@ -224,6 +229,11 @@ impl MpcLeaderCentricComputation<PresignOutput> for PresignComputation {
224229 . map ( Participant :: from)
225230 . collect :: < Vec < _ > > ( ) ;
226231 let me = channel. my_participant_id ( ) ;
232+ println ! (
233+ "computing presign {} {}" ,
234+ self . threshold,
235+ cs_participants. len( )
236+ ) ;
227237 let protocol = presign (
228238 & cs_participants,
229239 me. into ( ) ,
0 commit comments