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

Feat: support public input #30

Merged
merged 8 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
86 changes: 42 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
> [!WARNING]
> This is a research project and hasn't been audited. Use in production at your own risk.

Circuit for proving the correct encryption under BFV fully homomorphic encryption scheme. Note that this can be also generalized to any RLWE-based algorithms. Paper -> https://eprint.iacr.org/2024/594.
Circuit for proving the correct encryption under BFV fully homomorphic encryption scheme. Note that this can be also generalized to any RLWE-based algorithms. Paper -> https://eprint.iacr.org/2024/594. The implementation manages the public inputs of the circuit [in a slightly different way](https://github.com/privacy-scaling-explorations/greco/pull/30) than the one described in the paper.

### Generate Parameters

Expand Down Expand Up @@ -51,7 +51,7 @@ By default, the benchmarks are run on the input data generated by the python scr

To run the benchmarks on different parameters you have to:

1. Modify the constants being imported. For example `use crate::constants::sk_enc_constants_8192_4x55_65537::...`
1. Modify the constants being imported at the top of the file. For example `use crate::constants::sk_enc_constants_8192_4x55_65537::...`
2. Modify the `file_path` within `bench_sk_enc_full_prover()` function to point to the new input data file. For example `let file_path = "src/data/sk_enc_8192_4x55_65537.json";`

Given the same parameters, the benchmarks will run the prover and verifier for different values of `k`, where `2**k` is the maximum number of rows in the advice columns. After setting a specific `k`, halo2-lib will configure the circuit accordingly. With less rows at disposal, the configuration will contain more columns, and viceversa.
Expand Down Expand Up @@ -83,19 +83,19 @@ bfv params: "src/data/sk_enc_1024_1x27_65537"
+----+--------------------+--------------------+-----------------------+-------------------------+
| K | VK Generation Time | PK Generation Time | Proof Generation Time | Proof Verification Time |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 12 | 459.975208ms | 97.593417ms | 776.78975ms | 5.264583ms |
| 12 | 490.086041ms | 104.025833ms | 805.957292ms | 5.473208ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 13 | 376.945083ms | 82.856458ms | 685.505709ms | 3.661792ms |
| 13 | 425.17925ms | 86.270958ms | 786.931167ms | 3.958292ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 14 | 327.682125ms | 83.545375ms | 771.287958ms | 2.984834ms |
| 14 | 420.792916ms | 93.239208ms | 836.020791ms | 3.149542ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 15 | 353.973334ms | 98.673167ms | 927.688292ms | 2.498542ms |
| 15 | 405.360125ms | 99.7695ms | 955.489416ms | 2.868708ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 16 | 562.989334ms | 135.40525ms | 1.479128167s | 2.474292ms |
| 16 | 620.653458ms | 141.8055ms | 1.640361125s | 2.588709ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 17 | 771.174084ms | 230.993791ms | 2.5907405s | 2.771833ms |
| 17 | 907.310042ms | 235.223167ms | 2.67054475s | 2.668542ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 18 | 1.448189792s | 388.711083ms | 4.966078959s | 2.502875ms |
| 18 | 1.641826417s | 428.383166ms | 5.120378208s | 2.77925ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
```

Expand All @@ -112,19 +112,19 @@ bfv params: "src/data/sk_enc_2048_1x53_65537"
+----+--------------------+--------------------+-----------------------+-------------------------+
| K | VK Generation Time | PK Generation Time | Proof Generation Time | Proof Verification Time |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 12 | 984.314167ms | 209.913583ms | 1.597872292s | 8.236375ms |
| 12 | 1.02548225s | 220.633042ms | 1.671973959s | 8.7885ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 13 | 878.817375ms | 193.876416ms | 1.4118565s | 5.399292ms |
| 13 | 937.555209ms | 200.602167ms | 1.494908333s | 5.504542ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 14 | 771.242375ms | 186.790416ms | 1.386890583s | 3.735833ms |
| 14 | 826.149709ms | 198.48025ms | 1.475256583s | 4.139916ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 15 | 669.985041ms | 190.327167ms | 1.395613667s | 3.198541ms |
| 15 | 780.143541ms | 201.493042ms | 1.532136625s | 3.031834ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 16 | 849.207834ms | 219.047875ms | 1.786423708s | 2.649333ms |
| 16 | 820.142333ms | 232.910583ms | 1.97258525s | 2.8235ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 17 | 978.258416ms | 288.281ms | 2.821929417s | 2.700958ms |
| 17 | 1.155686625s | 311.328625ms | 3.081958s | 2.587541ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 18 | 1.477394209s | 452.682833ms | 5.152408292s | 2.576083ms |
| 18 | 1.702295666s | 499.721792ms | 5.291279833s | 2.588834ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
```

Expand All @@ -142,19 +142,19 @@ bfv params: "src/data/sk_enc_4096_2x55_65537"
+----+--------------------+--------------------+-----------------------+-------------------------+
| K | VK Generation Time | PK Generation Time | Proof Generation Time | Proof Verification Time |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 12 | 3.195995042s | 759.2565ms | 5.046092875s | 20.572291ms |
| 12 | 3.348614875s | 774.583583ms | 5.161994167s | 21.526084ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 13 | 2.791800458s | 649.398458ms | 4.3928835s | 12.524709ms |
| 13 | 2.906377042s | 683.615625ms | 4.391677667s | 13.025541ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 14 | 2.357667417s | 631.544333ms | 4.036068458s | 7.709ms |
| 14 | 2.4261365s | 645.739291ms | 4.09474375s | 8.119833ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 15 | 2.1610035s | 579.862292ms | 3.474897667s | 5.023917ms |
| 15 | 2.269133833s | 602.751583ms | 3.734384125s | 5.128375ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 16 | 1.986164917s | 590.40925ms | 3.76638225s | 3.719708ms |
| 16 | 2.161939667s | 614.730875ms | 3.86856775s | 3.715334ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 17 | 1.684586375s | 571.34275ms | 3.785945209s | 2.992958ms |
| 17 | 1.983521625s | 617.253042ms | 4.26015725s | 2.987833ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 18 | 2.234584458s | 745.59725ms | 6.14576425s | 2.646542ms |
| 18 | 2.683152334s | 781.056125ms | 6.43829325s | 3.073709ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
```

Expand All @@ -174,19 +174,19 @@ bfv params: "src/data/sk_enc_8192_4x55_65537"
+----+--------------------+--------------------+-----------------------+-------------------------+
| K | VK Generation Time | PK Generation Time | Proof Generation Time | Proof Verification Time |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 12 | 12.015320708s | 3.287664166s | 17.841099166s | 76.339042ms |
| 12 | 12.260128667s | 3.215819459s | 18.129232625s | 81.15875ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 13 | 10.122673209s | 2.693322459s | 14.74348625s | 37.897917ms |
| 13 | 10.736324042s | 2.808556291s | 15.87686625s | 39.417833ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 14 | 8.418134917s | 2.40066075s | 12.849173459s | 20.831916ms |
| 14 | 9.037218833s | 2.484174917s | 13.582268708s | 22.246125ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 15 | 6.549789916s | 2.019510917s | 9.986622458s | 11.373042ms |
| 15 | 6.576586083s | 2.077855666s | 10.57232875s | 10.488208ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 16 | 5.803876875s | 1.875661917s | 9.325606542s | 7.393ms |
| 16 | 6.135039375s | 1.919404291s | 9.59165725s | 7.775375ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 17 | 5.049139291s | 1.819083667s | 8.978745s | 4.181208ms |
| 17 | 5.278453s | 1.899231666s | 9.79360175s | 4.564875ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 18 | 4.78612025s | 1.866191166s | 10.295328167s | 3.325291ms |
| 18 | 5.676761667s | 2.186588542s | 11.418666042s | 3.698959ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
```

Expand All @@ -210,19 +210,17 @@ bfv params: "src/data/sk_enc_16384_8x54_65537"
+----+--------------------+--------------------+-----------------------+-------------------------+
| K | VK Generation Time | PK Generation Time | Proof Generation Time | Proof Verification Time |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 13 | 42.00265175s | 14.450244625s | 56.991641875s | 158.753791ms |
| 13 | 43.515304875s | 14.407916667s | 58.255132625s | 166.599041ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 14 | 35.048573583s | 11.7795115s | 48.7445865s | 71.56725ms |
| 14 | 35.551011334s | 12.041587959s | 50.729567334s | 76.108667ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 15 | 25.851191458s | 9.141273625s | 37.561299208s | 32.032583ms |
| 15 | 28.063048833s | 9.476986125s | 40.625269333s | 34.402ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 16 | 22.46793575s | 8.425404167s | 34.270651s | 17.28725ms |
| 16 | 24.613478458s | 8.841772291s | 36.525364292s | 19.868333ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 17 | 20.218826084s | 8.164861959s | 32.454668959s | 10.2455ms |
| 17 | 20.710349792s | 8.064435916s | 33.025659s | 10.015ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 18 | 17.590890541s | 7.103390958s | 29.432529166s | 6.9695ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 19 | 15.177152s | 6.799758542s | 30.783108166s | 3.855708ms |
| 18 | 17.944376875s | 7.127217625s | 31.521722708s | 7.063ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
```

Expand Down Expand Up @@ -252,16 +250,16 @@ bfv params: "src/data/sk_enc_32768_15x59_65537"
+----+--------------------+--------------------+-----------------------+-------------------------+
| K | VK Generation Time | PK Generation Time | Proof Generation Time | Proof Verification Time |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 14 | 149.354869083s | 65.239957417s | 177.298666333s | 337.225833ms |
| 14 | 152.501748625s | 68.303257667s | 188.803432959s | 361.9965ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 15 | 115.596876125s | 51.89580625s | 154.238312375s | 147.297625ms |
| 15 | 126.365190875s | 53.02766575s | 163.305771833s | 154.303292ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 16 | 94.846151459s | 40.290301042s | 130.1495495s | 61.721333ms |
| 16 | 102.026992625s | 41.624153458s | 137.814063958s | 66.756875ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 17 | 77.865249s | 34.1876465s | 111.415501042s | 26.904083ms |
| 17 | 83.088430792s | 35.14210775s | 119.241555167s | 29.228375ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 18 | 64.948204541s | 29.328586666s | 102.15197475s | 14.061625ms |
| 18 | 69.2703075s | 30.016031167s | 105.986900125s | 13.839083ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
| 19 | 62.038049125s | 29.776692208s | 104.779942208s | 8.43725ms |
| 19 | 65.224209125s | 29.8882395s | 109.52214475s | 8.5535ms |
+----+--------------------+--------------------+-----------------------+-------------------------+
```
Loading
Loading