Skip to content

feat(sdk): add verifyMessage and make signMessage compatible with Dash Core signed messages #4588

Description

@thephez

Summary

WasmSdk.signMessage (wasm-sdk) and wallet.signMessage (js-evo-sdk) exist, but there is no verifyMessage counterpart. Worse, the signature format produced is nonstandard, so nothing else in the ecosystem (Dash Core verifymessage, other wallets) can verify it either.

Current behavior

sign_message in packages/wasm-sdk/src/wallet/key_generation.rs:

  • hashes the raw message bytes with a single SHA-256 (no \x19DarkCoin Signed Message:\n magic prefix, no length varint)
  • signs with plain (non-recoverable) ECDSA
  • returns the 64-byte compact signature as hex

Dash Core's signmessage / verifymessage use the magic prefix, double SHA-256, and a 65-byte recoverable signature encoded as base64. The SDK output is incompatible with that, and because it has no recovery byte, a verifier would need the public key passed explicitly rather than recovering it from an address.

The only tests (packages/wasm-sdk/tests/unit/key-generation.spec.ts) check that the output is a string and is deterministic. No test round-trips a signature, which is how the gap went unnoticed.

History

Proposed fix

  1. Reimplement signMessage on top of the dashcore::sign_message module the SDK already depends on (signed_msg_hash, MessageSignature, base64 helpers) so output matches Dash Core's signmessage.
  2. Add verifyMessage(message, signature, address, network) using MessageSignature::is_signed_by_address / recover_pubkey, and expose it in js-evo-sdk's wallet facade.
  3. Add round-trip tests, plus a fixture generated by Dash Core signmessage to prove interoperability.

Breaking change

Changing the output format of signMessage is a breaking change to the wasm-sdk and js-evo-sdk wallet API. It should be flagged with ! in the commit and noted in the migration docs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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