Hyper-Greco: Verifiable FHE with GKR

September 25, 2024 · View on GitHub

GKR prover for BFV Secret Key Encryption based on Greco scheme.

Warning


This is a research project and hasn't been audited. Don't use it production.

Approach

  • This implementation uses linear-time GKR (Libra) prove system.
  • FHE input uni polys generated via circuit_sk.py are converted to multilinear polys on a boolean domain.
  • Polynomial multiplication in the circuit is computed as evaluation (FFT) -> dot product -> interpolation (IFFT)
  • Range checks for all input polys are batched and proved via a single Lasso node.
  • No intermediate commitments; prover can commit to private inputs according to application needs outside this scheme.

Lasso vs LogUp-GKR

LogUp was a first choice for range checks. It works really well for smaller tables (e.g. S_BOUND and E_BOUND) but cannot be naively applied for larger ones. Notably, the R2_BOUNDS table is too large, 2**55+, to be materialized. The halo2-lib range chip approach could've been used to remedy this (decomposition and lookup combination), but then Lasso is arguably a better realization of this technique.

Another downside of using LogUp is committing to lookup tables and multiplicities. Lasso avoids this when lookup tables are structured, which is the case for range checks.

Finally, while multiple lookup input columns can be batched for a single lookup table in LogUp, batching multiple lookup types (range bounds in this case) is impossible with LogUp, afaik. On the contrary, one can batch many lookup types and verify them via a single primary (collation) sum check and two grand product argument GKRs. The approach is inspired by Jolt's instructions lookups.

I should note that since S_BOUND and E_BOUND are small and each only requires a single subtable/dimension, when batching together with other larger-table lookups (which require multiple dimensions per suitable) -- there is a somewhat redundant overhead compared to, say running S_BOUND and E_BOUND as LogUp nodes. However, when accounting for witness generation and commitment/opening time also needed for LogUp batched, Lasso is still more practical. One approach that has not yet been explored is to have two Lasso nodes: one for small tables and one for large ones.

Version with LogUp checks and LogUP IOP can be found in this commit.

Results

Benchmarks run on M1 Macbook Pro with 10 cores and 32GB of RAM.

The parameters have been chosen targeting 128-bit security level for different values of n. For more information on parameters choise, please check Homomorphic Encryption Standard.

Field/extension field: Goldilocks, GoldilocksExt2

nnlogqi\log q_ikkWitness GenProof GenProof Verify
10242717.23 ms103 ms10.9ms
204852111.9 ms159 ms9.84ms
409655224.73 ms265 ms10.8ms
819255481.5 ms588 ms20.9ms
16384548310 ms1.51 s84.9ms
3276859161.04s5.06 s107.9ms

Field/extension field: BN254, BN254

nnlogqi\log q_ikkWitness GenProof GenProof Verify
102427139.0 ms236 ms22.0 ms
204852177.8 ms308 ms10.1 ms
4096552232.2 ms575 ms16.3 ms
8192554845 ms1.65 s36.0ms
163845483.55 s4.87 s166 ms
32768591612.2 s28.8 s529 ms

For comparison, see original Greco benchmarks (proved via Halo2 on M2 Macbook Pro with 12 cores and 32GB of RAM)

Run yourself

cargo test -r test_sk_enc_valid  -- --nocapture

Profiling charts

%%{
  init: {
    'theme': 'dark',
    'themeVariables': {
      'primaryColor': '#FFEC3D',
      'primaryTextColor': '#fff',
      'pie1': '#F5004F',
      'pie2': '#FFEC3D',
      'pie3': '#88D66C'
    }
  }
}%%
pie showData title GKR Prove (Goldilocks) - 1.88s 
    "Lasso" : 1.430
    "Poly mult (FFT/IFFT)" : 0.291
    "Other operations" : 0.128
%%{
  init: {
    'theme': 'dark',
    'themeVariables': {
      'primaryColor': '#FFEC3D',
      'primaryTextColor': '#fff',
      'pie1': '#F5004F',
      'pie2': '#FFEC3D',
      'pie3': '#88D66C'
    }
  }
}%%
pie showData title GKR Verify (Goldilocks) - 79.7ms
    "Lasso" : 39.5
    "Poly mult (FFT/IFFT)" : 5.1
    "Other operations" : 35.1

Known issues & limitations

  • GKR library used is not zero knowledge, thus may leak some sensitive information
  • Memory checking in Lasso uses challenge values sampled from the base field (not the extension field), which isn't secure enough when proving over the Goldilocks field
  • Number of ciphertexts (kk) must be a power of two

Acknowledgements