AbtDid v0.3.2 AbtDid.TypeBytes View Source
Encodes the DId type information into bytes.
Link to this section Summary
Link to this section Functions
Link to this function
bytes_to_struct(bytes)
View Source
bytes_to_struct(bytes)
View Source
bytes_to_struct(binary()) :: AbtDid.Type.t()
bytes_to_struct(binary()) :: AbtDid.Type.t()
Converts the DID type bytes to DID type struct.
Examples
iex> AbtDid.TypeBytes.bytes_to_struct(<<0, 1>>)
%AbtDid.Type{hash_type: :sha3, key_type: :ed25519, role_type: :account}
iex> AbtDid.TypeBytes.bytes_to_struct(<<0, 5>>)
%AbtDid.Type{hash_type: :sha3_512, key_type: :ed25519, role_type: :account}
iex> AbtDid.TypeBytes.bytes_to_struct("%")
%AbtDid.Type{role_type: :application, key_type: :secp256k1, hash_type: :sha3_512}
iex> AbtDid.TypeBytes.bytes_to_struct(<<196, 5>>)
** (RuntimeError) Invliad role type: "1"
Link to this function
struct_to_bytes(type)
View Source
struct_to_bytes(type)
View Source
struct_to_bytes(AbtDid.Type.t()) :: binary()
struct_to_bytes(AbtDid.Type.t()) :: binary()
Converts the DID type struct to type bytes.
Examples
iex> AbtDid.TypeBytes.struct_to_bytes(%AbtDid.Type{})
<<0, 1>>
iex> AbtDid.TypeBytes.struct_to_bytes(%AbtDid.Type{hash_type: :sha3_512})
<<0, 5>>
iex> AbtDid.TypeBytes.struct_to_bytes(%AbtDid.Type{role_type: :application, key_type: :secp256k1, hash_type: :sha3_512})
"%"
iex> AbtDid.TypeBytes.struct_to_bytes(%AbtDid.Type{role_type: :application, hash_type: :sha2})
** (RuntimeError) The hash_type :sha2 is only used for role_type :node or :validator.