[ANN] multicodec, multibase, multihash and multihash-digestif

Hello :wave:

Happy to announce the initial release of four somewhat related packages. They are all libraries falling under multiformats, which are

Self-describing values for Future-proofing. The Multiformats Project is a collection of protocols which aim to future-proof systems, today. They do this mainly by enhancing format values with self-description. This allows interoperability, protocol agility, and helps us avoid lock in.

Releases

Mutlicodec

Multicodec is a fairly simple package providing OCaml values and types for the multicodec. This is an agreed upon mapping of integers to protocols.

Multibase

Multibase provides self-identifying base encodings, so given a multibase-encoded string, this library can tell you what the base encoding was and if supported it will then decode the message. You can of course also encode messages too, with the currently supported encodings being Base32, Base58 and Base64.

Multihash and Multihash-digestif

Multihash provides self-describing hash functions. The library multihash takes a hash implementation and provides multihashes. Multihash-digestif is multihash using digestif as an implementation.

Use Case

One fun thing you can do is replace Irmin’s hash implementation with Multihash.

let main () =
  let open Lwt.Syntax in
  let config = Irmin_mem.config () in
  let* repo = Store.Repo.v config in
  let* main = Store.main repo in
  let* () = Store.set_exn ~info main [ "a" ] "Hello World" in
  let* hash = Store.hash main [ "a" ] in
  match hash with
  | Some md ->
      Format.printf "%a%!" Multihash_digestif.pp md;
      Lwt.return_unit
  | None -> assert false

let () = Lwt_main.run (main ())

And this program prints

ident(sha2-256) length(32) digest(4a 2b 43 6f 2b 5a 16 b0  1e 3c e5 28 5e 88 b1 99
                                  a9 a4 ae fd b1 e1 6a c8  31 c3 32 d4 92 c5 d1 57
                                  )

See this gist for all of the details.

Furture Work

Two short term goals are:

  1. Release Content-addressed Identifiers (CID)
  2. Release multiaddr

Thanks for reading :))

6 Likes