Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- class Empty a
- class SignableRepresentation a where
- getSignableRepresentation :: a -> ByteString
- getRandomWord64 :: MonadRandom m => m Word64
- readBinaryWord64 :: ByteString -> Word64
- writeBinaryWord64 :: Word64 -> ByteString
- readBinaryNatural :: ByteString -> Natural
- writeBinaryNatural :: Int -> Natural -> ByteString
- splitsAt :: [Int] -> ByteString -> [ByteString]
- bytesToNatural :: ByteString -> Natural
- naturalToBytes :: Int -> Natural -> ByteString
- slice :: Word -> Word -> ByteString -> ByteString
- decodeHexByteString :: ByteString -> Int -> Either String ByteString
- decodeHexString :: String -> Int -> Either String ByteString
- decodeHexStringQ :: String -> Int -> Q Exp
Documentation
class SignableRepresentation a where Source #
A class of types that have a representation in bytes that can be used for signing and verifying.
getSignableRepresentation :: a -> ByteString Source #
Instances
getRandomWord64 :: MonadRandom m => m Word64 Source #
Simple serialisation used in mock instances
readBinaryWord64 :: ByteString -> Word64 Source #
writeBinaryWord64 :: Word64 -> ByteString Source #
writeBinaryNatural :: Int -> Natural -> ByteString Source #
splitsAt :: [Int] -> ByteString -> [ByteString] Source #
Low level conversions
bytesToNatural :: ByteString -> Natural Source #
Create a Natural
out of a ByteString
, in big endian.
This is fast enough to use in production.
naturalToBytes :: Int -> Natural -> ByteString Source #
The inverse of bytesToNatural
. Note that this is a naive implementation
and only suitable for tests.
ByteString manipulation
slice :: Word -> Word -> ByteString -> ByteString Source #
Base16 conversion
decodeHexByteString :: ByteString -> Int -> Either String ByteString Source #
Decode base16 ByteString, while ensuring expected length.
decodeHexString :: String -> Int -> Either String ByteString Source #
Decode base16 String, while ensuring expected length. Unlike
decodeHexByteString
this function expects a '0x' prefix.