View Source Signet.Signer.Curvy (Signet v0.1.7)

Signer to sign messages using a private key directly.

Note: this should not be used in production systems. Please see Signet.Signer.CloudKMS.

Link to this section Summary

Functions

Get the Ethereum address associated with the given private key.

Signs the given message using the private key, after digesting the message with keccak.

Link to this section Functions

Link to this function

get_address(private_key)

View Source
@spec get_address(binary()) :: {:ok, binary()} | {:error, String.t()}

Get the Ethereum address associated with the given private key.

examples

Examples

iex> priv_key = "800509fa3e80882ad0be77c27505bdc91380f800d51ed80897d22f9fcc75f4bf" |> Base.decode16!(case: :mixed)
iex> {:ok, address} = Signet.Signer.Curvy.get_address(priv_key)
iex> Base.encode16(address)
"63CC7C25E0CDB121ABB0FE477A6B9901889F99A7"
Link to this function

sign(message, private_key)

View Source
@spec sign(String.t(), binary()) :: {:ok, Curvy.Signature.t()} | {:error, String.t()}

Signs the given message using the private key, after digesting the message with keccak.

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"