examples/ethereum_key_recovery/key_recovery.rb
# Signs a personal message with the given private key.
#
# @param private_key [Secp256k1::PrivateKey] key to use for signing.
# @param chain_id [Integer] unique identifier for chain.
# @return [String] binary signature data including recovery id v at end.
Signs a personal message with the given private key.
Signs a personal message with the given private key .
def sign(private_key, chain_id)
    ctx = Secp256k1::Context.new
    signature, recovery_id = ctx.sign_recoverable(private_key, hash).compact
    result = signature.bytes
    result = result.append(Chains.to_v(recovery_id, chain_id))
    result.pack('c*')
  end
def sign ( private_key , chain_id ) ctx = Secp256k1 :: Context . new signature , recovery_id = ctx . sign_recoverable ( private_key , hash ) . compact result = signature . bytes result = result . append ( Chains . to_v ( recovery_id , chain_id ) ) result . pack ( 'c*' ) end
Signs a personal message with the given private key.
Signs a personal message with the given private key .
binary signature data including recovery id v at end.
binary signature data including recovery id v at end .
String
private_key
key to use for signing.
key to use for signing .
chain_id
unique identifier for chain.
unique identifier for chain .