package octez-libs

  1. Overview
  2. Docs
A package that contains multiple base libraries used by the Octez suite

Install

Dune Dependency

Authors

Maintainers

Sources

octez-19.0.tar.gz
sha256=c6df840ebbf115e454db949028c595bec558a59a66cade73b52a6d099d6fa4d4
sha512=d8aee903b9fe130d73176bc8ec38b78c9ff65317da3cb4f3415f09af0c625b4384e7498201fdb61aa39086a7d5d409d0ab3423f9bc3ab989a680cf444a79bc13

doc/octez-libs.crypto/Tezos_crypto/Base58/index.html

Module Tezos_crypto.Base58Source

Prefixed Base58Check encodings

Sourcemodule Prefix : sig ... end
Sourcetype data = ..

An extensible sum-type for decoded data: one case per known "prefix". See for instance Hash.Block_hash.Hash or Environment.Ed25519.Public_key_hash.

Sourcetype 'a encoding = private {
  1. prefix : string;
  2. length : int;
  3. encoded_prefix : string;
  4. encoded_length : int;
  5. to_raw : 'a -> string;
  6. of_raw : string -> 'a option;
  7. wrap : 'a -> data;
}

Abstract representation of registered encodings. The type parameter is the type of the encoded data, for instance Hash.Block_hash.t.

Sourceval register_encoding : prefix:string -> length:int -> to_raw:('a -> string) -> of_raw:(string -> 'a option) -> wrap:('a -> data) -> 'a encoding

Register a new encoding. The function might raise Invalid_arg if the provided prefix overlaps with a previously registered prefix. The to_raw and of_raw are the ad-hoc serialisation/deserialisation for the data. The wrap should wrap the deserialised value into the extensible sum-type data (see the generic function decode).

Sourceval check_encoded_prefix : 'a encoding -> string -> int -> unit

Checks that an encoding has a certain prefix and length.

Sourcemodule Alphabet : sig ... end
Sourceval simple_encode : ?alphabet:Alphabet.t -> 'a encoding -> 'a -> string

Encoder for a given kind of data.

Sourceval simple_decode : ?alphabet:Alphabet.t -> 'a encoding -> string -> 'a option

Decoder for a given kind of data. It returns None when the decoded data does not start with the expected prefix.

Sourceval decode : ?alphabet:Alphabet.t -> string -> data option

Generic decoder. It returns None when the decoded data does not start with a registered prefix.

Completion of partial Base58Check value

Sourceval register_resolver : 'a encoding -> (string -> 'a list Lwt.t) -> unit

Register a (global) resolver for a previously registered kind of data.

Sourceval complete : ?alphabet:Alphabet.t -> string -> string list Lwt.t

Try to complete a prefix of a Base58Check encoded data, by using the previously registered resolver associated to this kind of data. Note that a prefix of n characters of a Base58-encoded value provides at least n/2 bytes of a prefix of the original value.

Low-level: distinct registering function for economic protocol

Sourcemodule Make (C : sig ... end) : sig ... end

See src/environment/v1/base58.mli for an inlined documentation.

Low-level Base58Check encodings

Sourceval safe_encode : ?alphabet:Alphabet.t -> string -> string

Base58Check-encoding/decoding functions (with error detections).

Sourceval safe_decode : ?alphabet:Alphabet.t -> string -> string option
Sourceval raw_encode : ?alphabet:Alphabet.t -> string -> string

Base58-encoding/decoding functions (without error detections).

Sourceval raw_decode : ?alphabet:Alphabet.t -> string -> string option
OCaml

Innovation. Community. Security.