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

Fix Misclassification of ECDSA Signatures in verifyMultisig() #1973

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

valentinfernandez1
Copy link
Contributor

@valentinfernandez1 valentinfernandez1 commented Jan 31, 2025

This PR addresses issue #1898 by refining the logic in verifyMultisig() to correctly distinguish between ECDSA, Ed25519, and Sr25519 signatures.

Problem:
Previously, verifyMultisig() misidentified certain ECDSA signatures (65 bytes) as Ed25519 or Sr25519 signatures (64 bytes) when the first byte of the ECDSA signature was 0 or 1. This happened because the function interpreted the first byte as a multisignature prefix rather than part of the ECDSA signature itself.

Solution:

  • Improved signature length handling:

    • If the signature is 66 bytes, it is treated as an ECDSA signature prefixed with a crypto type byte, so the prefix is removed before verification.
    • If the signature is 65 bytes, it could be:
      • A proper ECDSA signature, which should remain unchanged for verification.
      • An Ed25519/Sr25519 signature (1-byte prefix + 64-byte signature), in which case the prefix is removed before verification.
  • Improved verification order:

    • First, attempt Ed25519/Sr25519 verification by removing the prefix.
    • If verification fails, fall back to ECDSA verification using the full 65-byte signature.

    closes Signing and verifying a message using ECDSA sometimes fails #1898

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 this pull request may close these issues.

Signing and verifying a message using ECDSA sometimes fails
1 participant