crypto-multihash: Multihash library on top of cryptonite crypto library

[ bsd3, cryptography, library, program ] [ Propose Tags ]

Multihash is a protocol for encoding the hash algorithm and digest length at the start of the digest, see the official multihash github. Usage and additional informations are on README.md


[Skip to Readme]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.2.0.0, 0.2.0.1, 0.3.0.0, 0.4.0.0, 0.4.1.0, 0.4.2.0
Dependencies base (>=4.7 && <5), base58-bytestring, bytestring, containers, crypto-multihash, cryptonite, memory [details]
License BSD-3-Clause
Copyright 2016 Marcello Seri
Author Marcello Seri
Maintainer marcello.seri@gmail.com
Category Cryptography
Home page https://github.com/mseri/crypto-multihash#readme
Source repo head: git clone https://github.com/mseri/crypto-multihash
Uploaded by mseri at 2016-06-17T17:09:28Z
Distributions
Executables mh
Downloads 4329 total (20 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-06-17 [all 1 reports]

Readme for crypto-multihash-0.1.0.0

[back to package description]

Crypto Multihash

Multihash library implemented on top of cryptonite cryptographic library. Multihash is a protocol for encoding the hash algorithm and digest length at the start of the digest, see the official multihash github page.

This library is still experimental and the api is not guaranteed stable. I will increment the version number appropriately in case of breaking changes.

For the moment the library implements all the expected hashing algorithms with the exception of shake-128 and shake-256. A Multihash can be encoded in hex (Base16), bitcoin base58 (Base58) and base64 (Base64).

The Base32 encoding is not yet supported due to discrepancy between the encoding from Data.ByteArray.Encoding and the one appearing in the official multihash page.

Usage

{-# LANGUAGE OverloadedStrings #-}

import Crypto.Multihash
import Data.ByteString (ByteString)

main = do
    let m = multihash SHA256 ("test"::ByteString)
    putStrLn $ "Base16: " ++ (encode Base16 m)
    putStrLn $ "Base58: " ++ (encode Base58 m)
    putStrLn $ "Base64: " ++ (encode Base64 m)

Test

Some preliminary tests can be performed with stack test. A simple example encoder is in app/Main.hs. You can run it on files (e.g. echo -n test | stack exec mh -- somefile someotherfile) or read data from the standard input (e.g. echo -n test | stack exec mh -- -)

TODO

  • Implement hash checker that takes some data and an encoded multihash and check that the multihash corresponds to the data (inferring automatically the appropriate hash function)
  • Evaluate if throwing an error in the encode function is the wanted behaviour and anyway implement a safe version returning an Either type
  • Implement shake-128 and shake-256 multihashes
  • Implement Base32 encoding