fn crypto_verify_dealing(
        &self,
        id: &EcdsaMessageId,
        transcript_params: &IDkgTranscriptParams,
        signed_dealing: &EcdsaSignedDealing,
    ) -> EcdsaChangeSet {
        let dealing = signed_dealing.get();

        // Verify the dealer signature
        if let Err(error) = self
            .crypto
            .verify(signed_dealing, transcript_params.registry_version())
        {
            if error.is_replicated() {
                self.metrics
                    .pre_sign_errors_inc("verify_dealing_signature_permanent");
                return vec![EcdsaChangeAction::HandleInvalid(
                    id.clone(),
                    format!(
                        "Dealing signature validation(permanent error): dealer = {:?},
                              height = {:?}, transcript_id = {:?}, error = {:?}",
                        dealing.idkg_dealing.dealer_id,
                        dealing.requested_height,
                        dealing.idkg_dealing.transcript_id,
                        error
                    ),
                )];
            } else {
                // Defer in case of transient errors
                debug!(
                    self.log,
                    "Dealing signature validation(transient error): dealer = {:?},
                          height = {:?}, transcript_id = {:?}, error = {:?}",
                    dealing.idkg_dealing.dealer_id,
                    dealing.requested_height,
                    dealing.idkg_dealing.transcript_id,
                    error
                );
                self.metrics
                    .pre_sign_errors_inc("verify_dealing_signature_transient");
                return Default::default();
            }
        }

        IDkgProtocol::verify_dealing_public(&*self.crypto, transcript_params, &dealing.idkg_dealing)
            .map_or_else(
                |error| {
                    if error.is_replicated() {
                        self.metrics.pre_sign_errors_inc("verify_dealing_permanent");
                        vec![EcdsaChangeAction::HandleInvalid(
                            id.clone(),
                            format!(
                                "Dealing validation(permanent error): dealer = {:?},
                              height = {:?}, transcript_id = {:?}, error = {:?}",
                                dealing.idkg_dealing.dealer_id,
                                dealing.requested_height,
                                dealing.idkg_dealing.transcript_id,
                                error
                            ),
                        )]
                    } else {
                        // Defer in case of transient errors
                        debug!(
                            self.log,
                            "Dealing validation(transient error): dealer = {:?},
                          height = {:?}, transcript_id = {:?}, error = {:?}",
                            dealing.idkg_dealing.dealer_id,
                            dealing.requested_height,
                            dealing.idkg_dealing.transcript_id,
                            error
                        );
                        self.metrics.pre_sign_errors_inc("verify_dealing_transient");
                        Default::default()
                    }
                },
                |()| {
                    self.metrics.pre_sign_metrics_inc("dealing_received");
                    vec![EcdsaChangeAction::MoveToValidated(id.clone())]
                },
            )
    }
/// Helper to verify a dealing received for a transcript we are building
Helper to verify a dealing received for a transcript we are building
Helper to verify a dealing received for a transcript we are building
fn crypto_verify_dealing(
        &self,
        id: &EcdsaMessageId,
        transcript_params: &IDkgTranscriptParams,
        signed_dealing: &EcdsaSignedDealing,
    ) -> EcdsaChangeSet {
        let dealing = signed_dealing.get();
        // Verify the dealer signature
        if let Err(error) = self
            .crypto
            .verify(signed_dealing, transcript_params.registry_version())
        {
            if error.is_replicated() {
                self.metrics
                    .pre_sign_errors_inc("verify_dealing_signature_permanent");
                return vec![EcdsaChangeAction::HandleInvalid(
                    id.clone(),
                    format!(
                        "Dealing signature validation(permanent error): dealer = {:?},
                              height = {:?}, transcript_id = {:?}, error = {:?}",
                        dealing.idkg_dealing.dealer_id,
                        dealing.requested_height,
                        dealing.idkg_dealing.transcript_id,
                        error
                    ),
                )];
            } else {
                // Defer in case of transient errors
                debug!(
                    self.log,
                    "Dealing signature validation(transient error): dealer = {:?},
                          height = {:?}, transcript_id = {:?}, error = {:?}",
                    dealing.idkg_dealing.dealer_id,
                    dealing.requested_height,
                    dealing.idkg_dealing.transcript_id,
                    error
                );
                self.metrics
                    .pre_sign_errors_inc("verify_dealing_signature_transient");
                return Default::default();
            }
        }
        IDkgProtocol::verify_dealing_public(&*self.crypto, transcript_params, &dealing.idkg_dealing)
            .map_or_else(
                |error| {
                    if error.is_replicated() {
                        self.metrics.pre_sign_errors_inc("verify_dealing_permanent");
                        vec![EcdsaChangeAction::HandleInvalid(
                            id.clone(),
                            format!(
                                "Dealing validation(permanent error): dealer = {:?},
                              height = {:?}, transcript_id = {:?}, error = {:?}",
                                dealing.idkg_dealing.dealer_id,
                                dealing.requested_height,
                                dealing.idkg_dealing.transcript_id,
                                error
                            ),
                        )]
                    } else {
                        // Defer in case of transient errors
                        debug!(
                            self.log,
                            "Dealing validation(transient error): dealer = {:?},
                          height = {:?}, transcript_id = {:?}, error = {:?}",
                            dealing.idkg_dealing.dealer_id,
                            dealing.requested_height,
                            dealing.idkg_dealing.transcript_id,
                            error
                        );
                        self.metrics.pre_sign_errors_inc("verify_dealing_transient");
                        Default::default()
                    }
                },
                |()| {
                    self.metrics.pre_sign_metrics_inc("dealing_received");
                    vec![EcdsaChangeAction::MoveToValidated(id.clone())]
                },
            )
    }
fn crypto_verify_dealing ( & self , id : & EcdsaMessageId , transcript_params : & IDkgTranscriptParams , signed_dealing : & EcdsaSignedDealing , ) -> EcdsaChangeSet { let dealing = signed_dealing . get ( ) ; // Verify the dealer signature if let Err ( error ) = self . crypto . verify ( signed_dealing , transcript_params . registry_version ( ) ) { if error . is_replicated ( ) { self . metrics . pre_sign_errors_inc ( " " ) ; return vec ! [ EcdsaChangeAction HandleInvalid ( id clone ( ) format ( " " dealing idkg_dealing dealer_id dealing requested_height dealing idkg_dealing transcript_id error ) ) ] ; } else { // Defer in case of transient errors debug ! ( self log " " dealing idkg_dealing dealer_id dealing requested_height dealing idkg_dealing transcript_id error ) ; self . metrics . pre_sign_errors_inc ( " " ) ; return Default :: default ( ) ; } } IDkgProtocol :: verify_dealing_public ( & * self . crypto , transcript_params , & dealing . idkg_dealing ) . map_or_else ( | error | { if error . is_replicated ( ) { self . metrics . pre_sign_errors_inc ( " " ) ; vec ! [ EcdsaChangeAction HandleInvalid ( id clone ( ) format ( " " dealing idkg_dealing dealer_id dealing requested_height dealing idkg_dealing transcript_id error ) ) ] } else { // Defer in case of transient errors debug ! ( self log " " dealing idkg_dealing dealer_id dealing requested_height dealing idkg_dealing transcript_id error ) ; self . metrics . pre_sign_errors_inc ( " " ) ; Default :: default ( ) } } , | ( ) | { self . metrics . pre_sign_metrics_inc ( " " ) ; vec ! [ EcdsaChangeAction MoveToValidated ( id clone ( ) ) ] } , ) }
Helper to verify a dealing received for a transcript we are building
Helper to verify a dealing received for a transcript we are building
&self
id
&EcdsaMessageId
transcript_params
&IDkgTranscriptParams
signed_dealing
&EcdsaSignedDealing
&self
id
&EcdsaMessageId
transcript_params
&IDkgTranscriptParams
signed_dealing
&EcdsaSignedDealing