fhEVM v0.3: New Stack and Better Performances

January 19, 2024
Morten Dahl

This new version of Zama's fhEVM introduces a new technical stack and the first release of fhevm-go. Performance improvements are expected with the updated TFHE-rs version. Additionally, there's an early version of a centralized Key Management System (KMS) now available, enabling validators to decrypt without needing local decryption keys.

New blockchain stack

Design change.

We are launching fhevm-go that allows easier integrations in go-ethereum based blockchains. This refactor isolates the FHE operations library from the integration part to allow for easier to maintain and cleaner code.

Migration.

We are switching from evmos 0.9 to a new stack with:

  • go-ethereum v1.13.5
  • ethermint (forked from the latest open-source version)
  • CometBFT
  • TFHE-rs v0.4.1

This new stack is already available on our: https://devnet.zama.ai.

Compatibility with Shanghai VM.

fhEVM v0.3 is now compatible with Solidity ^0.8.20 (Shanghai EVM).

Operation cost and new features.

fhEVM v0.3 uses the native TFHE-rs CMUX operator which is way faster than the previous  one.

fhEVM v0.3 adds a simulation mode for faster development that mocks every FHE operation (read more in the documentation). The whole test suite takes 4 seconds in mocked mode instead of 21 minutes. Another advantage is that this mode allows to compute tests coverage, improving security best practices.

Details of Gas estimations for each operation.

We’ve updated gas prices to reflect more the underlying performance. Thanks to the new version of TFHE-rs we are using and its performance, we manage to reduce gas costs for some operations like [.c-inline-code]TFHE.div[.c-inline-code] and [.c-inline-code]TFHE.rem[.c-inline-code].

Function Name ebool/euint8 euint16 euint32
TFHE.add/TFHE.sub 120,000 150,000 180,000
TFHE.add/TFHE.sub (Scalar) 120,000 150,000 180,000
TFHE.mul 200,000 260,000 380,000
TFHE.mul (Scalar) 135,000 140,000 170,000
TFHE.and/TFHE.or/TFHE.xor 30,000 33,000 36,000
TFHE.div (Scalar) 450,000 500,000 550,000
TFHE.shr/TFHE.shl 150,000 180,000 210,000
TFHE.shr/TFHE.shl (Scalar) 32,000 32,000 32,000
TFHE.eq/TFHE.ne/TFHE.ge/TFHE.le/TFHE.gt/TFHE.lt 56,000 67,000 89,000
TFHE.eq/TFHE.ne/TFHE.ge/TFHE.le/TFHE.gt/TFHE.lt (Scalar) 56,000 67,000 89,000
TFHE.min/TFHE.max 220,000 280,000 340,000
TFHE.min/TFHE.max (Scalar) 140,000 165,000 190,000
TFHE.neg/TFHE.not 29,000 31,000 33,000
TFHE.cmux 60,000 65,000 70,000
TFHE.decrypt() 500,000 500,000 500,000
TFHE.randEuintX() 100,000 100,000 100,000

Additional links

Read more related posts