Skip to content

Commit

Permalink
feat: add not for ebool
Browse files Browse the repository at this point in the history
  • Loading branch information
immortal-tofu committed Feb 28, 2024
1 parent 8f39830 commit 35bbf84
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
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

0 comments on commit 35bbf84

Please sign in to comment.