Files
zooqueen bfb13c2488 pkg/fhe: rewrite adapter onto current luxfi/fhe API; fix build
The adapter targeted a removed tfhe-rs-style API (fhe.ServerKey,
DeserializeServerKey, DeserializeCiphertext, ct.Serialize,
DeserializeClientKey) and pinned a stale fhe v1.7.5, so the package did
not compile. The canonical API is radix-integer based:
IntegerEvaluator over *RadixCiphertext, built from IntegerParams +
BootstrapKey, with Marshal/UnmarshalBinary serialization.

- Rewrite the adapter: serverKey bytes -> *fhe.BootstrapKey (the public
  evaluation key); Ciphertext.Data -> marshaled *fhe.RadixCiphertext;
  ops -> IntegerEvaluator methods; Encrypt/Decrypt helpers ->
  IntegerEncryptor/Decryptor over a marshaled *fhe.SecretKey.
- Fix PN10QP27 / 2-bit-block params (repo default) in one place.
- Shl/Shr/Rotl/Rotr take a plaintext shift in the real API (rotates do
  not exist); reject them honestly instead of fabricating a shift from a
  ciphertext rhs.
- Bump fhe v1.7.5 -> v1.8.9; go mod tidy. v1.8.9 (proposed) adds the
  RadixCiphertext codec the adapter needs; a temporary replace points at
  the local checkout until that tag is published (see go.mod TODO).

Adds the repo's first tests: Encrypt/Decrypt round-trip, Execute
end-to-end plumbing, and unsupported-shift rejection.

GOWORK=off CGO_ENABLED=1 go build ./...  -> exit 0
go test ./pkg/fhe/...                     -> PASS
2026-06-21 22:34:50 -07:00
..