View Source Signet.Recover (Signet v0.1.7)
Link to this section Summary
Functions
Finds the given recid which recovers the given signature for the message to the given Ethereum address. This is a very simple guess-check-revise since there are only four possible values, and we only accept two of those.
Prefixes a message with "Etheruem Signed Message" prefix, as per EIP-191.
Recovers a signer's Ethereum address from a signed message. The message will be digested by keccak first. Note: the rec_id can be embeded in the signature or passed separately.
Recovers a signer's public key from a signed message. The message will be digested by keccak first. Note: the rec_id can be embeded in the signature or passed separately.
Link to this section Functions
Finds the given recid which recovers the given signature for the message to the given Ethereum address. This is a very simple guess-check-revise since there are only four possible values, and we only accept two of those.
examples
Examples
iex> priv_key = Base.decode16!("800509fa3e80882ad0be77c27505bdc91380f800d51ed80897d22f9fcc75f4bf", case: :mixed) iex> {:ok, sig} = Signet.Signer.Curvy.sign("test", priv_key) iex> {:ok, recid} = Signet.Recover.find_recid("test", sig, Base.decode16!("63CC7C25E0CDB121ABB0FE477A6B9901889F99A7")) iex> Signet.Recover.recover_eth("test", %{sig|recid: recid}) |> Base.encode16() "63CC7C25E0CDB121ABB0FE477A6B9901889F99A7"
Prefixes a message with "Etheruem Signed Message" prefix, as per EIP-191.
examples
Examples
iex> Signet.Recover.prefix_eth("hello") "Ethereum Signed Message:\n5hello"
Recovers a signer's Ethereum address from a signed message. The message will be digested by keccak first. Note: the rec_id can be embeded in the signature or passed separately.
examples
Examples
iex> priv_key = Base.decode16!("800509fa3e80882ad0be77c27505bdc91380f800d51ed80897d22f9fcc75f4bf", case: :mixed) iex> {:ok, sig} = Signet.Signer.Curvy.sign("test", priv_key) iex> {:ok, recid} = Signet.Recover.find_recid("test", sig, Base.decode16!("63CC7C25E0CDB121ABB0FE477A6B9901889F99A7")) iex> Signet.Recover.recover_eth("test", %{sig|recid: recid}) |> Base.encode16() "63CC7C25E0CDB121ABB0FE477A6B9901889F99A7"
Recovers a signer's public key from a signed message. The message will be digested by keccak first. Note: the rec_id can be embeded in the signature or passed separately.
examples
Examples
iex> priv_key = Base.decode16!("800509fa3e80882ad0be77c27505bdc91380f800d51ed80897d22f9fcc75f4bf", case: :mixed) iex> {:ok, sig} = Signet.Signer.Curvy.sign("test", priv_key) iex> {:ok, recid} = Signet.Recover.find_recid("test", sig, Base.decode16!("63CC7C25E0CDB121ABB0FE477A6B9901889F99A7")) iex> Signet.Recover.recover_public_key("test", %{sig|recid: recid}) |> Base.encode16() "0480076BFB96955526052B2676DFCA87E0B7869CE85E00C5DBCE29E76B8429D6DBF0F33B1A0095B2A9A4D9EA2A9746B122995A5B5874EE3161138C9D19F072B2D9"