Repository navigation
fix(calldata): refuse a Secp256k1Point that is not on the secp256k1 curve - #1765
Merged
PhilippeR26 merged 2 commits intoNov 24, 2026
Merged
Conversation
…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.
…id CodeQL false alerts
Contributor
|
🎉 This PR is included in version 11.9.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation and Resolution
A
core::starknet::secp256k1::Secp256k1Pointthat 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). Withaccount.declareAndDeploy, the class was declared and paid, then the deployment failed.CairoSecp256k1Pointnow checks a point given by the caller as soon as it is built, as thesecp256k1_newsyscall does:A point read from a node response is taken as it comes:
factoryFromApiResponsestill 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
CairoSecp256k1Pointfrom 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()andis()follow the same rule.CallData.compile, contract calls,Deployer.buildDeployerCallandaccount.declareAndDeployrefuse such a point before anything is sent, as a parameter or as already compiled constructor felts.SECP256K1_POINT_MAXis still exported, but is now refused (its x is not smaller than p): it is only the bound of the 512 bits.Development related changes
CairoSecp256k1Pointuse real points (the generator G, an Ethereum key, (0, 0)) instead of arbitrary values.account_eth_oz_090abi.Checklist: