Tezex.Michelson.Base58 (tezex v6.0.0)

Copy Markdown View Source

Validates the base58 literals of Michelson's address-like types and decodes them into the binary forms the protocol compares them by.

Prefixes are Octez's: src/lib_crypto/base58.ml, plus contract_hash.ml (KT1) and zk_rollup_repr.ml (epx1) in the protocol.

Summary

Functions

An address is compared by destination, then by entrypoint name, where no entrypoint means "default" (script_comparable.ml, compare_address). Destinations are tagged like their binary encoding (destination_repr.ml), so their byte order is the protocol's: implicit (tz1 < tz2 < tz3 < tz4) < KT1 < sr1 < epx1.

A key is compared by curve (ed25519 < secp256k1 < p256 < bls), then by key bytes (signature_v1.ml). The bytes here are the encoded ones; p256 keys need decompressing before they're compared, see Tezex.Michelson.Comparable.

A signature is compared by its raw bytes, whatever its prefix (signature_v1.ml), so edsig… and sig… with the same bytes are equal.

Functions

address(value)

@spec address(String.t()) :: {:ok, {binary(), String.t()}} | :error

An address is compared by destination, then by entrypoint name, where no entrypoint means "default" (script_comparable.ml, compare_address). Destinations are tagged like their binary encoding (destination_repr.ml), so their byte order is the protocol's: implicit (tz1 < tz2 < tz3 < tz4) < KT1 < sr1 < epx1.

chain_id(value)

@spec chain_id(String.t()) :: {:ok, binary()} | :error

decode(binary, value)

@spec decode(String.t(), String.t()) :: {:ok, term()} | :error

key(value)

@spec key(String.t()) :: {:ok, {0..3, binary()}} | :error

A key is compared by curve (ed25519 < secp256k1 < p256 < bls), then by key bytes (signature_v1.ml). The bytes here are the encoded ones; p256 keys need decompressing before they're compared, see Tezex.Michelson.Comparable.

key_hash(value)

@spec key_hash(String.t()) :: {:ok, binary()} | :error

signature(value)

@spec signature(String.t()) :: {:ok, binary()} | :error

A signature is compared by its raw bytes, whatever its prefix (signature_v1.ml), so edsig… and sig… with the same bytes are equal.