Skip to content

Commit

Permalink
Fixes after Petar's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
david-zk committed Aug 23, 2024
1 parent 807a848 commit 02f3c98
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 28 deletions.
22 changes: 1 addition & 21 deletions fhevm-engine/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion fhevm-engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ members = ["coprocessor", "executor", "fhevm-engine-common"]

[workspace.dependencies]
tfhe = { version = "0.8.0-alpha.2", features = ["boolean", "shortint", "integer", "aarch64-unix", "zk-pok"] }
tfhe-zk-pok = "0.2.1"
clap = { version = "4.5", features = ["derive"] }
2 changes: 1 addition & 1 deletion fhevm-engine/coprocessor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bigdecimal = "0.4"
fhevm-engine-common = { path = "../fhevm-engine-common" }
strum = { version = "0.26", features = ["derive"] }
bincode = "1.3.3"
keccak-asm = "0.1.3"
sha3 = "0.10.8"

[dev-dependencies]
testcontainers = "0.21"
Expand Down
13 changes: 8 additions & 5 deletions fhevm-engine/coprocessor/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::db_queries::{check_if_api_key_is_valid, check_if_ciphertexts_exist_in
use crate::server::coprocessor::GenericResponse;
use fhevm_engine_common::tfhe_ops::{check_fhe_operand_types, current_ciphertext_version, debug_trivial_encrypt_be_bytes, deserialize_fhe_ciphertext, try_expand_ciphertext_list};
use fhevm_engine_common::types::{FhevmError, SupportedFheCiphertexts};
use keccak_asm::{Digest, Keccak256};
use sha3::{Digest, Keccak256};
use crate::types::{CoprocessorError, TfheTenantKeys};
use crate::utils::sort_computations_by_dependencies;
use coprocessor::async_computation_input::Input;
Expand Down Expand Up @@ -289,12 +289,15 @@ impl coprocessor::fhevm_coprocessor_server::FhevmCoprocessor for CoprocessorServ
};

for (ct_idx, the_ct) in corresponding_unpacked.iter().enumerate() {
let mut handle: [u8; 32] = [0; 32];
handle.copy_from_slice(&blob_hash);
// this must succeed because we don't allow
// more handles than u8 size
let (serialized_type, serialized_ct) = the_ct.serialize();
let ciphertext_version = current_ciphertext_version();
let mut handle_hash = Keccak256::new();
handle_hash.update(&blob_hash);
handle_hash.update(&[idx as u8]);
let mut handle = handle_hash.finalize().to_vec();
assert_eq!(handle.len(), 32);
// idx cast to u8 must succeed because we don't allow
// more handles than u8 size
handle[29] = idx as u8;
handle[30] = serialized_type as u8;
handle[31] = ciphertext_version as u8;
Expand Down

0 comments on commit 02f3c98

Please sign in to comment.