polkadot-js / common

Utilities and base libraries for use across polkadot-js for Polkadot and Substrate. Includes base libraries, crypto helpers and cross-environment helpers.
Apache License 2.0
253 stars 144 forks source link

Signing and verifying a message using ECDSA sometimes fails #1898

Open rjwebb opened 10 months ago

rjwebb commented 10 months ago

Expected behaviour: I should be able to generate a KeyringPair that signs messages using the ECDSA algorithm and verify the signatures against the message + the KeyringPair's public key

Current behaviour: This works most of the time, approx 99/100 times, but sometimes the verification fails.

I'm working on a project that relies on being able to sign and verify data from the KeyringPair or from Polkadot wallets so I want to be able to rely on this functionality.

I'm using @polkadot/keyring, @polkadot/util and @polkadot/util-crypto at the latest version as of writing (12.6.1).

I've created a minimal repository here that reproduces the bug: https://github.com/rjwebb/polkadot-ecdsa-bug-reproduction