fn validate_node_signing_key(
    node_signing_key: &Option<PublicKey>,
    node_id: NodeId,
) -> Result<(), KeyValidationError> {
    let pubkey_proto = node_signing_key
        .as_ref()
        .ok_or_else(|| invalid_node_signing_key_error("key is missing"))?;

    let pubkey_bytes = BasicSigEd25519PublicKeyBytes::try_from(pubkey_proto)
        .map_err(|e| invalid_node_signing_key_error(format!("{}", e)))?;

    if node_id != derive_node_id(pubkey_bytes) {
        return Err(invalid_node_signing_key_error(format!(
            "key not valid for node ID {}",
            node_id
        )));
    }
    if !ic_crypto_internal_basic_sig_ed25519::verify_public_key(&pubkey_bytes) {
        return Err(invalid_node_signing_key_error("verification failed"));
    }
    Ok(())
}
/// Validates a node's signing key.
///
/// See the crate documentation for the exact checks that are performed.
Validates a node's signing key.
See the crate documentation for the exact checks that are performed.
Validates a node ' s signing key . See the crate documentation for the exact checks that are performed .
fn validate_node_signing_key(
    node_signing_key: &Option<PublicKey>,
    node_id: NodeId,
) -> Result<(), KeyValidationError> {
    let pubkey_proto = node_signing_key
        .as_ref()
        .ok_or_else(|| invalid_node_signing_key_error("key is missing"))?;
    let pubkey_bytes = BasicSigEd25519PublicKeyBytes::try_from(pubkey_proto)
        .map_err(|e| invalid_node_signing_key_error(format!("{}", e)))?;
    if node_id != derive_node_id(pubkey_bytes) {
        return Err(invalid_node_signing_key_error(format!(
            "key not valid for node ID {}",
            node_id
        )));
    }
    if !ic_crypto_internal_basic_sig_ed25519::verify_public_key(&pubkey_bytes) {
        return Err(invalid_node_signing_key_error("verification failed"));
    }
    Ok(())
}
fn validate_node_signing_key ( node_signing_key : & Option < PublicKey > , node_id : NodeId , ) -> Result < ( ) , KeyValidationError > { let pubkey_proto = node_signing_key . as_ref ( ) . ok_or_else ( | | invalid_node_signing_key_error ( " " ) ) ? ; let pubkey_bytes = BasicSigEd25519PublicKeyBytes :: try_from ( pubkey_proto ) . map_err ( | e | invalid_node_signing_key_error ( format ! ( " " e ) ) ) ? ; if node_id != derive_node_id ( pubkey_bytes ) { return Err ( invalid_node_signing_key_error ( format ! ( " " node_id ) ) ) ; } if ! ic_crypto_internal_basic_sig_ed25519 :: verify_public_key ( & pubkey_bytes ) { return Err ( invalid_node_signing_key_error ( " " ) ) ; } Ok ( ( ) ) }
Validates a node's signing key.
Validates a node ' s signing key .
node_signing_key
&Option<PublicKey>
node_id
NodeId
node_signing_key
&Option<PublicKey>
node_id
NodeId