/ test / CircuitCommon.hs
CircuitCommon.hs
 1  
 2  module CircuitCommon
 3    ( module R1CS
 4    , module System.FilePath
 5    , circuitRootDir
 6    , circuitLibSourceDir
 7    , toBitsLE , toBitsLE'
 8    )
 9    where 
10  
11  --------------------------------------------------------------------------------
12  
13  import Data.Bits
14  import System.FilePath
15  import R1CS
16  
17  --------------------------------------------------------------------------------
18  
19  circuitRootDir :: FilePath
20  circuitRootDir = "../circuit"
21  
22  circuitLibSourceDir :: FilePath
23  circuitLibSourceDir = circuitRootDir </> "lib"
24  
25  --------------------------------------------------------------------------------
26  
27  toBitsLE :: Integer -> [Int]
28  toBitsLE = go where
29    go 0 = []
30    go n = fromInteger (n .&. 1) : go (shiftR n 1)
31  
32  toBitsLE' :: Int -> Integer -> [Int]
33  toBitsLE' n what = take n (toBitsLE what ++ repeat 0)
34  
35  --------------------------------------------------------------------------------