Dealing with signed Integers

Hello,

I’m trying to implement homomorphic calculations on the smart contract and I realized that it currently does not support signed integers.

For example if i subtract 10 from 20, I get 4294967286 instead of -10.

Is there any way (or work around) to handle signed integers or negative values using fhevm?

Hello,
TFHE-rs (the library we are using under the hood) supports signed integers, but we didn’t implement it in fhEVM yet. Clearly, it is planned at some point to support signed integers, but we didn’t see many use cases using signed integers so far. What are you building with signed integers?

As you already noticed, if you substract a number from a uint, it will go from the maximum value of a uint32. Based on that you could implement some logic around it, but I wouldn’t recommend to do this kind of trick.

Thank you for your response. I’m trying to implement the calculation of different statistical operations (mode, median, variance etc) on encrypted numbers in the smart contract.