Class: Siwe::Adapter::EthGem
- Inherits:
-
Object
- Object
- Siwe::Adapter::EthGem
- Defined in:
- lib/siwe/adapter.rb
Overview
Default crypto adapter using the eth gem. Implements the SiweConfig interface from the TS reference implementation: verify_message → recover signer address from EIP-191 signed message hash_message → EIP-191 personal_sign hash get_address → normalize to EIP-55 checksum address
Instance Method Summary collapse
- #get_address(addr) ⇒ Object
- #hash_message(message) ⇒ Object
- #verify_message(message, signature) ⇒ Object
Instance Method Details
#get_address(addr) ⇒ Object
26 27 28 |
# File 'lib/siwe/adapter.rb', line 26 def get_address(addr) Eth::Address.new(addr).to_s end |
#hash_message(message) ⇒ Object
21 22 23 24 |
# File 'lib/siwe/adapter.rb', line 21 def () prefixed = Eth::Signature.() Eth::Util.keccak256(prefixed) end |
#verify_message(message, signature) ⇒ Object
16 17 18 19 |
# File 'lib/siwe/adapter.rb', line 16 def (, signature) public_key = Eth::Signature.personal_recover(, signature) Eth::Util.public_key_to_address(public_key).to_s end |