eth_sign
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
.
Return
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 (usually0
or1
)
Since
0.10.6
Parameters
a 32-byte array to be signed
the 32-byte private key with which to sign