Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype ByteString (n :: Natural) a = ByteString [a]
- class ShiftBits a where
- shiftBits :: a -> Integer -> a
- shiftBitsL :: a -> Natural -> a
- shiftBitsR :: a -> Natural -> a
- rotateBits :: a -> Integer -> a
- rotateBitsL :: a -> Natural -> a
- rotateBitsR :: a -> Natural -> a
- class ToWords a b where
- toWords :: a -> [b]
- class Concat a b where
- concat :: [a] -> b
- class Truncate a b where
- truncate :: a -> b
Documentation
newtype ByteString (n :: Natural) a Source #
A ByteString which stores n
bits and uses elements of a
as registers, one element per register.
Bit layout is Big-endian.
ByteString [a] |
Instances
class ShiftBits a where Source #
A class for data types that support bit shift and bit cyclic shift (rotation) operations.
(shiftBits | shiftBitsL, shiftBitsR), (rotateBits | rotateBitsL, rotateBitsR)
shiftBits :: a -> Integer -> a Source #
shiftBits performs a left shift when its agrument is greater than zero and a right shift otherwise.
shiftBitsL :: a -> Natural -> a Source #
shiftBitsR :: a -> Natural -> a Source #
rotateBits :: a -> Integer -> a Source #
rotateBits performs a left cyclic shift when its agrument is greater than zero and a right cyclic shift otherwise.
rotateBitsL :: a -> Natural -> a Source #
rotateBitsR :: a -> Natural -> a Source #
Instances
class ToWords a b where Source #
Describes types which can be split into words of equal size. Parameters have to be of different types as ByteString store their lengths on type level and hence after splitting they chagne types.
Instances
(KnownNat n, FromConstant Natural a) => ToWords Natural (ByteString n a) Source # | This allows us to calculate hash of a bytestring represented by a Natural number. This is only useful for testing when the length of the test string is unknown at compile time. This should not be exposed to users (and they probably won't find it useful anyway). |
Defined in ZkFold.Symbolic.Algorithms.Hash.SHA2 toWords :: Natural -> [ByteString n a] Source # | |
(KnownNat wordSize, KnownNat n, Finite (Zp p), wordSize <= n, 1 <= wordSize, 1 <= n, Mod n wordSize ~ 0) => ToWords (ByteString n (Zp p)) (ByteString wordSize (Zp p)) Source # | A ByteString of length |
Defined in ZkFold.Symbolic.Data.ByteString toWords :: ByteString n (Zp p) -> [ByteString wordSize (Zp p)] Source # | |
(KnownNat wordSize, 1 <= wordSize, 1 <= n, Mod n wordSize ~ 0) => ToWords (ByteString n (ArithmeticCircuit a)) (ByteString wordSize (ArithmeticCircuit a)) Source # | |
Defined in ZkFold.Symbolic.Data.ByteString toWords :: ByteString n (ArithmeticCircuit a) -> [ByteString wordSize (ArithmeticCircuit a)] Source # |
class Concat a b where Source #
Describes types which can be made by concatenating several words of equal length.
Instances
(KnownNat n, KnownNat m, m <= n, Mod n m ~ 0, Finite (Zp p)) => Concat (ByteString m (Zp p)) (ByteString n (Zp p)) Source # | Unfortunately, Haskell does not support dependent types yet,
so we have no possibility to infer the exact type of the result
(the list can contain an arbitrary number of words).
We can only impose some restrictions on |
Defined in ZkFold.Symbolic.Data.ByteString concat :: [ByteString m (Zp p)] -> ByteString n (Zp p) Source # | |
Mod n m ~ 0 => Concat (ByteString m (ArithmeticCircuit a)) (ByteString n (ArithmeticCircuit a)) Source # | |
Defined in ZkFold.Symbolic.Data.ByteString concat :: [ByteString m (ArithmeticCircuit a)] -> ByteString n (ArithmeticCircuit a) Source # |
class Truncate a b where Source #
Describes types that can be truncated by dropping several bits from the end (i.e. stored in the lower registers)
Instances
(KnownNat m, KnownNat n, n <= m, Finite (Zp p)) => Truncate (ByteString m (Zp p)) (ByteString n (Zp p)) Source # | Only a bigger ByteString can be truncated into a smaller one. |
Defined in ZkFold.Symbolic.Data.ByteString truncate :: ByteString m (Zp p) -> ByteString n (Zp p) Source # | |
(KnownNat n, n <= m) => Truncate (ByteString m (ArithmeticCircuit a)) (ByteString n (ArithmeticCircuit a)) Source # | |
Defined in ZkFold.Symbolic.Data.ByteString truncate :: ByteString m (ArithmeticCircuit a) -> ByteString n (ArithmeticCircuit a) Source # |