base58

Pure Haskell base58, base58check encoding/decoding (docs.ppad.tech/base58).
git clone git://git.ppad.tech/base58.git
Log | Files | Refs | README | LICENSE

commit efbdc8459547f08304d8ff75c223dfe9bb44c227
parent 94e9e1ea968a43ec7f1e0f7e85bd9d7a7efc6164
Author: Jared Tobin <jared@jtobin.io>
Date:   Fri, 27 Dec 2024 19:45:12 -0330

lib: group related stuff

Diffstat:
Mlib/Data/ByteString/Base58.hs | 18+++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/Data/ByteString/Base58.hs b/lib/Data/ByteString/Base58.hs @@ -75,6 +75,15 @@ leading_zeros = go mempty where | h == 0x31 -> go (BS.cons 0x00 acc) t | otherwise -> acc +-- to base256 +unroll_base256 :: Integer -> BS.ByteString +unroll_base256 = BS.reverse . BS.unfoldr coalg where + coalg a + | a == 0 = Nothing + | otherwise = Just $ + let (b, c) = quotRem a 256 + in (fi c, b) + -- from base256 roll_base256 :: BS.ByteString -> Integer roll_base256 = BS.foldl' alg 0 where @@ -97,12 +106,3 @@ roll_base58 bs = BS.foldl' alg 0 bs where Nothing -> error "ppad-base58 (roll_base58): not a base58-encoded bytestring" --- to base256 -unroll_base256 :: Integer -> BS.ByteString -unroll_base256 = BS.reverse . BS.unfoldr coalg where - coalg a - | a == 0 = Nothing - | otherwise = Just $ - let (b, c) = quotRem a 256 - in (fi c, b) -