Method: Klay::Signature#personal_recover

Defined in:
lib/klay/signature.rb

#personal_recover(message, signature, chain_id = Chain::CYPRESS) ⇒ String

Recovers a public key from a prefixed, personal message and a signature on a given chain. (EIP-191) Ref: https://eips.ethereum.org/EIPS/eip-191

Parameters:

  • message (String)

    the message string.

  • signature (String)

    the hex string containing the signature.

  • chain_id (Integer) (defaults to: Chain::CYPRESS)

    the chain ID the signature should be recovered from.

Returns:

  • (String)

    a hexa-decimal, uncompressed public key.



90
91
92
93
94
# File 'lib/klay/signature.rb', line 90

def personal_recover(message, signature, chain_id = Chain::CYPRESS)
  prefixed_message = prefix_message message
  hashed_message = Util.keccak256 prefixed_message
  recover hashed_message, signature, chain_id
end