Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tfhe): add automatic initialization for ciphertexts #72

Merged
merged 1 commit into from
Jul 7, 2023

Conversation

tremblaythibaultl
Copy link
Contributor

@tremblaythibaultl tremblaythibaultl commented Jul 7, 2023

This PR removes the following incorrect logic of some binary operators:

if (a == 0) {
  return b;
} else if (b == 0) {
  return a;
}

and introduces initialization logic such that if a 0 handle is passed to any binary operator, the handle is set to point to the trivial encryption of 0.
This makes it so that FHE operations on uninitialized ciphertexts do not revert, even in the case of ciphertext/plaintext operations.

This PR also introduces a fix for a bug regarding ciphertext/plaintext operations and Solidity's overload resolution.
With this fix, ciphertext/plaintext operations are only defined for values of the same bit width, meaning add(euint32 a, uint32 b) is defined but add(euint16 a, uint32 b) is not.
It is worth noting that the overload resolution process will implicitely upcast the uint value such that both

add(euint16 a, uint8 b)
add(euint16 a, uint16 b)

will work but

add(euint16 a, uint32 b)

will not.

Copy link
Contributor

@dartdart26 dartdart26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@tremblaythibaultl tremblaythibaultl merged commit e2cf0a4 into main Jul 7, 2023
@tremblaythibaultl tremblaythibaultl deleted the louis/fix-uninitialized branch July 7, 2023 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants