diff --git a/fhevm-engine/coprocessor/src/server.rs b/fhevm-engine/coprocessor/src/server.rs index ae75bd16..27297851 100644 --- a/fhevm-engine/coprocessor/src/server.rs +++ b/fhevm-engine/coprocessor/src/server.rs @@ -164,12 +164,12 @@ impl coprocessor::fhevm_coprocessor_server::FhevmCoprocessor for CoprocessorServ let ciphertext_version = current_ciphertext_version(); let mut handle_hash = Keccak256::new(); handle_hash.update(&blob_hash); - handle_hash.update(&[idx as u8]); + handle_hash.update(&[ct_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[29] = ct_idx as u8; handle[30] = serialized_type as u8; handle[31] = ciphertext_version as u8; @@ -424,6 +424,11 @@ impl coprocessor::fhevm_coprocessor_server::FhevmCoprocessor for CoprocessorServ return Err(tonic::Status::not_found("tenant private key not found")); } + let mut ct_indexes: BTreeMap<&[u8], usize> = BTreeMap::new(); + for (idx, h) in req.handles.iter().enumerate() { + ct_indexes.insert(h.as_slice(), idx); + } + assert_eq!(priv_key.len(), 1); let cts = sqlx::query!( @@ -448,18 +453,18 @@ impl coprocessor::fhevm_coprocessor_server::FhevmCoprocessor for CoprocessorServ let priv_key = priv_key.pop().unwrap().cks_key.unwrap(); - let values = tokio::task::spawn_blocking(move || { + let mut values = tokio::task::spawn_blocking(move || { let client_key: tfhe::ClientKey = bincode::deserialize(&priv_key).unwrap(); - let mut decrypted: Vec = Vec::with_capacity(cts.len()); + let mut decrypted: Vec<(Vec, DebugDecryptResponseSingle)> = Vec::with_capacity(cts.len()); for ct in cts { let deserialized = deserialize_fhe_ciphertext(ct.ciphertext_type, &ct.ciphertext) .unwrap(); - decrypted.push(DebugDecryptResponseSingle { + decrypted.push((ct.handle, DebugDecryptResponseSingle { output_type: ct.ciphertext_type as i32, value: deserialized.decrypt(&client_key), - }); + })); } decrypted @@ -467,6 +472,12 @@ impl coprocessor::fhevm_coprocessor_server::FhevmCoprocessor for CoprocessorServ .await .unwrap(); + values.sort_by_key(|(h, _)| { + ct_indexes.get(h.as_slice()).unwrap() + }); + + let values = values.into_iter().map(|i| i.1).collect::>(); + return Ok(tonic::Response::new(DebugDecryptResponse { values })); } diff --git a/fhevm-engine/coprocessor/src/tests/inputs.rs b/fhevm-engine/coprocessor/src/tests/inputs.rs index a5ff2f5b..9ce285d2 100644 --- a/fhevm-engine/coprocessor/src/tests/inputs.rs +++ b/fhevm-engine/coprocessor/src/tests/inputs.rs @@ -69,7 +69,7 @@ async fn test_fhe_inputs() -> Result<(), Box> { let resp = resp.get_ref(); assert_eq!(resp.values.len(), 5); - assert_eq!(resp.values[0].output_type, 1); + assert_eq!(resp.values[0].output_type, 0); assert_eq!(resp.values[0].value, "false"); assert_eq!(resp.values[1].output_type, 2); assert_eq!(resp.values[1].value, "1"); @@ -77,6 +77,97 @@ async fn test_fhe_inputs() -> Result<(), Box> { assert_eq!(resp.values[2].value, "2"); assert_eq!(resp.values[3].output_type, 4); assert_eq!(resp.values[3].value, "3"); + assert_eq!(resp.values[4].output_type, 5); + assert_eq!(resp.values[4].value, "4"); + + Ok(()) +} + +#[ignore] +#[tokio::test] +// custom function for integration testing in development environment +// uploads ciphertext batch from inputs to local coprocessor database +async fn custom_insert_inputs() -> Result<(), Box> { + let grpc_url = "http://127.0.0.1:50051"; + let db_url = "postgres://postgres:postgres@localhost/coprocessor"; + let api_key_header = format!("bearer {}", default_api_key()); + + let mut client = FhevmCoprocessorClient::connect(grpc_url).await?; + let pool = sqlx::postgres::PgPoolOptions::new() + .max_connections(2) + .connect(&db_url) + .await?; + + let keys = query_tenant_keys(vec![default_tenant_id()], &pool).await.map_err(|e| { + let e: Box = e; + e + })?; + let keys = &keys[0]; + + let mut builder = tfhe::CompactCiphertextListBuilder::new(&keys.pks); + let the_list = builder + .push(false) + .push(1u8) + .push(2u16) + .push(3u32) + .push(4u64) + .push(5u64) + .build(); + + let serialized = bincode::serialize(&the_list).unwrap(); + + println!("Encrypting inputs..."); + let mut input_request = tonic::Request::new(InputUploadBatch { + input_ciphertexts: vec![ + InputToUpload { + input_payload: serialized, + signature: Vec::new(), + } + ] + }); + input_request.metadata_mut().append( + "authorization", + MetadataValue::from_str(&api_key_header).unwrap(), + ); + + let uploaded = client.upload_inputs(input_request).await?; + let response = uploaded.get_ref(); + + for (idx, ur) in response.upload_responses.iter().enumerate() { + println!("request {idx}"); + for (idx, h) in ur.input_handles.iter().enumerate() { + println!(" ct {idx} 0x{}", hex::encode(&h.handle)); + } + } + + Ok(()) +} + +#[ignore] +#[tokio::test] +// custom function to decrypt the ciphertext from grpc +// ct_to_decrypt should be changed to your environment +async fn custom_decrypt_ct() -> Result<(), Box> { + let grpc_url = "http://127.0.0.1:50051"; + let api_key_header = format!("bearer {}", default_api_key()); + let ct_to_decrypt = "5bcaeef7d5bee3b5dffff3dfbfafcfb73cf57ddbbff73f777ffdfe677ebc0500"; + + let mut client = FhevmCoprocessorClient::connect(grpc_url).await?; + println!("Encrypting inputs..."); + let mut input_request = tonic::Request::new(DebugDecryptRequest { + handles: vec![ + hex::decode(ct_to_decrypt).unwrap() + ] + }); + input_request.metadata_mut().append( + "authorization", + MetadataValue::from_str(&api_key_header).unwrap(), + ); + + let uploaded = client.debug_decrypt_ciphertext(input_request).await?; + let response = uploaded.get_ref(); + + println!("{:#?}", response); Ok(()) } \ No newline at end of file diff --git a/fhevm-engine/coprocessor/src/tests/operators.rs b/fhevm-engine/coprocessor/src/tests/operators.rs index 02b2653c..7913652f 100644 --- a/fhevm-engine/coprocessor/src/tests/operators.rs +++ b/fhevm-engine/coprocessor/src/tests/operators.rs @@ -41,11 +41,15 @@ fn supported_bits() -> &'static [i32] { fn supported_types() -> &'static [i32] { &[ - 1, // bool + 0, // bool + // 1, TODO: add 4 bit support 2, // 8 bit 3, // 16 bit 4, // 32 bit 5, // 64 bit + // 6, TODO: add 128 bit support + // 7, TODO: add 160 bit support + // 8, TODO: add 256 bit support ] } @@ -332,6 +336,7 @@ async fn test_fhe_casts() -> Result<(), Box> { expected_result: String, } + let fhe_bool = 0; let mut output_handles = Vec::new(); let mut enc_request_payload = Vec::new(); let mut async_computations = Vec::new(); @@ -342,7 +347,7 @@ async fn test_fhe_casts() -> Result<(), Box> { let output_handle = next_handle(); let input = 7; let (_, inp_bytes) = BigInt::from(input).to_bytes_be(); - let output = if *type_to == 1 || *type_from == 1 { + let output = if *type_to == fhe_bool || *type_from == fhe_bool { // if bool output is 1 1 } else { @@ -361,7 +366,7 @@ async fn test_fhe_casts() -> Result<(), Box> { type_from: *type_from, type_to: *type_to, input, - expected_result: if *type_to == 1 { + expected_result: if *type_to == fhe_bool { (output > 0).to_string() } else { output.to_string() @@ -472,23 +477,25 @@ async fn test_fhe_if_then_else() -> Result<(), Box> { let mut async_computations = Vec::new(); let mut if_then_else_outputs: Vec = Vec::new(); + let fhe_bool_type = 0; let false_handle = next_handle(); let true_handle = next_handle(); enc_request_payload.push(DebugEncryptRequestSingle { handle: false_handle.clone(), le_value: BigInt::from(0).to_bytes_be().1, - output_type: 1, + output_type: fhe_bool_type, }); enc_request_payload.push(DebugEncryptRequestSingle { handle: true_handle.clone(), le_value: BigInt::from(1).to_bytes_be().1, - output_type: 1, + output_type: fhe_bool_type, }); + let fhe_bool_type = 0; for input_types in supported_types() { let left_handle = next_handle(); let right_handle = next_handle(); - let is_input_bool = *input_types == 1; + let is_input_bool = *input_types == fhe_bool_type; let (left_input, right_input) = if is_input_bool { (0, 1) @@ -516,7 +523,7 @@ async fn test_fhe_if_then_else() -> Result<(), Box> { input_bool: test_value, left_input, right_input, - expected_result: if *input_types == 1 { + expected_result: if *input_types == fhe_bool_type { (expected_result > 0).to_string() } else { expected_result.to_string() @@ -623,8 +630,9 @@ fn generate_binary_test_cases() -> Vec { } let expected_output = compute_expected_binary_output(&lhs, &rhs, op, bits); let operand = op as i32; + let fhe_bool_type = 0; let expected_output_type = if op.is_comparison() { - 1 // FheBool + fhe_bool_type } else { supported_bits_to_bit_type_in_db(bits) }; diff --git a/fhevm-engine/coprocessor/src/utils.rs b/fhevm-engine/coprocessor/src/utils.rs index 438ea61f..4cfaff49 100644 --- a/fhevm-engine/coprocessor/src/utils.rs +++ b/fhevm-engine/coprocessor/src/utils.rs @@ -98,35 +98,64 @@ pub fn sort_computations_by_dependencies<'a>( // least dependencies goes to the left, most dependencies to the right computation_dependencies.sort_by(|(_, deps_a), (_, deps_b)| deps_a.cmp(deps_b)); - let mut simulation_completed_outputs: HashSet<&[u8]> = HashSet::new(); - for (inp_idx, _) in computation_dependencies { - let async_comp = &input[inp_idx]; - for ih in &async_comp.inputs { - if let Some(Input::InputHandle(ih)) = &ih.input { - // this must be loop if we don't see that handle is completed here, for example - // [output: 1, deps: [0, 2, 3]] - // [output: 0, deps: [1, 2, 3]] - if !handles_to_check_in_db.contains(ih.as_slice()) - && !simulation_completed_outputs.contains(ih.as_slice()) - { - return Err( - CoprocessorError::CiphertextComputationDependencyLoopDetected { - uncomputable_output_handle: format!( - "0x{}", - hex::encode(&async_comp.output_handle) - ), - uncomputable_handle_dependency: format!("0x{}", hex::encode(ih)), - }, - ); + loop { + let mut progress_made_in_iteration = false; + let mut new_computation_dependencies: Vec<(usize, Vec)> = Vec::new(); + + let mut first_uncomputable_handle: &[u8] = [].as_slice(); + let mut first_uncomputable_handle_dependency: &[u8] = [].as_slice(); + + for (inp_idx, deps) in computation_dependencies { + let async_comp = &input[inp_idx]; + + let mut can_compute_this = true; + for ih in &async_comp.inputs { + if let Some(Input::InputHandle(ih)) = &ih.input { + if !handles_to_check_in_db.contains(ih.as_slice()) + && !simulation_completed_outputs.contains(ih.as_slice()) + { + if first_uncomputable_handle.is_empty() { + first_uncomputable_handle = async_comp.output_handle.as_slice(); + first_uncomputable_handle_dependency = ih.as_slice(); + } + can_compute_this = false; + } } } + + if can_compute_this { + progress_made_in_iteration = true; + simulation_completed_outputs.insert(&async_comp.output_handle); + res.push(async_comp); + } else { + // push uncomputable to new queue to try again later + new_computation_dependencies.push((inp_idx, deps)); + } } - simulation_completed_outputs.insert(&async_comp.output_handle); + if !progress_made_in_iteration { + // this must be loop if we don't see progress made + // [output: 1, deps: [0, 2, 3]] + // [output: 0, deps: [1, 2, 3]] + return Err( + CoprocessorError::CiphertextComputationDependencyLoopDetected { + uncomputable_output_handle: format!( + "0x{}", + hex::encode(&first_uncomputable_handle) + ), + uncomputable_handle_dependency: format!("0x{}", hex::encode(first_uncomputable_handle_dependency)), + }, + ); + } + + if new_computation_dependencies.is_empty() { + // everything computed, break loop + break; + } - res.push(async_comp); + computation_dependencies = new_computation_dependencies; } Ok((res, handles_to_check_in_db)) diff --git a/fhevm-engine/fhevm-engine-common/src/tfhe_ops.rs b/fhevm-engine/fhevm-engine-common/src/tfhe_ops.rs index a262f842..1dbd4ae5 100644 --- a/fhevm-engine/fhevm-engine-common/src/tfhe_ops.rs +++ b/fhevm-engine/fhevm-engine-common/src/tfhe_ops.rs @@ -12,7 +12,7 @@ pub fn deserialize_fhe_ciphertext( input_bytes: &[u8], ) -> Result { match input_type { - 1 => { + 0 => { let v: tfhe::FheBool = bincode::deserialize(input_bytes) .map_err(|e| FhevmError::DeserializationError(e))?; Ok(SupportedFheCiphertexts::FheBool(v)) @@ -49,7 +49,7 @@ pub fn debug_trivial_encrypt_be_bytes( input_bytes: &[u8], ) -> SupportedFheCiphertexts { match output_type { - 1 => SupportedFheCiphertexts::FheBool( + 0 => SupportedFheCiphertexts::FheBool( FheBool::try_encrypt_trivial(input_bytes[0] > 0).unwrap(), ), 2 => SupportedFheCiphertexts::FheUint8( @@ -90,6 +90,7 @@ pub fn debug_trivial_encrypt_be_bytes( pub fn current_ciphertext_version() -> i16 { 0 + 0 } pub fn try_expand_ciphertext_list( @@ -175,7 +176,8 @@ pub fn check_fhe_operand_types( assert_eq!(input_handles.len(), is_input_handle_scalar.len()); let fhe_op: SupportedFheOperations = fhe_operation.try_into()?; - let fhe_bool_type = 1; + // TODO: figure out typing system with constants + let fhe_bool_type = 0; let scalar_operands = is_input_handle_scalar .iter() @@ -277,7 +279,6 @@ pub fn check_fhe_operand_types( }); } - let fhe_bool_type = 1; if input_types[0] == fhe_bool_type && !fhe_op.supports_bool_inputs() { return Err(FhevmError::OperationDoesntSupportBooleanInputs { fhe_operation, @@ -303,8 +304,6 @@ pub fn check_fhe_operand_types( }); } - // TODO: figure out typing system with constants - let fhe_bool_type = 1; if input_types[0] != fhe_bool_type { return Err(FhevmError::FheIfThenElseUnexpectedOperandTypes { fhe_operation, @@ -389,7 +388,7 @@ pub fn validate_fhe_type(input_type: i32) -> Result<(), FhevmError> { .try_into() .or(Err(FhevmError::UnknownFheType(input_type)))?; match i16_type { - 1 | 2 | 3 | 4 | 5 => Ok(()), + 0 | 2 | 3 | 4 | 5 => Ok(()), _ => Err(FhevmError::UnknownFheType(input_type)), } } @@ -1438,7 +1437,7 @@ pub fn perform_fhe_operation( return Ok(SupportedFheCiphertexts::FheUint8(inp.clone())); } else { match l { - 1 => { + 0 => { let out: tfhe::FheBool = inp.gt(0); Ok(SupportedFheCiphertexts::FheBool(out)) } @@ -1467,7 +1466,7 @@ pub fn perform_fhe_operation( return Ok(SupportedFheCiphertexts::FheUint16(inp.clone())); } else { match l { - 1 => { + 0 => { let out: tfhe::FheBool = inp.gt(0); Ok(SupportedFheCiphertexts::FheBool(out)) } @@ -1496,7 +1495,7 @@ pub fn perform_fhe_operation( return Ok(SupportedFheCiphertexts::FheUint32(inp.clone())); } else { match l { - 1 => { + 0 => { let out: tfhe::FheBool = inp.gt(0); Ok(SupportedFheCiphertexts::FheBool(out)) } @@ -1525,7 +1524,7 @@ pub fn perform_fhe_operation( return Ok(SupportedFheCiphertexts::FheUint64(inp.clone())); } else { match l { - 1 => { + 0 => { let out: tfhe::FheBool = inp.gt(0); Ok(SupportedFheCiphertexts::FheBool(out)) } @@ -1549,8 +1548,7 @@ pub fn perform_fhe_operation( panic!("unknown cast pair") } }, - SupportedFheOperations::FheGetInputCiphertext => { - Err(FhevmError::UnknownFheOperation(fhe_operation_int as i32)) - } + SupportedFheOperations::FheRand => todo!("Implement FheRand"), + SupportedFheOperations::FheRandBounded => todo!("Implement FheRandBounded"), } -} +} \ No newline at end of file diff --git a/fhevm-engine/fhevm-engine-common/src/types.rs b/fhevm-engine/fhevm-engine-common/src/types.rs index 89f35e71..5e5f263c 100644 --- a/fhevm-engine/fhevm-engine-common/src/types.rs +++ b/fhevm-engine/fhevm-engine-common/src/types.rs @@ -236,6 +236,10 @@ pub enum SupportedFheOperations { FheNot = 21, FheCast = 30, FheIfThenElse = 31, + FheCast = 23, + FheIfThenElse = 25, + FheRand = 26, + FheRandBounded = 27, FheGetInputCiphertext = 32, } @@ -263,7 +267,9 @@ impl SupportedFheCiphertexts { pub fn type_num(&self) -> i16 { match self { - SupportedFheCiphertexts::FheBool(_) => 1, + // values taken to match with solidity library + SupportedFheCiphertexts::FheBool(_) => 0, + // TODO: add FheUint4 support SupportedFheCiphertexts::FheUint8(_) => 2, SupportedFheCiphertexts::FheUint16(_) => 3, SupportedFheCiphertexts::FheUint32(_) => 4, @@ -362,7 +368,10 @@ impl SupportedFheOperations { SupportedFheOperations::FheNot | SupportedFheOperations::FheNeg => { FheOperationType::Unary } - SupportedFheOperations::FheIfThenElse | SupportedFheOperations::FheCast => { + SupportedFheOperations::FheIfThenElse + | SupportedFheOperations::FheCast + | SupportedFheOperations::FheRand + | SupportedFheOperations::FheRandBounded => { FheOperationType::Other } SupportedFheOperations::FheGetInputCiphertext => FheOperationType::Other, @@ -418,8 +427,10 @@ impl TryFrom for SupportedFheOperations { 19 => Ok(SupportedFheOperations::FheMax), 20 => Ok(SupportedFheOperations::FheNeg), 21 => Ok(SupportedFheOperations::FheNot), - 30 => Ok(SupportedFheOperations::FheCast), - 31 => Ok(SupportedFheOperations::FheIfThenElse), + 23 => Ok(SupportedFheOperations::FheCast), + 25 => Ok(SupportedFheOperations::FheIfThenElse), + 26 => Ok(SupportedFheOperations::FheRand), + 27 => Ok(SupportedFheOperations::FheRandBounded), 32 => Ok(SupportedFheOperations::FheGetInputCiphertext), _ => Err(FhevmError::UnknownFheOperation(value as i32)), }; diff --git a/fhevm-engine/fhevm-go-coproc/.github/workflows/tests.yaml b/fhevm-engine/fhevm-go-coproc/.github/workflows/tests.yaml new file mode 100644 index 00000000..858561ad --- /dev/null +++ b/fhevm-engine/fhevm-go-coproc/.github/workflows/tests.yaml @@ -0,0 +1,26 @@ +name: Run Tests + +on: + push: + branches: + - 'main' + tags: + - '*' + pull_request: + +jobs: + build_and_test: + name: Build and test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: '1.22.0' + + - name: Run tests + run: make test diff --git a/fhevm-engine/fhevm-go-coproc/.gitignore b/fhevm-engine/fhevm-go-coproc/.gitignore new file mode 100644 index 00000000..e43b0f98 --- /dev/null +++ b/fhevm-engine/fhevm-go-coproc/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/fhevm-engine/fhevm-go-coproc/.gitmodules b/fhevm-engine/fhevm-go-coproc/.gitmodules new file mode 100644 index 00000000..e1b5f337 --- /dev/null +++ b/fhevm-engine/fhevm-go-coproc/.gitmodules @@ -0,0 +1,3 @@ +[submodule "tfhe-rs"] + path = tfhe-rs + url = https://github.com/zama-ai/tfhe-rs.git diff --git a/fhevm-engine/fhevm-go-coproc/Makefile b/fhevm-engine/fhevm-go-coproc/Makefile new file mode 100644 index 00000000..6151371b --- /dev/null +++ b/fhevm-engine/fhevm-go-coproc/Makefile @@ -0,0 +1,21 @@ +fhevm/coprocessor.pb.go: ../../proto/coprocessor.proto ../../proto/common.proto + protoc \ + --proto_path=../../proto/ \ + --go_opt=paths=source_relative \ + --go_opt=Mprotos/coprocessor.proto=github.com/zama-ai/fhevm-backend/fhevm-engine/fhevm-go-coproc \ + --go_opt=Mprotos/common.proto=github.com/zama-ai/fhevm-backend/fhevm-engine/fhevm-go-coproc \ + --go-grpc_out=./fhevm/ --go-grpc_opt=paths=source_relative \ + --go_out=./fhevm/ \ + coprocessor.proto common.proto + +.PHONY: build +build: fhevm/coprocessor.pb.go + cd fhevm && go build . + +.PHONY: run +run: fhevm/coprocessor.pb.go + cd fhevm && go run . + +.PHONY: test +test: fhevm/coprocessor.pb.go + cd fhevm && go test ./... diff --git a/fhevm-engine/fhevm-go-coproc/README.md b/fhevm-engine/fhevm-go-coproc/README.md new file mode 100644 index 00000000..2696a2e2 --- /dev/null +++ b/fhevm-engine/fhevm-go-coproc/README.md @@ -0,0 +1,42 @@ +# fhevm-go-coproc + +This is coprocessor library for fhevm. It is meant to be integrated into blockchains like go-ethereum. Since it is not trivial to take over control of the command line flags coprocessor is controlled by environment variables instead. + +Example configuration for go-ethereum: +``` +#!/bin/sh + +sudo chown -R ec2-user ./geth + +FHEVM_GO_INIT_CKS=1 \ +FHEVM_GO_KEYS_DIR=coproc-data/fhevm-keys \ +FHEVM_CIPHERTEXTS_DB=coproc-data/fhevm_ciphertexts.sqlite \ +FHEVM_CONTRACT_ADDRESS=0xF6D83188e045584953bE50e7D81F6498525e108b \ +FHEVM_COPROCESSOR_PRIVATE_KEY_FILE=coproc-data/coprocessor.key \ +/home/ec2-user/build/geth \ + --sepolia \ + --datadir=/home/ec2-user/geth \ + --syncmode=full \ + --http \ + --http.corsdomain='*' \ + --http.api=eth,net,web3,personal,admin,miner \ + --http.addr=0.0.0.0 \ + --http.vhosts=* \ + --ws \ + --ws.origins=* \ + --ws.addr=0.0.0.0 \ + --ws.api=eth,net,web3 +``` + +Environment variables: +- `FHEVM_GO_INIT_CKS` - Controls whether to try to load cks private key, the decryptions will work on coprocessor. Note that private key should be responsibility of the KMS but this is meant for debugging and not production. +- `FHEVM_GO_KEYS_DIR` - Directory from which to load pks/sks keys +- `FHEVM_CIPHERTEXTS_DB` - Path where to create ciphertexts database +- `FHEVM_CONTRACT_ADDRESS` - Contract address which to monitor on the blockchain +- `FHEVM_COPROCESSOR_PRIVATE_KEY_FILE` - private key file of the coprocessor where private key bytes are defined as `0x12345...`. This is ethereum private key. If file doesn't exist random key will be created. Public coprocessor ethereum address is logged upon initialization. + +Private key file of coprocessor should be 66 bytes in length. It represents ethereum 32 byte private key. +``` +cat coproc-data/coprocessor.key | wc -c +66 +``` diff --git a/fhevm-engine/fhevm-go-coproc/fhevm/api.go b/fhevm-engine/fhevm-go-coproc/fhevm/api.go new file mode 100644 index 00000000..d30f29aa --- /dev/null +++ b/fhevm-engine/fhevm-go-coproc/fhevm/api.go @@ -0,0 +1,610 @@ +package fhevm + +import ( + "context" + "crypto/ecdsa" + "database/sql" + "encoding/binary" + "errors" + "fmt" + "os" + "strings" + "sync" + "time" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + ethCrypto "github.com/ethereum/go-ethereum/crypto" + _ "github.com/mattn/go-sqlite3" + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" + "google.golang.org/protobuf/proto" +) + +type FheUintType uint8 + +const ( + FheBool FheUintType = 0 + FheUint4 FheUintType = 1 + FheUint8 FheUintType = 2 + FheUint16 FheUintType = 3 + FheUint32 FheUintType = 4 + FheUint64 FheUintType = 5 + FheUint128 FheUintType = 6 + FheUint160 FheUintType = 7 + FheUserBytes FheUintType = 255 +) + +type FheOp uint8 + +const ( + FheAdd FheOp = 0 + FheSub FheOp = 1 + FheMul FheOp = 2 + FheDiv FheOp = 3 + FheRem FheOp = 4 + FheBitAnd FheOp = 5 + FheBitOr FheOp = 6 + FheBitXor FheOp = 7 + FheShl FheOp = 8 + FheShr FheOp = 9 + FheRotl FheOp = 10 + FheRotr FheOp = 11 + FheEq FheOp = 12 + FheNe FheOp = 13 + FheGe FheOp = 14 + FheGt FheOp = 15 + FheLe FheOp = 16 + FheLt FheOp = 17 + FheMin FheOp = 18 + FheMax FheOp = 19 + FheNeg FheOp = 20 + FheNot FheOp = 21 + // unused + // VerifyCiphertext FheOp = 22 + FheCast FheOp = 23 + // unused + // TrivialEncrypt FheOp = 24 + FheIfThenElse FheOp = 25 + FheRand FheOp = 26 + FheRandBounded FheOp = 27 +) + +func (t FheUintType) String() string { + switch t { + case FheBool: + return "fheBool" + case FheUint4: + return "fheUint4" + case FheUint8: + return "fheUint8" + case FheUint16: + return "fheUint16" + case FheUint32: + return "fheUint32" + case FheUint64: + return "fheUint64" + case FheUint128: + return "fheUint128" + case FheUint160: + return "fheUint160" + default: + return "unknownFheUintType" + } +} + +func IsValidFheType(t byte) bool { + if uint8(t) < uint8(FheBool) || uint8(t) > uint8(FheUint160) { + return false + } + return true +} + +type SignedHandle struct { + Handle []byte + Signature []byte +} + +type CoprocessorApi interface { + CreateSession() CoprocessorSession + GetStore() ComputationStore +} + +type SegmentId int + +type CoprocessorSession interface { + Execute(input []byte, output []byte) error + ContractAddress() common.Address + NextSegment() SegmentId + InvalidateSinceSegment(id SegmentId) SegmentId + Commit() error + GetStore() ComputationStore +} + +type ComputationStore interface { + InsertComputation(computation ComputationToInsert) error + InsertComputationBatch(ciphertexts []ComputationToInsert) error +} + +type ApiImpl struct { + store *SqliteCiphertextStore + address common.Address + coprocessorKey *ecdsa.PrivateKey +} + +type SessionImpl struct { + address common.Address + coprocessorKey *ecdsa.PrivateKey + isCommitted bool + sessionStore *SessionComputationStore +} + +type ComputationOperand struct { + IsScalar bool + Handle []byte + FheUintType FheUintType +} + +type ComputationToInsert struct { + segmentId SegmentId + Operation FheOp + OutputHandle []byte + Operands []ComputationOperand +} + +type SessionComputationStore struct { + underlyingCiphertextStore ComputationStore + insertedHandles map[string]int + invalidatedSegments map[SegmentId]bool + inserts []ComputationToInsert + isCommitted bool + segmentCount int +} + +type SqliteCiphertextStore struct { + dbMutex sync.Mutex + dbConn *sql.DB + coprocessorUrl string + coprocessorApiKey string + jobChannel chan bool +} + +type handleOffset struct { + segment int + index int +} + +type ciphertextSegment struct { + inserts []ComputationToInsert + invalidated bool +} + +func (coprocApi *ApiImpl) CreateSession() CoprocessorSession { + return &SessionImpl{ + address: coprocApi.address, + coprocessorKey: coprocApi.coprocessorKey, + isCommitted: false, + sessionStore: &SessionComputationStore{ + isCommitted: false, + inserts: make([]ComputationToInsert, 0), + insertedHandles: make(map[string]int), + invalidatedSegments: make(map[SegmentId]bool), + underlyingCiphertextStore: coprocApi.store, + segmentCount: 0, + }, + } +} + +func (coprocApi *ApiImpl) GetStore() ComputationStore { + return coprocApi.store +} + +func (sessionApi *SessionImpl) Commit() error { + if sessionApi.isCommitted { + return errors.New("session is already comitted") + } + + err := sessionApi.sessionStore.Commit() + if err != nil { + return err + } + + return nil +} + +func (sessionApi *SessionImpl) Execute(data []byte, output []byte) error { + if len(data) < 4 { + return fmt.Errorf("input data must be at least 4 bytes for signature, got %d", len(data)) + } + + signature := binary.BigEndian.Uint32(data[0:4]) + callData := data[4:] + + method, exists := signatureToFheLibMethod[signature] + if exists { + fmt.Printf("Executing captured operation %s%s\n", method.Name, method.ArgTypes) + if len(output) >= 32 { + // where to get output handle from? + outputHandle := output[0:32] + return method.runFunction(sessionApi, callData, outputHandle) + } else { + return errors.New("no output data provided") + } + } else { + return fmt.Errorf("signature %d not recognized", signature) + } +} + +func (sessionApi *SessionImpl) NextSegment() SegmentId { + sessionApi.sessionStore.segmentCount = sessionApi.sessionStore.segmentCount + 1 + return SegmentId(sessionApi.sessionStore.segmentCount) +} + +func (sessionApi *SessionImpl) InvalidateSinceSegment(id SegmentId) SegmentId { + for idx := int(id); idx <= sessionApi.sessionStore.segmentCount; idx++ { + sessionApi.sessionStore.invalidatedSegments[SegmentId(idx)] = true + } + + return sessionApi.NextSegment() +} + +func (sessionApi *SessionImpl) ContractAddress() common.Address { + return sessionApi.address +} + +func (sessionApi *SessionImpl) GetStore() ComputationStore { + return sessionApi.sessionStore +} + +func (dbApi *SessionComputationStore) InsertComputationBatch(computations []ComputationToInsert) error { + for _, comp := range computations { + dbApi.InsertComputation(comp) + } + + return nil +} + +func (dbApi *SessionComputationStore) InsertComputation(computation ComputationToInsert) error { + _, found := dbApi.insertedHandles[string(computation.OutputHandle)] + if !found { + // preserve insertion order + dbApi.insertedHandles[string(computation.OutputHandle)] = len(dbApi.inserts) + computation.segmentId = SegmentId(dbApi.segmentCount) + dbApi.inserts = append(dbApi.inserts, computation) + } + + return nil +} + +func (dbApi *SessionComputationStore) Commit() error { + if dbApi.isCommitted { + return errors.New("session ciphertext store already committed") + } + + dbApi.isCommitted = true + + finalInserts := make([]ComputationToInsert, 0, len(dbApi.inserts)) + for _, ct := range dbApi.inserts { + if !dbApi.invalidatedSegments[ct.segmentId] { + finalInserts = append(finalInserts, ct) + } + } + + fmt.Printf("Inserting %d ciphertexts into database\n", len(finalInserts)) + + err := dbApi.underlyingCiphertextStore.InsertComputationBatch(finalInserts) + if err != nil { + return err + } + + return nil +} + +func computationToAsyncComputation(computation ComputationToInsert) AsyncComputation { + inputs := make([]*AsyncComputationInput, 0, len(computation.Operands)) + for _, operand := range computation.Operands { + if operand.IsScalar { + inputs = append(inputs, &AsyncComputationInput{ + Input: &AsyncComputationInput_Scalar{ + Scalar: operand.Handle, + }, + }) + } else { + inputs = append(inputs, &AsyncComputationInput{ + Input: &AsyncComputationInput_InputHandle{ + InputHandle: operand.Handle, + }, + }) + } + } + + return AsyncComputation{ + Operation: FheOperation(computation.Operation), + OutputHandle: computation.OutputHandle, + Inputs: inputs, + } +} + +func (dbApi *SqliteCiphertextStore) InsertComputation(computation ComputationToInsert) error { + dbApi.dbMutex.Lock() + defer dbApi.dbMutex.Unlock() + + async_computation := computationToAsyncComputation(computation) + marshalled, err := proto.Marshal(&async_computation) + if err != nil { + return err + } + + _, err = dbApi.dbConn.Exec(` + INSERT OR IGNORE INTO computations(output_handle, payload) + VALUES(?, ?) + `, computation.OutputHandle, marshalled) + if err != nil { + return err + } + return nil +} + +func (dbApi *SqliteCiphertextStore) InsertComputationBatch(computations []ComputationToInsert) error { + dbApi.dbMutex.Lock() + defer dbApi.dbMutex.Unlock() + + for _, comp := range computations { + async_computation := computationToAsyncComputation(comp) + marshalled, err := proto.Marshal(&async_computation) + if err != nil { + return err + } + + _, err = dbApi.dbConn.Exec(` + INSERT OR IGNORE INTO computations(output_handle, payload) + VALUES(?, ?) + `, comp.OutputHandle, marshalled) + if err != nil { + return err + } + } + + // notify channel of new work available + select { + case dbApi.jobChannel <- true: + default: + } + + return nil +} + +func InitCoprocessor() (CoprocessorApi, error) { + if sqliteDbPath, ok := os.LookupEnv("FHEVM_CIPHERTEXTS_DB"); ok { + contractAddr, hasAddr := os.LookupEnv("FHEVM_CONTRACT_ADDRESS") + if !hasAddr { + return nil, errors.New("FHEVM_CIPHERTEXTS_DB is set but FHEVM_CONTRACT_ADDRESS is not set") + } + fhevmContractAddress := common.HexToAddress(contractAddr) + + keyFile, hasKey := os.LookupEnv("FHEVM_COPROCESSOR_PRIVATE_KEY_FILE") + if !hasKey { + return nil, errors.New("FHEVM_CIPHERTEXTS_DB is set but FHEVM_COPROCESSOR_PRIVATE_KEY_FILE is not set") + } + + coprocUrl, hasUrl := os.LookupEnv("FHEVM_COPROCESSOR_URL") + if !hasUrl { + return nil, errors.New("FHEVM_COPROCESSOR_URL is not configured") + } + + coprocApiKey, hasApiKey := os.LookupEnv("FHEVM_COPROCESSOR_API_KEY") + if !hasApiKey { + return nil, errors.New("FHEVM_COPROCESSOR_API_KEY is not configured") + } + + ciphertextDb, err := CreateSqliteCiphertextStore(sqliteDbPath, context.Background(), coprocUrl, coprocApiKey) + if err != nil { + return nil, err + } + + keyBytes, err := os.ReadFile(keyFile) + if err != nil { + if !os.IsNotExist(err) { + return nil, err + } + // key file doesn't exist, generate + fmt.Printf("Key file not found in %s, generating and saving\n", keyFile) + privKey, err := ethCrypto.GenerateKey() + if err != nil { + return nil, err + } + keyBytes = []byte(hexutil.Encode(ethCrypto.FromECDSA(privKey))) + err = os.WriteFile(keyFile, keyBytes, 0o600) + if err != nil { + return nil, err + } + fmt.Printf("Generated and saved ECDSA private key in %s\n", keyFile) + } + + privKeyString := strings.TrimSpace(string(keyBytes)) + privKeyBytes, err := hexutil.Decode(privKeyString) + if err != nil { + return nil, err + } + + privKey, err := ethCrypto.ToECDSA(privKeyBytes) + if err != nil { + return nil, err + } + + pubKey := privKey.Public() + publicKeyECDSA, ok := pubKey.(*ecdsa.PublicKey) + if !ok { + return nil, errors.New("can't get ethereum public key from private") + } + + pubKeyAddr := ethCrypto.PubkeyToAddress(*publicKeyECDSA) + fmt.Printf("Public coprocessor eth address: %s\n", pubKeyAddr) + + apiImpl := ApiImpl{ + store: ciphertextDb, + address: fhevmContractAddress, + coprocessorKey: privKey, + } + + // background job to submit computations to coprocessor + scheduleCoprocessorFlushes(&apiImpl) + + return &apiImpl, nil + } + + return nil, nil +} + +func scheduleCoprocessorFlushes(impl *ApiImpl) { + // timer to send polling for messages every 10 seconds + go func() { + for { + time.Sleep(time.Millisecond * 10000) + select { + case impl.store.jobChannel <- true: + default: + } + } + }() + + // listen to new jobs, scheduled manually or by timer + go func() { + for { + <-impl.store.jobChannel + itemsComputed, err := flushWorkItemsToCoprocessor(impl.store) + if err != nil { + fmt.Printf("error flushing work items to coprocessor: %s\n", err) + } else { + fmt.Printf("successfully sent %d work items to the coprocessor\n", itemsComputed) + } + } + }() +} + +func flushWorkItemsToCoprocessor(store *SqliteCiphertextStore) (int, error) { + var asyncCompReq *AsyncComputeRequest + handlesToMarkDone := make([][]byte, 0) + { + store.dbMutex.Lock() + defer store.dbMutex.Unlock() + + // query all ciphertexts + response, err := store.dbConn.Query("SELECT output_handle, payload FROM computations WHERE is_sent = 0 LIMIT 700") + if err != nil { + return 0, err + } + + requests := make([]*AsyncComputation, 0, 16) + for response.Next() { + var outputHandle, payload []byte + err = response.Scan(&outputHandle, &payload) + if err != nil { + return 0, err + } + var ac AsyncComputation + err = proto.Unmarshal(payload, &ac) + if err != nil { + return 0, err + } + + requests = append(requests, &ac) + handlesToMarkDone = append(handlesToMarkDone, outputHandle) + } + + if response.Err() != nil { + return 0, err + } + + if len(requests) > 0 { + asyncCompReq = &AsyncComputeRequest{ + Computations: requests, + } + } + } + + if asyncCompReq != nil { + // send the request + var opts []grpc.DialOption + opts = append(opts, grpc.WithInsecure()) + conn, err := grpc.NewClient(store.coprocessorUrl, opts...) + if err != nil { + return 0, err + } + defer conn.Close() + + client := NewFhevmCoprocessorClient(conn) + md := metadata.Pairs("Authorization", fmt.Sprintf("Bearer %s", store.coprocessorApiKey)) + grpcContext := metadata.NewOutgoingContext(context.Background(), md) + _, err = client.AsyncCompute(grpcContext, asyncCompReq) + if err != nil { + return 0, err + } + + // mark handles done in db + store.dbMutex.Lock() + defer store.dbMutex.Unlock() + stmt, err := store.dbConn.Prepare("UPDATE computations SET is_sent = 1 WHERE output_handle = ?") + if err != nil { + return 0, err + } + + for _, handle := range handlesToMarkDone { + _, err := stmt.Exec(handle) + if err != nil { + return 0, err + } + } + + return len(asyncCompReq.Computations), nil + } + + return 0, nil +} + +func CreateSqliteCiphertextStore(dbPath string, ctx context.Context, coprocUrl, coprocApiKey string) (*SqliteCiphertextStore, error) { + dbConn, err := sql.Open("sqlite3", dbPath) + if err != nil { + return nil, err + } + + err = doMigrations(dbConn, ctx) + if err != nil { + return nil, err + } + + return &SqliteCiphertextStore{ + dbConn: dbConn, + dbMutex: sync.Mutex{}, + coprocessorUrl: coprocUrl, + coprocessorApiKey: coprocApiKey, + jobChannel: make(chan bool), + }, nil +} + +func doMigrations(dbConn *sql.DB, ctx context.Context) error { + trx, err := dbConn.BeginTx(ctx, &sql.TxOptions{}) + if err != nil { + return err + } + + _, err = trx.Exec(` + CREATE TABLE IF NOT EXISTS computations( + output_handle BINARY PRIMARY KEY, + payload BINARY, -- protobuf AsyncComputation type + is_sent INT DEFAULT 0 + ); + + CREATE INDEX computations_sent ON computations(is_sent); + `) + if err != nil { + return err + } + + err = trx.Commit() + if err != nil { + return err + } + + return nil +} diff --git a/fhevm-engine/fhevm-go-coproc/fhevm/common.pb.go b/fhevm-engine/fhevm-go-coproc/fhevm/common.pb.go new file mode 100644 index 00000000..80971e17 --- /dev/null +++ b/fhevm-engine/fhevm-go-coproc/fhevm/common.pb.go @@ -0,0 +1,223 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc v5.27.3 +// source: common.proto + +package fhevm + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type FheOperation int32 + +const ( + FheOperation_FHE_ADD FheOperation = 0 + FheOperation_FHE_SUB FheOperation = 1 + FheOperation_FHE_MUL FheOperation = 2 + FheOperation_FHE_DIV FheOperation = 3 + FheOperation_FHE_REM FheOperation = 4 + FheOperation_FHE_BIT_AND FheOperation = 5 + FheOperation_FHE_BIT_OR FheOperation = 6 + FheOperation_FHE_BIT_XOR FheOperation = 7 + FheOperation_FHE_SHL FheOperation = 8 + FheOperation_FHE_SHR FheOperation = 9 + FheOperation_FHE_ROTL FheOperation = 10 + FheOperation_FHE_ROTR FheOperation = 11 + FheOperation_FHE_EQ FheOperation = 12 + FheOperation_FHE_NE FheOperation = 13 + FheOperation_FHE_GE FheOperation = 14 + FheOperation_FHE_GT FheOperation = 15 + FheOperation_FHE_LE FheOperation = 16 + FheOperation_FHE_LT FheOperation = 17 + FheOperation_FHE_MIN FheOperation = 18 + FheOperation_FHE_MAX FheOperation = 19 + FheOperation_FHE_NEG FheOperation = 20 + FheOperation_FHE_NOT FheOperation = 21 + FheOperation_FHE_CAST FheOperation = 23 + FheOperation_FHE_IF_THEN_ELSE FheOperation = 25 + FheOperation_FHE_RAND FheOperation = 26 + FheOperation_FHE_RAND_BOUNDED FheOperation = 27 +) + +// Enum value maps for FheOperation. +var ( + FheOperation_name = map[int32]string{ + 0: "FHE_ADD", + 1: "FHE_SUB", + 2: "FHE_MUL", + 3: "FHE_DIV", + 4: "FHE_REM", + 5: "FHE_BIT_AND", + 6: "FHE_BIT_OR", + 7: "FHE_BIT_XOR", + 8: "FHE_SHL", + 9: "FHE_SHR", + 10: "FHE_ROTL", + 11: "FHE_ROTR", + 12: "FHE_EQ", + 13: "FHE_NE", + 14: "FHE_GE", + 15: "FHE_GT", + 16: "FHE_LE", + 17: "FHE_LT", + 18: "FHE_MIN", + 19: "FHE_MAX", + 20: "FHE_NEG", + 21: "FHE_NOT", + 23: "FHE_CAST", + 25: "FHE_IF_THEN_ELSE", + 26: "FHE_RAND", + 27: "FHE_RAND_BOUNDED", + } + FheOperation_value = map[string]int32{ + "FHE_ADD": 0, + "FHE_SUB": 1, + "FHE_MUL": 2, + "FHE_DIV": 3, + "FHE_REM": 4, + "FHE_BIT_AND": 5, + "FHE_BIT_OR": 6, + "FHE_BIT_XOR": 7, + "FHE_SHL": 8, + "FHE_SHR": 9, + "FHE_ROTL": 10, + "FHE_ROTR": 11, + "FHE_EQ": 12, + "FHE_NE": 13, + "FHE_GE": 14, + "FHE_GT": 15, + "FHE_LE": 16, + "FHE_LT": 17, + "FHE_MIN": 18, + "FHE_MAX": 19, + "FHE_NEG": 20, + "FHE_NOT": 21, + "FHE_CAST": 23, + "FHE_IF_THEN_ELSE": 25, + "FHE_RAND": 26, + "FHE_RAND_BOUNDED": 27, + } +) + +func (x FheOperation) Enum() *FheOperation { + p := new(FheOperation) + *p = x + return p +} + +func (x FheOperation) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (FheOperation) Descriptor() protoreflect.EnumDescriptor { + return file_common_proto_enumTypes[0].Descriptor() +} + +func (FheOperation) Type() protoreflect.EnumType { + return &file_common_proto_enumTypes[0] +} + +func (x FheOperation) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use FheOperation.Descriptor instead. +func (FheOperation) EnumDescriptor() ([]byte, []int) { + return file_common_proto_rawDescGZIP(), []int{0} +} + +var File_common_proto protoreflect.FileDescriptor + +var file_common_proto_rawDesc = []byte{ + 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, + 0x66, 0x68, 0x65, 0x76, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2a, 0xfb, 0x02, 0x0a, + 0x0c, 0x46, 0x68, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x0a, + 0x07, 0x46, 0x48, 0x45, 0x5f, 0x41, 0x44, 0x44, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x46, 0x48, + 0x45, 0x5f, 0x53, 0x55, 0x42, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x46, 0x48, 0x45, 0x5f, 0x4d, + 0x55, 0x4c, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x46, 0x48, 0x45, 0x5f, 0x44, 0x49, 0x56, 0x10, + 0x03, 0x12, 0x0b, 0x0a, 0x07, 0x46, 0x48, 0x45, 0x5f, 0x52, 0x45, 0x4d, 0x10, 0x04, 0x12, 0x0f, + 0x0a, 0x0b, 0x46, 0x48, 0x45, 0x5f, 0x42, 0x49, 0x54, 0x5f, 0x41, 0x4e, 0x44, 0x10, 0x05, 0x12, + 0x0e, 0x0a, 0x0a, 0x46, 0x48, 0x45, 0x5f, 0x42, 0x49, 0x54, 0x5f, 0x4f, 0x52, 0x10, 0x06, 0x12, + 0x0f, 0x0a, 0x0b, 0x46, 0x48, 0x45, 0x5f, 0x42, 0x49, 0x54, 0x5f, 0x58, 0x4f, 0x52, 0x10, 0x07, + 0x12, 0x0b, 0x0a, 0x07, 0x46, 0x48, 0x45, 0x5f, 0x53, 0x48, 0x4c, 0x10, 0x08, 0x12, 0x0b, 0x0a, + 0x07, 0x46, 0x48, 0x45, 0x5f, 0x53, 0x48, 0x52, 0x10, 0x09, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x48, + 0x45, 0x5f, 0x52, 0x4f, 0x54, 0x4c, 0x10, 0x0a, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x48, 0x45, 0x5f, + 0x52, 0x4f, 0x54, 0x52, 0x10, 0x0b, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x48, 0x45, 0x5f, 0x45, 0x51, + 0x10, 0x0c, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x48, 0x45, 0x5f, 0x4e, 0x45, 0x10, 0x0d, 0x12, 0x0a, + 0x0a, 0x06, 0x46, 0x48, 0x45, 0x5f, 0x47, 0x45, 0x10, 0x0e, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x48, + 0x45, 0x5f, 0x47, 0x54, 0x10, 0x0f, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x48, 0x45, 0x5f, 0x4c, 0x45, + 0x10, 0x10, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x48, 0x45, 0x5f, 0x4c, 0x54, 0x10, 0x11, 0x12, 0x0b, + 0x0a, 0x07, 0x46, 0x48, 0x45, 0x5f, 0x4d, 0x49, 0x4e, 0x10, 0x12, 0x12, 0x0b, 0x0a, 0x07, 0x46, + 0x48, 0x45, 0x5f, 0x4d, 0x41, 0x58, 0x10, 0x13, 0x12, 0x0b, 0x0a, 0x07, 0x46, 0x48, 0x45, 0x5f, + 0x4e, 0x45, 0x47, 0x10, 0x14, 0x12, 0x0b, 0x0a, 0x07, 0x46, 0x48, 0x45, 0x5f, 0x4e, 0x4f, 0x54, + 0x10, 0x15, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x48, 0x45, 0x5f, 0x43, 0x41, 0x53, 0x54, 0x10, 0x17, + 0x12, 0x14, 0x0a, 0x10, 0x46, 0x48, 0x45, 0x5f, 0x49, 0x46, 0x5f, 0x54, 0x48, 0x45, 0x4e, 0x5f, + 0x45, 0x4c, 0x53, 0x45, 0x10, 0x19, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x48, 0x45, 0x5f, 0x52, 0x41, + 0x4e, 0x44, 0x10, 0x1a, 0x12, 0x14, 0x0a, 0x10, 0x46, 0x48, 0x45, 0x5f, 0x52, 0x41, 0x4e, 0x44, + 0x5f, 0x42, 0x4f, 0x55, 0x4e, 0x44, 0x45, 0x44, 0x10, 0x1b, 0x42, 0x2d, 0x0a, 0x13, 0x69, 0x6f, + 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x66, 0x68, 0x65, 0x76, 0x6d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, + 0x6e, 0x42, 0x0b, 0x46, 0x68, 0x65, 0x76, 0x6d, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x50, 0x01, + 0x5a, 0x07, 0x2e, 0x2f, 0x66, 0x68, 0x65, 0x76, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_common_proto_rawDescOnce sync.Once + file_common_proto_rawDescData = file_common_proto_rawDesc +) + +func file_common_proto_rawDescGZIP() []byte { + file_common_proto_rawDescOnce.Do(func() { + file_common_proto_rawDescData = protoimpl.X.CompressGZIP(file_common_proto_rawDescData) + }) + return file_common_proto_rawDescData +} + +var file_common_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_common_proto_goTypes = []any{ + (FheOperation)(0), // 0: fhevm.common.FheOperation +} +var file_common_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_common_proto_init() } +func file_common_proto_init() { + if File_common_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_common_proto_rawDesc, + NumEnums: 1, + NumMessages: 0, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_common_proto_goTypes, + DependencyIndexes: file_common_proto_depIdxs, + EnumInfos: file_common_proto_enumTypes, + }.Build() + File_common_proto = out.File + file_common_proto_rawDesc = nil + file_common_proto_goTypes = nil + file_common_proto_depIdxs = nil +} diff --git a/fhevm-engine/fhevm-go-coproc/fhevm/coprocessor.pb.go b/fhevm-engine/fhevm-go-coproc/fhevm/coprocessor.pb.go new file mode 100644 index 00000000..1d61d21c --- /dev/null +++ b/fhevm-engine/fhevm-go-coproc/fhevm/coprocessor.pb.go @@ -0,0 +1,1446 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc v5.27.3 +// source: coprocessor.proto + +package fhevm + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type DebugEncryptRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Values []*DebugEncryptRequestSingle `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` +} + +func (x *DebugEncryptRequest) Reset() { + *x = DebugEncryptRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_coprocessor_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DebugEncryptRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DebugEncryptRequest) ProtoMessage() {} + +func (x *DebugEncryptRequest) ProtoReflect() protoreflect.Message { + mi := &file_coprocessor_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DebugEncryptRequest.ProtoReflect.Descriptor instead. +func (*DebugEncryptRequest) Descriptor() ([]byte, []int) { + return file_coprocessor_proto_rawDescGZIP(), []int{0} +} + +func (x *DebugEncryptRequest) GetValues() []*DebugEncryptRequestSingle { + if x != nil { + return x.Values + } + return nil +} + +type DebugEncryptRequestSingle struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Handle []byte `protobuf:"bytes,1,opt,name=handle,proto3" json:"handle,omitempty"` + LeValue []byte `protobuf:"bytes,2,opt,name=le_value,json=leValue,proto3" json:"le_value,omitempty"` + OutputType int32 `protobuf:"varint,3,opt,name=output_type,json=outputType,proto3" json:"output_type,omitempty"` +} + +func (x *DebugEncryptRequestSingle) Reset() { + *x = DebugEncryptRequestSingle{} + if protoimpl.UnsafeEnabled { + mi := &file_coprocessor_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DebugEncryptRequestSingle) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DebugEncryptRequestSingle) ProtoMessage() {} + +func (x *DebugEncryptRequestSingle) ProtoReflect() protoreflect.Message { + mi := &file_coprocessor_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DebugEncryptRequestSingle.ProtoReflect.Descriptor instead. +func (*DebugEncryptRequestSingle) Descriptor() ([]byte, []int) { + return file_coprocessor_proto_rawDescGZIP(), []int{1} +} + +func (x *DebugEncryptRequestSingle) GetHandle() []byte { + if x != nil { + return x.Handle + } + return nil +} + +func (x *DebugEncryptRequestSingle) GetLeValue() []byte { + if x != nil { + return x.LeValue + } + return nil +} + +func (x *DebugEncryptRequestSingle) GetOutputType() int32 { + if x != nil { + return x.OutputType + } + return 0 +} + +type DebugDecryptRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Handles [][]byte `protobuf:"bytes,1,rep,name=handles,proto3" json:"handles,omitempty"` +} + +func (x *DebugDecryptRequest) Reset() { + *x = DebugDecryptRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_coprocessor_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DebugDecryptRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DebugDecryptRequest) ProtoMessage() {} + +func (x *DebugDecryptRequest) ProtoReflect() protoreflect.Message { + mi := &file_coprocessor_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DebugDecryptRequest.ProtoReflect.Descriptor instead. +func (*DebugDecryptRequest) Descriptor() ([]byte, []int) { + return file_coprocessor_proto_rawDescGZIP(), []int{2} +} + +func (x *DebugDecryptRequest) GetHandles() [][]byte { + if x != nil { + return x.Handles + } + return nil +} + +type DebugDecryptResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Values []*DebugDecryptResponseSingle `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` +} + +func (x *DebugDecryptResponse) Reset() { + *x = DebugDecryptResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_coprocessor_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DebugDecryptResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DebugDecryptResponse) ProtoMessage() {} + +func (x *DebugDecryptResponse) ProtoReflect() protoreflect.Message { + mi := &file_coprocessor_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DebugDecryptResponse.ProtoReflect.Descriptor instead. +func (*DebugDecryptResponse) Descriptor() ([]byte, []int) { + return file_coprocessor_proto_rawDescGZIP(), []int{3} +} + +func (x *DebugDecryptResponse) GetValues() []*DebugDecryptResponseSingle { + if x != nil { + return x.Values + } + return nil +} + +type DebugDecryptResponseSingle struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + OutputType int32 `protobuf:"varint,1,opt,name=output_type,json=outputType,proto3" json:"output_type,omitempty"` + Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *DebugDecryptResponseSingle) Reset() { + *x = DebugDecryptResponseSingle{} + if protoimpl.UnsafeEnabled { + mi := &file_coprocessor_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DebugDecryptResponseSingle) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DebugDecryptResponseSingle) ProtoMessage() {} + +func (x *DebugDecryptResponseSingle) ProtoReflect() protoreflect.Message { + mi := &file_coprocessor_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DebugDecryptResponseSingle.ProtoReflect.Descriptor instead. +func (*DebugDecryptResponseSingle) Descriptor() ([]byte, []int) { + return file_coprocessor_proto_rawDescGZIP(), []int{4} +} + +func (x *DebugDecryptResponseSingle) GetOutputType() int32 { + if x != nil { + return x.OutputType + } + return 0 +} + +func (x *DebugDecryptResponseSingle) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +type AsyncComputation struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Operation FheOperation `protobuf:"varint,1,opt,name=operation,proto3,enum=fhevm.common.FheOperation" json:"operation,omitempty"` + OutputHandle []byte `protobuf:"bytes,3,opt,name=output_handle,json=outputHandle,proto3" json:"output_handle,omitempty"` + Inputs []*AsyncComputationInput `protobuf:"bytes,4,rep,name=inputs,proto3" json:"inputs,omitempty"` +} + +func (x *AsyncComputation) Reset() { + *x = AsyncComputation{} + if protoimpl.UnsafeEnabled { + mi := &file_coprocessor_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AsyncComputation) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AsyncComputation) ProtoMessage() {} + +func (x *AsyncComputation) ProtoReflect() protoreflect.Message { + mi := &file_coprocessor_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AsyncComputation.ProtoReflect.Descriptor instead. +func (*AsyncComputation) Descriptor() ([]byte, []int) { + return file_coprocessor_proto_rawDescGZIP(), []int{5} +} + +func (x *AsyncComputation) GetOperation() FheOperation { + if x != nil { + return x.Operation + } + return FheOperation_FHE_ADD +} + +func (x *AsyncComputation) GetOutputHandle() []byte { + if x != nil { + return x.OutputHandle + } + return nil +} + +func (x *AsyncComputation) GetInputs() []*AsyncComputationInput { + if x != nil { + return x.Inputs + } + return nil +} + +type AsyncComputationInput struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Input: + // + // *AsyncComputationInput_InputHandle + // *AsyncComputationInput_Scalar + Input isAsyncComputationInput_Input `protobuf_oneof:"input"` +} + +func (x *AsyncComputationInput) Reset() { + *x = AsyncComputationInput{} + if protoimpl.UnsafeEnabled { + mi := &file_coprocessor_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AsyncComputationInput) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AsyncComputationInput) ProtoMessage() {} + +func (x *AsyncComputationInput) ProtoReflect() protoreflect.Message { + mi := &file_coprocessor_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AsyncComputationInput.ProtoReflect.Descriptor instead. +func (*AsyncComputationInput) Descriptor() ([]byte, []int) { + return file_coprocessor_proto_rawDescGZIP(), []int{6} +} + +func (m *AsyncComputationInput) GetInput() isAsyncComputationInput_Input { + if m != nil { + return m.Input + } + return nil +} + +func (x *AsyncComputationInput) GetInputHandle() []byte { + if x, ok := x.GetInput().(*AsyncComputationInput_InputHandle); ok { + return x.InputHandle + } + return nil +} + +func (x *AsyncComputationInput) GetScalar() []byte { + if x, ok := x.GetInput().(*AsyncComputationInput_Scalar); ok { + return x.Scalar + } + return nil +} + +type isAsyncComputationInput_Input interface { + isAsyncComputationInput_Input() +} + +type AsyncComputationInput_InputHandle struct { + InputHandle []byte `protobuf:"bytes,1,opt,name=input_handle,json=inputHandle,proto3,oneof"` +} + +type AsyncComputationInput_Scalar struct { + Scalar []byte `protobuf:"bytes,2,opt,name=scalar,proto3,oneof"` +} + +func (*AsyncComputationInput_InputHandle) isAsyncComputationInput_Input() {} + +func (*AsyncComputationInput_Scalar) isAsyncComputationInput_Input() {} + +type CiphertextToUpload struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CiphertextType int32 `protobuf:"varint,1,opt,name=ciphertext_type,json=ciphertextType,proto3" json:"ciphertext_type,omitempty"` + CiphertextHandle []byte `protobuf:"bytes,2,opt,name=ciphertext_handle,json=ciphertextHandle,proto3" json:"ciphertext_handle,omitempty"` + CiphertextBytes []byte `protobuf:"bytes,3,opt,name=ciphertext_bytes,json=ciphertextBytes,proto3" json:"ciphertext_bytes,omitempty"` +} + +func (x *CiphertextToUpload) Reset() { + *x = CiphertextToUpload{} + if protoimpl.UnsafeEnabled { + mi := &file_coprocessor_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CiphertextToUpload) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CiphertextToUpload) ProtoMessage() {} + +func (x *CiphertextToUpload) ProtoReflect() protoreflect.Message { + mi := &file_coprocessor_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CiphertextToUpload.ProtoReflect.Descriptor instead. +func (*CiphertextToUpload) Descriptor() ([]byte, []int) { + return file_coprocessor_proto_rawDescGZIP(), []int{7} +} + +func (x *CiphertextToUpload) GetCiphertextType() int32 { + if x != nil { + return x.CiphertextType + } + return 0 +} + +func (x *CiphertextToUpload) GetCiphertextHandle() []byte { + if x != nil { + return x.CiphertextHandle + } + return nil +} + +func (x *CiphertextToUpload) GetCiphertextBytes() []byte { + if x != nil { + return x.CiphertextBytes + } + return nil +} + +type InputToUpload struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + InputPayload []byte `protobuf:"bytes,1,opt,name=input_payload,json=inputPayload,proto3" json:"input_payload,omitempty"` + Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` +} + +func (x *InputToUpload) Reset() { + *x = InputToUpload{} + if protoimpl.UnsafeEnabled { + mi := &file_coprocessor_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InputToUpload) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InputToUpload) ProtoMessage() {} + +func (x *InputToUpload) ProtoReflect() protoreflect.Message { + mi := &file_coprocessor_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InputToUpload.ProtoReflect.Descriptor instead. +func (*InputToUpload) Descriptor() ([]byte, []int) { + return file_coprocessor_proto_rawDescGZIP(), []int{8} +} + +func (x *InputToUpload) GetInputPayload() []byte { + if x != nil { + return x.InputPayload + } + return nil +} + +func (x *InputToUpload) GetSignature() []byte { + if x != nil { + return x.Signature + } + return nil +} + +type InputCiphertextResponseHandle struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Handle []byte `protobuf:"bytes,1,opt,name=handle,proto3" json:"handle,omitempty"` + CiphertextType int32 `protobuf:"varint,2,opt,name=ciphertext_type,json=ciphertextType,proto3" json:"ciphertext_type,omitempty"` +} + +func (x *InputCiphertextResponseHandle) Reset() { + *x = InputCiphertextResponseHandle{} + if protoimpl.UnsafeEnabled { + mi := &file_coprocessor_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InputCiphertextResponseHandle) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InputCiphertextResponseHandle) ProtoMessage() {} + +func (x *InputCiphertextResponseHandle) ProtoReflect() protoreflect.Message { + mi := &file_coprocessor_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InputCiphertextResponseHandle.ProtoReflect.Descriptor instead. +func (*InputCiphertextResponseHandle) Descriptor() ([]byte, []int) { + return file_coprocessor_proto_rawDescGZIP(), []int{9} +} + +func (x *InputCiphertextResponseHandle) GetHandle() []byte { + if x != nil { + return x.Handle + } + return nil +} + +func (x *InputCiphertextResponseHandle) GetCiphertextType() int32 { + if x != nil { + return x.CiphertextType + } + return 0 +} + +type InputCiphertextResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + InputHandles []*InputCiphertextResponseHandle `protobuf:"bytes,1,rep,name=input_handles,json=inputHandles,proto3" json:"input_handles,omitempty"` +} + +func (x *InputCiphertextResponse) Reset() { + *x = InputCiphertextResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_coprocessor_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InputCiphertextResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InputCiphertextResponse) ProtoMessage() {} + +func (x *InputCiphertextResponse) ProtoReflect() protoreflect.Message { + mi := &file_coprocessor_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InputCiphertextResponse.ProtoReflect.Descriptor instead. +func (*InputCiphertextResponse) Descriptor() ([]byte, []int) { + return file_coprocessor_proto_rawDescGZIP(), []int{10} +} + +func (x *InputCiphertextResponse) GetInputHandles() []*InputCiphertextResponseHandle { + if x != nil { + return x.InputHandles + } + return nil +} + +type InputUploadResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UploadResponses []*InputCiphertextResponse `protobuf:"bytes,1,rep,name=upload_responses,json=uploadResponses,proto3" json:"upload_responses,omitempty"` +} + +func (x *InputUploadResponse) Reset() { + *x = InputUploadResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_coprocessor_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InputUploadResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InputUploadResponse) ProtoMessage() {} + +func (x *InputUploadResponse) ProtoReflect() protoreflect.Message { + mi := &file_coprocessor_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InputUploadResponse.ProtoReflect.Descriptor instead. +func (*InputUploadResponse) Descriptor() ([]byte, []int) { + return file_coprocessor_proto_rawDescGZIP(), []int{11} +} + +func (x *InputUploadResponse) GetUploadResponses() []*InputCiphertextResponse { + if x != nil { + return x.UploadResponses + } + return nil +} + +// The request message containing the user's name. +type AsyncComputeRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Computations []*AsyncComputation `protobuf:"bytes,1,rep,name=computations,proto3" json:"computations,omitempty"` +} + +func (x *AsyncComputeRequest) Reset() { + *x = AsyncComputeRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_coprocessor_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AsyncComputeRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AsyncComputeRequest) ProtoMessage() {} + +func (x *AsyncComputeRequest) ProtoReflect() protoreflect.Message { + mi := &file_coprocessor_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AsyncComputeRequest.ProtoReflect.Descriptor instead. +func (*AsyncComputeRequest) Descriptor() ([]byte, []int) { + return file_coprocessor_proto_rawDescGZIP(), []int{12} +} + +func (x *AsyncComputeRequest) GetComputations() []*AsyncComputation { + if x != nil { + return x.Computations + } + return nil +} + +type CiphertextUploadBatch struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + InputCiphertexts []*CiphertextToUpload `protobuf:"bytes,1,rep,name=input_ciphertexts,json=inputCiphertexts,proto3" json:"input_ciphertexts,omitempty"` +} + +func (x *CiphertextUploadBatch) Reset() { + *x = CiphertextUploadBatch{} + if protoimpl.UnsafeEnabled { + mi := &file_coprocessor_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CiphertextUploadBatch) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CiphertextUploadBatch) ProtoMessage() {} + +func (x *CiphertextUploadBatch) ProtoReflect() protoreflect.Message { + mi := &file_coprocessor_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CiphertextUploadBatch.ProtoReflect.Descriptor instead. +func (*CiphertextUploadBatch) Descriptor() ([]byte, []int) { + return file_coprocessor_proto_rawDescGZIP(), []int{13} +} + +func (x *CiphertextUploadBatch) GetInputCiphertexts() []*CiphertextToUpload { + if x != nil { + return x.InputCiphertexts + } + return nil +} + +type InputUploadBatch struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + InputCiphertexts []*InputToUpload `protobuf:"bytes,1,rep,name=input_ciphertexts,json=inputCiphertexts,proto3" json:"input_ciphertexts,omitempty"` +} + +func (x *InputUploadBatch) Reset() { + *x = InputUploadBatch{} + if protoimpl.UnsafeEnabled { + mi := &file_coprocessor_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InputUploadBatch) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InputUploadBatch) ProtoMessage() {} + +func (x *InputUploadBatch) ProtoReflect() protoreflect.Message { + mi := &file_coprocessor_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InputUploadBatch.ProtoReflect.Descriptor instead. +func (*InputUploadBatch) Descriptor() ([]byte, []int) { + return file_coprocessor_proto_rawDescGZIP(), []int{14} +} + +func (x *InputUploadBatch) GetInputCiphertexts() []*InputToUpload { + if x != nil { + return x.InputCiphertexts + } + return nil +} + +type WaitBatch struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CiphertextHandles []string `protobuf:"bytes,1,rep,name=ciphertext_handles,json=ciphertextHandles,proto3" json:"ciphertext_handles,omitempty"` +} + +func (x *WaitBatch) Reset() { + *x = WaitBatch{} + if protoimpl.UnsafeEnabled { + mi := &file_coprocessor_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *WaitBatch) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WaitBatch) ProtoMessage() {} + +func (x *WaitBatch) ProtoReflect() protoreflect.Message { + mi := &file_coprocessor_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use WaitBatch.ProtoReflect.Descriptor instead. +func (*WaitBatch) Descriptor() ([]byte, []int) { + return file_coprocessor_proto_rawDescGZIP(), []int{15} +} + +func (x *WaitBatch) GetCiphertextHandles() []string { + if x != nil { + return x.CiphertextHandles + } + return nil +} + +type GenericResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ResponseCode int32 `protobuf:"varint,1,opt,name=responseCode,proto3" json:"responseCode,omitempty"` +} + +func (x *GenericResponse) Reset() { + *x = GenericResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_coprocessor_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GenericResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GenericResponse) ProtoMessage() {} + +func (x *GenericResponse) ProtoReflect() protoreflect.Message { + mi := &file_coprocessor_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GenericResponse.ProtoReflect.Descriptor instead. +func (*GenericResponse) Descriptor() ([]byte, []int) { + return file_coprocessor_proto_rawDescGZIP(), []int{16} +} + +func (x *GenericResponse) GetResponseCode() int32 { + if x != nil { + return x.ResponseCode + } + return 0 +} + +type FhevmResponses struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CiphertextHandles []string `protobuf:"bytes,1,rep,name=ciphertext_handles,json=ciphertextHandles,proto3" json:"ciphertext_handles,omitempty"` +} + +func (x *FhevmResponses) Reset() { + *x = FhevmResponses{} + if protoimpl.UnsafeEnabled { + mi := &file_coprocessor_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FhevmResponses) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FhevmResponses) ProtoMessage() {} + +func (x *FhevmResponses) ProtoReflect() protoreflect.Message { + mi := &file_coprocessor_proto_msgTypes[17] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FhevmResponses.ProtoReflect.Descriptor instead. +func (*FhevmResponses) Descriptor() ([]byte, []int) { + return file_coprocessor_proto_rawDescGZIP(), []int{17} +} + +func (x *FhevmResponses) GetCiphertextHandles() []string { + if x != nil { + return x.CiphertextHandles + } + return nil +} + +var File_coprocessor_proto protoreflect.FileDescriptor + +var file_coprocessor_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x63, 0x6f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x11, 0x66, 0x68, 0x65, 0x76, 0x6d, 0x2e, 0x63, 0x6f, 0x70, 0x72, 0x6f, + 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x1a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5b, 0x0a, 0x13, 0x44, 0x65, 0x62, 0x75, 0x67, 0x45, 0x6e, 0x63, + 0x72, 0x79, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x44, 0x0a, 0x06, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x66, 0x68, + 0x65, 0x76, 0x6d, 0x2e, 0x63, 0x6f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x2e, + 0x44, 0x65, 0x62, 0x75, 0x67, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x73, 0x22, 0x6f, 0x0a, 0x19, 0x44, 0x65, 0x62, 0x75, 0x67, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x12, 0x16, + 0x0a, 0x06, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, + 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x54, 0x79, + 0x70, 0x65, 0x22, 0x2f, 0x0a, 0x13, 0x44, 0x65, 0x62, 0x75, 0x67, 0x44, 0x65, 0x63, 0x72, 0x79, + 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x68, 0x61, 0x6e, + 0x64, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x07, 0x68, 0x61, 0x6e, 0x64, + 0x6c, 0x65, 0x73, 0x22, 0x5d, 0x0a, 0x14, 0x44, 0x65, 0x62, 0x75, 0x67, 0x44, 0x65, 0x63, 0x72, + 0x79, 0x70, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, 0x06, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x66, 0x68, + 0x65, 0x76, 0x6d, 0x2e, 0x63, 0x6f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x2e, + 0x44, 0x65, 0x62, 0x75, 0x67, 0x44, 0x65, 0x63, 0x72, 0x79, 0x70, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x73, 0x22, 0x53, 0x0a, 0x1a, 0x44, 0x65, 0x62, 0x75, 0x67, 0x44, 0x65, 0x63, 0x72, 0x79, + 0x70, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, + 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xb3, 0x01, 0x0a, 0x10, 0x41, 0x73, 0x79, 0x6e, + 0x63, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x38, 0x0a, 0x09, + 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x1a, 0x2e, 0x66, 0x68, 0x65, 0x76, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x46, + 0x68, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x6f, 0x70, 0x65, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, + 0x5f, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x6f, + 0x75, 0x74, 0x70, 0x75, 0x74, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x12, 0x40, 0x0a, 0x06, 0x69, + 0x6e, 0x70, 0x75, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x66, 0x68, + 0x65, 0x76, 0x6d, 0x2e, 0x63, 0x6f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x2e, + 0x41, 0x73, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x49, 0x6e, 0x70, 0x75, 0x74, 0x52, 0x06, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x73, 0x22, 0x5f, 0x0a, + 0x15, 0x41, 0x73, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x12, 0x23, 0x0a, 0x0c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5f, + 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x0b, + 0x69, 0x6e, 0x70, 0x75, 0x74, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x06, 0x73, + 0x63, 0x61, 0x6c, 0x61, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x06, 0x73, + 0x63, 0x61, 0x6c, 0x61, 0x72, 0x42, 0x07, 0x0a, 0x05, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x22, 0x95, + 0x01, 0x0a, 0x12, 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x54, 0x6f, 0x55, + 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, + 0x65, 0x78, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, + 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2b, + 0x0a, 0x11, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x5f, 0x68, 0x61, 0x6e, + 0x64, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x10, 0x63, 0x69, 0x70, 0x68, 0x65, + 0x72, 0x74, 0x65, 0x78, 0x74, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x63, + 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, + 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x22, 0x52, 0x0a, 0x0d, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x54, + 0x6f, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x69, 0x6e, 0x70, 0x75, 0x74, + 0x5f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, + 0x69, 0x6e, 0x70, 0x75, 0x74, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x1c, 0x0a, 0x09, + 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0x60, 0x0a, 0x1d, 0x49, 0x6e, + 0x70, 0x75, 0x74, 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x68, + 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x68, 0x61, 0x6e, + 0x64, 0x6c, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, + 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x63, 0x69, + 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x54, 0x79, 0x70, 0x65, 0x22, 0x70, 0x0a, 0x17, + 0x49, 0x6e, 0x70, 0x75, 0x74, 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x55, 0x0a, 0x0d, 0x69, 0x6e, 0x70, 0x75, 0x74, + 0x5f, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x30, + 0x2e, 0x66, 0x68, 0x65, 0x76, 0x6d, 0x2e, 0x63, 0x6f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, + 0x6f, 0x72, 0x2e, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, + 0x78, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, + 0x52, 0x0c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x73, 0x22, 0x6c, + 0x0a, 0x13, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x55, 0x0a, 0x10, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x5f, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x2a, 0x2e, 0x66, 0x68, 0x65, 0x76, 0x6d, 0x2e, 0x63, 0x6f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, + 0x73, 0x6f, 0x72, 0x2e, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, + 0x65, 0x78, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x0f, 0x75, 0x70, 0x6c, + 0x6f, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x22, 0x5e, 0x0a, 0x13, + 0x41, 0x73, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x47, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x66, 0x68, 0x65, 0x76, + 0x6d, 0x2e, 0x63, 0x6f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x2e, 0x41, 0x73, + 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, + 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x6b, 0x0a, 0x15, + 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, + 0x42, 0x61, 0x74, 0x63, 0x68, 0x12, 0x52, 0x0a, 0x11, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5f, 0x63, + 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x25, 0x2e, 0x66, 0x68, 0x65, 0x76, 0x6d, 0x2e, 0x63, 0x6f, 0x70, 0x72, 0x6f, 0x63, 0x65, + 0x73, 0x73, 0x6f, 0x72, 0x2e, 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x54, + 0x6f, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x43, 0x69, + 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x73, 0x22, 0x61, 0x0a, 0x10, 0x49, 0x6e, 0x70, + 0x75, 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x61, 0x74, 0x63, 0x68, 0x12, 0x4d, 0x0a, + 0x11, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5f, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, + 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x66, 0x68, 0x65, 0x76, 0x6d, + 0x2e, 0x63, 0x6f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x2e, 0x49, 0x6e, 0x70, + 0x75, 0x74, 0x54, 0x6f, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x10, 0x69, 0x6e, 0x70, 0x75, + 0x74, 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x73, 0x22, 0x3a, 0x0a, 0x09, + 0x57, 0x61, 0x69, 0x74, 0x42, 0x61, 0x74, 0x63, 0x68, 0x12, 0x2d, 0x0a, 0x12, 0x63, 0x69, 0x70, + 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x5f, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, + 0x74, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x73, 0x22, 0x35, 0x0a, 0x0f, 0x47, 0x65, 0x6e, 0x65, + 0x72, 0x69, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x72, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x22, + 0x3f, 0x0a, 0x0e, 0x46, 0x68, 0x65, 0x76, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x5f, + 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x63, + 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x73, + 0x32, 0xea, 0x04, 0x0a, 0x10, 0x46, 0x68, 0x65, 0x76, 0x6d, 0x43, 0x6f, 0x70, 0x72, 0x6f, 0x63, + 0x65, 0x73, 0x73, 0x6f, 0x72, 0x12, 0x5c, 0x0a, 0x0c, 0x41, 0x73, 0x79, 0x6e, 0x63, 0x43, 0x6f, + 0x6d, 0x70, 0x75, 0x74, 0x65, 0x12, 0x26, 0x2e, 0x66, 0x68, 0x65, 0x76, 0x6d, 0x2e, 0x63, 0x6f, + 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x2e, 0x41, 0x73, 0x79, 0x6e, 0x63, 0x43, + 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, + 0x66, 0x68, 0x65, 0x76, 0x6d, 0x2e, 0x63, 0x6f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, + 0x72, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x63, 0x0a, 0x11, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x43, 0x69, 0x70, + 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x73, 0x12, 0x28, 0x2e, 0x66, 0x68, 0x65, 0x76, 0x6d, + 0x2e, 0x63, 0x6f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x2e, 0x43, 0x69, 0x70, + 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x61, 0x74, + 0x63, 0x68, 0x1a, 0x22, 0x2e, 0x66, 0x68, 0x65, 0x76, 0x6d, 0x2e, 0x63, 0x6f, 0x70, 0x72, 0x6f, + 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5f, 0x0a, 0x10, 0x57, 0x61, 0x69, 0x74, + 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x26, 0x2e, 0x66, + 0x68, 0x65, 0x76, 0x6d, 0x2e, 0x63, 0x6f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, + 0x2e, 0x41, 0x73, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x66, 0x68, 0x65, 0x76, 0x6d, 0x2e, 0x63, 0x6f, 0x70, + 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x2e, 0x46, 0x68, 0x65, 0x76, 0x6d, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x22, 0x00, 0x12, 0x5d, 0x0a, 0x0c, 0x55, 0x70, 0x6c, + 0x6f, 0x61, 0x64, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x73, 0x12, 0x23, 0x2e, 0x66, 0x68, 0x65, 0x76, + 0x6d, 0x2e, 0x63, 0x6f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x2e, 0x49, 0x6e, + 0x70, 0x75, 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x61, 0x74, 0x63, 0x68, 0x1a, 0x26, + 0x2e, 0x66, 0x68, 0x65, 0x76, 0x6d, 0x2e, 0x63, 0x6f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, + 0x6f, 0x72, 0x2e, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6b, 0x0a, 0x16, 0x44, 0x65, 0x62, 0x75, + 0x67, 0x44, 0x65, 0x63, 0x72, 0x79, 0x70, 0x74, 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, + 0x78, 0x74, 0x12, 0x26, 0x2e, 0x66, 0x68, 0x65, 0x76, 0x6d, 0x2e, 0x63, 0x6f, 0x70, 0x72, 0x6f, + 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x44, 0x65, 0x63, 0x72, + 0x79, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x66, 0x68, 0x65, + 0x76, 0x6d, 0x2e, 0x63, 0x6f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x2e, 0x44, + 0x65, 0x62, 0x75, 0x67, 0x44, 0x65, 0x63, 0x72, 0x79, 0x70, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x66, 0x0a, 0x16, 0x44, 0x65, 0x62, 0x75, 0x67, 0x45, 0x6e, + 0x63, 0x72, 0x79, 0x70, 0x74, 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x12, + 0x26, 0x2e, 0x66, 0x68, 0x65, 0x76, 0x6d, 0x2e, 0x63, 0x6f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, + 0x73, 0x6f, 0x72, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x66, 0x68, 0x65, 0x76, 0x6d, 0x2e, + 0x63, 0x6f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x2e, 0x47, 0x65, 0x6e, 0x65, + 0x72, 0x69, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x37, 0x0a, + 0x18, 0x69, 0x6f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x66, 0x68, 0x65, 0x76, 0x6d, 0x63, 0x6f, + 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x42, 0x10, 0x46, 0x68, 0x65, 0x76, 0x6d, + 0x43, 0x6f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x50, 0x01, 0x5a, 0x07, 0x2e, + 0x2f, 0x66, 0x68, 0x65, 0x76, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_coprocessor_proto_rawDescOnce sync.Once + file_coprocessor_proto_rawDescData = file_coprocessor_proto_rawDesc +) + +func file_coprocessor_proto_rawDescGZIP() []byte { + file_coprocessor_proto_rawDescOnce.Do(func() { + file_coprocessor_proto_rawDescData = protoimpl.X.CompressGZIP(file_coprocessor_proto_rawDescData) + }) + return file_coprocessor_proto_rawDescData +} + +var file_coprocessor_proto_msgTypes = make([]protoimpl.MessageInfo, 18) +var file_coprocessor_proto_goTypes = []any{ + (*DebugEncryptRequest)(nil), // 0: fhevm.coprocessor.DebugEncryptRequest + (*DebugEncryptRequestSingle)(nil), // 1: fhevm.coprocessor.DebugEncryptRequestSingle + (*DebugDecryptRequest)(nil), // 2: fhevm.coprocessor.DebugDecryptRequest + (*DebugDecryptResponse)(nil), // 3: fhevm.coprocessor.DebugDecryptResponse + (*DebugDecryptResponseSingle)(nil), // 4: fhevm.coprocessor.DebugDecryptResponseSingle + (*AsyncComputation)(nil), // 5: fhevm.coprocessor.AsyncComputation + (*AsyncComputationInput)(nil), // 6: fhevm.coprocessor.AsyncComputationInput + (*CiphertextToUpload)(nil), // 7: fhevm.coprocessor.CiphertextToUpload + (*InputToUpload)(nil), // 8: fhevm.coprocessor.InputToUpload + (*InputCiphertextResponseHandle)(nil), // 9: fhevm.coprocessor.InputCiphertextResponseHandle + (*InputCiphertextResponse)(nil), // 10: fhevm.coprocessor.InputCiphertextResponse + (*InputUploadResponse)(nil), // 11: fhevm.coprocessor.InputUploadResponse + (*AsyncComputeRequest)(nil), // 12: fhevm.coprocessor.AsyncComputeRequest + (*CiphertextUploadBatch)(nil), // 13: fhevm.coprocessor.CiphertextUploadBatch + (*InputUploadBatch)(nil), // 14: fhevm.coprocessor.InputUploadBatch + (*WaitBatch)(nil), // 15: fhevm.coprocessor.WaitBatch + (*GenericResponse)(nil), // 16: fhevm.coprocessor.GenericResponse + (*FhevmResponses)(nil), // 17: fhevm.coprocessor.FhevmResponses + (FheOperation)(0), // 18: fhevm.common.FheOperation +} +var file_coprocessor_proto_depIdxs = []int32{ + 1, // 0: fhevm.coprocessor.DebugEncryptRequest.values:type_name -> fhevm.coprocessor.DebugEncryptRequestSingle + 4, // 1: fhevm.coprocessor.DebugDecryptResponse.values:type_name -> fhevm.coprocessor.DebugDecryptResponseSingle + 18, // 2: fhevm.coprocessor.AsyncComputation.operation:type_name -> fhevm.common.FheOperation + 6, // 3: fhevm.coprocessor.AsyncComputation.inputs:type_name -> fhevm.coprocessor.AsyncComputationInput + 9, // 4: fhevm.coprocessor.InputCiphertextResponse.input_handles:type_name -> fhevm.coprocessor.InputCiphertextResponseHandle + 10, // 5: fhevm.coprocessor.InputUploadResponse.upload_responses:type_name -> fhevm.coprocessor.InputCiphertextResponse + 5, // 6: fhevm.coprocessor.AsyncComputeRequest.computations:type_name -> fhevm.coprocessor.AsyncComputation + 7, // 7: fhevm.coprocessor.CiphertextUploadBatch.input_ciphertexts:type_name -> fhevm.coprocessor.CiphertextToUpload + 8, // 8: fhevm.coprocessor.InputUploadBatch.input_ciphertexts:type_name -> fhevm.coprocessor.InputToUpload + 12, // 9: fhevm.coprocessor.FhevmCoprocessor.AsyncCompute:input_type -> fhevm.coprocessor.AsyncComputeRequest + 13, // 10: fhevm.coprocessor.FhevmCoprocessor.UploadCiphertexts:input_type -> fhevm.coprocessor.CiphertextUploadBatch + 12, // 11: fhevm.coprocessor.FhevmCoprocessor.WaitComputations:input_type -> fhevm.coprocessor.AsyncComputeRequest + 14, // 12: fhevm.coprocessor.FhevmCoprocessor.UploadInputs:input_type -> fhevm.coprocessor.InputUploadBatch + 2, // 13: fhevm.coprocessor.FhevmCoprocessor.DebugDecryptCiphertext:input_type -> fhevm.coprocessor.DebugDecryptRequest + 0, // 14: fhevm.coprocessor.FhevmCoprocessor.DebugEncryptCiphertext:input_type -> fhevm.coprocessor.DebugEncryptRequest + 16, // 15: fhevm.coprocessor.FhevmCoprocessor.AsyncCompute:output_type -> fhevm.coprocessor.GenericResponse + 16, // 16: fhevm.coprocessor.FhevmCoprocessor.UploadCiphertexts:output_type -> fhevm.coprocessor.GenericResponse + 17, // 17: fhevm.coprocessor.FhevmCoprocessor.WaitComputations:output_type -> fhevm.coprocessor.FhevmResponses + 11, // 18: fhevm.coprocessor.FhevmCoprocessor.UploadInputs:output_type -> fhevm.coprocessor.InputUploadResponse + 3, // 19: fhevm.coprocessor.FhevmCoprocessor.DebugDecryptCiphertext:output_type -> fhevm.coprocessor.DebugDecryptResponse + 16, // 20: fhevm.coprocessor.FhevmCoprocessor.DebugEncryptCiphertext:output_type -> fhevm.coprocessor.GenericResponse + 15, // [15:21] is the sub-list for method output_type + 9, // [9:15] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name +} + +func init() { file_coprocessor_proto_init() } +func file_coprocessor_proto_init() { + if File_coprocessor_proto != nil { + return + } + file_common_proto_init() + if !protoimpl.UnsafeEnabled { + file_coprocessor_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*DebugEncryptRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_coprocessor_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*DebugEncryptRequestSingle); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_coprocessor_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*DebugDecryptRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_coprocessor_proto_msgTypes[3].Exporter = func(v any, i int) any { + switch v := v.(*DebugDecryptResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_coprocessor_proto_msgTypes[4].Exporter = func(v any, i int) any { + switch v := v.(*DebugDecryptResponseSingle); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_coprocessor_proto_msgTypes[5].Exporter = func(v any, i int) any { + switch v := v.(*AsyncComputation); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_coprocessor_proto_msgTypes[6].Exporter = func(v any, i int) any { + switch v := v.(*AsyncComputationInput); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_coprocessor_proto_msgTypes[7].Exporter = func(v any, i int) any { + switch v := v.(*CiphertextToUpload); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_coprocessor_proto_msgTypes[8].Exporter = func(v any, i int) any { + switch v := v.(*InputToUpload); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_coprocessor_proto_msgTypes[9].Exporter = func(v any, i int) any { + switch v := v.(*InputCiphertextResponseHandle); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_coprocessor_proto_msgTypes[10].Exporter = func(v any, i int) any { + switch v := v.(*InputCiphertextResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_coprocessor_proto_msgTypes[11].Exporter = func(v any, i int) any { + switch v := v.(*InputUploadResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_coprocessor_proto_msgTypes[12].Exporter = func(v any, i int) any { + switch v := v.(*AsyncComputeRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_coprocessor_proto_msgTypes[13].Exporter = func(v any, i int) any { + switch v := v.(*CiphertextUploadBatch); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_coprocessor_proto_msgTypes[14].Exporter = func(v any, i int) any { + switch v := v.(*InputUploadBatch); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_coprocessor_proto_msgTypes[15].Exporter = func(v any, i int) any { + switch v := v.(*WaitBatch); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_coprocessor_proto_msgTypes[16].Exporter = func(v any, i int) any { + switch v := v.(*GenericResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_coprocessor_proto_msgTypes[17].Exporter = func(v any, i int) any { + switch v := v.(*FhevmResponses); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_coprocessor_proto_msgTypes[6].OneofWrappers = []any{ + (*AsyncComputationInput_InputHandle)(nil), + (*AsyncComputationInput_Scalar)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_coprocessor_proto_rawDesc, + NumEnums: 0, + NumMessages: 18, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_coprocessor_proto_goTypes, + DependencyIndexes: file_coprocessor_proto_depIdxs, + MessageInfos: file_coprocessor_proto_msgTypes, + }.Build() + File_coprocessor_proto = out.File + file_coprocessor_proto_rawDesc = nil + file_coprocessor_proto_goTypes = nil + file_coprocessor_proto_depIdxs = nil +} diff --git a/fhevm-engine/fhevm-go-coproc/fhevm/fhelib.go b/fhevm-engine/fhevm-go-coproc/fhevm/fhelib.go new file mode 100644 index 00000000..236223b1 --- /dev/null +++ b/fhevm-engine/fhevm-go-coproc/fhevm/fhelib.go @@ -0,0 +1,183 @@ +package fhevm + +import ( + "encoding/binary" + "fmt" + + "github.com/ethereum/go-ethereum/crypto" +) + +type FheLibMethod struct { + // Name of the fhelib function + Name string + // types of the arguments that the fhelib function take. format is "(type1,type2...)" (e.g "(uint256,bytes1)") + ArgTypes string + runFunction func(sess CoprocessorSession, input []byte, outputHandle []byte) error + ScalarSupport bool + NonScalarDisabled bool +} + +var signatureToFheLibMethod = map[uint32]*FheLibMethod{} + +func FheLibMethods() []*FheLibMethod { + return []*FheLibMethod{ + { + Name: "fheAdd", + ArgTypes: "(uint256,uint256,bytes1)", + runFunction: fheAddRun, + ScalarSupport: true, + }, + { + Name: "fheSub", + ArgTypes: "(uint256,uint256,bytes1)", + runFunction: fheSubRun, + ScalarSupport: true, + }, + { + Name: "fheMul", + ArgTypes: "(uint256,uint256,bytes1)", + runFunction: fheMulRun, + ScalarSupport: true, + }, + { + Name: "fheRem", + ArgTypes: "(uint256,uint256,bytes1)", + runFunction: fheRemRun, + ScalarSupport: true, + NonScalarDisabled: true, + }, + { + Name: "fheBitAnd", + ArgTypes: "(uint256,uint256,bytes1)", + runFunction: fheBitAndRun, + ScalarSupport: false, + }, + { + Name: "fheBitOr", + ArgTypes: "(uint256,uint256,bytes1)", + runFunction: fheBitOrRun, + ScalarSupport: false, + }, + { + Name: "fheBitXor", + ArgTypes: "(uint256,uint256,bytes1)", + runFunction: fheBitXorRun, + ScalarSupport: false, + }, + { + Name: "fheShl", + ArgTypes: "(uint256,uint256,bytes1)", + runFunction: fheShlRun, + ScalarSupport: true, + }, + { + Name: "fheShr", + ArgTypes: "(uint256,uint256,bytes1)", + runFunction: fheShrRun, + ScalarSupport: true, + }, + { + Name: "fheRotl", + ArgTypes: "(uint256,uint256,bytes1)", + runFunction: fheRotlRun, + ScalarSupport: true, + }, + { + Name: "fheRotr", + ArgTypes: "(uint256,uint256,bytes1)", + runFunction: fheRotrRun, + ScalarSupport: true, + }, + { + Name: "fheEq", + ArgTypes: "(uint256,uint256,bytes1)", + runFunction: fheEqRun, + ScalarSupport: true, + }, + { + Name: "fheNe", + ArgTypes: "(uint256,uint256,bytes1)", + runFunction: fheNeRun, + ScalarSupport: true, + }, + { + Name: "fheGe", + ArgTypes: "(uint256,uint256,bytes1)", + runFunction: fheGeRun, + ScalarSupport: true, + }, + { + Name: "fheGt", + ArgTypes: "(uint256,uint256,bytes1)", + runFunction: fheGtRun, + ScalarSupport: true, + }, + { + Name: "fheLe", + ArgTypes: "(uint256,uint256,bytes1)", + runFunction: fheLeRun, + ScalarSupport: true, + }, + { + Name: "fheLt", + ArgTypes: "(uint256,uint256,bytes1)", + runFunction: fheLtRun, + ScalarSupport: true, + }, + { + Name: "fheMin", + ArgTypes: "(uint256,uint256,bytes1)", + runFunction: fheMinRun, + ScalarSupport: true, + }, + { + Name: "fheMax", + ArgTypes: "(uint256,uint256,bytes1)", + runFunction: fheMaxRun, + ScalarSupport: true, + }, + { + Name: "fheNeg", + ArgTypes: "(uint256)", + runFunction: fheNegRun, + }, + { + Name: "fheNot", + ArgTypes: "(uint256)", + runFunction: fheNotRun, + }, + { + Name: "fheIfThenElse", + ArgTypes: "(uint256,uint256,uint256)", + runFunction: fheIfThenElseRun, + }, + { + Name: "cast", + ArgTypes: "(uint256,bytes1)", + runFunction: castRun, + }, + { + Name: "fheRand", + ArgTypes: "(bytes1)", + runFunction: fheRandRun, + }, + { + Name: "fheRandBounded", + ArgTypes: "(uint256,bytes1)", + runFunction: fheRandBoundedRun, + }, + } +} + +func MakeKeccakSignature(input string) uint32 { + return binary.BigEndian.Uint32(crypto.Keccak256([]byte(input))[0:4]) +} + +func init() { + // create the mapping for every available fhelib method + for _, method := range FheLibMethods() { + signature := fmt.Sprintf("%s%s", method.Name, method.ArgTypes) + signatureNum := MakeKeccakSignature(signature) + signatureToFheLibMethod[signatureNum] = method + } +} diff --git a/fhevm-engine/fhevm-go-coproc/fhevm/fhelib_ops.go b/fhevm-engine/fhevm-go-coproc/fhevm/fhelib_ops.go new file mode 100644 index 00000000..c9ed5099 --- /dev/null +++ b/fhevm-engine/fhevm-go-coproc/fhevm/fhelib_ops.go @@ -0,0 +1,1484 @@ +package fhevm + +import ( + "errors" + "fmt" + "math/big" +) + +func handleType(handle []byte) FheUintType { + return FheUintType(handle[30]) +} + +func fheAddRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 65 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:65] + + isScalar, err := isScalarOp(input) + if err != nil { + return err + } + + operation := FheAdd + if !isScalar { + lhs, rhs, err := get2FheOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + + if err != nil { + return err + } + + return nil + } else { + lhs, rhs, err := getScalarOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + + if err != nil { + return err + } + return nil + } +} + +func fheSubRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 65 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:65] + + isScalar, err := isScalarOp(input) + if err != nil { + return err + } + + operation := FheSub + if !isScalar { + lhs, rhs, err := get2FheOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + + if err != nil { + return err + } + + return nil + } else { + lhs, rhs, err := getScalarOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + + if err != nil { + return err + } + return nil + } +} + +func fheMulRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 65 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:65] + + isScalar, err := isScalarOp(input) + if err != nil { + return err + } + + operation := FheMul + if !isScalar { + lhs, rhs, err := get2FheOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + + if err != nil { + return err + } + + return nil + } else { + lhs, rhs, err := getScalarOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + + if err != nil { + return err + } + return nil + } +} + +func fheRemRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 65 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:65] + + isScalar, err := isScalarOp(input) + if err != nil { + return err + } + + operation := FheRem + if !isScalar { + lhs, rhs, err := get2FheOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + + if err != nil { + return err + } + + return nil + } else { + lhs, rhs, err := getScalarOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + return nil + } +} + +func fheBitAndRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 65 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:65] + + isScalar, err := isScalarOp(input) + if err != nil { + return err + } + + operation := FheBitAnd + if !isScalar { + lhs, rhs, err := get2FheOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + + return nil + } else { + return errors.New("scalar fheBitAnd is not supported") + } +} + +func fheBitOrRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 65 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:65] + + isScalar, err := isScalarOp(input) + if err != nil { + return err + } + + operation := FheBitOr + if !isScalar { + lhs, rhs, err := get2FheOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + + return nil + } else { + return errors.New("scalar fheBitOr is not supported") + } +} + +func fheBitXorRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 65 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:65] + + isScalar, err := isScalarOp(input) + if err != nil { + return err + } + + operation := FheBitXor + if !isScalar { + lhs, rhs, err := get2FheOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + + return nil + } else { + return errors.New("scalar fheBitXor is not supported") + } +} + +func fheShlRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 65 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:65] + + isScalar, err := isScalarOp(input) + if err != nil { + return err + } + + operation := FheShl + if !isScalar { + lhs, rhs, err := get2FheOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + + return nil + } else { + lhs, rhs, err := getScalarOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + return nil + } +} + +func fheShrRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 65 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:65] + + isScalar, err := isScalarOp(input) + if err != nil { + return err + } + + operation := FheShr + if !isScalar { + lhs, rhs, err := get2FheOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + + return nil + } else { + lhs, rhs, err := getScalarOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + return nil + } +} + +func fheRotlRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 65 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:65] + + isScalar, err := isScalarOp(input) + if err != nil { + return err + } + + operation := FheRotl + if !isScalar { + lhs, rhs, err := get2FheOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + + return nil + } else { + lhs, rhs, err := getScalarOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + return nil + } +} + +func fheRotrRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 65 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:65] + + isScalar, err := isScalarOp(input) + if err != nil { + return err + } + + operation := FheRotr + if !isScalar { + lhs, rhs, err := get2FheOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + + return nil + } else { + lhs, rhs, err := getScalarOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + return nil + } +} + +func fheEqRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 65 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:65] + + isScalar, err := isScalarOp(input) + if err != nil { + return err + } + + operation := FheEq + if !isScalar { + lhs, rhs, err := get2FheOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + + return nil + } else { + lhs, rhs, err := getScalarOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + return nil + } +} + +func fheNeRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 65 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:65] + + isScalar, err := isScalarOp(input) + if err != nil { + return err + } + + operation := FheNe + if !isScalar { + lhs, rhs, err := get2FheOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + + return nil + } else { + lhs, rhs, err := getScalarOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + return nil + } +} + +func fheGeRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 65 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:65] + + isScalar, err := isScalarOp(input) + if err != nil { + return err + } + + operation := FheGe + if !isScalar { + lhs, rhs, err := get2FheOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + + return nil + } else { + lhs, rhs, err := getScalarOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + return nil + } +} + +func fheGtRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 65 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:65] + + isScalar, err := isScalarOp(input) + if err != nil { + return err + } + + operation := FheGt + if !isScalar { + lhs, rhs, err := get2FheOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + + return nil + } else { + lhs, rhs, err := getScalarOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + return nil + } +} + +func fheLeRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 65 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:65] + + isScalar, err := isScalarOp(input) + if err != nil { + return err + } + + operation := FheLe + if !isScalar { + lhs, rhs, err := get2FheOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + + return nil + } else { + lhs, rhs, err := getScalarOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + return nil + } +} + +func fheLtRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 65 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:65] + + isScalar, err := isScalarOp(input) + if err != nil { + return err + } + + operation := FheLt + if !isScalar { + lhs, rhs, err := get2FheOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + + return nil + } else { + lhs, rhs, err := getScalarOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + return nil + } +} + +func fheMinRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 65 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:65] + + isScalar, err := isScalarOp(input) + if err != nil { + return err + } + + operation := FheMin + if !isScalar { + lhs, rhs, err := get2FheOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + + return nil + } else { + lhs, rhs, err := getScalarOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + return nil + } +} + +func fheMaxRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 65 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:65] + + isScalar, err := isScalarOp(input) + if err != nil { + return err + } + + operation := FheMax + if !isScalar { + lhs, rhs, err := get2FheOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + + return nil + } else { + lhs, rhs, err := getScalarOperands(sess, input) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: lhs, + FheUintType: handleType(lhs), + IsScalar: false, + }, + { + Handle: rhs, + FheUintType: handleType(rhs), + IsScalar: isScalar, + }, + }, + }) + if err != nil { + return err + } + return nil + } +} + +func fheNegRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 32 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:32] + + ct, err := getSingleFheOperand(sess, input) + if err != nil { + return err + } + + operation := FheNeg + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: ct, + FheUintType: handleType(ct), + IsScalar: false, + }, + }, + }) + if err != nil { + return err + } + + return nil +} + +func fheNotRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 32 { + return fmt.Errorf("expected at least 65 bytes as input, got %d", len(unslicedInput)) + } + input := unslicedInput[0:32] + + ct, err := getSingleFheOperand(sess, input) + if err != nil { + return err + } + + operation := FheNot + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: ct, + FheUintType: handleType(ct), + IsScalar: false, + }, + }, + }) + if err != nil { + return err + } + + return nil +} + +func fheIfThenElseRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 96 { + return fmt.Errorf("expected at least 96 bytes as input, got %d", len(unslicedInput)) + } + inputs := unslicedInput[0:96] + + first, second, third, err := getThreeFheOperands(sess, inputs) + if err != nil { + return err + } + + if handleType(second) != handleType(third) { + return errors.New("fheIfThenElse second argument type doesn't match third argument type") + } + + operation := FheIfThenElse + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: first, + FheUintType: handleType(first), + IsScalar: false, + }, + { + Handle: second, + FheUintType: handleType(second), + IsScalar: false, + }, + { + Handle: third, + FheUintType: handleType(third), + IsScalar: false, + }, + }, + }) + if err != nil { + return err + } + + return nil +} + +func castRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 33 { + return fmt.Errorf("expected at least 33 bytes as input, got %d", len(unslicedInput)) + } + + inputCt := unslicedInput[0:32] + toType := unslicedInput[32] + + operation := FheCast + if !IsValidFheType(toType) { + return fmt.Errorf("invalid fhe type byte: %d", toType) + } + + sourceCt, err := getSingleFheOperand(sess, inputCt) + if err != nil { + return err + } + + err = sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: operation, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: sourceCt, + FheUintType: handleType(sourceCt), + IsScalar: false, + }, + { + Handle: []byte{toType}, + FheUintType: FheUint8, + IsScalar: true, + }, + }, + }) + if err != nil { + return err + } + + return nil +} + +func fheRandRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 1 { + return fmt.Errorf("expected at least 1 bytes as input, got %d", len(unslicedInput)) + } + + resultTypeByte := unslicedInput[0] + if !IsValidFheType(resultTypeByte) { + return fmt.Errorf("invalid fhe type byte: %d", resultTypeByte) + } + + err := sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: FheRand, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: outputHandle, + FheUintType: FheUint8, + IsScalar: true, + }, + }, + }) + if err != nil { + return err + } + + return nil +} + +func fheRandBoundedRun(sess CoprocessorSession, unslicedInput []byte, outputHandle []byte) error { + if len(unslicedInput) < 33 { + return fmt.Errorf("expected at least 1 bytes as input, got %d", len(unslicedInput)) + } + + resultTypeByte := unslicedInput[32] + if !IsValidFheType(resultTypeByte) { + return fmt.Errorf("invalid fhe type byte: %d", resultTypeByte) + } + + upperBound := big.NewInt(0) + upperBound.SetBytes(unslicedInput[0:32]) + + err := sess.GetStore().InsertComputation(ComputationToInsert{ + Operation: FheRandBounded, + OutputHandle: outputHandle, + Operands: []ComputationOperand{ + { + Handle: unslicedInput[0:32], + FheUintType: FheUint32, + IsScalar: true, + }, + { + Handle: outputHandle, + FheUintType: FheUint8, + IsScalar: true, + }, + }, + }) + if err != nil { + return err + } + + return nil +} + +func isScalarOp(input []byte) (bool, error) { + if len(input) != 65 { + return false, errors.New("input needs to contain two 256-bit sized values and 1 8-bit value") + } + isScalar := (input[64] == 1) + return isScalar, nil +} + +func get2FheOperands(sess CoprocessorSession, input []byte) (lhs []byte, rhs []byte, err error) { + if len(input) != 65 { + return nil, nil, errors.New("input needs to contain two 256-bit sized values and 1 8-bit value") + } + return input[0:32], input[32:64], nil +} + +func getSingleFheOperand(sess CoprocessorSession, input []byte) (operand []byte, err error) { + if len(input) != 32 { + return nil, errors.New("input needs to contain one 256-bit sized value") + } + return input[0:32], nil +} + +func getScalarOperands(sess CoprocessorSession, input []byte) (lhs []byte, rhs []byte, err error) { + if len(input) != 65 { + return nil, nil, errors.New("input needs to contain two 256-bit sized values and 1 8-bit value") + } + return input[0:32], input[32:64], nil +} + +func getThreeFheOperands(sess CoprocessorSession, input []byte) (first []byte, second []byte, third []byte, err error) { + if len(input) != 96 { + return nil, nil, nil, errors.New("input needs to contain three 256-bit sized values") + } + + return input[0:32], input[32:64], input[64:96], nil +} diff --git a/fhevm-engine/fhevm-go-coproc/go.mod b/fhevm-engine/fhevm-go-coproc/go.mod new file mode 100644 index 00000000..a77b9b85 --- /dev/null +++ b/fhevm-engine/fhevm-go-coproc/go.mod @@ -0,0 +1,21 @@ +module github.com/zama-ai/fhevm-backend/fhevm-engine/fhevm-go-coproc + +go 1.21 + +require ( + github.com/ethereum/go-ethereum v1.13.15 + github.com/mattn/go-sqlite3 v1.14.22 + google.golang.org/grpc v1.66.0 + google.golang.org/protobuf v1.34.1 +) + +require ( + github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect + github.com/holiman/uint256 v1.2.4 // indirect + golang.org/x/crypto v0.24.0 // indirect + golang.org/x/net v0.26.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/text v0.16.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect +) diff --git a/fhevm-engine/fhevm-go-coproc/go.sum b/fhevm-engine/fhevm-go-coproc/go.sum new file mode 100644 index 00000000..96245181 --- /dev/null +++ b/fhevm-engine/fhevm-go-coproc/go.sum @@ -0,0 +1,32 @@ +github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k= +github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/ethereum/go-ethereum v1.13.15 h1:U7sSGYGo4SPjP6iNIifNoyIAiNjrmQkz6EwQG+/EZWo= +github.com/ethereum/go-ethereum v1.13.15/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= +github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= +github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 h1:1GBuWVLM/KMVUv1t1En5Gs+gFZCNd360GGb4sSxtrhU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/grpc v1.66.0 h1:DibZuoBznOxbDQxRINckZcUvnCEvrW9pcWIE2yF9r1c= +google.golang.org/grpc v1.66.0/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= diff --git a/proto/common.proto b/proto/common.proto index 29779489..4fd196fd 100644 --- a/proto/common.proto +++ b/proto/common.proto @@ -3,6 +3,7 @@ syntax = "proto3"; option java_multiple_files = true; option java_package = "io.grpc.fhevmcommon"; option java_outer_classname = "FhevmCommon"; +option go_package = "./fhevm"; package fhevm.common; @@ -29,7 +30,9 @@ enum FheOperation { FHE_MAX = 19; FHE_NEG = 20; FHE_NOT = 21; - FHE_CAST = 30; - FHE_IF_THEN_ELSE = 31; + FHE_CAST = 23; + FHE_IF_THEN_ELSE = 25; + FHE_RAND = 26; + FHE_RAND_BOUNDED = 27; FHE_GET_CIPHERTEXT = 32; } diff --git a/proto/coprocessor.proto b/proto/coprocessor.proto index 10ac5d6b..85c64353 100644 --- a/proto/coprocessor.proto +++ b/proto/coprocessor.proto @@ -3,6 +3,7 @@ syntax = "proto3"; option java_multiple_files = true; option java_package = "io.grpc.fhevmcoprocessor"; option java_outer_classname = "FhevmCoprocessor"; +option go_package = "./fhevm"; package fhevm.coprocessor;