Method: Klay::Signature#recover_typed_data

Defined in:
lib/klay/signature.rb

#recover_typed_data(typed_data, signature, chain_id = Chain::CYPRESS) ⇒ String

Recovers a public key from a typed data structure and a signature on a given chain. (EIP-712) Ref: https://eips.ethereum.org/EIPS/eip-712

Parameters:

  • typed_data (Array)

    all the data in the typed data structure to be recovered.

  • 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.



103
104
105
106
# File 'lib/klay/signature.rb', line 103

def recover_typed_data(typed_data, signature, chain_id = Chain::CYPRESS)
  hash_to_sign = Eip712.hash typed_data
  recover hash_to_sign, signature, chain_id
end