Commit Graph

53 Commits

Author SHA1 Message Date
jatZama
3ba5c16820 chore: fixed FHEVMConfig imports 2024-12-03 12:00:47 +01:00
jatZama
83280c66d4 chore: update codegen and removed FHEVMConfig 2024-12-03 11:36:37 +01:00
PacificYield
ec49462f2e docs: updates NatSpec for lib contracts 2024-11-15 14:26:49 +01:00
Joseph-André Turk
45e860d577 feat: updated TFHEExecutor to support new types
chore: eq-neq  bool support and bitwise scalar support

chore: overloads for fheEq and fheNe

fix: reverts onchain when rhs is 0 in fheDiv-fheRem

feat: added support for scalar and,or,xor

chore: cleanup codegen

feat: adds euint128 and euint256 types

chore: removes ebool fheRandBounded and adds manual tests

feat: adds new types for fheRand

feat: adds trivialEncrypt for ebytesXXX

feat: adds fheEq fheNe ifThenElse for new types

chore: rename asyncDecrypt() to initGateway()
2024-10-18 02:33:10 +02:00
Joseph-André Turk
fa5cb0edaf feat: set protocol addresses in dApp storage
chore: removed useless import
2024-09-10 15:01:43 +02:00
Joseph-André Turk
25d10871e5 chore: refactored TFHEExecutor 2024-08-23 18:47:44 +02:00
Joseph-André Turk
a13cb753e9 feat: symbolic computation of fhe operations handles
chore: fixed typo
2024-08-23 18:22:31 +02:00
Joseph-André Turk
a1c02aa962 fix: allow for ebytes256 + reencrypt tests
chore: removed console logs
2024-07-09 14:13:27 +02:00
Joseph-André Turk
205f7e9fda fix: kmsverifier, solidity ver and silence transient warning
chore: updated version of package

chore: updated npmignore and deleted abstracts
2024-07-05 18:50:44 +02:00
Petar Ivanov
68ea71ac70 feat: update with latest Solidity implementation
There are a number of tests that are still not rewritten with the new
APIs. The EncryptedERC20 and Rand examples do work.
2024-06-21 08:05:05 +03:00
Petar Ivanov
d1d41843c1 feat: add support for list-based inputs
More info: https://github.com/zama-ai/fhevm-go/pull/120

API changes will be described in the documentation.

More tests and examples are to be done in a future commit.
2024-06-18 12:45:12 +03:00
Petar Ivanov
7c19b2b426 feat: introduce the ACL and TFHEExecutor contracts
Purpose of this commit is to establish a baseline for a working fhEVM
using the ACL and TFHEExecutor contracts. More tests and a rewrite of
examples will come in a future commit.

The ACL contract manages ciphertext permissions, removing the need for
privileged storage and memory in fhEVM.

The TFHEExecutor contract checks ciphertext permissions in the ACL
contract. Only TFHEExecutor is allowed to call FHE precompiles in the
fhEVM.

Not all tests are passing at that point. Only the Rand and the
EncryptedERC20 ones work.

Tests don't use the KMS for decryption. Instead, we load the secret FHE
key and pass it to fhevmjs for decryption.

Update to fhevmjs 0.5.0-1 and tfhe-rs 0.6.1
2024-06-12 11:30:52 +03:00
Clément 'birdy' Danjou
1e76d443ce fix: fix bug on require 2024-05-28 16:41:06 +02:00
Clément 'birdy' Danjou
82b50abb1c fix: remove length from call to fhevm-go 2024-05-27 14:56:20 +02:00
Clément 'birdy' Danjou
6d11c5e768 feat: add array equality 2024-05-23 15:05:14 +02:00
Clément 'birdy' Danjou
0f6dd3bb06 feat: add rotl and rotr 2024-04-04 15:27:07 +02:00
Clément 'birdy' Danjou
faad51a6ea feat: introduce select in place of cmux 2024-03-08 11:31:53 +01:00
Clément 'birdy' Danjou
756e4e6dae refactor: remove deprecated optReq 2024-03-08 03:34:30 +01:00
Petar Ivanov
fe1e97065e feat: add upper bound for encrypted random integers
Add overloads of TFHE.randEuint() methods that accept an upper bound,
e.g. TFHE.randEuint32(uint32 upperBound). The returned integer will be
in the [0, upperBound) range. Moreover, upperBound must be a power of
2 - that is a design choice for performance reasons.

Note that, as of now, the random numbers are generated in the plain and
are completely public and predictable. An FHE version is coming soon.

Add tests to cover above functionality.
2024-01-09 17:17:40 +02:00
Joseph-André Turk
535b055fc8 Updated Solidity version to ^0.8.20 and OpenZeppelin Contracts to ^5.0.1
updated to ethermint node

updated node dev version

removed parallel flag from hardhat test

reput inband test for ci

setup evm version to Paris to avoid PUSH0 error and updated hardhat version

removed utils.ts.new file

synced package.json and package-lock.json

