View Source Dpos.Utils (DPoS v0.4.0)

Utility functions for DPoS.

Summary

Functions

Converts the wallet address to binary.

Derives a wallet address from the public key.

Encodes the binary in base 16.

Reverses the given binary (from little-endian to big-endian).

Seed a keypair from a secret key.

Signs a message and returns the signature.

Ensures signature is a binary 64 bytes long.

Verifies a message.

Functions

Link to this function

address_to_binary(address, suffix_length)

View Source
@spec address_to_binary(String.t(), pos_integer()) :: binary()

Converts the wallet address to binary.

Link to this function

derive_address(pub_key, suffix)

View Source
@spec derive_address(binary(), String.t()) :: String.t()

Derives a wallet address from the public key.

@spec hexdigest(binary()) :: String.t()

Encodes the binary in base 16.

Returns nil if binary is nil.

@spec reverse_binary(binary()) :: integer()

Reverses the given binary (from little-endian to big-endian).

@spec seed_keypair(String.t()) :: {:ok, binary(), binary()}

Seed a keypair from a secret key.

Link to this function

sign_message(msg, priv_key)

View Source
@spec sign_message(String.t(), binary()) :: {:ok, binary()}

Signs a message and returns the signature.

Link to this function

signature_to_binary(sig)

View Source
@spec signature_to_binary(binary()) :: binary()

Ensures signature is a binary 64 bytes long.

Returns an empty binary if signature is nil.

Link to this function

verify_message(msg, sig, pub_key)

View Source
@spec verify_message(String.t(), binary(), binary()) :: :ok

Verifies a message.