/// Verifies that an incorrect algorithm id causes dealing to fail.
///
/// Note: This error SHOULD be caught immediately, so there is no point in
/// returning the result for further use.
///
/// # Side effects
/// Some randomness is consumed from rng.  The state is completely
/// unchanged.
Verifies that an incorrect algorithm id causes dealing to fail.
Note: This error SHOULD be caught immediately, so there is no point in
returning the result for further use.
Verifies that an incorrect algorithm id causes dealing to fail . Note : This error SHOULD be caught immediately so there is no point in returning the result for further use .
pub fn deal_with_incorrect_algorithm_id_should_fail(&mut self, rng: &mut ChaCha20Rng) {
        // Note: We assume that any change in algorithm id makes this invalid.  At
        // present this is true, however if we introduce a new algorithm that uses the
        // same type of forward secure encryption key, this would have to change.
        let incorrect_algorithm_id: AlgorithmId = loop {
            let algorithm_id = random_algorithm_id(rng);
            if algorithm_id != self.config.algorithm_id {
                break algorithm_id;
            }
        };
        let (_dealer_index, dealer_id) = self
            .config
            .dealers
            .iter()
            .choose(rng)
            .expect("Config has no dealers");
        let dealer_node = self
            .network
            .nodes_by_node_id
            .get_mut(&dealer_id)
            .expect("Could not find dealer in nodes");
        let dealing = dealer_node.create_dealing(
            incorrect_algorithm_id,
            self.config
                .dealers
                .position(dealer_node.node_id)
                .expect("The node is not in the set of Dealers"),
            self.config.threshold.get(),
            self.config.epoch,
            self.config.receiver_keys.clone(),
            self.config
                .resharing_transcript
                .as_ref()
                .map(CspPublicCoefficients::from),
        );
        match dealing {
            Ok(_) => panic!(
                "Dealing should fail with AlgorithmId: {:?}",
                incorrect_algorithm_id
            ),
            Err(CspDkgCreateReshareDealingError::UnsupportedAlgorithmId(algorithm_id)) => {
                assert_eq!(
                    algorithm_id, incorrect_algorithm_id,
                    "Wrong algorithm_id reported"
                )
            }
            Err(error) => panic!("Incorrect error: {:?}", error),
        }
    }
pub fn deal_with_incorrect_algorithm_id_should_fail ( & mut self , rng : & mut ChaCha20Rng ) { // Note: We assume that any change in algorithm id makes this invalid.  At // present this is true, however if we introduce a new algorithm that uses the // same type of forward secure encryption key, this would have to change. let incorrect_algorithm_id : AlgorithmId = loop { let algorithm_id = random_algorithm_id ( rng ) ; if algorithm_id != self . config . algorithm_id { break algorithm_id ; } } ; let ( _dealer_index , dealer_id ) = self . config . dealers . iter ( ) . choose ( rng ) . expect ( " " ) ; let dealer_node = self . network . nodes_by_node_id . get_mut ( & dealer_id ) . expect ( " " ) ; let dealing = dealer_node . create_dealing ( incorrect_algorithm_id , self . config . dealers . position ( dealer_node . node_id ) . expect ( " " ) , self . config . threshold . get ( ) , self . config . epoch , self . config . receiver_keys . clone ( ) , self . config . resharing_transcript . as_ref ( ) . map ( CspPublicCoefficients :: from ) , ) ; match dealing { Ok ( _ ) => panic ! ( " " incorrect_algorithm_id ) , Err ( CspDkgCreateReshareDealingError :: UnsupportedAlgorithmId ( algorithm_id ) ) => { assert_eq ! ( algorithm_id incorrect_algorithm_id " " ) } Err ( error ) => panic ! ( " " error ) , } }
Verifies that an incorrect algorithm id causes dealing to fail.
Verifies that an incorrect algorithm id causes dealing to fail .
&mut self
rng
&mut ChaCha20Rng
side effects
Some randomness is consumed from rng.  The state is completely
unchanged.
Some randomness is consumed from rng . The state is completely unchanged .