polkadot-runtime-template icon indicating copy to clipboard operation
polkadot-runtime-template copied to clipboard

šŸŽ [Feature Request]: Add `secp256r1` precompile

Open ozgunozerk opened this issue 1 year ago • 6 comments

templates

  • [ ] Generic Runtime Template
  • [X] Evm Template

What is the feature you would like to see?

Citing from: https://eips.ethereum.org/EIPS/eip-7212

ā€œsecp256r1ā€ elliptic curve is a standardized curve by NIST which has the same calculations by different input parameters with ā€œsecp256k1ā€ elliptic curve used by the ā€œecrecoverā€ precompiled contract. The cost of combined attacks and the security conditions are almost the same for both curves. Adding a precompiled contract which is similar to ā€œecrecoverā€ can provide signature verifications using the ā€œsecp256r1ā€ elliptic curve in the smart contracts and multi-faceted benefits can occur. One important factor is that this curve is widely used and supported in many modern devices such as Apple’s Secure Enclave, Webauthn, Android Keychain which proves the user adoption. Additionally, the introduction of this precompiled contract could enable valuable features in the account abstraction which allows more efficient and flexible management of accounts by transaction signs in mobile devices. Most of the modern devices and applications rely on the ā€œsecp256r1ā€ elliptic curve. The addition of this precompiled contract enables the verification of device native transaction signing mechanisms. For example:

  • Apple’s Secure Enclave: There is a separate ā€œTrusted Execution Environmentā€ in Apple hardware which can sign arbitrary messages and can only be accessed by biometric identification.
  • Webauthn: Web Authentication (WebAuthn) is a web standard published by the World Wide Web Consortium (W3C). WebAuthn aims to standardize an interface for authenticating users to web-based applications and services using public-key cryptography. It is being used by almost all of the modern web browsers.
  • Android Keystore: Android Keystore is an API that manages the private keys and signing methods. The private keys are not processed while using Keystore as the applications’ signing method. Also, it can be done in the ā€œTrusted Execution Environmentā€ in the microchip.
  • Passkeys: Passkeys is utilizing FIDO Alliance and W3C standards. It replaces passwords with cryptographic key-pairs which is also can be used for the elliptic curve cryptography.

Contribution Guidelines

  • [X] I agree to follow this project's Contribution Guidelines

ozgunozerk avatar Jul 30 '24 13:07 ozgunozerk

@ozgunozerk Keen to see this happening .. any timeline ?

stiiifff avatar Dec 18 '24 09:12 stiiifff

Are we talking about this: https://www.evm.codes/precompiled?fork=cancun#0x01

Because the link is broken.

athei avatar Dec 20 '24 11:12 athei

@athei it's about this one: https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md. There is a Polkadot RFC https://github.com/polkadot-fellows/RFCs/pull/113 to add a host function. FYI Moonbeam has a precompile but this is obviously not efficient to implement this in the runtime.

stiiifff avatar Dec 20 '24 12:12 stiiifff

Ahh okay I confused it with the already available secp256k1. Thanks.

athei avatar Dec 20 '24 12:12 athei

any timeline ?

Working on it. Now we are proposing and getting feedback on precompile prioritization with Parity. I expect it to be included in our next milestone and am looking forward to taking it on, but not 100% sure on the timeline especially if it includes implementing the host function https://github.com/polkadot-fellows/RFCs/pull/113

FYI Moonbeam has a precompile but this is obviously not efficient to implement this in the runtime.

@stiiifff Thanks for linking to this! Is it inefficient because it does not use the proposed host function https://github.com/polkadot-fellows/RFCs/pull/113 ?

4meta5 avatar Dec 20 '24 18:12 4meta5

@4meta5 Yes, indeed

stiiifff avatar Jan 08 '25 10:01 stiiifff