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
872 changes: 853 additions & 19 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
resolver = "3"
members = [
"post-compute"
"post-compute",
"pre-compute"
]
10 changes: 5 additions & 5 deletions post-compute/src/api/worker_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use serde::Serialize;
///
/// # Example
///
/// ```
/// ```rust
/// use tee_worker_post_compute::{
/// api::worker_api::ExitMessage,
/// compute::errors::ReplicateStatusCause,
Expand All @@ -49,7 +49,7 @@ impl<'a> From<&'a ReplicateStatusCause> for ExitMessage<'a> {
///
/// # Example
///
/// ```
/// ```rust
/// use tee_worker_post_compute::api::worker_api::WorkerApiClient;
///
/// let client = WorkerApiClient::new("http://worker:13100");
Expand Down Expand Up @@ -80,7 +80,7 @@ impl WorkerApiClient {
///
/// # Example
///
/// ```
/// ```rust
/// use tee_worker_post_compute::api::worker_api::WorkerApiClient;
///
/// let client = WorkerApiClient::from_env();
Expand Down Expand Up @@ -119,7 +119,7 @@ impl WorkerApiClient {
///
/// # Example
///
/// ```
/// ```rust
/// use tee_worker_post_compute::{
/// api::worker_api::{ExitMessage, WorkerApiClient},
/// compute::errors::ReplicateStatusCause,
Expand Down Expand Up @@ -189,7 +189,7 @@ impl WorkerApiClient {
///
/// # Example
///
/// ```
/// ```rust
/// use tee_worker_post_compute::{
/// api::worker_api::WorkerApiClient,
/// compute::computed_file::ComputedFile,
Expand Down
6 changes: 3 additions & 3 deletions post-compute/src/compute/computed_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub struct ComputedFile {
///
/// # Example
///
/// ```
/// ```rust
/// use tee_worker_post_compute::compute::computed_file::read_computed_file;
///
/// match read_computed_file("0x123456789abcdef", "/iexec_out") {
Expand Down Expand Up @@ -153,7 +153,7 @@ pub fn read_computed_file(
///
/// # Example
///
/// ```
/// ```rust
/// use tee_worker_post_compute::compute::computed_file::{
/// build_result_digest_in_computed_file,
/// ComputedFile
Expand Down Expand Up @@ -235,7 +235,7 @@ pub fn build_result_digest_in_computed_file(
///
/// # Example
///
/// ```
/// ```rust
/// use tee_worker_post_compute::compute::computed_file::{
/// sign_computed_file,
/// ComputedFile
Expand Down
9 changes: 6 additions & 3 deletions post-compute/src/compute/utils/hash_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use sha256::{Sha256Digest, digest};
pub fn concatenate_and_hash(hexa_strings: &[&str]) -> String {
let mut hasher = Keccak256::default();
for hexa_string in hexa_strings {
println!("value {hexa_string}");
hasher.update(hex_string_to_byte_array(hexa_string));
}
format!("0x{:x}", hasher.finalize())
Expand All @@ -19,15 +18,19 @@ pub fn hex_string_to_byte_array(input: &str) -> Vec<u8> {

let mut data: Vec<u8> = vec![];
let start_idx = if len % 2 != 0 {
let byte = u8::from_str_radix(&clean_input[0..1], 16).expect("");
let byte =
u8::from_str_radix(&clean_input[0..1], 16).expect("Invalid hex digit in input string");
data.push(byte);
1
} else {
0
};

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

data
Expand Down
6 changes: 3 additions & 3 deletions post-compute/src/compute/utils/result_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use std::{
///
/// # Example
///
/// ```
/// ```rust
/// use tee_worker_post_compute::compute::{computed_file::ComputedFile, utils::result_utils::compute_web3_result_digest};
///
/// let computed_file = ComputedFile {
Expand Down Expand Up @@ -93,7 +93,7 @@ pub fn compute_web3_result_digest(computed_file: &ComputedFile) -> String {
///
/// # Example
///
/// ```
/// ```rust
/// use tee_worker_post_compute::compute::{computed_file::ComputedFile, utils::result_utils::compute_web2_result_digest};
///
/// let computed_file = ComputedFile {
Expand Down Expand Up @@ -225,7 +225,7 @@ pub fn sha256_file(file_path: &Path) -> String {
///
/// # Example
///
/// ```
/// ```rust
/// use std::path::Path;
/// use tee_worker_post_compute::compute::utils::result_utils::get_file_tree_sha256;
///
Expand Down
29 changes: 29 additions & 0 deletions pre-compute/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "tee-worker-pre-compute"
version = "0.1.0"
edition = "2024"

[dependencies]
aes = "0.8.4"
alloy-signer = "0.15.9"
alloy-signer-local = "0.15.9"
base64 = "0.22.1"
cbc = { version = "0.1.2", features = ["alloc"] }
env_logger = "0.11.8"
log = "0.4.27"
multiaddr = "0.18.2"
reqwest = { version = "0.12.15", features = ["blocking", "json"] }
serde = "1.0.219"
sha256 = "1.6.0"
sha3 = "0.10.8"
thiserror = "2.0.12"

[dev-dependencies]
mockall = "0.13.1"
serde_json = "1.0.140"
temp-env = "0.3.6"
tempfile = "3.20.0"
testcontainers = { version = "0.25.0", features = ["blocking"] }
testing_logger = "0.1.1"
tokio = { version = "1.45.0", features = ["macros", "rt-multi-thread"] }
wiremock = "0.6.3"
1 change: 1 addition & 0 deletions pre-compute/src/api.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod worker_api;
Loading