README.md (3296B)
1 # base58 2 3 [](https://hackage.haskell.org/package/ppad-base58) 4  5 [](https://docs.ppad.tech/base58) 6 7 A pure Haskell implementation of base58 and base58check encoding & 8 decoding on strict ByteStrings. 9 10 ## Usage 11 12 A sample GHCi session: 13 14 ``` 15 > :set -XOverloadedStrings 16 > 17 > -- import qualified 18 > import qualified Data.ByteString.Base58 as B58 19 > import qualified Data.ByteString.Base58Check as B58Check 20 > 21 > -- simple base58 encoding and decoding 22 > let b58 = B58.encode "hello world" 23 > b58 24 "StV1DL6CwTryKyV" 25 > 26 > B58.decode b58 27 Just "hello world" 28 > 29 > -- base58check is a versioned, checksummed format 30 > let b58check = B58Check.encode "\NULhello world" -- 0x00 version byte 31 > b58check 32 "13vQB7B6MrGQZaxCqW9KER" 33 > 34 > B58Check.decode b58check 35 Just "\NULhello world" 36 ``` 37 38 ## Documentation 39 40 Haddocks (API documentation, etc.) are hosted at 41 [docs.ppad.tech/base58](https://docs.ppad.tech/base58). 42 43 ## Performance 44 45 The aim is best-in-class performance for pure, highly-auditable Haskell 46 code. 47 48 Current benchmark figures on a M4 Silicon MacBook Air look like (use 49 `cabal bench` to run the benchmark suite): 50 51 ``` 52 benchmarking ppad-base58/base58/encode/hello world 53 time 356.9 ns (355.7 ns .. 359.2 ns) 54 1.000 R² (1.000 R² .. 1.000 R²) 55 mean 357.4 ns (356.7 ns .. 359.4 ns) 56 std dev 3.439 ns (1.609 ns .. 6.911 ns) 57 58 benchmarking ppad-base58/base58/decode/StV1DL6CwTryKyV 59 time 397.7 ns (397.2 ns .. 398.1 ns) 60 1.000 R² (1.000 R² .. 1.000 R²) 61 mean 397.3 ns (397.1 ns .. 397.6 ns) 62 std dev 942.3 ps (752.8 ps .. 1.232 ns) 63 64 benchmarking ppad-base58/base58check/encode/0x00, hello world 65 time 2.430 μs (2.428 μs .. 2.431 μs) 66 1.000 R² (1.000 R² .. 1.000 R²) 67 mean 2.433 μs (2.432 μs .. 2.434 μs) 68 std dev 4.715 ns (3.868 ns .. 5.971 ns) 69 70 benchmarking ppad-base58/base58check/decode/13vQB7B6MrGQZaxCqW9KER 71 time 2.500 μs (2.497 μs .. 2.504 μs) 72 1.000 R² (1.000 R² .. 1.000 R²) 73 mean 2.506 μs (2.503 μs .. 2.510 μs) 74 std dev 9.919 ns (7.444 ns .. 14.66 ns) 75 ``` 76 77 ## Security 78 79 This library aims at the maximum security achievable in a 80 garbage-collected language under an optimizing compiler such as GHC, in 81 which strict constant-timeness can be challenging to achieve. 82 83 If you discover any vulnerabilities, please disclose them via 84 security@ppad.tech. 85 86 ## Development 87 88 You'll require [Nix][nixos] with [flake][flake] support enabled. Enter a 89 development shell with: 90 91 ``` 92 $ nix develop 93 ``` 94 95 Then do e.g.: 96 97 ``` 98 $ cabal repl ppad-base58 99 ``` 100 101 to get a REPL for the main library. 102 103 ## Attribution 104 105 The vectors used in the test suite for both base58 106 and base58check are verbatim from paulmillr's 107 [scure-base](https://github.com/paulmillr/scure-base) library. 108 109 [nixos]: https://nixos.org/ 110 [flake]: https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html