Skip to content

Commit f7bffd5

Browse files
committed
chore(host-contracts): add sum in impl interface contract and generate rust bindings
1 parent d545108 commit f7bffd5

42 files changed

Lines changed: 5006 additions & 656 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

coprocessor/fhevm-engine/fhevm-engine-common/src/tfhe_ops.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3583,7 +3583,9 @@ mod fhe_sum_tests {
35833583

35843584
#[test]
35853585
fn fhe_sum_scalar_not_supported() {
3586-
assert!(!does_fhe_operation_support_scalar(&SupportedFheOperations::FheSum));
3586+
assert!(!does_fhe_operation_support_scalar(
3587+
&SupportedFheOperations::FheSum
3588+
));
35873589
assert!(!SupportedFheOperations::FheSum.does_have_more_than_one_scalar());
35883590
}
35893591

host-contracts/lib/Impl.sol

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,13 @@ interface IFHEVMExecutor {
267267
*/
268268
function fheRandBounded(uint256 upperBound, FheType randType) external returns (bytes32 result);
269269

270+
/**
271+
* @notice Computes FHESum operation over an array of ciphertexts.
272+
* @param values Array of ciphertext handles; all must be the same FheType.
273+
* @return result Result handle of the same FheType as the inputs.
274+
*/
275+
function fheSum(bytes32[] calldata values) external returns (bytes32 result);
276+
270277
/**
271278
* @notice Returns the address of the InputVerifier contract used by the coprocessor.
272279
* @return inputVerifierAddress Address of the InputVerifier.
@@ -705,6 +712,11 @@ library Impl {
705712
result = IFHEVMExecutor($.CoprocessorAddress).fheRandBounded(upperBound, randType);
706713
}
707714

715+
function sum(bytes32[] memory values) internal returns (bytes32 result) {
716+
CoprocessorConfig storage $ = getCoprocessorConfig();
717+
result = IFHEVMExecutor($.CoprocessorAddress).fheSum(values);
718+
}
719+
708720
/**
709721
* @notice Allows the use of handle by address account for this transaction.
710722
* @dev The caller must be allowed to use handle for allowTransient() to succeed.

0 commit comments

Comments
 (0)