Packages

Various modules and helpers for working with Nimiq primitives in the Gleam programming language or as a CLI

Current section

Files

Jump to
nimiq_gleam src transaction@signature_proof_algorithm.erl
Raw

src/transaction@signature_proof_algorithm.erl

-module(transaction@signature_proof_algorithm).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([to_int/1, from_int/1]).
-export_type([signature_proof_algorithm/0]).
-type signature_proof_algorithm() :: ed25519 | e_s256.
-file("src/transaction/signature_proof_algorithm.gleam", 8).
-spec to_int(signature_proof_algorithm()) -> integer().
to_int(Algorithm) ->
case Algorithm of
ed25519 ->
0;
e_s256 ->
1
end.
-file("src/transaction/signature_proof_algorithm.gleam", 15).
-spec from_int(integer()) -> {ok, signature_proof_algorithm()} |
{error, binary()}.
from_int(Value) ->
case Value of
0 ->
{ok, ed25519};
1 ->
{ok, e_s256};
_ ->
{error,
<<"Invalid signature proof algorithm: "/utf8,
(erlang:integer_to_binary(Value))/binary>>}
end.