ExPlasma.Crypto (ExPlasma v0.2.0)
Signs and validates signatures. Constructed signatures can be used directly
in Ethereum with ecrecover
call.
Link to this section Summary
Functions
Given public key, returns an address.
Produces a KECCAK digest for the message.
Recovers the address of the signer from a binary-encoded signature.
Link to this section Types
Link to this type
address_t()
Specs
address_t() :: <<_::160>>
Link to this type
hash_t()
Specs
hash_t() :: <<_::256>>
Link to this type
pub_key_t()
Specs
pub_key_t() :: <<_::512>>
Link to this type
recover_address_error()
Specs
recover_address_error() :: :corrupted_witness | :invalid_message
Link to this type
sig_t()
Specs
sig_t() :: <<_::520>>
Link to this section Functions
Link to this function
generate_address(arg)
Specs
Given public key, returns an address.
Link to this function
keccak_hash(message)
Specs
Produces a KECCAK digest for the message.
Example
iex> ExPlasma.Crypto.keccak_hash("omg!")
<<241, 85, 204, 147, 187, 239, 139, 133, 69, 248, 239, 233, 219, 51, 189, 54,
171, 76, 106, 229, 69, 102, 203, 7, 21, 134, 230, 92, 23, 209, 187, 12>>
Link to this function
recover_address(arg1, arg2)
Specs
recover_address(hash_t(), sig_t()) :: {:ok, address_t()} | {:error, recover_address_error()}
Recovers the address of the signer from a binary-encoded signature.