diff --git a/fhevm-engine/coprocessor/src/tests/inputs.rs b/fhevm-engine/coprocessor/src/tests/inputs.rs index 9ce285d2..566a946b 100644 --- a/fhevm-engine/coprocessor/src/tests/inputs.rs +++ b/fhevm-engine/coprocessor/src/tests/inputs.rs @@ -1,5 +1,6 @@ use std::str::FromStr; +use tfhe::integer::U256; use tonic::metadata::MetadataValue; use crate::{db_queries::query_tenant_keys, server::coprocessor::{fhevm_coprocessor_client::FhevmCoprocessorClient, DebugDecryptRequest, InputToUpload, InputUploadBatch}, tests::utils::{default_api_key, default_tenant_id, setup_test_app}}; @@ -28,6 +29,12 @@ async fn test_fhe_inputs() -> Result<(), Box> { .push(2u16) .push(3u32) .push(4u64) + .push(5u128) + // TODO: 160 bits test + .push(U256::from(7u32)) + // .push(StaticUnsignedBigInt::<8>::from(8u32)) + // .push(StaticUnsignedBigInt::<16>::from(9u32)) + // .push(StaticUnsignedBigInt::<32>::from(10u32)) .build(); let serialized = bincode::serialize(&the_list).unwrap(); @@ -51,7 +58,7 @@ async fn test_fhe_inputs() -> Result<(), Box> { let first_resp = &resp.upload_responses[0]; - assert_eq!(first_resp.input_handles.len(), 5); + assert_eq!(first_resp.input_handles.len(), 7); let mut decr_handles: Vec> = Vec::new(); for handle in &first_resp.input_handles { @@ -67,7 +74,9 @@ async fn test_fhe_inputs() -> Result<(), Box> { ); let resp = client.debug_decrypt_ciphertext(decrypt_request).await?; let resp = resp.get_ref(); - assert_eq!(resp.values.len(), 5); + assert_eq!(resp.values.len(), 7); + // TODO: add ebytes support, we only support 256 bits max + // assert_eq!(resp.values.len(), 10); assert_eq!(resp.values[0].output_type, 0); assert_eq!(resp.values[0].value, "false"); @@ -79,6 +88,16 @@ async fn test_fhe_inputs() -> Result<(), Box> { assert_eq!(resp.values[3].value, "3"); assert_eq!(resp.values[4].output_type, 5); assert_eq!(resp.values[4].value, "4"); + assert_eq!(resp.values[5].output_type, 6); + assert_eq!(resp.values[5].value, "5"); + assert_eq!(resp.values[6].output_type, 8); + assert_eq!(resp.values[6].value, "7"); + // assert_eq!(resp.values[7].output_type, 9); + // assert_eq!(resp.values[7].value, "8"); + // assert_eq!(resp.values[8].output_type, 10); + // assert_eq!(resp.values[8].value, "9"); + // assert_eq!(resp.values[9].output_type, 11); + // assert_eq!(resp.values[9].value, "10"); Ok(()) } diff --git a/fhevm-engine/fhevm-engine-common/src/tfhe_ops.rs b/fhevm-engine/fhevm-engine-common/src/tfhe_ops.rs index 3e651cc6..754946d5 100644 --- a/fhevm-engine/fhevm-engine-common/src/tfhe_ops.rs +++ b/fhevm-engine/fhevm-engine-common/src/tfhe_ops.rs @@ -2018,7 +2018,7 @@ pub fn perform_fhe_operation( } SupportedFheOperations::FheCast => match (&input_operands[0], &input_operands[1]) { (SupportedFheCiphertexts::FheBool(inp), SupportedFheCiphertexts::Scalar(op)) => { - let (l, h) = op.to_low_high_u128(); + let (l, _) = op.to_low_high_u128(); let l = l as i16; let type_id = input_operands[0].type_num(); if l == type_id { @@ -2070,7 +2070,7 @@ pub fn perform_fhe_operation( } } (SupportedFheCiphertexts::FheUint8(inp), SupportedFheCiphertexts::Scalar(op)) => { - let (l, h) = op.to_low_high_u128(); + let (l, _) = op.to_low_high_u128(); let l = l as i16; let type_id = input_operands[0].type_num(); if l == type_id { @@ -2122,7 +2122,7 @@ pub fn perform_fhe_operation( } } (SupportedFheCiphertexts::FheUint16(inp), SupportedFheCiphertexts::Scalar(op)) => { - let (l, h) = op.to_low_high_u128(); + let (l, _) = op.to_low_high_u128(); let l = l as i16; let type_id = input_operands[0].type_num(); if l == type_id { @@ -2174,7 +2174,7 @@ pub fn perform_fhe_operation( } } (SupportedFheCiphertexts::FheUint32(inp), SupportedFheCiphertexts::Scalar(op)) => { - let (l, h) = op.to_low_high_u128(); + let (l, _) = op.to_low_high_u128(); let l = l as i16; let type_id = input_operands[0].type_num(); if l == type_id { @@ -2226,7 +2226,7 @@ pub fn perform_fhe_operation( } } (SupportedFheCiphertexts::FheUint64(inp), SupportedFheCiphertexts::Scalar(op)) => { - let (l, h) = op.to_low_high_u128(); + let (l, _) = op.to_low_high_u128(); let l = l as i16; let type_id = input_operands[0].type_num(); if l == type_id { @@ -2278,7 +2278,7 @@ pub fn perform_fhe_operation( } } (SupportedFheCiphertexts::FheUint128(inp), SupportedFheCiphertexts::Scalar(op)) => { - let (l, h) = op.to_low_high_u128(); + let (l, _) = op.to_low_high_u128(); let l = l as i16; let type_id = input_operands[0].type_num(); if l == type_id { @@ -2330,7 +2330,7 @@ pub fn perform_fhe_operation( } } (SupportedFheCiphertexts::FheUint160(inp), SupportedFheCiphertexts::Scalar(op)) => { - let (l, h) = op.to_low_high_u128(); + let (l, _) = op.to_low_high_u128(); let l = l as i16; let type_id = input_operands[0].type_num(); if l == type_id { @@ -2382,7 +2382,7 @@ pub fn perform_fhe_operation( } } (SupportedFheCiphertexts::FheUint256(inp), SupportedFheCiphertexts::Scalar(op)) => { - let (l, h) = op.to_low_high_u128(); + let (l, _) = op.to_low_high_u128(); let l = l as i16; let type_id = input_operands[0].type_num(); if l == type_id { @@ -2434,7 +2434,7 @@ pub fn perform_fhe_operation( } } (SupportedFheCiphertexts::FheBytes64(inp), SupportedFheCiphertexts::Scalar(op)) => { - let (l, h) = op.to_low_high_u128(); + let (l, _) = op.to_low_high_u128(); let l = l as i16; let type_id = input_operands[0].type_num(); if l == type_id { @@ -2486,7 +2486,7 @@ pub fn perform_fhe_operation( } } (SupportedFheCiphertexts::FheBytes128(inp), SupportedFheCiphertexts::Scalar(op)) => { - let (l, h) = op.to_low_high_u128(); + let (l, _) = op.to_low_high_u128(); let l = l as i16; let type_id = input_operands[0].type_num(); if l == type_id { @@ -2538,7 +2538,7 @@ pub fn perform_fhe_operation( } } (SupportedFheCiphertexts::FheBytes256(inp), SupportedFheCiphertexts::Scalar(op)) => { - let (l, h) = op.to_low_high_u128(); + let (l, _) = op.to_low_high_u128(); let l = l as i16; let type_id = input_operands[0].type_num(); if l == type_id {