@@ -97,17 +97,14 @@ pub async fn hamming_distance(
9797 // Remix
9898 tracing:: trace!( "remix self" ) ;
9999 let ( mut x_code, mut y_code) = {
100- let inner_state = Arc :: clone ( & state) ;
100+ let state = Arc :: clone ( & state) ;
101101 rokio:: spawn ( move || -> Result < _ , CryptoError > {
102- crypto:: remix (
103- & mut x_code,
104- & mut y_code,
105- inner_state. pub_key_set ( ) . shared_key ( ) ,
106- ) ?;
102+ crypto:: remix ( & mut x_code, & mut y_code, state. pub_key_set ( ) . shared_key ( ) ) ?;
107103 Ok ( ( x_code, y_code) )
108104 } )
109105 . await ?
110106 } ;
107+ // This algorithm runs serially and it's not fast to serialize and deserialize 2*25600 bits
111108 tracing:: trace!( "remix participants" ) ;
112109 for node in & state. crypto . participants {
113110 ( x_code, y_code) = request_remix (
@@ -120,23 +117,30 @@ pub async fn hamming_distance(
120117 . unwrap_or ( ( x_code, y_code) ) ;
121118 tracing:: trace!( id = ?node, "remix participant" ) ;
122119 }
123- let ( x_code, y_code) = ( Arc :: new ( x_code) , Arc :: new ( y_code) ) ;
120+
121+ let x_code = Arc :: new ( x_code) ;
122+ let y_code = Arc :: new ( y_code) ;
124123
125124 // Decrypt
126125 tracing:: trace!( "request shares" ) ;
127126 let ( x_shares, y_shares) = {
128- let ( x_state, y_state) = ( Arc :: clone ( & state) , Arc :: clone ( & state) ) ;
129127 let ( x_inner_code, y_inner_code) = ( Arc :: clone ( & x_code) , Arc :: clone ( & y_code) ) ;
130128
131129 let ( mut x_shares, mut y_shares, x_self_share, y_self_share) = tokio:: join!(
132130 request_all_shares( & x_code, & state) ,
133131 request_all_shares( & y_code, & state) ,
134- rokio:: spawn( move || {
135- crypto:: decryption_share_for( & x_state. crypto. active_participant, & x_inner_code)
136- } ) ,
137- rokio:: spawn( move || {
138- crypto:: decryption_share_for( & y_state. crypto. active_participant, & y_inner_code)
139- } )
132+ {
133+ let state = Arc :: clone( & state) ;
134+ rokio:: spawn( move || {
135+ crypto:: decryption_share_for( & state. crypto. active_participant, & x_inner_code)
136+ } )
137+ } ,
138+ {
139+ let state = Arc :: clone( & state) ;
140+ rokio:: spawn( move || {
141+ crypto:: decryption_share_for( & state. crypto. active_participant, & y_inner_code)
142+ } )
143+ }
140144 ) ;
141145 x_shares. push ( x_self_share) ;
142146 y_shares. push ( y_self_share) ;
0 commit comments