prettier
2024-01-09 11:05:38 +01:00
Clément 'birdy' Danjou
616f99823b feat() use new cmux 2024-01-08 15:35:51 +01:00
David
bd581422e5 Add network1 development support 2023-10-24 10:56:15 +08:00
youben11
d35e512aa0 feat(lib): add support for the remainder operation 2023-10-10 14:58:18 +01:00
David
0b1eca810e Add stateful opt req test 2023-10-09 12:41:31 +08:00
David
ba72900223 Fix optimistic requires 2023-10-06 11:19:18 +08:00
Clément 'birdy' Danjou
cb1b8a27f1 fix() force 0.8.19 2023-09-25 16:37:13 +02:00
Clément 'birdy' Danjou
59f3480e3f fix() force 0.8.19 version for everything 2023-09-25 16:03:23 +02:00
David
3d133c6951 Implement operator overloading
following operators are supported:
+, - (unary and binary), *, &, |, ^, ~ (unary)
2023-09-21 10:16:47 +03:00
David
f9a7ee72bf Use fheLib precompile for all internal functions 2023-09-19 14:29:01 +03:00
Petar Ivanov
6e35f79e87 Fix input type for the fheRand precompile
Change from bytes32[1] to bytes1[1] as we only send 1 byte for the int
type.

Fix compiler warning in GovernorZama.sol.
2023-09-14 15:06:36 +03:00
Petar Ivanov
323b991765 Add support for the FHE rand precompile
At the moment, the underlying implementation is using a plaintext
PRNG. Because of that, we put a warning for users to be aware of.

Support generation of 8, 16 and 32-bit unsigned integers. Users call it
by `TFHE.randEuint32()` and so on for other types. Can only be called in
transactions - calling it in view functions will fail.

Add tests.

Finally, update the `fhevmjs` dependency to `~0.2.0`.
2023-09-07 15:18:52 +02:00
Louis Tremblay Thibault
7079aa15ad Remove TFHE.req (#121)
* fix(lib): remove requires

* fix(contracts): remove use of `TFHE.req`
2023-09-06 16:19:10 +02:00
David
13c41043f3 Rewrite codegen first stab 2023-08-24 11:34:50 +03:00
David
9c24c582ef Add div scalar function 2023-08-11 09:24:37 +03:00
Petar Ivanov
8bf0e4cf5d Add support for TFHE.decrypt() (#89)
The decrypt() function decrypts the given euint value.

There are a few considerations when doing decryption:
 * if a transaction is reverted due to a failed TFHE.optimisticReq(),
   then any decryptions would leak information as they would already
   have been decrypted when the txn is reverted at the end (due to the
   nature of TFHE.optimisticReq()). To avoid that, we decrypt all optimistic
   requires accumulated up to the decrypt call.
 * gas estimation might be more imprecise, because control flow can now
   depend on decrypted values (that gas estimation doesn't know of as it
   always uses 0)

Remove req/optReq uint overloads.
2023-08-01 11:13:28 +03:00
Clément 'birdy' Danjou
fedd2f952c chore: update prettier conf and update code style 2023-07-28 16:31:23 +02:00
Louis Tremblay Thibault
35d94658a3 feat(tfhe): add support for ebool type (#86)
* feat(tfhe): add support for `ebool` type

* fix(auction): use `ebool` adequately

* fix(cmux): fix CMUX example

* fix(lib): rename variables to be consistent

* fix(lib): fix comments
2023-07-14 11:43:47 +02:00
Petar Ivanov
05a9e3cb60 Add method documentation in TFHE.sol (#85)
Add documentation for methods that didn't have any. Move doc that was
in Impl.sol to TFHE.sol (e.g. cmux, optReq).

Also, fix neg() and not() in TFHE.sol such that they return a result.
2023-07-12 15:54:32 +03:00
Louis Tremblay Thibault
f03245ae89 fix(tfhe): add neg and not overloads (#76) 2023-07-11 10:31:13 +02:00
Louis Tremblay Thibault
1ae6cdc592 fix(lib): make solc max version 0.8.19 (#81)
* fix(lib): make solc max version 0.8.19

* fix(tfhe): delete Trivial.sol
2023-07-11 10:30:59 +02:00
Louis Tremblay Thibault
e2cf0a4835 fix(tfhe): add automatic initialization for cts (#72) 2023-07-07 12:15:13 +02:00
Louis Tremblay Thibault
4c9eafdcb2 fix(impl): fix mul bug (#64) 2023-06-30 10:25:02 +02:00
Louis Tremblay Thibault
ba089fd2a4 Add scalar ops for same size operators (#65)
* fix(tfhe): fix lhs/rhs inversion bug

* fix(tfhe): add same-size scalar ops
2023-06-30 10:24:49 +02:00
Louis Tremblay Thibault
d2ecb53f3b Add scalar ops (#62)
* feat(fhe): add scalar ops

* feat(fhe): add missing ops
2023-06-29 11:24:28 +02:00
Clément 'birdy' Danjou
c167fd0de7 feat() Update name of optReq and req 2023-06-26 18:34:13 +02:00
Louis Tremblay Thibault
f59adff99f feat(fhe): add missing FHE operators (#53)
* feat: add casting

* feat(ops): add missing fhe ops

* feat(tfhe): type rules

* fix(tfhe): change `lte` to `le`
2023-06-26 11:29:10 +02:00
Louis Tremblay Thibault
ab09a06c30 feat: add casting (#50)
* feat: add casting

* fix(style): run prettier
2023-06-22 13:40:27 +02:00
Petar Ivanov
89dbfcce89 Set flag in fhePubKey to signal call from the lib 2023-06-22 13:16:19 +03:00
Louis Tremblay Thibault
f30df9b0ec feat(precompile): add trivial encrypt (#48)
* feat(precompiles): add trivial encrypt

* fix(trivial): fix precompile address
2023-06-21 15:14:46 +02:00
Petar Ivanov
25488ac4db Add support for the fhePubKey precompile
Expose as the fhePubKey() function in TFHE.sol.
2023-06-19 13:08:32 +03:00