Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions post-compute/src/compute/computed_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub fn read_computed_file(
///
/// let mut computed_file = ComputedFile {
/// task_id: Some("0x123".to_string()),
/// callback_data: Some("0xabc...".to_string()),
/// callback_data: Some("0x0000000000000000000000000000000000000000000000000000000000000001".to_string()),
/// deterministic_output_path: None,
/// result_digest: None,
/// enclave_signature: None,
Expand All @@ -170,7 +170,13 @@ pub fn read_computed_file(
///
/// // For a web3 callback task
/// match build_result_digest_in_computed_file(&mut computed_file, true) {
/// Ok(()) => println!("Result digest: {:?}", computed_file.result_digest),
/// Ok(()) => {
/// assert_eq!(
/// computed_file.result_digest,
/// Some("0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6".to_string())
/// );
/// println!("Result digest: {:?}", computed_file.result_digest);
/// },
/// Err(e) => eprintln!("Error computing digest: {:?}", e),
/// }
/// ```
Expand Down Expand Up @@ -442,7 +448,7 @@ mod tests {
assert!(result.is_ok());
assert_eq!(
computed_file.result_digest,
Some("0xcb371be217faa47dab94e0d0ff0840c6cbf41645f0dc1a6ae3f34447155a76f3".to_string())
Some("0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6".to_string())
);
}

Expand Down
12 changes: 0 additions & 12 deletions post-compute/src/compute/utils/hash_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ pub fn sha256<D: Sha256Digest>(input: D) -> String {
format!("0x{}", digest(input))
}

pub fn keccak256(input: &str) -> String {
format!("0x{:x}", Keccak256::digest(input))
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -105,12 +101,4 @@ mod tests {
sha256(String::from("utf8String"))
)
}

#[test]
fn get_keccak256_digest() {
assert_eq!(
"0x234b7550275b36696569d306216e035df78db522674abecff884c64e7558ef17",
keccak256("utf8String")
);
}
}
10 changes: 6 additions & 4 deletions post-compute/src/compute/utils/result_utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::compute::utils::hash_utils::{concatenate_and_hash, sha256};
use crate::compute::{computed_file::ComputedFile, utils::hash_utils::keccak256};
use crate::compute::{
computed_file::ComputedFile,
utils::hash_utils::{concatenate_and_hash, sha256},
};
use log::error;
use std::{
fs::{self, DirEntry},
Expand Down Expand Up @@ -62,7 +64,7 @@ pub fn compute_web3_result_digest(computed_file: &ComputedFile) -> String {
}
};

keccak256(callback_data)
concatenate_and_hash(&[callback_data])
}

/// Computes the result digest for web2 tasks using SHA256 hashing of output files.
Expand Down Expand Up @@ -299,7 +301,7 @@ mod tests {

assert_eq!(
result,
"0xcb371be217faa47dab94e0d0ff0840c6cbf41645f0dc1a6ae3f34447155a76f3"
"0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6"
);
}

Expand Down