-
Notifications
You must be signed in to change notification settings - Fork 3
Refactor and WHIR Integration #20
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2b81dff
Refactor to prepare for WHIR
b-wagn cabdd42
Add dummy WHIR VM impl
b-wagn 227d4a0
Reintegrate best attack
b-wagn 8ee419b
Add parameters back to console output
b-wagn 45ce004
Fix argument passing bug
asn-d6 a12d2f2
Revive markdown reporting
asn-d6 add57ec
Start integrating WHIR VMs
b-wagn e55f631
Implement proof size estimator for WHIR
b-wagn af32779
Add a prox gaps regime class
b-wagn a6f3f8d
Start integratingWHIR RBR errors
b-wagn cc60ec5
Implement WHIR sec levels
b-wagn f93bd4f
Add JBR
b-wagn 441e967
Add batching for WHIR
b-wagn 9e0f644
Add grinding for WHIR
b-wagn ef05fa4
Fix markdown reporting for WHIR
asn-d6 74451a9
Update soundcalc/zkvms/whir_based_vm.py
b-wagn 0b32597
Fix minor bug in proof size
b-wagn fe4e9dd
Rename num_polys -> batch size
b-wagn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "cSpell.words": [ | ||
| "soundcalc", | ||
| "zkvm", | ||
| "zkvms" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,47 +1,36 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from ..zkevms.zkevm import zkEVMParams | ||
|
|
||
| import math | ||
|
|
||
| KIB = (1024 * 8) # Kilobytes | ||
|
|
||
|
|
||
| def get_rho_plus(H: int, D: float, max_combo: int) -> float: | ||
| """Compute rho+. See page 16 of Ha22""" | ||
| # XXX Should this be (H + 2) / D? This part is cryptic in [Ha22] | ||
| # TODO Figure out | ||
| return (H + max_combo) / D | ||
|
|
||
| def get_DEEP_ALI_errors(L_plus: float, params: zkEVMParams): | ||
| def get_bits_of_security_from_error(error: float) -> int: | ||
| """ | ||
| Compute common proof system error components that are shared across regimes. | ||
| Some of them depend on the list size L_plus | ||
|
|
||
| Returns a dictionary containing levels for ALI and DEEP | ||
| Returns the maximum k such that error <= 2^{-k} | ||
| """ | ||
| return int(math.floor(-math.log2(error))) | ||
|
|
||
| # TODO Check that it holds for all regimes | ||
|
|
||
| # XXX These proof system errors are actually quite RISC0 specific. | ||
| # See Section 3.4 from the RISC0 technical report. | ||
| # We might want to generalize this further for other zkEVMs. | ||
| # For example, Miden also computes similar values for DEEP-ALI in: | ||
| # https://github.com/facebook/winterfell/blob/2f78ee9bf667a561bdfcdfa68668d0f9b18b8315/air/src/proof/security.rs#L188-L210 | ||
| e_ALI = L_plus * params.num_columns / params.F | ||
| e_DEEP = ( | ||
| L_plus | ||
| * (params.AIR_max_degree * (params.trace_length + params.max_combo - 1) + (params.trace_length - 1)) | ||
| / (params.F - params.trace_length - params.D) | ||
| ) | ||
|
|
||
| levels = {} | ||
| levels["ALI"] = get_bits_of_security_from_error(e_ALI) | ||
| levels["DEEP"] = get_bits_of_security_from_error(e_DEEP) | ||
| def get_size_of_merkle_path_bits(num_leafs: int, tuple_size: int, element_size_bits: int, hash_size_bits: int) -> int: | ||
| """ | ||
| Compute the size of a Merkle path in bits. | ||
|
|
||
| return levels | ||
| We assume a Merkle tree that represents num_leafs tuples of elements | ||
| where each element has size element_size_bits and one tuple contains tuple_size | ||
| many elements. Each leaf of the tree contains one such tuple. | ||
|
|
||
| def get_bits_of_security_from_error(error: float) -> int: | ||
| """ | ||
| Returns the maximum k such that error <= 2^{-k} | ||
| Note: the result counts both the leaf itself and the Merkle path. | ||
| """ | ||
| return int(math.floor(-math.log2(error))) | ||
| assert num_leafs > 0 | ||
| leaf_size = tuple_size * element_size_bits | ||
| sibling = tuple_size * element_size_bits | ||
| tree_depth = math.ceil(math.log2(num_leafs)) | ||
| co_path = (tree_depth - 1) * hash_size_bits | ||
| return leaf_size + sibling + co_path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
|
|
||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, it would be good if we could unify
soundcalc/proxgaps/andsoundcalc/regimes/, as they essentially do things related to proximity gaps.