(rng: &mut StdRng, batch_size: u32, num_parties: u16)
| 187 | let mut rng = StdRng::seed_from_u64(0u64); |
| 188 | |
| 189 | fn check<const SALT_SIZE: usize>(rng: &mut StdRng, batch_size: u32, num_parties: u16) { |
| 190 | let label = b"test".to_vec(); |
| 191 | let mut parties = vec![]; |
| 192 | let mut commitments = vec![]; |
| 193 | |
| 194 | // All parties generate and commit to their share of the joint randomness |
| 195 | let start = Instant::now(); |
| 196 | for i in 1..=num_parties { |
| 197 | let (party, comm) = Party::<Fr, SALT_SIZE>::commit::<_, Sha3_256>( |
| 198 | rng, |
| 199 | i, |
| 200 | batch_size, |
| 201 | label.clone(), |
| 202 | ); |
| 203 | parties.push(party); |
| 204 | commitments.push(comm); |
| 205 | } |
| 206 | let commit_time = start.elapsed(); |
| 207 | |
| 208 | // All parties send commitment to their shares to others |
| 209 | let start = Instant::now(); |
| 210 | for i in 1..=num_parties { |
| 211 | for j in 1..=num_parties { |
| 212 | if i != j { |
| 213 | parties[i as usize - 1] |
| 214 | .receive_commitment(j, commitments[j as usize - 1].clone()) |
| 215 | .unwrap(); |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | let process_commit_time = start.elapsed(); |
| 220 | |
| 221 | // All parties send their shares to others |
| 222 | let start = Instant::now(); |
| 223 | for receiver_id in 1..=num_parties { |
| 224 | for sender_id in 1..=num_parties { |
| 225 | if receiver_id != sender_id { |
| 226 | assert!( |
| 227 | !parties[receiver_id as usize - 1].has_shares_from_all_who_committed() |
| 228 | ); |
| 229 | let share = parties[sender_id as usize - 1].own_shares_and_salts.clone(); |
| 230 | parties[receiver_id as usize - 1] |
| 231 | .receive_shares::<Sha3_256>(sender_id, share) |
| 232 | .unwrap(); |
| 233 | } |
| 234 | } |
| 235 | assert!(parties[receiver_id as usize - 1].has_shares_from_all_who_committed()); |
| 236 | } |
| 237 | let process_shares_time = start.elapsed(); |
| 238 | |
| 239 | // Shares are received correctly |
| 240 | for i in 1..=num_parties { |
| 241 | for j in 1..=num_parties { |
| 242 | if i != j { |
| 243 | assert_eq!( |
| 244 | parties[j as usize - 1].other_shares.get(&i).unwrap(), |
| 245 | &parties[i as usize - 1] |
| 246 | .own_shares_and_salts |
nothing calls this directly
no test coverage detected