Skip to content

Conversation

lorenzogentile404
Copy link
Contributor

No description provided.

@lorenzogentile404 lorenzogentile404 linked an issue Jun 2, 2025 that may be closed by this pull request
@@ -0,0 +1,11 @@
(module bls)

(defconstraint id-increment ()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we don't do like with other modules and just call WCP to check the id increment ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used this same approach in ecdata, too. Is there any advantage in doing this with wcp lookups?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simplicity, we do like this with SHAKIRA, BLAKEMODEXP, less columns, we had a failing edgecase with the manual byte decomposition with EcDAta on mainnet few months ago

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we even have a spec issue to delete it from EcData : https://github.com/Consensys/linea-specification-internal/issues/482


(defun (assumption---fresh-new-stamp) (- STAMP (prev STAMP)))

(defconstraint cancun ()
(vanishes! (flag-sum-eip-bls12-precompiles)))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Cancun Constraint Disables BLS12 Precompiles

The cancun constraint (vanishes! (flag-sum-eip-bls12-precompiles)) forces all BLS12 precompile flags to zero. This disables the new BLS12-381 precompiles in Cancun, making the EIP-2537 functionality unusable.

Fix in Cursor Fix in Web


(defun (assumption---fresh-new-stamp) (- STAMP (prev STAMP)))

(defconstraint cancun ()
(vanishes! (flag-sum-eip-bls12-precompiles)))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: BLS12-381 Precompiles Vanish Despite EIP-253

The (vanishes! (flag-sum-eip-bls12-precompiles)) constraint disables all BLS12-381 precompiles in Cancun. This directly contradicts the PR's goal of adding EIP-2537 BLS support, making the new functionality non-functional.

Fix in Cursor Fix in Web

(vanishes! (shift MOD_FLAG 5))
(vanishes! (shift WCP_FLAG 5))
(eq! (shift BLS_REF_TABLE_FLAG 5) 1)
(eq! (shift OUTGOING_INST 5) (wght-sum-prc-bls))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Invalid Opcode in Discount Constraint

In the prc-g1-msm-prc-g2-msm---compute-discount constraint, OUTGOING_INST is set to (wght-sum-prc-bls). This value is a weighted sum of flags, not a single instruction opcode, which makes the instruction invalid for lookups.

Fix in Cursor Fix in Web


(defun (assumption---fresh-new-stamp) (- STAMP (prev STAMP)))

(defconstraint cancun ()
(vanishes! (flag-sum-eip-bls12-precompiles)))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Cancun Bug Disables EIP-2537 BLS12-38

The cancun constraint (vanishes! (flag-sum-eip-bls12-precompiles)) effectively disables all EIP-2537 BLS12-381 precompiles. This makes the feature non-functional in Cancun, which seems contrary to the PR's intent.

Fix in Cursor Fix in Web

$(wildcard bls/cancun/specialized_constraints/*.lisp) \
$(wildcard bls/cancun/top_level_flags_mint_mext_wtrv_wnon/*.lisp) \
$(wildcard bls/cancun/utilities/*.lisp) \

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Duplicate Variable Overwrites Build Configuration

The BLS_CANCUN variable is defined twice in the Makefile. The second definition overwrites the first, unintentionally excluding specific files like bls/cancun/generalities/cancun_restriction.lisp from the build. This results in missing constraint files.

Fix in Cursor Fix in Web

$(wildcard bls/cancun/specialized_constraints/*.lisp) \
$(wildcard bls/cancun/top_level_flags_mint_mext_wtrv_wnon/*.lisp) \
$(wildcard bls/cancun/utilities/*.lisp) \

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Duplicate Variable Overwrites Build Configuration

The BLS_CANCUN variable is defined twice in the Makefile. The second definition overwrites the first, causing cancun_restriction.lisp (present in the initial definition) to be excluded from the build. This could result in missing functionality.

Fix in Cursor Fix in Web

$(wildcard bls/cancun/specialized_constraints/*.lisp) \
$(wildcard bls/cancun/top_level_flags_mint_mext_wtrv_wnon/*.lisp) \
$(wildcard bls/cancun/utilities/*.lisp) \

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Variable Redefinition Causes Build Failures

The BLS_CANCUN variable is defined twice. The second definition overwrites the first, which unintentionally excludes cancun_restriction.lisp from the Cancun build. This also leaves BLS_PRAGUE undefined, causing build failures for the Prague target, as the second definition's content seems intended for BLS_PRAGUE.

Additional Locations (1)

Fix in Cursor Fix in Web

$(wildcard bls/cancun/specialized_constraints/*.lisp) \
$(wildcard bls/cancun/top_level_flags_mint_mext_wtrv_wnon/*.lisp) \
$(wildcard bls/cancun/utilities/*.lisp) \

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Duplicate Variable Definition Causes Module Exclusion

The BLS_CANCUN variable is defined twice. The second definition overwrites the first, unintentionally excluding cancun_restriction.lisp from the BLS_CANCUN module. This appears to be a copy-paste error, possibly intended for the undefined BLS_PRAGUE variable.

Fix in Cursor Fix in Web

$(wildcard bls/cancun/specialized_constraints/*.lisp) \
$(wildcard bls/cancun/top_level_flags_mint_mext_wtrv_wnon/*.lisp) \
$(wildcard bls/cancun/utilities/*.lisp) \

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Variable Redefinition and Undefined References

The BLS_CANCUN variable is defined twice; the second definition overwrites the first and omits cancun_restriction.lisp, which was present initially. This means cancun_restriction.lisp will be missing from Cancun builds. Additionally, BLS_PRAGUE is referenced in ZKEVM_MODULES_PRAGUE but is never defined, leading to no BLS files being included for Prague builds.

Additional Locations (1)

Fix in Cursor Fix in Web

(vanishes! (shift MOD_FLAG 5))
(vanishes! (shift WCP_FLAG 5))
(eq! (shift BLS_REF_TABLE_FLAG 5) 1)
(eq! (shift OUTGOING_INST 5) (wght-sum-prc-bls))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Instruction Opcode Mismatch

The prc-g1-msm-prc-g2-msm---compute-discount constraint assigns (wght-sum-prc-bls) to OUTGOING_INST. OUTGOING_INST is intended for instruction opcode constants (e.g., EVM_INST_LT), but (wght-sum-prc-bls) computes and returns a weighted sum. This results in a type mismatch for the OUTGOING_INST field.

Fix in Cursor Fix in Web

$(wildcard bls/cancun/specialized_constraints/*.lisp) \
$(wildcard bls/cancun/top_level_flags_mint_mext_wtrv_wnon/*.lisp) \
$(wildcard bls/cancun/utilities/*.lisp) \

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Duplicate Variable Definition Causes Build Exclusions

The BLS_CANCUN variable is defined twice in the Makefile. The second definition overwrites the first, which means files like bls/cancun/generalities/cancun_restriction.lisp are unintentionally excluded from the Cancun build. This could lead to unexpected behavior or build failures.

Fix in Cursor Fix in Web

(begin (wcpGeneralizedCallToLT 0 e_Im_3 e_Im_2 e_Im_1 e_Im_0 BLS_PRIME_3 BLS_PRIME_2 BLS_PRIME_1 BLS_PRIME_0)
(wcpGeneralizedCallToLT 4 e_Re_3 e_Re_2 e_Re_1 e_Re_0 BLS_PRIME_3 BLS_PRIME_2 BLS_PRIME_1 BLS_PRIME_0)
(eq! internal_checks_passed (* e_Im_is_in_range e_Re_is_in_range))
)))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: File Name Mismatch: FP2 to G2 Mapping

The file bls/cancun/specialized_constraints/map_fp2_to_g3.lisp appears to be misnamed. Its content implements map_fp2_to_g2 functionality, which is reflected in the map-fp2-to-g2-hypothesis function and DATA_BLS_MAP_FP2_TO_G2_FLAG constant.

Fix in Cursor Fix in Web

GAS_CONST_BLS_MAP_FP_TO_G1 5500
GAS_CONST_BLS_MAP_FP2_TO_G2 23800
GAS_CONST_BLS_PAIRING_CHECK 37700
GAS_CONST_BLS_PAIRING_CHECK_PAIR 32600
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Opcode Assignment Error Causes Overflow

The OUTGOING_INST field, defined as a byte for an opcode, is assigned (wght-sum-prc-bls). This function returns a sum of instruction weights, not a specific opcode constant, which is a type mismatch and can cause overflow. Additionally, the OOB_INST_... constants for BLS precompiles are currently undefined.

Additional Locations (1)

Fix in Cursor Fix in Web

@lorenzogentile404 lorenzogentile404 force-pushed the eip-2537-precompile-for-bls12-381-curve-operations branch from 854b009 to d0f6cb9 Compare September 10, 2025 15:42
@lorenzogentile404 lorenzogentile404 enabled auto-merge (squash) September 12, 2025 09:04
@lorenzogentile404 lorenzogentile404 merged commit f4df65a into master Sep 12, 2025
6 checks passed
@lorenzogentile404 lorenzogentile404 deleted the eip-2537-precompile-for-bls12-381-curve-operations branch September 12, 2025 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EIP-2537: Precompile for BLS12-381 curve operations
3 participants