Skip to content

Commit 47224cd

Browse files
refactor: improve error handling in hex parsing and clean up debug logs
1 parent d63a3b5 commit 47224cd

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

post-compute/src/compute/utils/hash_utils.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use sha256::{Sha256Digest, digest};
44
pub fn concatenate_and_hash(hexa_strings: &[&str]) -> String {
55
let mut hasher = Keccak256::default();
66
for hexa_string in hexa_strings {
7-
println!("value {hexa_string}");
87
hasher.update(hex_string_to_byte_array(hexa_string));
98
}
109
format!("0x{:x}", hasher.finalize())
@@ -19,15 +18,19 @@ pub fn hex_string_to_byte_array(input: &str) -> Vec<u8> {
1918

2019
let mut data: Vec<u8> = vec![];
2120
let start_idx = if len % 2 != 0 {
22-
let byte = u8::from_str_radix(&clean_input[0..1], 16).expect("");
21+
let byte =
22+
u8::from_str_radix(&clean_input[0..1], 16).expect("Invalid hex digit in input string");
2323
data.push(byte);
2424
1
2525
} else {
2626
0
2727
};
2828

2929
for i in (start_idx..len).step_by(2) {
30-
data.push(u8::from_str_radix(&clean_input[i..i + 2], 16).expect(""));
30+
data.push(
31+
u8::from_str_radix(&clean_input[i..i + 2], 16)
32+
.expect("Invalid hex digit in input string"),
33+
);
3134
}
3235

3336
data

pre-compute/src/compute/signer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn sign_enclave_challenge(
4545
) -> Result<String, ReplicateStatusCause> {
4646
let signer: PrivateKeySigner = enclave_challenge_private_key
4747
.parse::<PrivateKeySigner>()
48-
.map_err(|_| ReplicateStatusCause::PreComputeWorkerAddressMissing)?;
48+
.map_err(|_| ReplicateStatusCause::PreComputeTeeChallengePrivateKeyMissing)?;
4949

5050
let signature: Signature = signer
5151
.sign_message_sync(&hex_string_to_byte_array(message_hash))

pre-compute/src/compute/utils/hash_utils.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use sha256::digest;
44
pub fn concatenate_and_hash(hexa_strings: &[&str]) -> String {
55
let mut hasher = Keccak256::default();
66
for hexa_string in hexa_strings {
7-
println!("value {hexa_string}");
87
hasher.update(hex_string_to_byte_array(hexa_string));
98
}
109
format!("0x{:x}", hasher.finalize())

0 commit comments

Comments
 (0)