-
Notifications
You must be signed in to change notification settings - Fork 21
EIP-7951: Precompile for secp256r1 Curve Support #817
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
base: master
Are you sure you want to change the base?
Changes from 30 commits
b049d33
683c690
b0e8be1
812739b
fd53f84
ff3faed
c53a2f2
d3ea5f9
60235fe
e2a76f9
73cf33d
46f6500
7740e5f
da87f2e
63cfb67
177afca
3335fca
961b7da
84cb1ab
b1ecca9
cd73010
2f23e74
40959eb
c483d9e
78ad636
00e31bc
2fd0833
2a547ac
29694c1
7a5f259
8923512
4ad1faf
ee70747
15aa249
75983c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| (module blake2fmodexpdata) | ||
|
|
||
| (defcolumns | ||
| (STAMP :i16) | ||
| (ID :i32) | ||
| (PHASE :byte) | ||
| (INDEX :byte :display :dec) | ||
| (INDEX_MAX :byte :display :dec) | ||
| (LIMB :i128 :display :bytes) | ||
| (IS_MODEXP_BASE :binary@prove) | ||
| (IS_MODEXP_EXPONENT :binary@prove) | ||
| (IS_MODEXP_MODULUS :binary@prove) | ||
| (IS_MODEXP_RESULT :binary@prove) | ||
| (IS_BLAKE_DATA :binary@prove) | ||
| (IS_BLAKE_PARAMS :binary@prove) | ||
| (IS_BLAKE_RESULT :binary@prove) | ||
| ) | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| (module blake2fmodexpdata) | ||
|
|
||
| (defconst | ||
| INDEX_MAX_MODEXP 63 | ||
| INDEX_MAX_MODEXP_BASE INDEX_MAX_MODEXP | ||
| INDEX_MAX_MODEXP_EXPONENT INDEX_MAX_MODEXP | ||
| INDEX_MAX_MODEXP_MODULUS INDEX_MAX_MODEXP | ||
| INDEX_MAX_MODEXP_RESULT INDEX_MAX_MODEXP | ||
| INDEX_MAX_BLAKE_DATA 12 | ||
| INDEX_MAX_BLAKE_PARAMS 1 | ||
| INDEX_MAX_BLAKE_RESULT 3) | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| (module blake2fmodexpdata) | ||
|
|
||
| (defun (flag-sum) | ||
| (+ IS_MODEXP_BASE | ||
| IS_MODEXP_EXPONENT | ||
| IS_MODEXP_MODULUS | ||
| IS_MODEXP_RESULT | ||
| IS_BLAKE_DATA | ||
| IS_BLAKE_PARAMS | ||
| IS_BLAKE_RESULT)) | ||
|
|
||
| (defun (phase-sum) | ||
| (+ (* PHASE_MODEXP_BASE IS_MODEXP_BASE) | ||
| (* PHASE_MODEXP_EXPONENT IS_MODEXP_EXPONENT) | ||
| (* PHASE_MODEXP_MODULUS IS_MODEXP_MODULUS) | ||
| (* PHASE_MODEXP_RESULT IS_MODEXP_RESULT) | ||
| (* PHASE_BLAKE_DATA IS_BLAKE_DATA) | ||
| (* PHASE_BLAKE_PARAMS IS_BLAKE_PARAMS) | ||
| (* PHASE_BLAKE_RESULT IS_BLAKE_RESULT))) | ||
|
|
||
| (defun (index-max-sum) | ||
| (+ (* INDEX_MAX_MODEXP_BASE IS_MODEXP_BASE) | ||
| (* INDEX_MAX_MODEXP_EXPONENT IS_MODEXP_EXPONENT) | ||
| (* INDEX_MAX_MODEXP_MODULUS IS_MODEXP_MODULUS) | ||
| (* INDEX_MAX_MODEXP_RESULT IS_MODEXP_RESULT) | ||
| (* INDEX_MAX_BLAKE_DATA IS_BLAKE_DATA) | ||
| (* INDEX_MAX_BLAKE_PARAMS IS_BLAKE_PARAMS) | ||
| (* INDEX_MAX_BLAKE_RESULT IS_BLAKE_RESULT))) | ||
|
|
||
| (defconstraint no-stamp-no-flag () | ||
| (if-zero STAMP | ||
| (vanishes! (flag-sum)) | ||
| (eq! (flag-sum) 1))) | ||
|
|
||
| (defconstraint set-phase-and-index () | ||
| (begin (eq! PHASE (phase-sum)) | ||
| (eq! INDEX_MAX (index-max-sum)))) | ||
|
|
||
| (defconstraint stamp-constancies () | ||
| (stamp-constancy STAMP ID)) | ||
|
|
||
| (defconstraint index-constancies (:guard INDEX) | ||
| (remained-constant! (phase-sum))) | ||
|
|
||
| (defconstraint first-row (:domain {0}) | ||
| (vanishes! STAMP)) | ||
|
|
||
| (defconstraint no-stamp-nothing () | ||
| (if-zero STAMP | ||
| (begin (vanishes! ID) | ||
| (vanishes! (next INDEX))))) | ||
|
|
||
| (defun (stamp-increment) | ||
| (force-bin (+ (* (- 1 IS_MODEXP_BASE) (next IS_MODEXP_BASE)) | ||
| (* (- 1 IS_BLAKE_DATA) (next IS_BLAKE_DATA))))) | ||
|
|
||
| (defconstraint stamp-increases () | ||
| (will-inc! STAMP (stamp-increment))) | ||
|
|
||
| (defun (transition-bit) | ||
| (force-bin (+ (* IS_MODEXP_BASE (next IS_MODEXP_EXPONENT)) | ||
| (* IS_MODEXP_EXPONENT (next IS_MODEXP_MODULUS)) | ||
| (* IS_MODEXP_MODULUS (next IS_MODEXP_RESULT)) | ||
| (* IS_MODEXP_RESULT | ||
| (+ (next IS_MODEXP_BASE) (next IS_BLAKE_DATA))) | ||
| (* IS_BLAKE_DATA (next IS_BLAKE_PARAMS)) | ||
| (* IS_BLAKE_PARAMS (next IS_BLAKE_RESULT)) | ||
| (* IS_BLAKE_RESULT | ||
| (+ (next IS_MODEXP_BASE) (next IS_BLAKE_DATA)))))) | ||
|
|
||
| (defconstraint heartbeat (:guard STAMP) | ||
| (if-zero (- INDEX_MAX INDEX) | ||
| (eq! (transition-bit) 1) | ||
| (will-inc! INDEX 1))) | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| (defun (blake2fmodexpdata-into-wcp-oob-into-wcp-activation-flag) | ||
| (force-bin (* (~ blake2fmodexpdata.STAMP) | ||
| (- blake2fmodexpdata.STAMP (prev blake2fmodexpdata.STAMP))))) | ||
|
|
||
| (defclookup | ||
| blake2fmodexpdata-into-wcp | ||
| ;; target colums (in WCP) | ||
| ( | ||
| wcp.ARG_1_HI | ||
| wcp.ARG_1_LO | ||
| wcp.ARG_2_HI | ||
| wcp.ARG_2_LO | ||
| wcp.RES | ||
| wcp.INST | ||
| ) | ||
| ;; source selector | ||
| (blake2fmodexpdata-into-wcp-oob-into-wcp-activation-flag) | ||
| ;; source columns | ||
| ( | ||
| 0 | ||
| (prev blake2fmodexpdata.ID) | ||
| 0 | ||
| blake2fmodexpdata.ID | ||
| 1 | ||
| EVM_INST_LT | ||
| )) | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -228,6 +228,7 @@ | |
| GAS_CONST_IDENTITY 15 | ||
| GAS_CONST_IDENTITY_WORD 3 | ||
| GAS_CONST_MODEXP 200 | ||
| GAS_CONST_MODEXP_EIP_7823 500 | ||
| GAS_CONST_ECADD 150 | ||
| GAS_CONST_ECMUL 6000 | ||
| GAS_CONST_ECPAIRING 45000 | ||
|
|
@@ -244,6 +245,7 @@ | |
| GAS_CONST_BLS_MAP_FP2_TO_G2 23800 | ||
| GAS_CONST_BLS_PAIRING_CHECK 37700 | ||
| GAS_CONST_BLS_PAIRING_CHECK_PAIR 32600 | ||
| GAS_CONST_P256_VERIFY 6900 | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EVM MISC ;; | ||
|
|
@@ -270,6 +272,7 @@ | |
| HISTORY_STORAGE_ADDRESS_HI 0x0000f908 | ||
| HISTORY_STORAGE_ADDRESS_LO 0x27f1c53a10cb7a02335b175320002935 | ||
| EIP_7825_TRANSACTION_GAS_LIMIT_CAP 0x1000000 ;; 2^24 == 16777216 appears in OSAKA | ||
| EIP_7823_MODEXP_UPPER_BYTE_SIZE_BOUND 1024 | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LINEA MISC ;; | ||
|
|
@@ -326,6 +329,7 @@ | |
| PRECOMPILE_CALL_DATA_UNIT_SIZE___BLS_PAIRING_CHECK 384 | ||
| PRECOMPILE_CALL_DATA_SIZE___FP_TO_G1 64 | ||
| PRECOMPILE_CALL_DATA_SIZE___FP2_TO_G2 128 | ||
| PRECOMPILE_CALL_DATA_SIZE___P256_VERIFY 160 | ||
|
|
||
| PRC_ECPAIRING_SIZE (* 6 WORD_SIZE) | ||
| PRECOMPILE_CALL_DATA_SIZE___BLAKE2F 213 | ||
|
|
@@ -340,6 +344,7 @@ | |
| PRECOMPILE_RETURN_DATA_SIZE___BLS_PAIRING_CHECK 32 | ||
| PRECOMPILE_RETURN_DATA_SIZE___BLS_MAP_FP_TO_G1 128 | ||
| PRECOMPILE_RETURN_DATA_SIZE___BLS_MAP_FP2_TO_G2 256 | ||
| PRECOMPILE_RETURN_DATA_SIZE___P256_VERIFY 32 | ||
|
|
||
| PRC_BLS_G1_MSM_MAX_DISCOUNT 519 | ||
| PRC_BLS_G2_MSM_MAX_DISCOUNT 524 | ||
|
|
@@ -403,6 +408,8 @@ | |
| PHASE_ECMUL_RESULT 0x070B | ||
| PHASE_ECPAIRING_DATA 0x080A | ||
| PHASE_ECPAIRING_RESULT 0x080B | ||
| PHASE_P256_VERIFY_DATA 0x100A | ||
| PHASE_P256_VERIFY_RESULT 0x100B | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Phase IDs collide for precompile operationsPhase constant collision: PHASE_P256_VERIFY_DATA is set to 0x100A, which is identical to the existing PHASE_BLS_MAP_FP_TO_G1_DATA constant (also 0x100A). These phase identifiers must be unique to correctly distinguish between different precompile operations. This collision will cause the system to confuse P256_VERIFY operations with BLS_MAP_FP_TO_G1 operations. |
||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; BLS DATA MODULE ;; | ||
|
|
@@ -521,6 +528,7 @@ | |
| OOB_INST_BLS_PAIRING_CHECK 0xFF0F | ||
| OOB_INST_BLS_MAP_FP_TO_G1 0xFF10 | ||
| OOB_INST_BLS_MAP_FP2_TO_G2 0xFF11 | ||
| OOB_INST_P256_VERIFY 0xF100 | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RLP* MODULE ;; | ||
|
|
||
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 Definitions: A Recipe for Confusion
MMU_LONDONis defined twice on lines 57 and 63, creating a duplicate variable definition. The second definition on line 63 overwrites the first, which could lead to unexpected behavior or confusion about which definition is used in the build process.