ink icon indicating copy to clipboard operation
ink copied to clipboard

`ecdsa_recover` produces inconsistent results in ink! v6 e2e tests

Open AlexD10S opened this issue 6 months ago • 1 comments

An issue was reported in our Telegram group regarding the ecdsa_recover method in ink! v6:

Hello, I am encountering an issue with the ecdsa_recover method with ink! v6 It seems the method doesn't work in e2e tests. I reproduced the issue here: https://github.com/GuiGou12358/test_ecddsa_recover/blob/main/test_ecdsa_recover/lib.rs This test fails: https://github.com/GuiGou12358/test_ecddsa_recover/blob/main/test_ecdsa_recover/lib.rs#L94

A possible cause is the update to the secp256k1 library in https://github.com/use-ink/ink/pull/2340 which introduced a change inside ecdsa_recover function:

- let recovery_id = RecoveryId::from_i32(recovery_byte as i32) 
+ let recovery_id = RecoveryId::try_from(recovery_byte as i32)

It's worth noting that the internal test here still passes: https://github.com/use-ink/ink/blob/641f05706e4f7ff1fb7c60e261ed0f4bc833f2f0/crates/engine/src/tests.rs#L179

AlexD10S avatar Jun 18 '25 18:06 AlexD10S

It seems the latests changes in ecrecover precompile https://github.com/use-ink/ink/blob/641f05706e4f7ff1fb7c60e261ed0f4bc833f2f0/crates/env/src/engine/on_chain/pallet_revive.rs#L359 are what's causing the inconsistent results, with secp256k1 working fine in unit tests but behaving differently in e2e tests, returning an empty output

AlexD10S avatar Jun 23 '25 09:06 AlexD10S