Skip to content

Chi Squared Test

moritzwinger edited this page Mar 31, 2021 · 10 revisions

Task

The Χ2 or chi-squared tests are common statistical tests. For our application, we specifically consider Pearson's Goodness-of-Fit test as it can be used to test for deviation from the Hardy-Weinberg equilibrium in Genome Wide Association Studies (GWAS).

We split the computation into a polynomial part on the server and a final set of divisions on the client, as proposed by Lauter et al. First, the server receives the encrypted genotype counts N0, N1, N2 then it computes α, (βi)i=0,1,2 as follows:
α = (4N0 N2 - N12)2
β1 = 2(2N0+N1)2
β2 = (2N0+N1)(2N2+N1)
β3= 2(2N2+N1)2
and returns the encrypted results to the client. Decrypting these, the client can compute the test statistic as
Χ2 = α/2N ( 1/β1 + 1/β2 + 1/β3). While we consider the genotype counts as inputs, a more realistic deployment scenario would see the server calculate these over an encrypted genomic database.

Implementation in Tools

Cingulata

As the input circuit is already multiplicative depth-optimized, Cingulata's optimizations cannot improve the circuit. Instead, the optimized circuit has a larger multiplicative depth (38 instead of 16), although also significantly less expensive AND gates (277 instead of 1698).

Input circuit
	x depth 16, x gates 796, + gates 1698               <-- Original circuit
Executing optimization command ""
	x depth 15, x gates 576, + gates 1286 *
Executing optimization command "resyn2"
	x depth 40, x gates 894, + gates 326
Executing optimization command "resyn2rs"
	x depth 35, x gates 903, + gates 297
Executing optimization command "recadd3;resyn2rs"
	x depth 38, x gates 2770, + gates 277               <-- optimized circuit

SEAL-BFV

If you are compiling on Apple M1 (arm64) add the following to your CMAkeLists.txt before the line project(eval_benchmark):

SET(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "Build architectures for Mac OS X" FORCE)

SEAL-BFV-SIMD

TFHE

EVA

See https://github.com/MarbleHE/SoK/blob/master/EVA/source/chi_squared/chi_squared.py

Clone this wiki locally