# Homomorphic Threshold Decryption

A sketch of one construction is as follows.

Write a value $v∈[−2_{63},2_{63})$ in radix $11$ with signed coefficients, i.e., as $v=v_{0}+v_{1}2_{11}+⋯+v_{5}2_{55}$ with $v_{i}∈[−2_{11},2_{11})$. Encode each coefficient $v_{i}$ as $v_{i}B$ and use ElGamal encryption to form the ciphertext $Enc_{D}(v)=(Enc_{D}(v_{0}B),…,Enc_{D}(v_{5}B)).$

Each ElGamal ciphertext consists of two group elements; if group elements can be encoded in 32 bytes, this gives a 384-byte ciphertext. To decrypt $Enc_{D}(v)$, use ElGamal decryption to obtain the group elements $(v_{0}B,…,v_{5}B)$, and then use a lookup table to recover $v_{i}$ from $v_{i}B$, or fail if the value is unknown.

This can in principle be done inside of a zkSNARK circuit if the underlying group is an embedded elliptic curve, together with certification that the ciphertext was correctly formed with in-range coefficients.

Addition and subtraction of ciphertexts are done componentwise, using the homomorphic property of ElGamal encryptions, and the fact that $v_{i}B+w_{i}B=(v_{i}+w_{i})B$.

Adding $n=2_{k}$ ciphertexts of values whose coefficients were bounded as $∣v_{i,k}∣≤2_{11}$ results in a sum whose coefficients $w_{i}$ are bounded as $∣w_{i}∣≤n2_{11}=2_{11+k}$. Choosing $k=7$ and accounting for sign means that a lookup table of size $2⋅2_{11+7}=2_{19}$ is sufficient to decrypt sums of up to 128 well-formed ciphertexts. Sums of more than 128 ciphertexts can be handled by summing blocks of 128, decrypting the block sum, and summing the plaintexts.

Unfortunately, this method reveals slightly more information about a sum of encrypted summands than would be ideal. Ideally, it would reveal only the sum of the encrypted summands, but in fact it reveals the sum of each radix-$11$ chunk, without carrying between them. Carrying collapses information about the summands, but that information is revealed by this scheme. This seems unlikely to be a problem in practice, but it is worth quantifying.

## TODO

- the bounds above are a ballpark estimation; refine them and make them precise
- work out integration with ABCI++ protocol phases