Skip to content

Conversation

@lorenzogentile404
Copy link
Contributor

@lorenzogentile404 lorenzogentile404 commented Oct 27, 2025

Note

Adds P256_VERIFY (secp256r1) precompile with full constraints, constants, OOB plumbing, and Makefile wiring for the Osaka fork.

  • Protocol/Constants:
    • Add GAS_CONST_P256_VERIFY, PRECOMPILE_CALL_DATA_SIZE___P256_VERIFY, PRECOMPILE_RETURN_DATA_SIZE___P256_VERIFY, EC phases (PHASE_P256_VERIFY_*), and OOB opcode OOB_INST_P256_VERIFY in constants/constants.lisp.
  • EC Data (Osaka):
    • New module ecdata/osaka/* with columns.lisp, constants.lisp (secp256r1 params), constraints.lisp implementing P256_VERIFY plus existing EC ops, and lookups lookups/ecdata_into_{ext,wcp}.lisp.
  • OOB (Osaka):
    • Add IS_P256_VERIFY flag, CT_MAX_P256_VERIFY, and include P256_VERIFY in flag/weight/ct-max sums in shorthands.lisp and constants.lisp.
    • Extend common post-Cancun precompile logic to include P256_VERIFY in fixed call-data/gas checks; update heartbeat to use ct-max-sum.
  • Build:
    • Update Makefile to introduce EC_DATA_LONDON and EC_DATA_OSAKA, include EC data per fork, and wire Osaka modules (OOB_OSAKA, MMU_OSAKA, RLP_TXN_RCPT_OSAKA).

Written by Cursor Bugbot for commit e2a76f9. This will update automatically on new commits. Configure here.

@lorenzogentile404 lorenzogentile404 linked an issue Oct 27, 2025 that may be closed by this pull request
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

(* ECADD (is_ecadd))
(* ECMUL (is_ecmul))
(* ECPAIRING (is_ecpairing)
(* P256_VERIFY (is_p256_verify)))))
Copy link

Choose a reason for hiding this comment

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

Bug: Syntax Error Affects Address Sum Calculation

The address_sum function is missing a closing parenthesis for the ECPAIRING term. This incorrectly nests the P256_VERIFY term, causing address_sum to calculate incorrectly and impacting stamp-constancy constraints.

Fix in Cursor Fix in Web

(callToMULMOD (+ k 1) P_x_hi P_x_lo P_x_hi P_x_lo P_R1_HI P_R1_LO)
(callToMULMOD (+ k 2) P_x_square_hi P_x_square_lo P_x_hi P_x_lo P_R1_HI P_R1_LO)
(callToMULMOD (+ k 3) A_COEFF_R1_HI A_COEFF_R1_LO P_x_hi P_x_lo P_R1_HI P_R1_LO)
(callToADDMOD (+ k 4) P_x_cube_hi P_x_lo a_times_P_x_hi a_times_P_x_lo P_R1_HI P_R1_LO)
Copy link

Choose a reason for hiding this comment

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

Bug: Incorrect Argument in Curve Membership Validation

The callToADDMOD at (+ k 4) in callToR1MembershipEXT uses P_x_lo instead of P_x_cube_lo as the second argument. This leads to an incorrect calculation of P_x_cube + a*P_x, which is critical for validating R1 curve membership during P256_VERIFY operations.

Fix in Cursor Fix in Web

;; 3.4.5 R1 membership ;;
;; utilities ;;
;;;;;;;;;;;;;;;;;;;;;;;;;
(defun (callToR1Membership k P_x_hi P_x_lo P_y_hi P_y_lo)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only non trivial part of this PR.

;; ;;
;; 3.7.3 Interface for ;;
;; Gnark ;;
;;;;;;;;;;;;;;;;;;;;;;;;;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those can be converted into computed columns.

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-7951: Precompile for secp256r1 Curve Support

2 participants