Skip to content

[FEATURE] let Keypair:sign return a recoverable (non malleable) signature #81

@elmariachi111

Description

@elmariachi111

The Keypair:sign function in this package returns the (actually deprecated) hex / byte representation of a signature and not the noble library's Signature object. That representation unfortunately is missing the recovery bit that's required to recover the the signature's public key correctly, however. What oc works is calling the relevant ecdsa verify function with the public key if the verifier knows it at that point.

Due to the x-symmetric nature of the underlying elliptic curve this leads to at least 2 signatures being equally valid over the same (hashed) message. The EVM ecosystem considered this potentially dangerous (not by itself but for implementers) in 2015 / EIP-2 already. Library implementations (OpenZeppelin / viem) always add the recovery bit (v+27 in EVM) to the signature bytes or flip a signature to the only valid side of the curve.

Here's a gist with a happy path and the nillion variant as a starting point to test that issue: https://gist.github.com/elmariachi111/3486fde2d4746d511eb2869ac51076e3

Reading is believing:

My suggestion would be: either let Keypair:sign return

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions