Skip to content

fix(calldata): refuse a Secp256k1Point that is not on the secp256k1 curve - #1765

Merged
PhilippeR26 merged 2 commits into
starknet-io:developfrom
PhilippeR26:fix/ethSignValidation
Nov 24, 2026
Merged

PhilippeR26 merged 2 commits into
starknet-io:developfrom
PhilippeR26:fix/ethSignValidation

Conversation

@PhilippeR26

Copy link
Copy Markdown
Collaborator

Motivation and Resolution

A core::starknet::secp256k1::Secp256k1Point that is not on the secp256k1 curve was accepted by the codec and sent. The contract refuses it when it reads its parameters (Failed to deserialize param #1). With account.declareAndDeploy, the class was declared and paid, then the deployment failed.

CairoSecp256k1Point now checks a point given by the caller as soon as it is built, as the secp256k1_new syscall does:

  • (0, 0), the point at infinity, is accepted;
  • x and y must be smaller than p, the prime of the curve;
  • the point must satisfy y^2 = x^3 + 7 modulo p.

A point read from a node response is taken as it comes: factoryFromApiResponse still checks that each felt fits in 128 bits, but not the curve.

Already compiled constructor felts are refused too, with no change in the deployer: the round-trip check added by #1730 (issue #830) writes them again through the codec.

RPC version (if applicable)

N/A

Usage related changes

  • Building a CairoSecp256k1Point from a value (one number, struct, four limbs, fromHex) throws when the point is not on the curve, or when a coordinate is not smaller than p. validate() and is() follow the same rule.
  • CallData.compile, contract calls, Deployer.buildDeployerCall and account.declareAndDeploy refuse such a point before anything is sent, as a parameter or as already compiled constructor felts.
  • SECP256K1_POINT_MAX is still exported, but is now refused (its x is not smaller than p): it is only the bound of the 512 bits.
  • Reading responses and events is unchanged.

Development related changes

  • The unit tests of CairoSecp256k1Point use real points (the generator G, an Ethereum key, (0, 0)) instead of arbitrary values.
  • New tests: the curve check in every form, coordinates equal to 1 + p, a response not on the curve read as it comes, both parsing strategies, and the deploy path with the account_eth_oz_090 abi.

Checklist:

  • Performed a self-review of the code
  • Rebased to the last commit of the target branch (or merged it into my branch)
  • Documented the changes in code (API docs will be generated automatically)
  • Updated the tests
  • All tests are passing

…urve

A point given by the caller is now checked as soon as it is built: it must be on the curve y^2 = x^3 + 7 modulo p with coordinates smaller than p, or be (0, 0), the point at infinity. A contract refuses any other point when it reads its parameters, so a deployment with such a key failed on the node, after the class was declared and paid. A point read from a node response is still taken as it comes.
@PhilippeR26
PhilippeR26 merged commit 1538f32 into starknet-io:develop Nov 24, 2026
9 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 11.9.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants