{-# LANGUAGE TypeOperators #-}

module ZkFold.Symbolic.Algorithms.Hash.Blake2b.Constants ( blake2b_iv, sigma ) where

import           GHC.IsList                      (IsList (..))
import           Numeric.Natural                 (Natural)
import           Prelude                         (Int, map, type (~), ($), (<$>))

import           ZkFold.Base.Algebra.Basic.Class (FromConstant (..))

-- | Initialization Vector (same as for SHA-512)
blake2b_iv :: (FromConstant Natural x, IsList (v x), Item (v x) ~ x) => v x
blake2b_iv :: forall x (v :: Type -> Type).
(FromConstant Natural x, IsList (v x), Item (v x) ~ x) =>
v x
blake2b_iv = [Item (v x)] -> v x
forall l. IsList l => [Item l] -> l
fromList ([Item (v x)] -> v x) -> [Item (v x)] -> v x
forall a b. (a -> b) -> a -> b
$ forall a b. FromConstant a b => a -> b
fromConstant @Natural (Natural -> x) -> [Natural] -> [x]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$>
    [ Natural
0x6a09e667f3bcc908, Natural
0xbb67ae8584caa73b, Natural
0x3c6ef372fe94f82b, Natural
0xa54ff53a5f1d36f1,
      Natural
0x510e527fade682d1, Natural
0x9b05688c2b3e6c1f, Natural
0x1f83d9abfb41bd6b, Natural
0x5be0cd19137e2179 ]

sigma :: forall v .
       ( IsList (v Int)
       , IsList (v (v Int))
       , Item (v Int) ~ Int
       , Item (v (v Int)) ~ v Int
       ) => v (v Int)
sigma :: forall (v :: Type -> Type).
(IsList (v Int), IsList (v (v Int)), Item (v Int) ~ Int,
 Item (v (v Int)) ~ v Int) =>
v (v Int)
sigma = [Item (v (v Int))] -> v (v Int)
forall l. IsList l => [Item l] -> l
fromList ([Item (v (v Int))] -> v (v Int))
-> [Item (v (v Int))] -> v (v Int)
forall a b. (a -> b) -> a -> b
$ ([Int] -> v Int) -> [[Int]] -> [v Int]
forall a b. (a -> b) -> [a] -> [b]
map [Int] -> v Int
[Item (v Int)] -> v Int
forall l. IsList l => [Item l] -> l
fromList [
           [ Int
0, Int
1, Int
2, Int
3, Int
4, Int
5, Int
6, Int
7, Int
8, Int
9, Int
10, Int
11, Int
12, Int
13, Int
14, Int
15 ],
           [ Int
14, Int
10, Int
4, Int
8, Int
9, Int
15, Int
13, Int
6, Int
1, Int
12, Int
0, Int
2, Int
11, Int
7, Int
5, Int
3 ],
           [ Int
11, Int
8, Int
12, Int
0, Int
5, Int
2, Int
15, Int
13, Int
10, Int
14, Int
3, Int
6, Int
7, Int
1, Int
9, Int
4 ],
           [ Int
7, Int
9, Int
3, Int
1, Int
13, Int
12, Int
11, Int
14, Int
2, Int
6, Int
5, Int
10, Int
4, Int
0, Int
15, Int
8 ],
           [ Int
9, Int
0, Int
5, Int
7, Int
2, Int
4, Int
10, Int
15, Int
14, Int
1, Int
11, Int
12, Int
6, Int
8, Int
3, Int
13 ],
           [ Int
2, Int
12, Int
6, Int
10, Int
0, Int
11, Int
8, Int
3, Int
4, Int
13, Int
7, Int
5, Int
15, Int
14, Int
1, Int
9 ],
           [ Int
12, Int
5, Int
1, Int
15, Int
14, Int
13, Int
4, Int
10, Int
0, Int
7, Int
6, Int
3, Int
9, Int
2, Int
8, Int
11 ],
           [ Int
13, Int
11, Int
7, Int
14, Int
12, Int
1, Int
3, Int
9, Int
5, Int
0, Int
15, Int
4, Int
8, Int
6, Int
2, Int
10 ],
           [ Int
6, Int
15, Int
14, Int
9, Int
11, Int
3, Int
0, Int
8, Int
12, Int
2, Int
13, Int
7, Int
1, Int
4, Int
10, Int
5 ],
           [ Int
10, Int
2, Int
8, Int
4, Int
7, Int
6, Int
1, Int
5, Int
15, Int
11, Int
9, Int
14, Int
3, Int
12, Int
13, Int
0 ],
           [ Int
0, Int
1, Int
2, Int
3, Int
4, Int
5, Int
6, Int
7, Int
8, Int
9, Int
10, Int
11, Int
12, Int
13, Int
14, Int
15 ],
           [ Int
14, Int
10, Int
4, Int
8, Int
9, Int
15, Int
13, Int
6, Int
1, Int
12, Int
0, Int
2, Int
11, Int
7, Int
5, Int
3 ]
       ]