fn verify_contribution(
    path_before: &str,
    path_after: &str,
    participant_contrib: [u8; 64],
    raw_subgroup_checks: bool,
) {
    #[allow(clippy::large_enum_variant)]
    enum Message {
        Done(MPCSmall),
        Error(io::Error),
    }

    let start_total = Instant::now();

    info!(
        "verifying contribution:\n    before: {}\n    after: {}\n    contrib: {}",
        path_before,
        path_after,
        hex_string(&participant_contrib)
    );

    let (before_tx, before_rx) = channel::<Message>();
    let (after_tx, after_rx) = channel::<Message>();

    let path_before = path_before.to_string();
    let path_after = path_after.to_string();

    let before_thread: JoinHandle<()> = thread::spawn(move || {
        let start_read = Instant::now();
        let is_large = path_before.contains("large");
        let is_raw = path_before.ends_with("raw");

        if !is_raw {
            warn!("using non-raw 'before' params");
        }

        if is_raw {
            warn!("skipping subgroup checks when deserializing small-raw 'before' params");
        }

        let read_res: io::Result<MPCSmall> = if is_large {
            info!(
                "reading large 'before' params as `MPCSmall`: {}",
                path_before
            );
            read_small_params_from_large_file(&path_before)
        } else {
            info!(
                "reading small 'before' params as `MPCSmall`: {}",
                path_before
            );
            File::open(&path_before).and_then(|file| {
                let mut reader = BufReader::with_capacity(1024 * 1024, file);
                MPCSmall::read(&mut reader, is_raw, false)
            })
        };

        match read_res {
            Ok(params) => {
                let dt_read = start_read.elapsed().as_secs();
                info!("successfully read 'before' params, dt_read={}s", dt_read);
                before_tx.send(Message::Done(params)).expect("send failure");
            }
            Err(e) => {
                error!("failed to read 'before' params: {}", e);
                before_tx.send(Message::Error(e)).expect("send failure");
            }
        };
    });

    let after_thread: JoinHandle<()> = thread::spawn(move || {
        let start_read = Instant::now();
        let is_large = path_after.contains("large");
        let is_raw = path_after.ends_with("raw");

        if !is_raw {
            warn!("using non-raw 'after' params");
        }

        if is_raw && !raw_subgroup_checks {
            warn!("skipping subgroup checks when deserializing small-raw 'after' params")
        }

        let read_res: io::Result<MPCSmall> = if is_large {
            info!("reading large 'after' params as `MPCSmall`: {}", path_after);
            read_small_params_from_large_file(&path_after)
        } else {
            info!("reading small 'after' params as `MPCSmall`: {}", path_after);
            File::open(&path_after).and_then(|file| {
                let mut reader = BufReader::with_capacity(1024 * 1024, file);
                MPCSmall::read(&mut reader, is_raw, raw_subgroup_checks)
            })
        };

        match read_res {
            Ok(params) => {
                let dt_read = start_read.elapsed().as_secs();
                info!("successfully read 'after' params, dt_read={}s", dt_read);
                after_tx.send(Message::Done(params)).expect("send failure");
            }
            Err(e) => {
                error!("failed to read 'after' params: {}", e);
                after_tx.send(Message::Error(e)).expect("send failure");
            }
        };
    });

    let mut before_params: Option<MPCSmall> = None;
    let mut after_params: Option<MPCSmall> = None;

    loop {
        if before_params.is_none() {
            match before_rx.try_recv() {
                Ok(Message::Done(params)) => {
                    before_params = Some(params);
                    info!("received 'before' params from thread");
                }
                Ok(Message::Error(e)) => panic!("'before' thread panic-ed: {}", e),
                Err(TryRecvError::Disconnected) => panic!("'before' thread disconnected"),
                Err(TryRecvError::Empty) => {}
            };
        }

        if after_params.is_none() {
            match after_rx.try_recv() {
                Ok(Message::Done(params)) => {
                    after_params = Some(params);
                    info!("received 'after' params from thread");
                }
                Ok(Message::Error(e)) => panic!("'after' thread panic-ed: {}", e),
                Err(TryRecvError::Disconnected) => panic!("'after' thread disconnected"),
                Err(TryRecvError::Empty) => {}
            };
        }

        if before_params.is_some() && after_params.is_some() {
            break;
        }

        thread::sleep(Duration::from_secs(3));
    }

    before_thread.join().expect("thread join failure");
    after_thread.join().expect("thread join failure");

    info!("verifying contribution");
    let start_verification = Instant::now();

    let calculated_contrib = phase2::small::verify_contribution_small(
        &before_params.expect("before params failure"),
        &after_params.expect("after params failure"),
    )
    .expect("failed to calculate expected contribution");

    assert_eq!(
        &participant_contrib[..],
        &calculated_contrib[..],
        "provided contribution hash does not match expected contribution hash \
        \n\tprovided: {}\n\texpected: {}",
        hex_string(&participant_contrib),
        hex_string(&calculated_contrib)
    );

    info!(
        "successfully verified contribution, dt_verify={}s, dt_total={}s",
        start_verification.elapsed().as_secs(),
        start_total.elapsed().as_secs()
    );
}
/// If `raw_subgroup_checks` is true, then `verify_contribution` ensures that the G1 points of the 'after' contribution
/// are in the correct subgroup. This is expensive, so the 'before' contribution is not checked. This assumes that all
/// 'after' contributions will be separately verified, and ensures that the subgroup check will happen once (but no
/// more). This means the very first 'before' params will not have the subgroup check. However, the verifier will have
/// constructed these deterministically such that they are known to be in the subgroup.
If `raw_subgroup_checks` is true, then `verify_contribution` ensures that the G1 points of the 'after' contribution
are in the correct subgroup. This is expensive, so the 'before' contribution is not checked. This assumes that all
'after' contributions will be separately verified, and ensures that the subgroup check will happen once (but no
more). This means the very first 'before' params will not have the subgroup check. However, the verifier will have
constructed these deterministically such that they are known to be in the subgroup.
If ` raw_subgroup_checks ` is true then ` verify_contribution ` ensures that the G1 points of the ' after ' contribution are in the correct subgroup . This is expensive so the ' before ' contribution is not checked . This assumes that all ' after ' contributions will be separately verified and ensures that the subgroup check will happen once ( but no more ) . This means the very first ' before ' params will not have the subgroup check . However the verifier will have constructed these deterministically such that they are known to be in the subgroup .
fn verify_contribution(
    path_before: &str,
    path_after: &str,
    participant_contrib: [u8; 64],
    raw_subgroup_checks: bool,
) {
    #[allow(clippy::large_enum_variant)]
    enum Message {
        Done(MPCSmall),
        Error(io::Error),
    }
    let start_total = Instant::now();
    info!(
        "verifying contribution:\n    before: {}\n    after: {}\n    contrib: {}",
        path_before,
        path_after,
        hex_string(&participant_contrib)
    );
    let (before_tx, before_rx) = channel::<Message>();
    let (after_tx, after_rx) = channel::<Message>();
    let path_before = path_before.to_string();
    let path_after = path_after.to_string();
    let before_thread: JoinHandle<()> = thread::spawn(move || {
        let start_read = Instant::now();
        let is_large = path_before.contains("large");
        let is_raw = path_before.ends_with("raw");
        if !is_raw {
            warn!("using non-raw 'before' params");
        }
        if is_raw {
            warn!("skipping subgroup checks when deserializing small-raw 'before' params");
        }
        let read_res: io::Result<MPCSmall> = if is_large {
            info!(
                "reading large 'before' params as `MPCSmall`: {}",
                path_before
            );
            read_small_params_from_large_file(&path_before)
        } else {
            info!(
                "reading small 'before' params as `MPCSmall`: {}",
                path_before
            );
            File::open(&path_before).and_then(|file| {
                let mut reader = BufReader::with_capacity(1024 * 1024, file);
                MPCSmall::read(&mut reader, is_raw, false)
            })
        };
        match read_res {
            Ok(params) => {
                let dt_read = start_read.elapsed().as_secs();
                info!("successfully read 'before' params, dt_read={}s", dt_read);
                before_tx.send(Message::Done(params)).expect("send failure");
            }
            Err(e) => {
                error!("failed to read 'before' params: {}", e);
                before_tx.send(Message::Error(e)).expect("send failure");
            }
        };
    });
    let after_thread: JoinHandle<()> = thread::spawn(move || {
        let start_read = Instant::now();
        let is_large = path_after.contains("large");
        let is_raw = path_after.ends_with("raw");
        if !is_raw {
            warn!("using non-raw 'after' params");
        }
        if is_raw && !raw_subgroup_checks {
            warn!("skipping subgroup checks when deserializing small-raw 'after' params")
        }
        let read_res: io::Result<MPCSmall> = if is_large {
            info!("reading large 'after' params as `MPCSmall`: {}", path_after);
            read_small_params_from_large_file(&path_after)
        } else {
            info!("reading small 'after' params as `MPCSmall`: {}", path_after);
            File::open(&path_after).and_then(|file| {
                let mut reader = BufReader::with_capacity(1024 * 1024, file);
                MPCSmall::read(&mut reader, is_raw, raw_subgroup_checks)
            })
        };
        match read_res {
            Ok(params) => {
                let dt_read = start_read.elapsed().as_secs();
                info!("successfully read 'after' params, dt_read={}s", dt_read);
                after_tx.send(Message::Done(params)).expect("send failure");
            }
            Err(e) => {
                error!("failed to read 'after' params: {}", e);
                after_tx.send(Message::Error(e)).expect("send failure");
            }
        };
    });
    let mut before_params: Option<MPCSmall> = None;
    let mut after_params: Option<MPCSmall> = None;
    loop {
        if before_params.is_none() {
            match before_rx.try_recv() {
                Ok(Message::Done(params)) => {
                    before_params = Some(params);
                    info!("received 'before' params from thread");
                }
                Ok(Message::Error(e)) => panic!("'before' thread panic-ed: {}", e),
                Err(TryRecvError::Disconnected) => panic!("'before' thread disconnected"),
                Err(TryRecvError::Empty) => {}
            };
        }
        if after_params.is_none() {
            match after_rx.try_recv() {
                Ok(Message::Done(params)) => {
                    after_params = Some(params);
                    info!("received 'after' params from thread");
                }
                Ok(Message::Error(e)) => panic!("'after' thread panic-ed: {}", e),
                Err(TryRecvError::Disconnected) => panic!("'after' thread disconnected"),
                Err(TryRecvError::Empty) => {}
            };
        }
        if before_params.is_some() && after_params.is_some() {
            break;
        }
        thread::sleep(Duration::from_secs(3));
    }
    before_thread.join().expect("thread join failure");
    after_thread.join().expect("thread join failure");
    info!("verifying contribution");
    let start_verification = Instant::now();
    let calculated_contrib = phase2::small::verify_contribution_small(
        &before_params.expect("before params failure"),
        &after_params.expect("after params failure"),
    )
    .expect("failed to calculate expected contribution");
    assert_eq!(
        &participant_contrib[..],
        &calculated_contrib[..],
        "provided contribution hash does not match expected contribution hash \
        \n\tprovided: {}\n\texpected: {}",
        hex_string(&participant_contrib),
        hex_string(&calculated_contrib)
    );
    info!(
        "successfully verified contribution, dt_verify={}s, dt_total={}s",
        start_verification.elapsed().as_secs(),
        start_total.elapsed().as_secs()
    );
}
fn verify_contribution ( path_before : & str , path_after : & str , participant_contrib : [ u8 ; 64 ] , raw_subgroup_checks : bool , ) { # [ allow ( clippy large_enum_variant ) ] enum Message { Done ( MPCSmall ) , Error ( io :: Error ) , } let start_total = Instant :: now ( ) ; info ! ( " \n \n \n " path_before path_after hex_string ( participant_contrib ) ) ; let ( before_tx , before_rx ) = channel :: < Message > ( ) ; let ( after_tx , after_rx ) = channel :: < Message > ( ) ; let path_before = path_before . to_string ( ) ; let path_after = path_after . to_string ( ) ; let before_thread : JoinHandle < ( ) > = thread :: spawn ( move | | { let start_read = Instant :: now ( ) ; let is_large = path_before . contains ( " " ) ; let is_raw = path_before . ends_with ( " " ) ; if ! is_raw { warn ! ( " " ) ; } if is_raw { warn ! ( " " ) ; } let read_res : io :: Result < MPCSmall > = if is_large { info ! ( " " path_before ) ; read_small_params_from_large_file ( & path_before ) } else { info ! ( " " path_before ) ; File :: open ( & path_before ) . and_then ( | file | { let mut reader = BufReader :: with_capacity ( 1024 * 1024 , file ) ; MPCSmall :: read ( & mut reader , is_raw , false ) } ) } ; match read_res { Ok ( params ) => { let dt_read = start_read . elapsed ( ) . as_secs ( ) ; info ! ( " " dt_read ) ; before_tx . send ( Message :: Done ( params ) ) . expect ( " " ) ; } Err ( e ) => { error ! ( " " e ) ; before_tx . send ( Message :: Error ( e ) ) . expect ( " " ) ; } } ; } ) ; let after_thread : JoinHandle < ( ) > = thread :: spawn ( move | | { let start_read = Instant :: now ( ) ; let is_large = path_after . contains ( " " ) ; let is_raw = path_after . ends_with ( " " ) ; if ! is_raw { warn ! ( " " ) ; } if is_raw && ! raw_subgroup_checks { warn ! ( " " ) } let read_res : io :: Result < MPCSmall > = if is_large { info ! ( " " path_after ) ; read_small_params_from_large_file ( & path_after ) } else { info ! ( " " path_after ) ; File :: open ( & path_after ) . and_then ( | file | { let mut reader = BufReader :: with_capacity ( 1024 * 1024 , file ) ; MPCSmall :: read ( & mut reader , is_raw , raw_subgroup_checks ) } ) } ; match read_res { Ok ( params ) => { let dt_read = start_read . elapsed ( ) . as_secs ( ) ; info ! ( " " dt_read ) ; after_tx . send ( Message :: Done ( params ) ) . expect ( " " ) ; } Err ( e ) => { error ! ( " " e ) ; after_tx . send ( Message :: Error ( e ) ) . expect ( " " ) ; } } ; } ) ; let mut before_params : Option < MPCSmall > = None ; let mut after_params : Option < MPCSmall > = None ; loop { if before_params . is_none ( ) { match before_rx . try_recv ( ) { Ok ( Message :: Done ( params ) ) => { before_params = Some ( params ) ; info ! ( " " ) ; } Ok ( Message :: Error ( e ) ) => panic ! ( " " e ) , Err ( TryRecvError :: Disconnected ) => panic ! ( " " ) , Err ( TryRecvError :: Empty ) => { } } ; } if after_params . is_none ( ) { match after_rx . try_recv ( ) { Ok ( Message :: Done ( params ) ) => { after_params = Some ( params ) ; info ! ( " " ) ; } Ok ( Message :: Error ( e ) ) => panic ! ( " " e ) , Err ( TryRecvError :: Disconnected ) => panic ! ( " " ) , Err ( TryRecvError :: Empty ) => { } } ; } if before_params . is_some ( ) && after_params . is_some ( ) { break ; } thread :: sleep ( Duration :: from_secs ( 3 ) ) ; } before_thread . join ( ) . expect ( " " ) ; after_thread . join ( ) . expect ( " " ) ; info ! ( " " ) ; let start_verification = Instant :: now ( ) ; let calculated_contrib = phase2 :: small :: verify_contribution_small ( & before_params . expect ( " " ) , & after_params . expect ( " " ) , ) . expect ( " " ) ; assert_eq ! ( participant_contrib [ ] calculated_contrib [ ] " \
 \n \t \n \t " hex_string ( participant_contrib ) hex_string ( calculated_contrib ) ) ; info ! ( " " start_verification elapsed ( ) as_secs ( ) start_total elapsed ( ) as_secs ( ) ) ; }
If `raw_subgroup_checks` is true, then `verify_contribution` ensures that the G1 points of the 'after' contribution
are in the correct subgroup.
If ` raw_subgroup_checks ` is true then ` verify_contribution ` ensures that the G1 points of the ' after ' contribution are in the correct subgroup .
path_before
&str
path_after
&str
participant_contrib
[u8; 64]
raw_subgroup_checks
bool
path_before
&str
path_after
&str
participant_contrib
[u8; 64]
raw_subgroup_checks
bool