fix(libzkevm): zkvm_bls12_* and zkvm_ripemd160 to be spec conformant#2865
Open
han0110 wants to merge 2 commits into
Open
fix(libzkevm): zkvm_bls12_* and zkvm_ripemd160 to be spec conformant#2865han0110 wants to merge 2 commits into
zkvm_bls12_* and zkvm_ripemd160 to be spec conformant#2865han0110 wants to merge 2 commits into
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
Crate
libzkevmhas a few places that are noteth-act/zkvm-standardsconformant, this PR attempts to fix that.Solution
zkvm_bls12_g1_add,zkvm_bls12_g1_msmUse all zeros for point at infinity (was
0x40flag ofbls12_381). Reject coordinates with flag bits set.zkvm_bls12_g2_add,zkvm_bls12_g2_msmSame, plus Fp2 order is
c0 || c1(wasc1 || c0).zkvm_bls12_pairingSkip pairs with a point at infinity as perf improvement.
zkvm_bls12_map_fp2_to_g2Read Fp2 input as
c0 || c1. Hardcode the image ofu = 0to work around abls12_381bug (its SWU emits an off-curvey = 0point foru = 0, the only affected input, which cofactor clearing then collapses to infinity). Image derived from withpy_ecc.zkvm_ripemd160Write the digest to the last 20 bytes.
Also update conformance tests, examples, and test vectors to the corrected encoding, and verified against the test suites of
execution-specs@tests-zkevm@v0.4.1(23264 fixtures).PR Checklist