Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Public Key Encryption #34

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
dde5211
feat: add input struct for pk encryption circuit
Vishalkulkarni45 Apr 27, 2024
af08f13
feat: completed phase0 assigning value
Vishalkulkarni45 Apr 27, 2024
0975688
feat: completed phase1 assigning and adding constrain
Vishalkulkarni45 Apr 27, 2024
c1335b0
chore: re-arranged the folders
Vishalkulkarni45 Apr 30, 2024
8dec0a8
feat(wip): generate input for public key enc circuit
Vishalkulkarni45 Apr 30, 2024
82d7563
feat: generated inputs for pk_enc circuit
Vishalkulkarni45 May 5, 2024
7a9925a
feat: added pk0 range check
Vishalkulkarni45 May 10, 2024
dc9e7ff
feat: generated inputs for ciphertext 1
Vishalkulkarni45 May 13, 2024
10ddad8
feat:tested the ciphertext part 2 circuit
Vishalkulkarni45 May 13, 2024
247e406
feat: pull prover test
Vishalkulkarni45 May 14, 2024
dfc375e
feat: added public inputs
Vishalkulkarni45 May 14, 2024
796bb93
chore:refactored script
Vishalkulkarni45 May 15, 2024
c6ce650
fix: resolve comments from upstream PR#31
auryn-macmillan Aug 13, 2024
92a9a83
address the simple comments
auryn-macmillan Aug 19, 2024
9237518
define numpy version
auryn-macmillan Aug 19, 2024
4e41272
update readme
auryn-macmillan Aug 19, 2024
4c71b86
fix variable names
auryn-macmillan Aug 19, 2024
096341c
resolve assert errors in circuit_pk.py
auryn-macmillan Aug 19, 2024
5d8a776
update test_pk_enc_invalid_polys() to test for a modified secret
auryn-macmillan Aug 19, 2024
62493d2
fix typo
auryn-macmillan Aug 19, 2024
5ed06fc
typo
auryn-macmillan Aug 20, 2024
afd7f0c
fixed docstrings for p1i and p2i, added python virtual environment ig…
Aug 21, 2024
ff4ee14
Updated docstring
Aug 21, 2024
cd03e30
fix: update requirements.txt
auryn-macmillan Aug 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ Cargo.lock
*.pdb

# KZG PARAMS
params
params

# Python virtual environment
.venv/
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,23 @@ python3 scripts/circuit_sk.py -n 4096 -qis '[
]' -t 65537
```

To generate the parameters for the public key proof of encryption circuit run the following command:

```bash
python3 scripts/circuit_pk.py -n 4096 -qis '[
27424203952895201,
27424203952895203
]' -t 65537
```

Where `-n` is the degree of the cyclotomic polynomial that defines the ring, `-qis` is the list of moduli qis such that qis[i] is the modulus of the i-th CRT basis of the modulus q of the ciphertext space, `-t` is the plaintext modulus. The value of `𝜎` for the gaussian distribution is set to 3.2 by default.

You can modify these parameters to fit your needs. Note that the python script used to generate the inputs is largely unoptimized and can take a while to run for parameters with large `n`, since the polynomial multiplication is not done using NTT.

As a result:
- A file `./src/data/sk_enc_{n}_{qis_len}x{qis_bitsize}_{t}.json` is generated including the input to the circuit that can be used for testing for those specific parameters. It includes a random secret key, a random plaintext message and the corresponding ciphertext encrypted under the secret key.
- A file `./src/data/sk_enc_{n}_{qis_len}x{qis_bitsize}_{t}_zeroes.json` is generated. In this file all the coefficients of the input polynomials are set to zero. This input is used at key generation time, when the actual inputs are not known.
- A file `./src/constants/sk_enc_constants_{n}_{qis_len}x{qis_bitsize}_{t}.rs` is generated including the generic constants for the circuit. Note that we separate them from the input because these should be known at compile time.
- A file `./src/data/{p|s}k_enc_{n}_{qis_len}x{qis_bitsize}_{t}.json` is generated including the input to the circuit that can be used for testing for those specific parameters. It includes a random secret key, a random plaintext message and the corresponding ciphertext encrypted under the secret key.
- A file `./src/data/{p|s}k_enc_{n}_{qis_len}x{qis_bitsize}_{t}_zeroes.json` is generated. In this file all the coefficients of the input polynomials are set to zero. This input is used at key generation time, when the actual inputs are not known.
- A file `./src/constants/{p|s}k_enc_constants_{n}_{qis_len}x{qis_bitsize}_{t}.rs` is generated including the generic constants for the circuit. Note that we separate them from the input because these should be known at compile time.

On top of that, the console will print an estimatation of the number of advice cells needed to compile the circuit in halo2 considering a single advice column and a lookup table of size 2^8. Spoiler: around 90% of the constraints are generated by the range checks on the polynomial coefficients.

Expand Down
Loading
Loading