fn validate_deploy(deploy: &Deploy) -> Result<(), DeployConfigurationFailure> {
    if deploy.approvals.is_empty() {
        warn!(?deploy, "deploy has no approvals");
        return Err(DeployConfigurationFailure::EmptyApprovals);
    }
    let serialized_body = serialize_body(&deploy.payment, &deploy.session);
    let body_hash = Digest::hash(&serialized_body);
    if body_hash != deploy.header.body_hash {
        warn!(?deploy, ?body_hash, "invalid deploy body hash");
        return Err(DeployConfigurationFailure::InvalidBodyHash);
    }

    let serialized_header = serialize_header(&deploy.header);
    let hash = DeployHash::new(Digest::hash(&serialized_header));
    if hash != deploy.hash {
        warn!(?deploy, ?hash, "invalid deploy hash");
        return Err(DeployConfigurationFailure::InvalidDeployHash);
    }

    for (index, approval) in deploy.approvals.iter().enumerate() {
        if let Err(error) = crypto::verify(&deploy.hash, &approval.signature, &approval.signer) {
            warn!(?deploy, "failed to verify approval {}: {}", index, error);
            return Err(DeployConfigurationFailure::InvalidApproval {
                index,
                error_msg: error.to_string(),
            });
        }
    }

    Ok(())
}
// Computationally expensive validity check for a given deploy instance, including
// asymmetric_key signing verification.
Computationally expensive validity check for a given deploy instance, including
asymmetric_key signing verification.
Computationally expensive validity check for a given deploy instance including asymmetric_key signing verification .
fn validate_deploy(deploy: &Deploy) -> Result<(), DeployConfigurationFailure> {
    if deploy.approvals.is_empty() {
        warn!(?deploy, "deploy has no approvals");
        return Err(DeployConfigurationFailure::EmptyApprovals);
    }
    let serialized_body = serialize_body(&deploy.payment, &deploy.session);
    let body_hash = Digest::hash(&serialized_body);
    if body_hash != deploy.header.body_hash {
        warn!(?deploy, ?body_hash, "invalid deploy body hash");
        return Err(DeployConfigurationFailure::InvalidBodyHash);
    }
    let serialized_header = serialize_header(&deploy.header);
    let hash = DeployHash::new(Digest::hash(&serialized_header));
    if hash != deploy.hash {
        warn!(?deploy, ?hash, "invalid deploy hash");
        return Err(DeployConfigurationFailure::InvalidDeployHash);
    }
    for (index, approval) in deploy.approvals.iter().enumerate() {
        if let Err(error) = crypto::verify(&deploy.hash, &approval.signature, &approval.signer) {
            warn!(?deploy, "failed to verify approval {}: {}", index, error);
            return Err(DeployConfigurationFailure::InvalidApproval {
                index,
                error_msg: error.to_string(),
            });
        }
    }
    Ok(())
}
fn validate_deploy ( deploy : & Deploy ) -> Result < ( ) , DeployConfigurationFailure > { if deploy . approvals . is_empty ( ) { warn ! ( deploy " " ) ; return Err ( DeployConfigurationFailure :: EmptyApprovals ) ; } let serialized_body = serialize_body ( & deploy . payment , & deploy . session ) ; let body_hash = Digest :: hash ( & serialized_body ) ; if body_hash != deploy . header . body_hash { warn ! ( deploy body_hash " " ) ; return Err ( DeployConfigurationFailure :: InvalidBodyHash ) ; } let serialized_header = serialize_header ( & deploy . header ) ; let hash = DeployHash :: new ( Digest :: hash ( & serialized_header ) ) ; if hash != deploy . hash { warn ! ( deploy hash " " ) ; return Err ( DeployConfigurationFailure :: InvalidDeployHash ) ; } for ( index , approval ) in deploy . approvals . iter ( ) . enumerate ( ) { if let Err ( error ) = crypto :: verify ( & deploy . hash , & approval . signature , & approval . signer ) { warn ! ( deploy " " index error ) ; return Err ( DeployConfigurationFailure :: InvalidApproval { index , error_msg : error . to_string ( ) , } ) ; } } Ok ( ( ) ) }
Computationally expensive validity check for a given deploy instance, including
asymmetric_key signing verification.
Computationally expensive validity check for a given deploy instance including asymmetric_key signing verification .
deploy
&Deploy
deploy
&Deploy