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
- 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.
- Add
verifyMessage(message, signature, address, network) using MessageSignature::is_signed_by_address / recover_pubkey, and expose it in js-evo-sdk's wallet facade.
- 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.
Summary
WasmSdk.signMessage(wasm-sdk) andwallet.signMessage(js-evo-sdk) exist, but there is noverifyMessagecounterpart. Worse, the signature format produced is nonstandard, so nothing else in the ecosystem (Dash Coreverifymessage, other wallets) can verify it either.Current behavior
sign_messageinpackages/wasm-sdk/src/wallet/key_generation.rs:\x19DarkCoin Signed Message:\nmagic prefix, no length varint)Dash Core's
signmessage/verifymessageuse 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
signMessagewas added in feat(sdk): wasm sdk core and test suite #2709 as part of the initial wasm-sdk wallet helpers.Proposed fix
signMessageon top of thedashcore::sign_messagemodule the SDK already depends on (signed_msg_hash,MessageSignature, base64 helpers) so output matches Dash Core'ssignmessage.verifyMessage(message, signature, address, network)usingMessageSignature::is_signed_by_address/recover_pubkey, and expose it in js-evo-sdk's wallet facade.signmessageto prove interoperability.Breaking change
Changing the output format of
signMessageis 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.