diff --git a/reports/zisk.md b/reports/zisk.md index c7b9601..1c09419 100644 --- a/reports/zisk.md +++ b/reports/zisk.md @@ -29,12 +29,12 @@ How to read this report: - [SpecifiedRanges](#specifiedranges) - [VirtualTable0](#virtualtable0) - [VirtualTable1](#virtualtable1) -- [ArithEq Compressor](#aritheq-compressor) -- [ArithEq384 Compressor](#aritheq384-compressor) -- [Keccakf Compressor](#keccakf-compressor) -- [Sha256f Compressor](#sha256f-compressor) -- [VirtualTable1 Compressor](#virtualtable1-compressor) -- [Recursive1](#recursive1) +- [ArithEq-compressor](#aritheq-compressor) +- [ArithEq384-compressor](#aritheq384-compressor) +- [Keccakf-compressor](#keccakf-compressor) +- [Sha256f-compressor](#sha256f-compressor) +- [VirtualTable0-compressor](#virtualtable0-compressor) +- [VirtualTable1-compressor](#virtualtable1-compressor) - [Recursive2](#recursive2) - [Final](#final) @@ -81,8 +81,8 @@ How to read this report: | regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | commit round 4 | commit round 5 | query phase | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| UDR | 53 | 190 | 168 | 164 | 168 | 172 | 176 | 176 | 179 | 53 | -| JBR | 58 | 185 | 163 | 143 | 147 | 151 | 155 | 155 | 158 | 58 | +| UDR | 53 | 189 | 168 | 164 | 168 | 172 | 176 | 176 | 179 | 53 | +| JBR | 58 | 184 | 163 | 143 | 147 | 151 | 155 | 155 | 158 | 58 | | best attack | 128 | — | — | — | — | — | — | — | — | — | @@ -105,8 +105,8 @@ How to read this report: | regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | commit round 4 | commit round 5 | query phase | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| UDR | 53 | 188 | 167 | 164 | 168 | 172 | 176 | 176 | 179 | 53 | -| JBR | 58 | 183 | 162 | 142 | 146 | 150 | 154 | 154 | 157 | 58 | +| UDR | 53 | 187 | 167 | 164 | 168 | 172 | 176 | 176 | 179 | 53 | +| JBR | 58 | 182 | 162 | 142 | 146 | 150 | 154 | 154 | 157 | 58 | | best attack | 128 | — | — | — | — | — | — | — | — | — | @@ -153,8 +153,8 @@ How to read this report: | regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | commit round 4 | commit round 5 | query phase | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| UDR | 53 | 188 | 168 | 165 | 169 | 173 | 174 | 177 | 180 | 53 | -| JBR | 58 | 183 | 163 | 143 | 147 | 151 | 152 | 155 | 158 | 58 | +| UDR | 53 | 187 | 168 | 165 | 169 | 173 | 174 | 177 | 180 | 53 | +| JBR | 58 | 182 | 163 | 143 | 147 | 151 | 152 | 155 | 158 | 58 | | best attack | 128 | — | — | — | — | — | — | — | — | — | @@ -177,8 +177,8 @@ How to read this report: | regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | commit round 4 | commit round 5 | query phase | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| UDR | 53 | 187 | 168 | 164 | 168 | 172 | 173 | 176 | 179 | 53 | -| JBR | 58 | 182 | 163 | 142 | 146 | 150 | 151 | 154 | 157 | 58 | +| UDR | 53 | 186 | 168 | 164 | 168 | 172 | 173 | 176 | 179 | 53 | +| JBR | 58 | 181 | 163 | 142 | 146 | 150 | 151 | 154 | 157 | 58 | | best attack | 128 | — | — | — | — | — | — | — | — | — | @@ -225,8 +225,8 @@ How to read this report: | regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | commit round 4 | commit round 5 | query phase | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| UDR | 53 | 188 | 167 | 164 | 168 | 172 | 176 | 176 | 179 | 53 | -| JBR | 58 | 183 | 162 | 143 | 147 | 151 | 155 | 155 | 158 | 58 | +| UDR | 53 | 187 | 167 | 164 | 168 | 172 | 176 | 176 | 179 | 53 | +| JBR | 58 | 182 | 162 | 143 | 147 | 151 | 155 | 155 | 158 | 58 | | best attack | 128 | — | — | — | — | — | — | — | — | — | @@ -249,8 +249,8 @@ How to read this report: | regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | commit round 4 | commit round 5 | query phase | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| UDR | 53 | 188 | 167 | 164 | 168 | 172 | 176 | 176 | 179 | 53 | -| JBR | 58 | 183 | 162 | 143 | 147 | 151 | 155 | 155 | 158 | 58 | +| UDR | 53 | 187 | 167 | 164 | 168 | 172 | 176 | 176 | 179 | 53 | +| JBR | 58 | 182 | 162 | 143 | 147 | 151 | 155 | 155 | 158 | 58 | | best attack | 128 | — | — | — | — | — | — | — | — | — | @@ -321,8 +321,8 @@ How to read this report: | regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | commit round 4 | commit round 5 | query phase | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| UDR | 53 | 188 | 167 | 164 | 168 | 172 | 176 | 176 | 179 | 53 | -| JBR | 58 | 183 | 162 | 143 | 147 | 151 | 155 | 155 | 158 | 58 | +| UDR | 53 | 187 | 167 | 164 | 168 | 172 | 176 | 176 | 179 | 53 | +| JBR | 58 | 182 | 162 | 143 | 147 | 151 | 155 | 155 | 158 | 58 | | best attack | 128 | — | — | — | — | — | — | — | — | — | @@ -345,8 +345,8 @@ How to read this report: | regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | commit round 4 | commit round 5 | query phase | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| UDR | 53 | 187 | 167 | 163 | 167 | 171 | 175 | 175 | 178 | 53 | -| JBR | 58 | 182 | 162 | 142 | 146 | 150 | 154 | 154 | 157 | 58 | +| UDR | 53 | 186 | 167 | 163 | 167 | 171 | 175 | 175 | 178 | 53 | +| JBR | 58 | 181 | 162 | 142 | 146 | 150 | 154 | 154 | 157 | 58 | | best attack | 128 | — | — | — | — | — | — | — | — | — | @@ -369,8 +369,8 @@ How to read this report: | regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | commit round 4 | query phase | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| UDR | 53 | 186 | 169 | 164 | 168 | 172 | 176 | 180 | 53 | -| JBR | 58 | 181 | 164 | 143 | 147 | 151 | 155 | 159 | 58 | +| UDR | 53 | 185 | 169 | 164 | 168 | 172 | 176 | 180 | 53 | +| JBR | 58 | 180 | 164 | 143 | 147 | 151 | 155 | 159 | 58 | | best attack | 128 | — | — | — | — | — | — | — | — | @@ -431,19 +431,19 @@ How to read this report: - Grinding (bits): 0 - Field: Goldilocks³ - Rate (ρ): 0.5 -- Trace length (H): $2^{16}$ -- FRI rounds: 3 -- FRI folding factors: [16, 16, 16] +- Trace length (H): $2^{21}$ +- FRI rounds: 5 +- FRI folding factors: [16, 16, 8, 8, 8] - FRI early stop degree: 32 - Batching: Powers -**Proof Size Estimate:** 24694 KiB, where 1 KiB = 1024 bytes +**Proof Size Estimate:** 2058 KiB, where 1 KiB = 1024 bytes -| regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | query phase | -| --- | --- | --- | --- | --- | --- | --- | --- | --- | -| UDR | 53 | 180 | 173 | 163 | 167 | 171 | 175 | 53 | -| JBR | 58 | 175 | 168 | 141 | 145 | 149 | 153 | 58 | -| best attack | 128 | — | — | — | — | — | — | — | +| regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | commit round 4 | commit round 5 | query phase | +| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | +| UDR | 53 | 185 | 168 | 161 | 165 | 169 | 170 | 173 | 176 | 53 | +| JBR | 58 | 180 | 163 | 140 | 144 | 148 | 149 | 152 | 155 | 58 | +| best attack | 128 | — | — | — | — | — | — | — | — | — | ## Sha256f @@ -509,12 +509,12 @@ How to read this report: - FRI early stop degree: 32 - Batching: Powers -**Proof Size Estimate:** 1238 KiB, where 1 KiB = 1024 bytes +**Proof Size Estimate:** 1298 KiB, where 1 KiB = 1024 bytes | regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | commit round 4 | query phase | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| UDR | 53 | 185 | 169 | 163 | 167 | 171 | 175 | 179 | 53 | -| JBR | 58 | 180 | 164 | 142 | 146 | 150 | 154 | 158 | 58 | +| UDR | 53 | 184 | 169 | 163 | 167 | 171 | 175 | 179 | 53 | +| JBR | 58 | 179 | 164 | 142 | 146 | 150 | 154 | 158 | 58 | | best attack | 128 | — | — | — | — | — | — | — | — | @@ -542,7 +542,7 @@ How to read this report: | best attack | 128 | — | — | — | — | — | — | — | — | -## ArithEq Compressor +## ArithEq-compressor **Parameters:** - Polynomial commitment scheme: FRI @@ -557,7 +557,7 @@ How to read this report: - FRI early stop degree: 32 - Batching: Powers -**Proof Size Estimate:** 916 KiB, where 1 KiB = 1024 bytes +**Proof Size Estimate:** 691 KiB, where 1 KiB = 1024 bytes | regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | commit round 4 | query phase | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | @@ -566,7 +566,7 @@ How to read this report: | best attack | 128 | — | — | — | — | — | — | — | — | -## ArithEq384 Compressor +## ArithEq384-compressor **Parameters:** - Polynomial commitment scheme: FRI @@ -581,7 +581,7 @@ How to read this report: - FRI early stop degree: 32 - Batching: Powers -**Proof Size Estimate:** 916 KiB, where 1 KiB = 1024 bytes +**Proof Size Estimate:** 691 KiB, where 1 KiB = 1024 bytes | regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | commit round 4 | query phase | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | @@ -590,7 +590,7 @@ How to read this report: | best attack | 128 | — | — | — | — | — | — | — | — | -## Keccakf Compressor +## Keccakf-compressor **Parameters:** - Polynomial commitment scheme: FRI @@ -599,22 +599,22 @@ How to read this report: - Grinding (bits): 0 - Field: Goldilocks³ - Rate (ρ): 0.25 -- Trace length (H): $2^{21}$ -- FRI rounds: 5 -- FRI folding factors: [16, 16, 16, 8, 8] +- Trace length (H): $2^{18}$ +- FRI rounds: 4 +- FRI folding factors: [16, 16, 16, 8] - FRI early stop degree: 32 - Batching: Powers -**Proof Size Estimate:** 974 KiB, where 1 KiB = 1024 bytes +**Proof Size Estimate:** 691 KiB, where 1 KiB = 1024 bytes -| regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | commit round 4 | commit round 5 | query phase | -| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| UDR | 43 | 185 | 168 | 161 | 165 | 169 | 173 | 173 | 176 | 43 | -| JBR | 61 | 179 | 162 | 138 | 142 | 146 | 150 | 150 | 153 | 61 | -| best attack | 128 | — | — | — | — | — | — | — | — | — | +| regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | commit round 4 | query phase | +| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | +| UDR | 43 | 185 | 171 | 164 | 168 | 172 | 176 | 176 | 43 | +| JBR | 61 | 179 | 165 | 141 | 145 | 149 | 153 | 153 | 61 | +| best attack | 128 | — | — | — | — | — | — | — | — | -## Sha256f Compressor +## Sha256f-compressor **Parameters:** - Polynomial commitment scheme: FRI @@ -629,7 +629,7 @@ How to read this report: - FRI early stop degree: 32 - Batching: Powers -**Proof Size Estimate:** 946 KiB, where 1 KiB = 1024 bytes +**Proof Size Estimate:** 721 KiB, where 1 KiB = 1024 bytes | regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | commit round 4 | query phase | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | @@ -638,7 +638,7 @@ How to read this report: | best attack | 128 | — | — | — | — | — | — | — | — | -## VirtualTable1 Compressor +## VirtualTable0-compressor **Parameters:** - Polynomial commitment scheme: FRI @@ -653,7 +653,7 @@ How to read this report: - FRI early stop degree: 32 - Batching: Powers -**Proof Size Estimate:** 916 KiB, where 1 KiB = 1024 bytes +**Proof Size Estimate:** 691 KiB, where 1 KiB = 1024 bytes | regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | commit round 4 | query phase | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | @@ -662,28 +662,28 @@ How to read this report: | best attack | 128 | — | — | — | — | — | — | — | — | -## Recursive1 +## VirtualTable1-compressor **Parameters:** - Polynomial commitment scheme: FRI - Hash size (bits): 256 -- Number of queries: 43 +- Number of queries: 64 - Grinding (bits): 0 - Field: Goldilocks³ -- Rate (ρ): 0.125 -- Trace length (H): $2^{17}$ +- Rate (ρ): 0.25 +- Trace length (H): $2^{18}$ - FRI rounds: 4 - FRI folding factors: [16, 16, 16, 8] - FRI early stop degree: 32 - Batching: Powers -**Proof Size Estimate:** 625 KiB, where 1 KiB = 1024 bytes +**Proof Size Estimate:** 691 KiB, where 1 KiB = 1024 bytes | regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | commit round 4 | query phase | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| UDR | 35 | 185 | 172 | 164 | 168 | 172 | 176 | 176 | 35 | -| JBR | 62 | 178 | 165 | 139 | 143 | 147 | 151 | 151 | 62 | -| best attack | 129 | — | — | — | — | — | — | — | — | +| UDR | 43 | 185 | 171 | 164 | 168 | 172 | 176 | 176 | 43 | +| JBR | 61 | 179 | 165 | 141 | 145 | 149 | 153 | 153 | 61 | +| best attack | 128 | — | — | — | — | — | — | — | — | ## Recursive2 @@ -701,12 +701,12 @@ How to read this report: - FRI early stop degree: 32 - Batching: Powers -**Proof Size Estimate:** 625 KiB, where 1 KiB = 1024 bytes +**Proof Size Estimate:** 409 KiB, where 1 KiB = 1024 bytes | regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | commit round 3 | commit round 4 | query phase | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | -| UDR | 35 | 185 | 172 | 164 | 168 | 172 | 176 | 176 | 35 | -| JBR | 62 | 178 | 165 | 139 | 143 | 147 | 151 | 151 | 62 | +| UDR | 35 | 185 | 171 | 164 | 168 | 172 | 176 | 176 | 35 | +| JBR | 62 | 178 | 164 | 140 | 144 | 148 | 152 | 152 | 62 | | best attack | 129 | — | — | — | — | — | — | — | — | @@ -725,11 +725,11 @@ How to read this report: - FRI early stop degree: 1024 - Batching: Powers -**Proof Size Estimate:** 449 KiB, where 1 KiB = 1024 bytes +**Proof Size Estimate:** 289 KiB, where 1 KiB = 1024 bytes | regime | total | ALI | DEEP | batching | commit round 1 | commit round 2 | query phase | | --- | --- | --- | --- | --- | --- | --- | --- | -| UDR | 29 | 185 | 173 | 164 | 169 | 174 | 29 | -| JBR | 62 | 177 | 165 | 138 | 143 | 148 | 62 | +| UDR | 29 | 185 | 172 | 164 | 169 | 174 | 29 | +| JBR | 62 | 177 | 164 | 138 | 143 | 148 | 62 | | best attack | 128 | — | — | — | — | — | — | diff --git a/soundcalc/zkvms/zisk.py b/soundcalc/zkvms/zisk.py index 73bea7a..83bbb75 100644 --- a/soundcalc/zkvms/zisk.py +++ b/soundcalc/zkvms/zisk.py @@ -4,96 +4,38 @@ from ..common.fields import * - -def _parse_fri_folding_arities(fri_fa_str: str) -> tuple[list[int], int]: - """ - Parse FRI folding arity string like "23-19-15-11-8-5" into folding factors and early stop degree. - - The sequence represents log2 of domain sizes at each step. - E.g., "23-19-15-11-8-5" means: - - 23→19: fold by 2^(23-19) = 16 - - 19→15: fold by 2^4 = 16 - - 15→11: fold by 2^4 = 16 - - 11→8: fold by 2^3 = 8 - - 8→5: fold by 2^3 = 8 - - Final 5: early_stop_degree = 2^5 = 32 - """ - values = [int(x) for x in fri_fa_str.split('-')] - folding_factors = [] - for i in range(len(values) - 1): - fold_log = values[i] - values[i + 1] - folding_factors.append(1 << fold_log) - early_stop_degree = 1 << values[-1] - return folding_factors, early_stop_degree - - -def _make_circuit(name, bits, bf, d, fixed, stage1, pols, queries, opens, fri_fa) -> FRIBasedCircuit: - """Factory function to create a circuit from table parameters.""" - FRI_folding_factors, FRI_early_stop_degree = _parse_fri_folding_arities(fri_fa) - - return FRIBasedCircuit(FRIBasedVMConfig( - name=name, - trace_length=1 << bits, - rho=1 / (1 << bf), - AIR_max_degree=d, - num_columns=fixed + stage1, - batch_size=pols, - num_queries=queries, - max_combo=opens, - FRI_folding_factors=FRI_folding_factors, - FRI_early_stop_degree=FRI_early_stop_degree, +from pathlib import Path +import toml + +### Load ZisK configuration from YAML file +### It can be autogenerated by doing the following: +### 1. Download pil2-proofman (https://github.com/0xPolygonHermez/pil2-proofman.git) and connect it to feature/soundness-info branch +### 2. Download the current zisk setup. Currently, it is preferrable to download it from source since using ziskup will automatically generate the extended fixed polynomials, which are not required. It uses around 7GB. It can be downloaded from "https://storage.googleapis.com/zisk-setup/zisk-provingkey-0.14.0.tar.gz". It can be extracted with "tar -xvzf zisk-provingkey-0.14.0.tar.gz" +### 3. Run the following command on pil2-proofman: "cargo run --bin proofman-cli soundness -k -a -o " +toml_path = Path(__file__).parent / "zisk.toml" + +with open(toml_path, "r") as f: + config = toml.load(f) + +def _make_circuit(section: dict) -> FRIBasedCircuit: + cfg = FRIBasedVMConfig( + name=section["name"], + hash_size_bits=config["zkevm"]["hash_size_bits"], + rho=section["rho"], + trace_length=section["trace_length"], field=GOLDILOCKS_3, - hash_size_bits=256, - power_batching=True, - grinding_query_phase=0, - )) - - -# Base ZisK circuits -# Columns: (name, bits, bf, d, fixed, stage1, pols, queries, opens, fri_fa) -# -# See https://github.com/ethereum/soundcalc/issues/18 for more details: -# -# -# Aligned for better reading: -# bits bf d fix stg1 pols qry opn fri_fa -ZISK_BASE_CIRCUITS = [ - ("Main", 22, 1, 3, 3, 38, 61, 128, 3, "23-19-15-11-8-5"), - ("Rom", 22, 1, 2, 1, 1, 18, 128, 3, "23-19-15-11-8-5"), - ("Mem", 22, 1, 3, 2, 13, 29, 128, 3, "23-19-15-11-8-5"), - ("RomData", 21, 1, 3, 2, 6, 19, 128, 3, "22-18-14-11-8-5"), - ("InputData", 21, 1, 3, 2, 9, 27, 128, 3, "22-18-14-11-8-5"), - ("MemAlign", 21, 1, 3, 2, 29, 59, 128, 3, "22-18-14-11-8-5"), - ("MemAlignByte", 22, 1, 3, 1, 16, 25, 128, 3, "23-19-15-11-8-5"), - ("MemAlignReadByte", 22, 1, 3, 1, 10, 18, 128, 3, "23-19-15-11-8-5"), - ("MemAlignWriteByte", 22, 1, 3, 1, 14, 23, 128, 3, "23-19-15-11-8-5"), - ("Arith", 21, 1, 3, 1, 44, 64, 128, 3, "22-18-14-11-8-5"), - ("Binary", 22, 1, 3, 1, 39, 49, 128, 3, "23-19-15-11-8-5"), - ("BinaryAdd", 22, 1, 3, 1, 10, 18, 128, 3, "23-19-15-11-8-5"), - ("BinaryExtension", 22, 1, 3, 1, 29, 40, 128, 3, "23-19-15-11-8-5"), - ("Add256", 20, 1, 3, 1, 47, 69, 128, 3, "21-17-13-9-5"), - ("ArithEq", 20, 1, 3, 2, 39, 434, 128, 36, "21-17-13-9-5"), - ("ArithEq384", 20, 1, 3, 2, 33, 536, 128, 54, "21-17-13-9-5"), - ("Keccakf", 16, 1, 3, 2, 2137, 4065, 128, 26, "17-13-9-5"), - ("Sha256f", 18, 1, 3, 2, 102, 1265, 128, 87, "19-15-11-8-5"), - ("SpecifiedRanges", 20, 1, 3, 34, 33, 88, 128, 3, "21-17-13-9-5"), - ("VirtualTable0", 20, 1, 3, 100, 16, 129, 128, 3, "21-17-13-9-5"), - ("VirtualTable1", 20, 1, 3, 145, 16, 174, 128, 3, "21-17-13-9-5"), -] - -# Recursive Proving Circuits -# bits bf d fix stg1 pols qry opn fri_fa -ZISK_RECURSIVE_CIRCUITS = [ - ("ArithEq Compressor", 18, 2, 3, 45, 36, 238, 64, 4, "20-16-12-8-5"), - ("ArithEq384 Compressor", 18, 2, 3, 45, 36, 238, 64, 4, "20-16-12-8-5"), - ("Keccakf Compressor", 21, 2, 3, 45, 36, 238, 64, 4, "23-19-15-11-8-5"), - ("Sha256f Compressor", 19, 2, 3, 45, 36, 238, 64, 4, "21-17-13-9-5"), - ("VirtualTable1 Compressor",18, 2, 3, 45, 36, 238, 64, 4, "20-16-12-8-5"), - ("Recursive1", 17, 3, 3, 45, 36, 243, 43, 4, "20-16-12-8-5"), - ("Recursive2", 17, 3, 3, 45, 36, 243, 43, 4, "20-16-12-8-5"), - ("Final", 16, 4, 3, 45, 42, 249, 32, 4, "20-15-10"), -] - + num_columns=section["num_columns"], + batch_size=section["num_pols"], + power_batching=section["power_batching"], + num_queries=section["num_queries"], + AIR_max_degree=section["air_max_degree"], + FRI_folding_factors=section.get("fri_folding_factors"), + FRI_early_stop_degree=section.get("fri_early_stop_degree"), + max_combo=section["opening_points"], + grinding_query_phase=section.get("grinding_query_phase", 0), + ) + + return FRIBasedCircuit(cfg) class ZiskPreset: @staticmethod @@ -104,31 +46,12 @@ def default() -> FRIBasedVM: For ZisK, we populate the parameters from the following data: https://github.com/ethereum/soundcalc/issues/18 """ - circuits = [_make_circuit(*row) for row in ZISK_BASE_CIRCUITS] - circuits += [_make_circuit(*row) for row in ZISK_RECURSIVE_CIRCUITS] - return FRIBasedVM(name="ZisK", circuits=circuits) - - -if __name__ == "__main__": - import unittest - class TestParseFriFoldingArities(unittest.TestCase): - def test_main_circuit_fri_fa(self): - # 23-19-15-11-8-5: folds by 16,16,16,8,8 then stops at degree 32 - factors, early_stop = _parse_fri_folding_arities("23-19-15-11-8-5") - self.assertEqual(factors, [16, 16, 16, 8, 8]) - self.assertEqual(early_stop, 32) + circuits = [] - def test_short_fri_fa(self): - # 17-13-9-5: folds by 16,16,16 then stops at degree 32 - factors, early_stop = _parse_fri_folding_arities("17-13-9-5") - self.assertEqual(factors, [16, 16, 16]) - self.assertEqual(early_stop, 32) + ### Basics AIRs configuration + for section in config.get("circuits"): + circuits.append(_make_circuit(section)) - def test_final_circuit_fri_fa(self): - # 20-15-10: folds by 32,32 then stops at degree 1024 - factors, early_stop = _parse_fri_folding_arities("20-15-10") - self.assertEqual(factors, [32, 32]) - self.assertEqual(early_stop, 1024) - unittest.main() + return FRIBasedVM(config["zkevm"]["name"], circuits=circuits) diff --git a/soundcalc/zkvms/zisk.toml b/soundcalc/zkvms/zisk.toml new file mode 100644 index 0000000..1ff3225 --- /dev/null +++ b/soundcalc/zkvms/zisk.toml @@ -0,0 +1,441 @@ +[zkevm] +name = "ZisK" +protocol_family = "FRI_STARK" +version = "0.14.0" +field = "Goldilocks^3" +hash_size_bits = 256 + +[[circuits]] +name = "Main" +group = "basic" +trace_length = 4194304 +rho = 0.5 +air_max_degree = 3 +num_columns = 51 +opening_points = 3 +num_pols = 61 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 16, 8, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "Rom" +group = "basic" +trace_length = 4194304 +rho = 0.5 +air_max_degree = 2 +num_columns = 5 +opening_points = 3 +num_pols = 18 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 16, 8, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "Mem" +group = "basic" +trace_length = 4194304 +rho = 0.5 +air_max_degree = 3 +num_columns = 20 +opening_points = 3 +num_pols = 29 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 16, 8, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "RomData" +group = "basic" +trace_length = 2097152 +rho = 0.5 +air_max_degree = 3 +num_columns = 13 +opening_points = 3 +num_pols = 19 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 8, 8, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "InputData" +group = "basic" +trace_length = 2097152 +rho = 0.5 +air_max_degree = 3 +num_columns = 19 +opening_points = 3 +num_pols = 27 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 8, 8, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "MemAlign" +group = "basic" +trace_length = 2097152 +rho = 0.5 +air_max_degree = 3 +num_columns = 39 +opening_points = 3 +num_pols = 59 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 8, 8, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "MemAlignByte" +group = "basic" +trace_length = 4194304 +rho = 0.5 +air_max_degree = 3 +num_columns = 23 +opening_points = 3 +num_pols = 25 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 16, 8, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "MemAlignReadByte" +group = "basic" +trace_length = 4194304 +rho = 0.5 +air_max_degree = 3 +num_columns = 16 +opening_points = 3 +num_pols = 18 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 16, 8, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "MemAlignWriteByte" +group = "basic" +trace_length = 4194304 +rho = 0.5 +air_max_degree = 3 +num_columns = 21 +opening_points = 3 +num_pols = 23 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 16, 8, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "Arith" +group = "basic" +trace_length = 2097152 +rho = 0.5 +air_max_degree = 3 +num_columns = 62 +opening_points = 3 +num_pols = 64 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 8, 8, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "Binary" +group = "basic" +trace_length = 4194304 +rho = 0.5 +air_max_degree = 3 +num_columns = 47 +opening_points = 3 +num_pols = 49 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 16, 8, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "BinaryAdd" +group = "basic" +trace_length = 4194304 +rho = 0.5 +air_max_degree = 3 +num_columns = 16 +opening_points = 3 +num_pols = 18 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 16, 8, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "BinaryExtension" +group = "basic" +trace_length = 4194304 +rho = 0.5 +air_max_degree = 3 +num_columns = 38 +opening_points = 3 +num_pols = 40 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 16, 8, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "Add256" +group = "basic" +trace_length = 1048576 +rho = 0.5 +air_max_degree = 3 +num_columns = 67 +opening_points = 3 +num_pols = 69 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 16, 16] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "ArithEq" +group = "basic" +trace_length = 1048576 +rho = 0.5 +air_max_degree = 3 +num_columns = 57 +opening_points = 36 +num_pols = 434 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 16, 16] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "ArithEq384" +group = "basic" +trace_length = 1048576 +rho = 0.5 +air_max_degree = 3 +num_columns = 51 +opening_points = 54 +num_pols = 536 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 16, 16] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "Keccakf" +group = "basic" +trace_length = 2097152 +rho = 0.5 +air_max_degree = 3 +num_columns = 71 +opening_points = 71 +num_pols = 265 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 8, 8, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "Sha256f" +group = "basic" +trace_length = 262144 +rho = 0.5 +air_max_degree = 3 +num_columns = 113 +opening_points = 87 +num_pols = 1265 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 8, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "SpecifiedRanges" +group = "basic" +trace_length = 1048576 +rho = 0.5 +air_max_degree = 3 +num_columns = 86 +opening_points = 3 +num_pols = 88 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 16, 16] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "VirtualTable0" +group = "basic" +trace_length = 1048576 +rho = 0.5 +air_max_degree = 3 +num_columns = 137 +opening_points = 3 +num_pols = 139 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 16, 16] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "VirtualTable1" +group = "basic" +trace_length = 1048576 +rho = 0.5 +air_max_degree = 3 +num_columns = 172 +opening_points = 3 +num_pols = 174 +power_batching = true +num_queries = 128 +fri_folding_factors = [16, 16, 16, 16] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "ArithEq-compressor" +group = "compression" +trace_length = 262144 +rho = 0.25 +air_max_degree = 5 +num_columns = 119 +opening_points = 4 +num_pols = 163 +power_batching = true +num_queries = 64 +fri_folding_factors = [16, 16, 16, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "ArithEq384-compressor" +group = "compression" +trace_length = 262144 +rho = 0.25 +air_max_degree = 5 +num_columns = 119 +opening_points = 4 +num_pols = 163 +power_batching = true +num_queries = 64 +fri_folding_factors = [16, 16, 16, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "Keccakf-compressor" +group = "compression" +trace_length = 262144 +rho = 0.25 +air_max_degree = 5 +num_columns = 119 +opening_points = 4 +num_pols = 163 +power_batching = true +num_queries = 64 +fri_folding_factors = [16, 16, 16, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "Sha256f-compressor" +group = "compression" +trace_length = 524288 +rho = 0.25 +air_max_degree = 5 +num_columns = 119 +opening_points = 4 +num_pols = 163 +power_batching = true +num_queries = 64 +fri_folding_factors = [16, 16, 16, 16] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "VirtualTable0-compressor" +group = "compression" +trace_length = 262144 +rho = 0.25 +air_max_degree = 5 +num_columns = 119 +opening_points = 4 +num_pols = 163 +power_batching = true +num_queries = 64 +fri_folding_factors = [16, 16, 16, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "VirtualTable1-compressor" +group = "compression" +trace_length = 262144 +rho = 0.25 +air_max_degree = 5 +num_columns = 119 +opening_points = 4 +num_pols = 163 +power_batching = true +num_queries = 64 +fri_folding_factors = [16, 16, 16, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "Recursive2" +group = "aggregation" +trace_length = 131072 +rho = 0.125 +air_max_degree = 8 +num_columns = 92 +opening_points = 4 +num_pols = 136 +power_batching = true +num_queries = 43 +fri_folding_factors = [16, 16, 16, 8] +fri_early_stop_degree = 32 +grinding_query_phase = 0 + +[[circuits]] +name = "Final" +group = "final" +trace_length = 65536 +rho = 0.0625 +air_max_degree = 8 +num_columns = 98 +opening_points = 4 +num_pols = 142 +power_batching = true +num_queries = 32 +fri_folding_factors = [32, 32] +fri_early_stop_degree = 1024 +grinding_query_phase = 0