Skip to content
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

Make ECDSA signature verification host call customizable #2016

Open
xlc opened this issue Oct 29, 2024 · 5 comments · May be fixed by #2019
Open

Make ECDSA signature verification host call customizable #2016

xlc opened this issue Oct 29, 2024 · 5 comments · May be fixed by #2019

Comments

@xlc
Copy link
Contributor

xlc commented Oct 29, 2024

paritytech/smoldot#2955 covers many host calls but not ext_crypto_secp256k1_ecdsa_recover_version_2, which is used by Moonbeam for their Ethereum signature verification. This means Chopsticks won't be able to mock their signature.

cc @albertov19 AcalaNetwork/chopsticks#845

@tomaka
Copy link
Contributor

tomaka commented Oct 29, 2024

This is a bit complicated, because smoldot simply calls libsecp256k1::recover, which verifies the signature and returns the public key both in the same function call.

Since the ext_crypto_secp256k1_ecdsa_recover_version_2 function returns that public key, if the signature is invalid it simply can't proceed.

libsecp256k1 doesn't seem to have a way to pass a dummy signature and still recover the public key. Looking at the implementation, recovering the public key involves some math, and some of that math might return InvalidSignature, so it seems to make sense to me that this is implemented as a single function, it's not just "security by restrictive public API" like some libraries do. But also maybe this just checks whether the signature has a valid format, rather than check the signature itself? I don't know enough about secp256k1 to know what makes sense to implement.

@tomaka
Copy link
Contributor

tomaka commented Oct 29, 2024

Does it make sense for you if, when you're trying to mock an ECDSA signature, smoldot asks you to provide the associated public key?

@ermalkaleci
Copy link
Contributor

@xlc I don't think there's a need to change anything on smoldot. Chopsticks mock signature is creating signature with 64 bytes while ecdsa is 65. I think that might be the issue. Checking now

@ermalkaleci
Copy link
Contributor

my bad, seems like RuntimeCall::SignatureVerification is called at all

@xlc
Copy link
Contributor Author

xlc commented Oct 29, 2024

Does it make sense for you if, when you're trying to mock an ECDSA signature, smoldot asks you to provide the associated public key?

yeah that’s fine. we can modify the mock signature format to include a public key

@tomaka tomaka linked a pull request Nov 1, 2024 that will close this issue
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 a pull request may close this issue.

3 participants