Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Commit

Permalink
fix: fix the destroy instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
immortal-tofu committed Jun 14, 2024
1 parent f00a728 commit 19d1022
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions fhevm/tfhe/tfhe_ciphertext.go
Original file line number Diff line number Diff line change
Expand Up @@ -2689,29 +2689,41 @@ func GenerateObliviousPseudoRandom(generatedType FheUintType, seed uint64, numbe
switch generatedType {
case FheUint4:
resultPtr = C.generate_oblivious_pseudo_random_uint4(C.uint64_t(seed), C.uint64_t(numberOfBits), sks)
if resultPtr == nil {
return nil, errors.New("GenerateObliviousPseudoRandom: generation failed")
}
defer C.destroy_fhe_uint4(resultPtr)
case FheUint8:
resultPtr = C.generate_oblivious_pseudo_random_uint8(C.uint64_t(seed), C.uint64_t(numberOfBits), sks)
if resultPtr == nil {
return nil, errors.New("GenerateObliviousPseudoRandom: generation failed")
}
defer C.destroy_fhe_uint8(resultPtr)
case FheUint16:
resultPtr = C.generate_oblivious_pseudo_random_uint16(C.uint64_t(seed), C.uint64_t(numberOfBits), sks)
if resultPtr == nil {
return nil, errors.New("GenerateObliviousPseudoRandom: generation failed")
}
defer C.destroy_fhe_uint16(resultPtr)
case FheUint32:
resultPtr = C.generate_oblivious_pseudo_random_uint32(C.uint64_t(seed), C.uint64_t(numberOfBits), sks)
if resultPtr == nil {
return nil, errors.New("GenerateObliviousPseudoRandom: generation failed")
}
defer C.destroy_fhe_uint32(resultPtr)
case FheUint64:
resultPtr = C.generate_oblivious_pseudo_random_uint64(C.uint64_t(seed), C.uint64_t(numberOfBits), sks)
if resultPtr == nil {
return nil, errors.New("GenerateObliviousPseudoRandom: generation failed")
}
defer C.destroy_fhe_uint64(resultPtr)
default:
return nil, fmt.Errorf("GenerateObliviousPseudoRandom: unsupported ciphertext type %d", generatedType)
}
if resultPtr == nil {
return nil, errors.New("GenerateObliviousPseudoRandom: generation failed")
}
defer C.destroy_fhe_bool(resultPtr)

ser := &C.DynamicBuffer{}

switch generatedType {
case FheBool:
ret := C.serialize_fhe_bool(resultPtr, ser)
if ret != 0 {
return nil, errors.New("GenerateObliviousPseudoRandom: serialization failed")
}
case FheUint4:
ret := C.serialize_fhe_uint4(resultPtr, ser)
if ret != 0 {
Expand Down

0 comments on commit 19d1022

Please sign in to comment.