-
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
Open
lorenzogentile404
wants to merge
34
commits into
master
Choose a base branch
from
780-eip-7951-precompile-for-secp256r1-curve-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 33 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
b049d33
updated oob columns and renaming shorthands
lorenzogentile404 683c690
Merge branch 'master' into 780-eip-7951-precompile-for-secp256r1-curv…
lorenzogentile404 b0e8be1
updated shorthands
lorenzogentile404 812739b
added specialized computation
lorenzogentile404 fd53f84
added osaka ecdata
lorenzogentile404 ff3faed
updated ec_data columns
lorenzogentile404 c53a2f2
updated ec_data generalities
lorenzogentile404 d3ea5f9
added utils
lorenzogentile404 60235fe
added specialized computation
lorenzogentile404 e2a76f9
added circuit selector
lorenzogentile404 73cf33d
used ISZERO instead of LT for ECRECOVER and P256_VERIFY
lorenzogentile404 46f6500
Merge branch 'master' into 780-eip-7951-precompile-for-secp256r1-curv…
lorenzogentile404 7740e5f
fixed Makefile
lorenzogentile404 da87f2e
fixed callToR1MembershipEXT
lorenzogentile404 63cfb67
fixed address_sum
lorenzogentile404 177afca
used computed columns for circuit selectors
lorenzogentile404 3335fca
partially updated osaka hub with P256_VERIFY
lorenzogentile404 961b7da
fixed precompile success case
lorenzogentile404 84cb1ab
fixed naming
lorenzogentile404 b1ecca9
fixed formatting
lorenzogentile404 cd73010
Merge branch 'master' into 780-eip-7951-precompile-for-secp256r1-curv…
lorenzogentile404 2f23e74
EIP-7823: Set upper bounds for `MODEXP` --- `OOB` side (#813)
OlivierBBB 40959eb
EIP-7823: Set upper bounds for `MODEXP` --- `BLAKE_MODEXP` side (#812)
OlivierBBB c483d9e
EIP-7823: Set upper bounds for `MODEXP` --- `MMU` side (#814)
OlivierBBB 78ad636
Automatic vanishing constraints of `misc/XXX_?` columns when `misc/XX…
OlivierBBB 00e31bc
EIP-7823: Set upper bounds for `MODEXP` --- `HUB` side (#815)
OlivierBBB 2fd0833
Merge branch 'master' into 780-eip-7951-precompile-for-secp256r1-curv…
lorenzogentile404 2a547ac
Replace `R@C` in ROFF constant name with `RAC` (#822)
OlivierBBB 29694c1
Merge branch 'master' into 780-eip-7951-precompile-for-secp256r1-curv…
lorenzogentile404 7a5f259
removed deprecated comments
lorenzogentile404 8923512
added TODOs
lorenzogentile404 4ad1faf
feat: precompile processing justifying success and FKTR update for pv…
amkCha ee70747
feat: update nsr and flag sums + rm TODOs
amkCha 15aa249
Merge branch 'master' into 780-eip-7951-precompile-for-secp256r1-curv…
lorenzogentile404 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,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) | ||
| ) | ||
|
|
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,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) | ||
|
|
||
|
|
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,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))) | ||
|
|
||
|
|
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,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 | ||
| )) | ||
|
|
||
|
|
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
Oops, something went wrong.
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.
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: Phase IDs collide for precompile operations
Phase 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.