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

Feature/add new types #92

Merged
merged 9 commits into from
Mar 1, 2024
Prev Previous commit
Next Next commit
feat: add not for ebool
  • Loading branch information
immortal-tofu committed Feb 28, 2024
commit 35bbf84864451c9f793acf4f297be8741d53aa2d
7 changes: 7 additions & 0 deletions fhevm/contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,9 @@ func FheLibNeg(t *testing.T, fheUintType FheUintType) {
func FheLibNot(t *testing.T, fheUintType FheUintType) {
var pt, expected uint64
switch fheUintType {
case FheBool:
pt = 1
expected = 0
case FheUint4:
pt = 5
expected = uint64(15 - uint8(pt))
Expand Down Expand Up @@ -3078,6 +3081,10 @@ func TestFheLibNeg4(t *testing.T) {
FheLibNeg(t, FheUint4)
}

func TestFheLibNotBool(t *testing.T) {
FheLibNot(t, FheBool)
}

func TestFheLibNot4(t *testing.T) {
FheLibNot(t, FheUint4)
}
Expand Down
4 changes: 3 additions & 1 deletion fhevm/tfhe_ciphertext.go
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,9 @@ func (lhs *TfheCiphertext) Neg() (*TfheCiphertext, error) {

func (lhs *TfheCiphertext) Not() (*TfheCiphertext, error) {
return lhs.executeUnaryCiphertextOperation(lhs,
boolUnaryNotSupportedOp,
func(lhs unsafe.Pointer) (unsafe.Pointer, error) {
return C.not_fhe_bool(lhs, sks), nil
},
func(lhs unsafe.Pointer) (unsafe.Pointer, error) {
return C.not_fhe_uint4(lhs, sks), nil
},
Expand Down
2 changes: 2 additions & 0 deletions fhevm/tfhe_wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ void* neg_fhe_uint32(void* ct, void* sks);

void* neg_fhe_uint64(void* ct, void* sks);

void* not_fhe_bool(void* ct, void* sks);

void* not_fhe_uint4(void* ct, void* sks);

void* not_fhe_uint8(void* ct, void* sks);
Expand Down
Loading