Skip to content

Commit

Permalink
check
Browse files Browse the repository at this point in the history
  • Loading branch information
eichhorl committed Mar 4, 2025
1 parent d37c766 commit 88c6fa8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions rs/crypto/utils/canister_threshold_sig/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ pub fn derive_vetkd_public_key(
Ok(derived_key.serialize().to_vec())
}

/// Checks if the given bytes deserialize into a correct public key
pub fn is_valid_transport_public_key(transport_public_key: &[u8; 48]) -> bool {
G2Affine::deserialize(transport_public_key).is_ok()
}

#[derive(Clone, Eq, PartialEq, Debug)]
pub enum VetKdPublicKeyDeriveError {
InvalidAlgorithmId,
Expand Down
8 changes: 7 additions & 1 deletion rs/execution_environment/src/execution_environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use ic_base_types::PrincipalId;
use ic_config::execution_environment::Config as ExecutionConfig;
use ic_config::flag_status::FlagStatus;
use ic_crypto_utils_canister_threshold_sig::{
derive_threshold_public_key, derive_vetkd_public_key,
derive_threshold_public_key, derive_vetkd_public_key, is_valid_transport_public_key,
};
use ic_cycles_account_manager::{
is_delayed_ingress_induction_cost, CyclesAccountManager, IngressInductionCost,
Expand Down Expand Up @@ -2859,6 +2859,12 @@ impl ExecutionEnvironment {
),
));
};
if !is_valid_transport_public_key(&args.encryption_public_key) {
return Err(UserError::new(
ErrorCode::CanisterRejectedMessage,
"The provided transport public key is invalid.",
));
}
self.sign_with_threshold(
(*request).clone(),
ThresholdArguments::VetKd(VetKdArguments {
Expand Down

0 comments on commit 88c6fa8

Please sign in to comment.