Elrondex.Account (Elrondex v0.1.1) View Source

Link to this section Summary

Functions

Generates an account based on a specific address.

Generates an account based on a specific private key.

Generates an account based on a specific public key.

Generates a random account.

Converts an account's private key to hex format.

Converts an account's public key to hex format.

Returns an account's address from the public key.

Signs the data.

Verifies the signature of the data.

Link to this section Functions

Generates an account based on a specific address.

Arguments

  • address - a wallet's address

Examples

iex> Elrondex.Test.Bob.address()
...> |> Elrondex.Account.from_address()
...> |> Map.get(:public_key)
<<203, 118, 219, 103, 28, 45, 57, 174, 200, 185, 187, 95, 244, 197, 165, 240,
28, 122, 88, 250, 13, 128, 6, 242, 143, 81, 69, 130, 54, 31, 71, 129>>
Link to this function

from_mnemonic(mnemonic, passphrase \\ "", account_index \\ 0)

View Source

Returns an account from the mnemonic.

Arguments

  • mnemonic - a wallet's mnemonic

Examples

iex> Elrondex.Test.Bob.mnemonic()
...> |> Elrondex.Account.from_mnemonic()
...> |> Map.get(:address)
...> "erd1edmdkecu95u6aj9ehd0lf3d97qw85k86pkqqdu5029zcydslg7qs3tdc59"
Link to this function

from_private_key(private_key)

View Source

Generates an account based on a specific private key.

Arguments

  • private_key - a private key (in binary or in hex format)

Examples

iex> Elrondex.Test.Bob.private_key()
...> |> Elrondex.Account.from_private_key()
...> |> Map.get(:address)
"erd1edmdkecu95u6aj9ehd0lf3d97qw85k86pkqqdu5029zcydslg7qs3tdc59"

iex> Elrondex.Test.Bob.hex_private_key()
...> |> Elrondex.Account.from_private_key()
...> |> Map.get(:address)
"erd1edmdkecu95u6aj9ehd0lf3d97qw85k86pkqqdu5029zcydslg7qs3tdc59"
Link to this function

from_public_key(public_key)

View Source

Generates an account based on a specific public key.

Arguments

  • public_key - a public key (in binary or in hex format)

Examples

iex> Elrondex.Test.Bob.public_key()
...> |>Elrondex.Account.from_public_key()
...> |>Map.get(:address)
"erd1edmdkecu95u6aj9ehd0lf3d97qw85k86pkqqdu5029zcydslg7qs3tdc59"

Generates a random account.

Examples

iex> Elrondex.Account.generate_random().address
...> |> String.slice(0, 3)
"erd"
Link to this function

hex_private_key(account)

View Source

Converts an account's private key to hex format.

Arguments

  • account - the account that uses the key

Examples

iex> Elrondex.Test.Bob.private_key()
...> |> Elrondex.Account.from_private_key()
...> |> Elrondex.Account.hex_private_key()
"5d251c79a032263f4af11acd06d6d5d92646b408a256a282155b8363e2f168bf"

Converts an account's public key to hex format.

Arguments

  • account - the account that uses the key

Examples

iex> Elrondex.Test.Bob.public_key()
...> |> Elrondex.Account.from_public_key()
...> |> Elrondex.Account.hex_public_key()
"cb76db671c2d39aec8b9bb5ff4c5a5f01c7a58fa0d8006f28f514582361f4781"
Link to this function

public_key_to_address(public_key)

View Source

Returns an account's address from the public key.

Arguments

  • public_key - a public key (in binary or in hex format)

    Examples

    iex> Elrondex.Test.Bob.account().public_key() ...> |> Elrondex.Account.public_key_to_address "erd1edmdkecu95u6aj9ehd0lf3d97qw85k86pkqqdu5029zcydslg7qs3tdc59"

    iex> Elrondex.Test.Bob.hex_public_key() ...> |> Elrondex.Account.public_key_to_address() "erd1edmdkecu95u6aj9ehd0lf3d97qw85k86pkqqdu5029zcydslg7qs3tdc59"

Link to this function

sign(data_to_sign, account)

View Source

Signs the data.

Arguments

  • data_to_sign - data to sign
  • account - the account that signs
Link to this function

sign_verify(data_to_sign, signature, account)

View Source

Verifies the signature of the data.

Arguments

  • data_to_sign - data to sign
  • signature - the signature
  • account - the account that signed