diff --git a/pkg/fhevm/operators_arithmetic.go b/pkg/fhevm/operators_arithmetic.go index 904b5f1..87c99e9 100644 --- a/pkg/fhevm/operators_arithmetic.go +++ b/pkg/fhevm/operators_arithmetic.go @@ -8,7 +8,6 @@ import ( "go.opentelemetry.io/otel/trace" ) - func fheAddRun(environment EVMEnvironment, caller common.Address, addr common.Address, input []byte, readOnly bool, runSpan trace.Span) ([]byte, error) { input = input[:minInt(65, len(input))] diff --git a/pkg/fhevm/operators_arithmetic_gas.go b/pkg/fhevm/operators_arithmetic_gas.go index 015a848..33916cc 100644 --- a/pkg/fhevm/operators_arithmetic_gas.go +++ b/pkg/fhevm/operators_arithmetic_gas.go @@ -108,4 +108,4 @@ func fheRemRequiredGas(environment EVMEnvironment, input []byte) uint64 { } return environment.FhevmParams().GasCosts.FheScalarRem[lhs.fheUintType()] } -} \ No newline at end of file +} diff --git a/pkg/fhevm/operators_bit.go b/pkg/fhevm/operators_bit.go index 2af1956..502f3e7 100644 --- a/pkg/fhevm/operators_bit.go +++ b/pkg/fhevm/operators_bit.go @@ -140,7 +140,6 @@ func fheShrRun(environment EVMEnvironment, caller common.Address, addr common.Ad } } - func fheNegRun(environment EVMEnvironment, caller common.Address, addr common.Address, input []byte, readOnly bool, runSpan trace.Span) ([]byte, error) { input = input[:minInt(32, len(input))] @@ -215,7 +214,6 @@ func fheNotRun(environment EVMEnvironment, caller common.Address, addr common.Ad return resultHash[:], nil } - func fheBitAndRun(environment EVMEnvironment, caller common.Address, addr common.Address, input []byte, readOnly bool, runSpan trace.Span) ([]byte, error) { input = input[:minInt(65, len(input))] diff --git a/pkg/fhevm/operators_bit_gas.go b/pkg/fhevm/operators_bit_gas.go index b8e77fb..bf9ea00 100644 --- a/pkg/fhevm/operators_bit_gas.go +++ b/pkg/fhevm/operators_bit_gas.go @@ -42,7 +42,6 @@ func fheShrRequiredGas(environment EVMEnvironment, input []byte) uint64 { return fheShlRequiredGas(environment, input) } - func fheNegRequiredGas(environment EVMEnvironment, input []byte) uint64 { input = input[:minInt(32, len(input))] diff --git a/pkg/fhevm/operators_comparison.go b/pkg/fhevm/operators_comparison.go index 22a6b24..48b335a 100644 --- a/pkg/fhevm/operators_comparison.go +++ b/pkg/fhevm/operators_comparison.go @@ -9,7 +9,6 @@ import ( "go.opentelemetry.io/otel/trace" ) - func fheLeRun(environment EVMEnvironment, caller common.Address, addr common.Address, input []byte, readOnly bool, runSpan trace.Span) ([]byte, error) { input = input[:minInt(65, len(input))] @@ -406,7 +405,6 @@ func fheNeRun(environment EVMEnvironment, caller common.Address, addr common.Add } } - func fheMinRun(environment EVMEnvironment, caller common.Address, addr common.Address, input []byte, readOnly bool, runSpan trace.Span) ([]byte, error) { input = input[:minInt(65, len(input))] @@ -539,7 +537,6 @@ func fheMaxRun(environment EVMEnvironment, caller common.Address, addr common.Ad } } - func fheIfThenElseRun(environment EVMEnvironment, caller common.Address, addr common.Address, input []byte, readOnly bool, runSpan trace.Span) ([]byte, error) { input = input[:minInt(96, len(input))] diff --git a/pkg/fhevm/operators_comparison_gas.go b/pkg/fhevm/operators_comparison_gas.go index 33076b6..0e3fba0 100644 --- a/pkg/fhevm/operators_comparison_gas.go +++ b/pkg/fhevm/operators_comparison_gas.go @@ -86,7 +86,6 @@ func fheNeRequiredGas(environment EVMEnvironment, input []byte) uint64 { return fheEqRequiredGas(environment, input) } - func fheMinRequiredGas(environment EVMEnvironment, input []byte) uint64 { input = input[:minInt(65, len(input))] @@ -123,7 +122,6 @@ func fheMaxRequiredGas(environment EVMEnvironment, input []byte) uint64 { return fheMinRequiredGas(environment, input) } - func fheIfThenElseRequiredGas(environment EVMEnvironment, input []byte) uint64 { input = input[:minInt(96, len(input))] diff --git a/pkg/fhevm/operators_crypto.go b/pkg/fhevm/operators_crypto.go index 34b287f..5beb698 100644 --- a/pkg/fhevm/operators_crypto.go +++ b/pkg/fhevm/operators_crypto.go @@ -17,7 +17,6 @@ import ( "google.golang.org/grpc/credentials/insecure" ) - func verifyCiphertextRun(environment EVMEnvironment, caller common.Address, addr common.Address, input []byte, readOnly bool, runSpan trace.Span) ([]byte, error) { logger := environment.GetLogger() // first 32 bytes of the payload is offset, then 32 bytes are size of byte array diff --git a/pkg/fhevm/params.go b/pkg/fhevm/params.go index 45a6b40..b18d157 100644 --- a/pkg/fhevm/params.go +++ b/pkg/fhevm/params.go @@ -84,7 +84,7 @@ func DefaultGasCosts() GasCosts { tfhe.FheUint64: 500000, }, FheBitwiseOp: map[tfhe.FheUintType]uint64{ - tfhe.FheBool: 16000 + AdjustFHEGas, + tfhe.FheBool: 16000 + AdjustFHEGas, tfhe.FheUint4: 22000 + AdjustFHEGas, tfhe.FheUint8: 24000 + AdjustFHEGas, tfhe.FheUint16: 24000 + AdjustFHEGas, @@ -177,7 +177,7 @@ func DefaultGasCosts() GasCosts { }, // TODO: Costs will depend on the complexity of doing reencryption/decryption by the oracle. FheReencrypt: map[tfhe.FheUintType]uint64{ - tfhe.FheBool: 1000, + tfhe.FheBool: 1000, tfhe.FheUint4: 1000, tfhe.FheUint8: 1000, tfhe.FheUint16: 1100, @@ -185,7 +185,7 @@ func DefaultGasCosts() GasCosts { }, // As of now, verification costs only cover ciphertext deserialization and assume there is no ZKPoK to verify. FheVerify: map[tfhe.FheUintType]uint64{ - tfhe.FheBool: 200, + tfhe.FheBool: 200, tfhe.FheUint4: 200, tfhe.FheUint8: 200, tfhe.FheUint16: 300, @@ -193,7 +193,7 @@ func DefaultGasCosts() GasCosts { tfhe.FheUint64: 800, }, FheTrivialEncrypt: map[tfhe.FheUintType]uint64{ - tfhe.FheBool: 100, + tfhe.FheBool: 100, tfhe.FheUint4: 100, tfhe.FheUint8: 100, tfhe.FheUint16: 200, diff --git a/pkg/kms/constants.go b/pkg/kms/constants.go index 108414e..5538daf 100644 --- a/pkg/kms/constants.go +++ b/pkg/kms/constants.go @@ -3,4 +3,4 @@ package kms import "os" // URL of the KMS gRPC endpoint -var KmsEndpointAddr = os.Getenv("KMS_ENDPOINT_ADDR") \ No newline at end of file +var KmsEndpointAddr = os.Getenv("KMS_ENDPOINT_ADDR") diff --git a/pkg/tfhe/tfhe_ciphertext.go b/pkg/tfhe/tfhe_ciphertext.go index 56b96c5..ad39c0b 100644 --- a/pkg/tfhe/tfhe_ciphertext.go +++ b/pkg/tfhe/tfhe_ciphertext.go @@ -17,7 +17,7 @@ import ( type FheUintType uint8 const ( - FheBool FheUintType = 0 + FheBool FheUintType = 0 FheUint4 FheUintType = 1 FheUint8 FheUintType = 2 FheUint16 FheUintType = 3 @@ -340,8 +340,8 @@ func (ct *TfheCiphertext) executeUnaryCiphertextOperation(rhs *TfheCiphertext, return nil, errors.New("Bool unary op deserialization failed") } res_ptr, err := opBool(ct_ptr) - if (err != nil) { - return nil, err; + if err != nil { + return nil, err } C.destroy_fhe_bool(ct_ptr) if res_ptr == nil { @@ -360,8 +360,8 @@ func (ct *TfheCiphertext) executeUnaryCiphertextOperation(rhs *TfheCiphertext, return nil, errors.New("8 bit unary op deserialization failed") } res_ptr, err := op4(ct_ptr) - if (err != nil) { - return nil, err; + if err != nil { + return nil, err } C.destroy_fhe_uint4(ct_ptr) if res_ptr == nil { @@ -380,8 +380,8 @@ func (ct *TfheCiphertext) executeUnaryCiphertextOperation(rhs *TfheCiphertext, return nil, errors.New("8 bit unary op deserialization failed") } res_ptr, err := op8(ct_ptr) - if (err != nil) { - return nil, err; + if err != nil { + return nil, err } C.destroy_fhe_uint8(ct_ptr) if res_ptr == nil { @@ -400,8 +400,8 @@ func (ct *TfheCiphertext) executeUnaryCiphertextOperation(rhs *TfheCiphertext, return nil, errors.New("16 bit unary op deserialization failed") } res_ptr, err := op16(ct_ptr) - if (err != nil) { - return nil, err; + if err != nil { + return nil, err } C.destroy_fhe_uint16(ct_ptr) if res_ptr == nil { @@ -420,8 +420,8 @@ func (ct *TfheCiphertext) executeUnaryCiphertextOperation(rhs *TfheCiphertext, return nil, errors.New("32 bit unary op deserialization failed") } res_ptr, err := op16(ct_ptr) - if (err != nil) { - return nil, err; + if err != nil { + return nil, err } C.destroy_fhe_uint32(ct_ptr) if res_ptr == nil { @@ -440,8 +440,8 @@ func (ct *TfheCiphertext) executeUnaryCiphertextOperation(rhs *TfheCiphertext, return nil, errors.New("64 bit unary op deserialization failed") } res_ptr, err := op64(ct_ptr) - if (err != nil) { - return nil, err; + if err != nil { + return nil, err } C.destroy_fhe_uint64(ct_ptr) if res_ptr == nil { @@ -474,7 +474,7 @@ func (lhs *TfheCiphertext) executeBinaryCiphertextOperation(rhs *TfheCiphertext, } res := new(TfheCiphertext) - if(returnBool) { + if returnBool { res.FheUintType = FheBool } else { res.FheUintType = lhs.FheUintType @@ -492,8 +492,8 @@ func (lhs *TfheCiphertext) executeBinaryCiphertextOperation(rhs *TfheCiphertext, return nil, errors.New("bool binary op deserialization failed") } res_ptr, err := opBool(lhs_ptr, rhs_ptr) - if (err != nil) { - return nil, err; + if err != nil { + return nil, err } C.destroy_fhe_bool(lhs_ptr) C.destroy_fhe_bool(rhs_ptr) @@ -518,15 +518,15 @@ func (lhs *TfheCiphertext) executeBinaryCiphertextOperation(rhs *TfheCiphertext, return nil, errors.New("4 bit binary op deserialization failed") } res_ptr, err := op4(lhs_ptr, rhs_ptr) - if (err != nil) { - return nil, err; + if err != nil { + return nil, err } C.destroy_fhe_uint4(lhs_ptr) C.destroy_fhe_uint4(rhs_ptr) if res_ptr == nil { return nil, errors.New("4 bit binary op failed") } - if (returnBool) { + if returnBool { ret := C.serialize_fhe_bool(res_ptr, res_ser) C.destroy_fhe_bool(res_ptr) if ret != 0 { @@ -552,15 +552,15 @@ func (lhs *TfheCiphertext) executeBinaryCiphertextOperation(rhs *TfheCiphertext, return nil, errors.New("8 bit binary op deserialization failed") } res_ptr, err := op8(lhs_ptr, rhs_ptr) - if (err != nil) { - return nil, err; + if err != nil { + return nil, err } C.destroy_fhe_uint8(lhs_ptr) C.destroy_fhe_uint8(rhs_ptr) if res_ptr == nil { return nil, errors.New("8 bit binary op failed") } - if (returnBool) { + if returnBool { ret := C.serialize_fhe_bool(res_ptr, res_ser) C.destroy_fhe_bool(res_ptr) if ret != 0 { @@ -586,15 +586,15 @@ func (lhs *TfheCiphertext) executeBinaryCiphertextOperation(rhs *TfheCiphertext, return nil, errors.New("16 bit binary op deserialization failed") } res_ptr, err := op16(lhs_ptr, rhs_ptr) - if (err != nil) { - return nil, err; + if err != nil { + return nil, err } C.destroy_fhe_uint16(lhs_ptr) C.destroy_fhe_uint16(rhs_ptr) if res_ptr == nil { return nil, errors.New("16 bit binary op failed") } - if (returnBool) { + if returnBool { ret := C.serialize_fhe_bool(res_ptr, res_ser) C.destroy_fhe_bool(res_ptr) if ret != 0 { @@ -620,8 +620,8 @@ func (lhs *TfheCiphertext) executeBinaryCiphertextOperation(rhs *TfheCiphertext, return nil, errors.New("32 bit binary op deserialization failed") } res_ptr, err := op32(lhs_ptr, rhs_ptr) - if (err != nil) { - return nil, err; + if err != nil { + return nil, err } C.destroy_fhe_uint32(lhs_ptr) C.destroy_fhe_uint32(rhs_ptr) @@ -629,7 +629,7 @@ func (lhs *TfheCiphertext) executeBinaryCiphertextOperation(rhs *TfheCiphertext, return nil, errors.New("32 bit binary op failed") } - if (returnBool) { + if returnBool { ret := C.serialize_fhe_bool(res_ptr, res_ser) C.destroy_fhe_bool(res_ptr) if ret != 0 { @@ -655,15 +655,15 @@ func (lhs *TfheCiphertext) executeBinaryCiphertextOperation(rhs *TfheCiphertext, return nil, errors.New("64 bit binary op deserialization failed") } res_ptr, err := op64(lhs_ptr, rhs_ptr) - if (err != nil) { - return nil, err; + if err != nil { + return nil, err } C.destroy_fhe_uint64(lhs_ptr) C.destroy_fhe_uint64(rhs_ptr) if res_ptr == nil { return nil, errors.New("64 bit binary op failed") } - if (returnBool) { + if returnBool { ret := C.serialize_fhe_bool(res_ptr, res_ser) C.destroy_fhe_bool(res_ptr) if ret != 0 { @@ -860,7 +860,7 @@ func (lhs *TfheCiphertext) executeBinaryScalarOperation(rhs uint64, op64 func(lhs unsafe.Pointer, rhs C.uint64_t) (unsafe.Pointer, error), returnBool bool) (*TfheCiphertext, error) { res := new(TfheCiphertext) - if(returnBool) { + if returnBool { res.FheUintType = FheBool } else { res.FheUintType = lhs.FheUintType @@ -874,8 +874,8 @@ func (lhs *TfheCiphertext) executeBinaryScalarOperation(rhs uint64, } scalar := C.bool(rhs == 1) res_ptr, err := opBool(lhs_ptr, scalar) - if (err != nil) { - return nil, err; + if err != nil { + return nil, err } C.destroy_fhe_bool(lhs_ptr) if res_ptr == nil { @@ -895,14 +895,14 @@ func (lhs *TfheCiphertext) executeBinaryScalarOperation(rhs uint64, } scalar := C.uint8_t(rhs) res_ptr, err := op4(lhs_ptr, scalar) - if (err != nil) { - return nil, err; + if err != nil { + return nil, err } C.destroy_fhe_uint4(lhs_ptr) if res_ptr == nil { return nil, errors.New("4 bit scalar op failed") } - if (returnBool) { + if returnBool { ret := C.serialize_fhe_bool(res_ptr, res_ser) C.destroy_fhe_bool(res_ptr) if ret != 0 { @@ -924,14 +924,14 @@ func (lhs *TfheCiphertext) executeBinaryScalarOperation(rhs uint64, } scalar := C.uint8_t(rhs) res_ptr, err := op8(lhs_ptr, scalar) - if (err != nil) { - return nil, err; + if err != nil { + return nil, err } C.destroy_fhe_uint8(lhs_ptr) if res_ptr == nil { return nil, errors.New("8 bit scalar op failed") } - if (returnBool) { + if returnBool { ret := C.serialize_fhe_bool(res_ptr, res_ser) C.destroy_fhe_bool(res_ptr) if ret != 0 { @@ -953,14 +953,14 @@ func (lhs *TfheCiphertext) executeBinaryScalarOperation(rhs uint64, } scalar := C.uint16_t(rhs) res_ptr, err := op16(lhs_ptr, scalar) - if (err != nil) { - return nil, err; + if err != nil { + return nil, err } C.destroy_fhe_uint16(lhs_ptr) if res_ptr == nil { return nil, errors.New("16 bit scalar op failed") } - if (returnBool) { + if returnBool { ret := C.serialize_fhe_bool(res_ptr, res_ser) C.destroy_fhe_bool(res_ptr) if ret != 0 { @@ -982,14 +982,14 @@ func (lhs *TfheCiphertext) executeBinaryScalarOperation(rhs uint64, } scalar := C.uint32_t(rhs) res_ptr, err := op32(lhs_ptr, scalar) - if (err != nil) { - return nil, err; + if err != nil { + return nil, err } C.destroy_fhe_uint32(lhs_ptr) if res_ptr == nil { return nil, errors.New("32 bit scalar op failed") } - if (returnBool) { + if returnBool { ret := C.serialize_fhe_bool(res_ptr, res_ser) C.destroy_fhe_bool(res_ptr) if ret != 0 { @@ -1011,14 +1011,14 @@ func (lhs *TfheCiphertext) executeBinaryScalarOperation(rhs uint64, } scalar := C.uint64_t(rhs) res_ptr, err := op64(lhs_ptr, scalar) - if (err != nil) { - return nil, err; + if err != nil { + return nil, err } C.destroy_fhe_uint64(lhs_ptr) if res_ptr == nil { return nil, errors.New("64 bit scalar op failed") } - if (returnBool) { + if returnBool { ret := C.serialize_fhe_bool(res_ptr, res_ser) C.destroy_fhe_bool(res_ptr) if ret != 0 { @@ -1822,75 +1822,75 @@ func (ct *TfheCiphertext) CastTo(castToType FheUintType) (*TfheCiphertext, error default: panic("castTo: unexpected type to cast to") } - case FheUint4: - switch castToType { - case FheUint8: - from_ptr := C.deserialize_fhe_uint4(toDynamicBufferView(ct.Serialization)) - if from_ptr == nil { - return nil, errors.New("castTo failed to deserialize FheUint4 ciphertext") - } - to_ptr := C.cast_4_8(from_ptr, sks) - C.destroy_fhe_uint4(from_ptr) - if to_ptr == nil { - return nil, errors.New("castTo failed to cast FheUint4 to FheUint16") - } - var err error - res.Serialization, err = serialize(to_ptr, castToType) - C.destroy_fhe_uint8(to_ptr) - if err != nil { - return nil, err - } - case FheUint16: - from_ptr := C.deserialize_fhe_uint4(toDynamicBufferView(ct.Serialization)) - if from_ptr == nil { - return nil, errors.New("castTo failed to deserialize FheUint4 ciphertext") - } - to_ptr := C.cast_4_16(from_ptr, sks) - C.destroy_fhe_uint4(from_ptr) - if to_ptr == nil { - return nil, errors.New("castTo failed to cast FheUint4 to FheUint16") - } - var err error - res.Serialization, err = serialize(to_ptr, castToType) - C.destroy_fhe_uint16(to_ptr) - if err != nil { - return nil, err - } - case FheUint32: - from_ptr := C.deserialize_fhe_uint4(toDynamicBufferView(ct.Serialization)) - if from_ptr == nil { - return nil, errors.New("castTo failed to deserialize FheUint4 ciphertext") - } - to_ptr := C.cast_4_32(from_ptr, sks) - C.destroy_fhe_uint4(from_ptr) - if to_ptr == nil { - return nil, errors.New("castTo failed to cast FheUint4 to FheUint32") - } - var err error - res.Serialization, err = serialize(to_ptr, castToType) - C.destroy_fhe_uint32(to_ptr) - if err != nil { - return nil, err - } - case FheUint64: - from_ptr := C.deserialize_fhe_uint4(toDynamicBufferView(ct.Serialization)) - if from_ptr == nil { - return nil, errors.New("castTo failed to deserialize FheUint4 ciphertext") - } - to_ptr := C.cast_4_64(from_ptr, sks) - C.destroy_fhe_uint4(from_ptr) - if to_ptr == nil { - return nil, errors.New("castTo failed to cast FheUint4 to FheUint64") - } - var err error - res.Serialization, err = serialize(to_ptr, castToType) - C.destroy_fhe_uint64(to_ptr) - if err != nil { - return nil, err - } - default: - panic("castTo: unexpected type to cast to") + case FheUint4: + switch castToType { + case FheUint8: + from_ptr := C.deserialize_fhe_uint4(toDynamicBufferView(ct.Serialization)) + if from_ptr == nil { + return nil, errors.New("castTo failed to deserialize FheUint4 ciphertext") + } + to_ptr := C.cast_4_8(from_ptr, sks) + C.destroy_fhe_uint4(from_ptr) + if to_ptr == nil { + return nil, errors.New("castTo failed to cast FheUint4 to FheUint16") + } + var err error + res.Serialization, err = serialize(to_ptr, castToType) + C.destroy_fhe_uint8(to_ptr) + if err != nil { + return nil, err + } + case FheUint16: + from_ptr := C.deserialize_fhe_uint4(toDynamicBufferView(ct.Serialization)) + if from_ptr == nil { + return nil, errors.New("castTo failed to deserialize FheUint4 ciphertext") } + to_ptr := C.cast_4_16(from_ptr, sks) + C.destroy_fhe_uint4(from_ptr) + if to_ptr == nil { + return nil, errors.New("castTo failed to cast FheUint4 to FheUint16") + } + var err error + res.Serialization, err = serialize(to_ptr, castToType) + C.destroy_fhe_uint16(to_ptr) + if err != nil { + return nil, err + } + case FheUint32: + from_ptr := C.deserialize_fhe_uint4(toDynamicBufferView(ct.Serialization)) + if from_ptr == nil { + return nil, errors.New("castTo failed to deserialize FheUint4 ciphertext") + } + to_ptr := C.cast_4_32(from_ptr, sks) + C.destroy_fhe_uint4(from_ptr) + if to_ptr == nil { + return nil, errors.New("castTo failed to cast FheUint4 to FheUint32") + } + var err error + res.Serialization, err = serialize(to_ptr, castToType) + C.destroy_fhe_uint32(to_ptr) + if err != nil { + return nil, err + } + case FheUint64: + from_ptr := C.deserialize_fhe_uint4(toDynamicBufferView(ct.Serialization)) + if from_ptr == nil { + return nil, errors.New("castTo failed to deserialize FheUint4 ciphertext") + } + to_ptr := C.cast_4_64(from_ptr, sks) + C.destroy_fhe_uint4(from_ptr) + if to_ptr == nil { + return nil, errors.New("castTo failed to cast FheUint4 to FheUint64") + } + var err error + res.Serialization, err = serialize(to_ptr, castToType) + C.destroy_fhe_uint64(to_ptr) + if err != nil { + return nil, err + } + default: + panic("castTo: unexpected type to cast to") + } case FheUint8: switch castToType { case FheUint4: @@ -2187,7 +2187,7 @@ func (ct *TfheCiphertext) Decrypt() (big.Int, error) { var result C.bool ret = C.decrypt_fhe_bool(cks, ptr, &result) C.destroy_fhe_bool(ptr) - if (result) { + if result { value = 1 } else { value = 0 diff --git a/pkg/tfhe/tfhe_key_management.go b/pkg/tfhe/tfhe_key_management.go index b079285..9be572a 100644 --- a/pkg/tfhe/tfhe_key_management.go +++ b/pkg/tfhe/tfhe_key_management.go @@ -67,7 +67,7 @@ func initCiphertextSizes() { compactFheCiphertextSize = make(map[FheUintType]uint) ExpandedFheCiphertextSize[FheBool] = uint(len(new(TfheCiphertext).TrivialEncrypt(*big.NewInt(0), FheBool).Serialize())) - ExpandedFheCiphertextSize[FheUint4] = uint(len(new(TfheCiphertext).TrivialEncrypt(*big.NewInt(0), FheUint4).Serialize())) + ExpandedFheCiphertextSize[FheUint4] = uint(len(new(TfheCiphertext).TrivialEncrypt(*big.NewInt(0), FheUint4).Serialize())) ExpandedFheCiphertextSize[FheUint8] = uint(len(new(TfheCiphertext).TrivialEncrypt(*big.NewInt(0), FheUint8).Serialize())) ExpandedFheCiphertextSize[FheUint16] = uint(len(new(TfheCiphertext).TrivialEncrypt(*big.NewInt(0), FheUint16).Serialize())) ExpandedFheCiphertextSize[FheUint32] = uint(len(new(TfheCiphertext).TrivialEncrypt(*big.NewInt(0), FheUint32).Serialize())) diff --git a/pkg/tfhe/tfhe_wrappers.go b/pkg/tfhe/tfhe_wrappers.go index c546e7b..a017be5 100644 --- a/pkg/tfhe/tfhe_wrappers.go +++ b/pkg/tfhe/tfhe_wrappers.go @@ -71,7 +71,7 @@ func EncryptAndSerializeCompact(value uint64, fheUintType FheUintType) []byte { case FheBool: val := false if value == 1 { - val = true + val = true } C.public_key_encrypt_and_serialize_fhe_bool_list(pks, C.bool(val), out) case FheUint4: