winner of the AlephZero hacker track at ZK Hack Krakow 2024
In-circuit data encryption: In the context of privacy systems with anonymity revokers (see for instance this example) one must provide encryptions of in-circuit witnesses, thus really implement in-circuit encryption. In this bounty we would like you to implement and benchmark a symmetric encryption scheme as a Halo2 circuit. An example basic design is provided here in this doc, and other useful resources include this paper, and this blog article.
CPA-secure zk-friendly encryption, developed during ZK Hack Kraków 2024.
We base the algorithm on the assumption that the zk-friendly hash function Poseidon is pseudorandom. However, the use of the hash function is black-box and any other zk-friendly pseudorandom function could be used in its place.
To compute
- Sample
$\mathsf{nonce} \leftarrow_\$ \mathbb{F}$ - Compute
$\mathsf{pad} := H(k, \mathsf{nonce})$ - Output the ciphertext
$\mathsf{pad} + m$
In the general case of encrypting a vector
- Sample
$\mathsf{nonce} \leftarrow_\$ \mathbb{F}$ - Compute
$\mathsf{seed} := H(k, \mathsf{nonce})$ - For
$i := 1, \dots, n$ , compute$\mathsf{pad}_i := H(\mathsf{seed}, i)$ - Output the ciphertext
$\left(\mathsf{pad}_1 + m_1, \dots, \mathsf{pad}_n + m_n\right)$
This algorithm is very similar to the one published by AlephZero, however, we arrived at it independently.