FUNCTION
eth_sign
function eth_sign(data_hash: byte_array, privkey: byte_array): (byte_array, byte_array, integer)Compute an Ethereum signature.
The given 32-byte array data_hash is typically a cryptographic hash obtained from a larger data
structure using a hashing function such as hash(), sha256() or keccak256().
The public key corresponding to the given private key can be computed from the original value of
data_hash and the returned signature tuple (r, s, rec_id) using the eth_ecrecover() method:
val (r, s, rec_id) = eth_sign(data_hash, privkey);
val pubkey = eth_ecrecover(r, s, rec_id, data_hash);
The returned signature component rec_id is an adjusted recovery identifier, equivalent to
Ethereum's recovery identifier (usually denoted as v) minus 27, i.e. rec_id == v - 27.
Parameters
- data_hash — a 32-byte array to be signed
- privkey — the 32-byte private key with which to sign
Returns
a tuple containing the signature components:
r, the first 32 bytes of the signatures, the second 32 bytes of the signaturerec_id, the adjusted recovery identifier (usually0or1)
Since
0.10.6
© 2026 Chromia