eth_sign
Sign, verify, ecrecover, or reformat a secp256k1 signature over a 32-byte hash.
Instructions
Sign, verify, ecrecover, or reformat a secp256k1 signature over a 32-byte hash.
This signs a raw digest — unlike the JSON-RPC eth_sign/personal_sign, it
adds no "\x19Ethereum Signed Message" prefix. Hash a message first with
eth_hash (kind=eip191 for personal_sign, eip712 for typed data), or pass a
transaction's signing hash (eth_tx_codec's signing_hash) or a user
operation's hash (eth_userop_hash).
action=sign (message_hash, private_key_file) -> {signature (65-byte, v=27/28),
r, s, v, yParity, eip2098, address}. The nonce is RFC 6979, so the result is
deterministic and matches eth_account/ethers; s is always low (EIP-2).
address is the signer's, to confirm the right key was used. The key is
never echoed.
action=verify (message_hash, signature, address) -> {valid, recovered, low_s};
a signature that recovers no key is soft: valid false plus reason.
action=recover (message_hash, signature) -> {address, low_s}.
action=convert (signature, signature_format) -> {format, result, low_s}.
low_s is false for a malleable high-s signature: the ecrecover precompile
accepts it, but Ethereum transactions and OpenZeppelin's ECDSA reject it.
Example: eth_sign("sign", message_hash="0x…32 bytes…", private_key_file="~/keys/dev.key") -> {signature: "0x…1b", r, s, v: 27, …}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | 'sign' a digest with the key in `private_key_file`; 'verify' a signature against an expected `address`; 'recover' the signer address (ecrecover); 'convert' a signature between forms. | |
| address | No | action=verify: the expected signer's 20-byte address (any casing). | |
| signature | No | For verify/recover/convert: a 65-byte r || s || v hex string (v 27/28 or 0/1), a 64-byte EIP-2098 compact hex string, or an object {r, s, v} / {r, s, yParity} (ints as int, decimal, or 0x-hex). | |
| message_hash | No | The 32-byte digest to sign or check, as hex (0x optional) — signed exactly as given, with no prefix added. Required for sign, verify, and recover. | |
| private_key_file | No | action=sign only: path of a file holding the private key as 64 hex digits (0x and surrounding whitespace optional) or as 32 raw bytes; `~` is expanded. The server reads it itself, so the key never appears in the call or the result, and no error quotes the file's contents. There is deliberately no inline key argument. | |
| signature_format | No | action=convert: the form to produce — 'rsv' (object {r, s, v, yParity}), 'packed65' (65-byte r || s || v, v=27/28), or 'eip2098' (64-byte compact; low-s signatures only). Default packed65. | packed65 |