-
Notifications
You must be signed in to change notification settings - Fork 19
Eip 2537 precompile for bls12 381 curve operations #654
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
Eip 2537 precompile for bls12 381 curve operations #654
Conversation
@@ -0,0 +1,11 @@ | |||
(module bls) | |||
|
|||
(defconstraint id-increment () |
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.
Why we don't do like with other modules and just call WCP to check the id increment ?
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.
We used this same approach in ecdata
, too. Is there any advantage in doing this with wcp lookups?
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.
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
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.
we even have a spec issue to delete it from EcData : https://github.com/Consensys/linea-specification-internal/issues/482
oob/cancun/shorthands.lisp
Outdated
|
||
(defun (assumption---fresh-new-stamp) (- STAMP (prev STAMP))) | ||
|
||
(defconstraint cancun () | ||
(vanishes! (flag-sum-eip-bls12-precompiles))) |
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.
oob/cancun/shorthands.lisp
Outdated
|
||
(defun (assumption---fresh-new-stamp) (- STAMP (prev STAMP))) | ||
|
||
(defconstraint cancun () | ||
(vanishes! (flag-sum-eip-bls12-precompiles))) |
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.
(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)) |
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.
oob/cancun/shorthands.lisp
Outdated
|
||
(defun (assumption---fresh-new-stamp) (- STAMP (prev STAMP))) | ||
|
||
(defconstraint cancun () | ||
(vanishes! (flag-sum-eip-bls12-precompiles))) |
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.
$(wildcard bls/cancun/specialized_constraints/*.lisp) \ | ||
$(wildcard bls/cancun/top_level_flags_mint_mext_wtrv_wnon/*.lisp) \ | ||
$(wildcard bls/cancun/utilities/*.lisp) \ | ||
|
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.
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.
$(wildcard bls/cancun/specialized_constraints/*.lisp) \ | ||
$(wildcard bls/cancun/top_level_flags_mint_mext_wtrv_wnon/*.lisp) \ | ||
$(wildcard bls/cancun/utilities/*.lisp) \ | ||
|
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.
$(wildcard bls/cancun/specialized_constraints/*.lisp) \ | ||
$(wildcard bls/cancun/top_level_flags_mint_mext_wtrv_wnon/*.lisp) \ | ||
$(wildcard bls/cancun/utilities/*.lisp) \ | ||
|
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.
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)
$(wildcard bls/cancun/specialized_constraints/*.lisp) \ | ||
$(wildcard bls/cancun/top_level_flags_mint_mext_wtrv_wnon/*.lisp) \ | ||
$(wildcard bls/cancun/utilities/*.lisp) \ | ||
|
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.
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.
$(wildcard bls/cancun/specialized_constraints/*.lisp) \ | ||
$(wildcard bls/cancun/top_level_flags_mint_mext_wtrv_wnon/*.lisp) \ | ||
$(wildcard bls/cancun/utilities/*.lisp) \ | ||
|
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.
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)
(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)) |
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.
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.
$(wildcard bls/cancun/specialized_constraints/*.lisp) \ | ||
$(wildcard bls/cancun/top_level_flags_mint_mext_wtrv_wnon/*.lisp) \ | ||
$(wildcard bls/cancun/utilities/*.lisp) \ | ||
|
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.
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.
(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)) | ||
))) |
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.
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 |
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.
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)
854b009
to
d0f6cb9
Compare
No description provided.