2023-09-07 13:12:45 +02:00
2023-08-24 11:34:50 +03:00
2023-08-24 11:34:50 +03:00
2023-09-07 13:12:45 +02:00
2023-09-01 08:19:17 +03:00

fhEVM

A Solidity library for interacting with an fhEVM blockchain.

Install

npm install fhevm

or

yarn install fhevm

Usage

// SPDX-License-Identifier: BSD-3-Clause-Clear

pragma solidity >=0.8.13 <0.8.20;

import "fhevm/lib/TFHE.sol";

contract Counter {
  euint32 counter;

  function add(bytes calldata encryptedValue) public {
    euint32 value = TFHE.asEuint32(encryptedValue);
    counter = TFHE.add(counter, value);
  }

  function getCounter(bytes32 publicKey) returns (bytes memory) {
    return TFHE.reencrypt(counter, publicKey);
  }
}

See our documentation on https://docs.zama.ai/homepage/ for more examples.

Development Guide

Install dependencies (Solidity libraries and dev tools)

npm install

Note: Solidity files are formatted with prettier.

Generate TFHE lib and tests

npm run codegen

WARNING: Use this command to generate Solidity code and prettier result automatically!

Files that are generated now (can be seen inside codegen/main.ts)

lib/Common.sol
lib/Precompiles.sol
lib/Impl.sol
lib/TFHE.sol
contracts/tests/TFHETestSuiteX.sol
test/tfheOperations/tfheOperations.ts

Adding new operators

Operators can be defined as data inside codegen/common.ts file and code automatically generates solidity overloads. Test for overloads must be added (or the build doesn't pass) inside codegen/overloadsTests.ts file.

Test

npm test
Description
No description provided
Readme BSD-3-Clause 22 MiB
Languages
TypeScript 99.4%
Python 0.5%