From f574b322818930cf87f5a739a3045dd81daa86f2 Mon Sep 17 00:00:00 2001 From: parodyBit <58690522+parodyBit@users.noreply.github.com> Date: Thu, 2 Jan 2025 10:28:18 -0700 Subject: [PATCH] Include validator pkh in authorization --- node/src/actors/json_rpc/api.rs | 10 ++++++---- src/cli/node/json_rpc_client.rs | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/node/src/actors/json_rpc/api.rs b/node/src/actors/json_rpc/api.rs index a3ba3a632..8a3842347 100644 --- a/node/src/actors/json_rpc/api.rs +++ b/node/src/actors/json_rpc/api.rs @@ -2045,10 +2045,12 @@ pub async fn stake(params: Result) -> JsonRpcResult { // This is the actual message that gets signed as part of the authorization let msg = withdrawer.as_secp256k1_msg(); - let authorization = params - .authorization - .try_do_magic(|hex_str| KeyedSignature::from_recoverable_hex(&hex_str, &msg)) - .map_err(internal_error)?; + let authorization = params.authorization.try_do_magic(|hex_str| { + KeyedSignature::from_recoverable_hex( + &hex_str[hex_str.char_indices().nth_back(129).unwrap().0..], + &msg, + ) + }).map_err(internal_error)?; let validator = PublicKeyHash::from_public_key(&authorization.public_key); log::debug!( "[STAKE] A stake authorization was provided, and it was signed by validator {}", diff --git a/src/cli/node/json_rpc_client.rs b/src/cli/node/json_rpc_client.rs index ea4be0786..5e17f6fa0 100644 --- a/src/cli/node/json_rpc_client.rs +++ b/src/cli/node/json_rpc_client.rs @@ -1039,8 +1039,19 @@ pub fn authorize_st(addr: SocketAddr, withdrawer: Option) -> Result<(), let message = authorization.withdrawer.as_secp256k1_msg(); - let auth_bytes = authorization.signature.to_recoverable_bytes(&message)?; - let auth_string = hex::encode(auth_bytes); + let auth_string = { + let validator_bytes: [u8; 20] = authorization + .signature + .public_key + .pkh() + .as_ref() + .try_into()?; + let signature_bytes: [u8; 65] = authorization + .signature + .to_recoverable_bytes(&message) + .unwrap(); + hex::encode([&validator_bytes[..], &signature_bytes[..]].concat()) + }; let auth_qr = qrcode::QrCode::new(&auth_string)?; let auth_ascii = auth_qr