Files
fhe-coprocessor/go.mod
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

37 lines
1.4 KiB
AMPL

module github.com/luxfi/fhe-coprocessor
go 1.26.4
require (
github.com/luxfi/fhe v1.8.9
github.com/nats-io/nats.go v1.48.0
github.com/redis/go-redis/v9 v9.7.0
go.uber.org/zap v1.27.1
)
// TODO(fhe-coprocessor): drop this replace once luxfi/fhe v1.8.9 is published.
// v1.8.9 adds RadixCiphertext MarshalBinary/UnmarshalBinary, which the adapter
// requires; until the tag is pushed, build against the local checkout.
replace github.com/luxfi/fhe => ../fhe
require (
github.com/ALTree/bigfloat v0.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/klauspost/compress v1.18.4 // indirect
github.com/luxfi/lattice/v7 v7.1.0 // indirect
github.com/luxfi/math v1.4.1 // indirect
github.com/luxfi/pq v1.0.3 // indirect
github.com/nats-io/nkeys v0.4.15 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/stretchr/testify v1.11.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.49.0 // indirect
golang.org/x/exp v0.0.0-20260312153236-7ab1446f8b90 // indirect
golang.org/x/sys v0.42.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)