diff --git a/CHANGES.md b/CHANGES.md
new file mode 100644
--- /dev/null
+++ b/CHANGES.md
@@ -0,0 +1,6 @@
+Changelog for lol-tests project
+================================
+
+0.0.0.1
+-----
+ * Initial commit: moved tests from package lol to lol-tests.
diff --git a/Crypto/Lol/Tests.hs b/Crypto/Lol/Tests.hs
new file mode 100644
--- /dev/null
+++ b/Crypto/Lol/Tests.hs
@@ -0,0 +1,71 @@
+{-|
+Module      : Crypto.Lol.Tests
+Description : Infrastructure for testing Lol.
+Copyright   : (c) Eric Crockett, 2011-2017
+                  Chris Peikert, 2011-2017
+License     : GPL-2
+Maintainer  : ecrockett0@email.com
+Stability   : experimental
+Portability : POSIX
+
+Infrastructure for testing Lol.
+-}
+
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE GADTs                 #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE PolyKinds             #-}
+{-# LANGUAGE RankNTypes            #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+module Crypto.Lol.Tests
+(test
+,testIO
+,TF.testGroup
+,nestGroup
+,testGroupM
+,genTestArgs
+,Test(..)) where
+
+import Crypto.Lol.Utils.GenArgs
+
+import qualified Test.Framework as TF
+import Test.Framework.Providers.QuickCheck2
+import Test.QuickCheck
+
+-- | Test a 'Bool' value.
+test :: Bool -> Test params
+test = Test
+
+-- | Test a monadic 'Bool' value.
+testIO :: IO Bool -> Test params
+testIO = TestIO
+
+-- | Apply parameters to a list of 'TF.Test'
+nestGroup :: String -> [proxy (a :: k) -> TF.Test] -> proxy a -> TF.Test
+nestGroup s ts p = TF.testGroup s $ map ($ p) ts
+
+-- | Wrapper around QuickCheck's 'TF.testGroup'
+testGroupM :: String -> [IO TF.Test] -> TF.Test
+testGroupM str = TF.buildTest . (TF.testGroup str <$>) . sequence
+
+-- | Converts a function mapping zero or more arguments to a 'Test' @a@
+-- by generating random inputs to the function
+genTestArgs :: (GenArgs bnch, ResultOf bnch ~ Test a)
+  => String -> bnch -> proxy a -> TF.Test
+genTestArgs s f _ = testProperty s $ ioProperty $ do
+  res <- genArgs f
+  case res of
+    Test b -> return b
+    TestIO b -> b
+
+-- | Wrapper for simple 'Testable' property, with phantom parameters.
+data Test params where
+  Test :: Bool -> Test params
+  TestIO :: IO Bool -> Test params
+
+instance (ResultOf (Test params) ~ Test params)
+  => GenArgs (Test params) where
+  genArgs = return
diff --git a/Crypto/Lol/Tests/CycTests.hs b/Crypto/Lol/Tests/CycTests.hs
new file mode 100644
--- /dev/null
+++ b/Crypto/Lol/Tests/CycTests.hs
@@ -0,0 +1,85 @@
+{-|
+Module      : Crypto.Lol.Tests.CycTests
+Description : Tests for the 'Cyc' interface.
+Copyright   : (c) Eric Crockett, 2011-2017
+                  Chris Peikert, 2011-2017
+License     : GPL-2
+Maintainer  : ecrockett0@email.com
+Stability   : experimental
+Portability : POSIX
+
+Tests for the 'Cyc' interface.
+-}
+
+{-# LANGUAGE DataKinds             #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE NoImplicitPrelude     #-}
+{-# LANGUAGE PartialTypeSignatures #-}
+{-# LANGUAGE PolyKinds             #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeOperators         #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+{-# OPTIONS_GHC -fno-warn-partial-type-signatures #-}
+
+module Crypto.Lol.Tests.CycTests where
+
+import Control.Applicative
+import Control.Monad (liftM2,join)
+
+import Crypto.Lol
+
+import Crypto.Lol.Utils.ShowType
+import Crypto.Lol.Tests
+
+import qualified Test.Framework as TF
+
+-- | Tests for single-index operations. There must be a CRT basis for \(O_m\) over @r@.
+cycTests1 :: forall t m r . _ => Proxy '(m,r) -> Proxy t -> TF.Test
+cycTests1 _ _ =
+  let ptmr = Proxy :: Proxy '(t,m,r)
+  in testGroup (showType ptmr) $ ($ ptmr) <$> [
+      genTestArgs "mulGPow" prop_mulgPow,
+      genTestArgs "mulGDec" prop_mulgDec,
+      genTestArgs "mulGCRT" prop_mulgCRT
+      ]
+
+-- | Tests for inter-ring operations. There must be a CRT basis for \(O_{m'}\) over @r@.
+cycTests2 :: forall t m m' r . _ => Proxy '(m,m',r) -> Proxy t -> TF.Test
+cycTests2 _ _ =
+  let ptmr = Proxy :: Proxy '(t,m,m',r)
+  in testGroup (showType ptmr) $ ($ ptmr) <$> [
+      genTestArgs "crtSet" prop_crtSet_pairs,
+      genTestArgs "coeffsPow" prop_coeffsBasis
+      ]
+
+prop_mulgPow :: _ => Cyc t m r -> Test '(t,m,r)
+prop_mulgPow x =
+  let y = advisePow x
+  in test $ y == (fromJust' "prop_mulgPow failed divisibility!" $ divG $ mulG y)
+
+prop_mulgDec :: _ => Cyc t m r -> Test '(t,m,r)
+prop_mulgDec x =
+  let y = adviseDec x
+  in test $ y == (fromJust' "prop_mulgDec failed divisibility!" $ divG $ mulG y)
+
+prop_mulgCRT :: _ => Cyc t m r -> Test '(t,m,r)
+prop_mulgCRT x =
+  let y = adviseCRT x
+  in test $ y == (fromJust' "prop_mulgCRT failed divisibility!" $ divG $ mulG y)
+
+prop_coeffsBasis :: forall t m m' r . _
+  => Cyc t m' r -> Test '(t,m,m',r)
+prop_coeffsBasis x =
+  let xs = map embed (coeffsCyc Pow x :: [Cyc t m r])
+      bs = proxy powBasis (Proxy::Proxy m)
+  in test $ (sum $ zipWith (*) xs bs) == x
+
+-- verifies that CRT set elements satisfy c_i * c_j = delta_ij * c_i
+-- necessary (but not sufficient) condition
+prop_crtSet_pairs :: forall t m m' r . (CElt t r, Fact m', _)
+  => Test '(t,m,m',r)
+prop_crtSet_pairs =
+  let crtset = proxy crtSet (Proxy::Proxy m) :: [Cyc t m' r]
+      pairs = join (liftM2 (,)) crtset
+  in test $ and $ map (\(a,b) -> if a == b then a*b == a else a*b == zero) pairs
diff --git a/Crypto/Lol/Tests/Standard.hs b/Crypto/Lol/Tests/Standard.hs
new file mode 100644
--- /dev/null
+++ b/Crypto/Lol/Tests/Standard.hs
@@ -0,0 +1,122 @@
+{-|
+Module      : Crypto.Lol.Tests.Standard
+Description : High-level tensor tests.
+Copyright   : (c) Eric Crockett, 2011-2017
+                  Chris Peikert, 2011-2017
+License     : GPL-2
+Maintainer  : ecrockett0@email.com
+Stability   : experimental
+Portability : POSIX
+
+High-level test groups and parameters,
+which can be used to verify a 'Tensor' implementation.
+-}
+
+{-# LANGUAGE DataKinds             #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE PartialTypeSignatures #-}
+{-# LANGUAGE PolyKinds             #-}
+{-# LANGUAGE TypeFamilies          #-}
+{-# LANGUAGE TypeOperators         #-}
+
+{-# OPTIONS_GHC -fno-warn-partial-type-signatures #-}
+
+module Crypto.Lol.Tests.Standard where
+
+import Crypto.Lol.Factored
+import Crypto.Lol.Tests.CycTests
+import Crypto.Lol.Tests.TensorTests
+import Crypto.Lol.Tests.ZqTests
+import Crypto.Lol.Types
+
+import Data.Int
+import Data.Proxy
+
+import Test.Framework
+
+infixr 9 **
+data a ** b
+
+defaultTestMain :: _ => Proxy t -> IO ()
+defaultTestMain =
+  flip defaultMainWithArgs
+    ["--threads=1","--maximum-generated-tests=100"] . defaultTests
+
+type family Zq (a :: k) :: * where
+  Zq (a ** b) = (Zq a, Zq b)
+  Zq q = (ZqBasic q Int64)
+
+-- | Default parameters for 'ZqBasic' tests
+zqTs :: Test
+zqTs = testGroup "Zq Tests" $ [
+  zqTests (Proxy::Proxy (Zq 3)),
+  zqTests (Proxy::Proxy (Zq 7)),
+  zqTests (Proxy::Proxy (Zq (3 ** 5))),
+  zqTests (Proxy::Proxy (Zq (3 ** 5 ** 7)))]
+
+-- | Default @m@/@r@ test parameters, for an arbitrary 'Tensor'.
+defaultTests :: _ => Proxy t -> [Test]
+defaultTests pt = [
+  testGroup "Tensor Tests" $ ($ pt) <$> [
+    tensorTests1 (Proxy::Proxy '(F7,  Zq 29)),
+    tensorTests1 (Proxy::Proxy '(F12, SmoothZQ1)),
+    tensorTests1 (Proxy::Proxy '(F1,  Zq 17)),
+    tensorTests1 (Proxy::Proxy '(F2,  Zq 17)),
+    tensorTests1 (Proxy::Proxy '(F4,  Zq 17)),
+    tensorTests1 (Proxy::Proxy '(F8,  Zq 17)),
+    tensorTests1 (Proxy::Proxy '(F21, Zq 8191)),
+    tensorTests1 (Proxy::Proxy '(F42, Zq 8191)),
+    tensorTests1 (Proxy::Proxy '(F42, ZQ1)),
+    tensorTests1 (Proxy::Proxy '(F2,  ZQ2)),
+    tensorTests1 (Proxy::Proxy '(F3,  ZQ2)),
+    tensorTests1 (Proxy::Proxy '(F7,  ZQ2)),
+    tensorTests1 (Proxy::Proxy '(F6,  ZQ2)),
+    tensorTests1 (Proxy::Proxy '(F42, SmoothZQ3)),
+    tensorTests1 (Proxy::Proxy '(F42, ZQ2)),
+    tensorTests1 (Proxy::Proxy '(F89, Zq 179)),
+
+    tensorTests2 (Proxy::Proxy '(F1, F7,  Zq 29)),
+    tensorTests2 (Proxy::Proxy '(F4, F12, Zq 536871001)),
+    tensorTests2 (Proxy::Proxy '(F4, F12, SmoothZQ1)),
+    tensorTests2 (Proxy::Proxy '(F2, F8,  Zq 17)),
+    tensorTests2 (Proxy::Proxy '(F8, F8,  Zq 17)),
+    tensorTests2 (Proxy::Proxy '(F2, F8,  SmoothZQ1)),
+    tensorTests2 (Proxy::Proxy '(F4, F8,  Zq 17)),
+    tensorTests2 (Proxy::Proxy '(F3, F21, Zq 8191)),
+    tensorTests2 (Proxy::Proxy '(F7, F21, Zq 8191)),
+    tensorTests2 (Proxy::Proxy '(F3, F42, Zq 8191)),
+    tensorTests2 (Proxy::Proxy '(F3, F21, ZQ1)),
+    tensorTests2 (Proxy::Proxy '(F7, F21, ZQ2)),
+    tensorTests2 (Proxy::Proxy '(F3, F42, ZQ3))],
+
+  testGroup "Cyc Tests" $ ($ pt) <$> [
+    cycTests1    (Proxy::Proxy '(F7,  Zq 29)),
+    cycTests1    (Proxy::Proxy '(F7,  Zq 32)),
+    cycTests1    (Proxy::Proxy '(F12, SmoothZQ1)),
+    cycTests1    (Proxy::Proxy '(F1,  Zq 17)),
+    cycTests1    (Proxy::Proxy '(F2,  Zq 17)),
+    cycTests1    (Proxy::Proxy '(F4,  Zq 17)),
+    cycTests1    (Proxy::Proxy '(F8,  Zq 17)),
+    cycTests1    (Proxy::Proxy '(F21, Zq 8191)),
+    cycTests1    (Proxy::Proxy '(F42, Zq 8191)),
+    cycTests1    (Proxy::Proxy '(F42, ZQ1)),
+    cycTests1    (Proxy::Proxy '(F42, Zq 1024)),
+    cycTests1    (Proxy::Proxy '(F42, ZQ2)),
+    cycTests1    (Proxy::Proxy '(F89, Zq 179)),
+
+    cycTests2    (Proxy::Proxy '(F1, F7, Zq PP8)),
+    cycTests2    (Proxy::Proxy '(F1, F7, Zq PP2))]]
+
+-- three 24-bit moduli, enough to handle rounding for p=32 (depth-4 circuit at ~17 bits per mul)
+type ZQ1 = Zq 18869761
+type ZQ2 = Zq (19393921 ** 18869761)
+type ZQ3 = Zq (19918081 ** 19393921 ** 18869761)
+
+-- the next three moduli are "good" for any index dividing 128*27*25*7
+type SmoothQ1 = 2148249601
+type SmoothQ2 = 2148854401
+type SmoothQ3 = 2150668801
+
+type SmoothZQ1 = Zq 2148249601
+type SmoothZQ2 = Zq (2148854401 ** 2148249601)
+type SmoothZQ3 = Zq (2148854401 ** 2148249601 ** 2150668801)
diff --git a/Crypto/Lol/Tests/TensorTests.hs b/Crypto/Lol/Tests/TensorTests.hs
new file mode 100644
--- /dev/null
+++ b/Crypto/Lol/Tests/TensorTests.hs
@@ -0,0 +1,274 @@
+{-|
+Module      : Crypto.Lol.Tests.TensorTests
+Description : Tests for the 'Tensor' interface.
+Copyright   : (c) Eric Crockett, 2011-2017
+                  Chris Peikert, 2011-2017
+License     : GPL-2
+Maintainer  : ecrockett0@email.com
+Stability   : experimental
+Portability : POSIX
+
+Tests for the 'Tensor' interface.
+-}
+
+{-# LANGUAGE ConstraintKinds       #-}
+{-# LANGUAGE DataKinds             #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE PartialTypeSignatures #-}
+{-# LANGUAGE RebindableSyntax      #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+{-# LANGUAGE TypeOperators         #-}
+{-# LANGUAGE UndecidableInstances  #-}
+
+{-# OPTIONS_GHC -fno-warn-partial-type-signatures #-}
+
+module Crypto.Lol.Tests.TensorTests where
+
+import Crypto.Lol.Tests
+import Crypto.Lol.Utils.ShowType
+
+import Crypto.Lol
+import Crypto.Lol.Cyclotomic.Tensor
+
+import Control.Applicative
+
+import Data.Maybe
+
+import qualified Test.Framework as TF
+
+--testGroupM "GSqNormDec"       $ applyLift (Proxy::Proxy NormParams) $ genTestArgs prop_gsqnorm,
+
+-- | Tests for single-index operations. There must be a CRT basis for \(O_m\) over @r@.
+tensorTests1 :: forall t m r . _ => Proxy '(m,r) -> Proxy t -> TF.Test
+tensorTests1 _ _ =
+  let ptmr = Proxy :: Proxy '(t,m,r)
+  in testGroup (showType ptmr) $ ($ ptmr) <$> [
+      genTestArgs   "fmapT comparison" prop_fmapT,
+      genTestArgs   "fmap comparison"  prop_fmap,
+      nestGroup  "GInv.G == id" [
+        genTestArgs "Pow basis"        prop_ginv_pow,
+        genTestArgs "Dec basis"        prop_ginv_dec,
+        genTestArgs "CRT basis"        prop_ginv_crt],
+      genTestArgs   "CRTInv.CRT == id" prop_crt_inv,
+      genTestArgs   "LInv.L == id"     prop_l_inv,
+      genTestArgs   "Scalar"           prop_scalar_crt,
+      nestGroup  "G commutes with L" [
+        genTestArgs "Dec basis"        prop_g_dec,
+        genTestArgs "CRT basis"        prop_g_crt],
+      genTestArgs "Tw and Em ID for equal indices" prop_twEmID
+      ]
+
+-- | Tests for inter-ring operations. There must be a CRT basis for \(O_{m'}\) over @r@.
+tensorTests2 :: forall t m m' r . _ => Proxy '(m,m',r) -> Proxy t -> TF.Test
+tensorTests2 _ _ =
+  let ptmr = Proxy :: Proxy '(t,m,m',r)
+  in testGroup (showType ptmr) $ ($ ptmr) <$> [
+      nestGroup  "Tw.Em == id" [
+        genTestArgs "Pow basis"                      prop_trem_pow,
+        genTestArgs "Dec basis"                      prop_trem_dec,
+        genTestArgs "CRT basis"                      prop_trem_crt],
+      nestGroup  "Em commutes with L" [
+        genTestArgs "Dec basis"                      prop_embed_dec,
+        genTestArgs "CRT basis"                      prop_embed_crt],
+      nestGroup  "Tw commutes with L" [
+        genTestArgs "Dec basis"                      prop_twace_dec,
+        genTestArgs "CRT basis"                      prop_twace_crt],
+      nestGroup  "Twace invariants" [
+        genTestArgs "Invar1 Pow basis"               prop_twace_invar1_pow,
+        genTestArgs "Invar1 Dec basis"               prop_twace_invar1_dec,
+        genTestArgs "Invar1 CRT basis"               prop_twace_invar1_crt,
+        genTestArgs "Invar2 Pow/Dec basis"           prop_twace_invar2_powdec,
+        genTestArgs "Invar2 CRT basis"               prop_twace_invar2_crt]
+      ]
+
+prop_fmapT :: _ => t m r -> Test '(t,m,r)
+prop_fmapT x = test $ fmapT id x == x \\ witness entailEqT x \\ witness entailIndexT x
+
+prop_fmap :: _ => t m r -> Test '(t,m,r)
+prop_fmap x = test $ (fmap id x) == x \\ witness entailEqT x \\ witness entailIndexT x
+
+-- divG . mulG == id in Pow basis
+prop_ginv_pow :: _ => t m r -> Test '(t,m,r)
+prop_ginv_pow x = test $ (fromMaybe (error "could not divide by G in prop_ginv_pow") $
+  divGPow $ mulGPow x) == x \\ witness entailEqT x
+
+-- divG . mulG == id in Dec basis
+prop_ginv_dec :: _ => t m r -> Test '(t,m,r)
+prop_ginv_dec x = test $ (fromMaybe (error "could not divide by G in prop_ginv_dec") $
+  divGDec $ mulGDec x) == x \\ witness entailEqT x
+
+-- divG . mulG == id in CRT basis
+prop_ginv_crt :: _ => t m r -> Test '(t,m,r)
+prop_ginv_crt x = test $ fromMaybe (error "no CRT in prop_ginv_crt") $ do
+  divGCRT' <- divGCRT
+  mulGCRT' <- mulGCRT
+  return $ (divGCRT' $ mulGCRT' x) == x \\ witness entailEqT x
+
+-- mulGDec == lInv. mulGPow . l
+prop_g_dec :: _ => t m r -> Test '(t,m,r)
+prop_g_dec x = test $ (mulGDec x) == (lInv $ mulGPow $ l x) \\ witness entailEqT x
+
+prop_g_crt :: _ => t m r -> Test '(t,m,r)
+prop_g_crt x = test $ fromMaybe (error "no CRT in prop_g_crt") $ do
+  mulGCRT' <- mulGCRT
+  crt' <- crt
+  crtInv' <- crtInv
+  return $ (mulGCRT' x) == (crt' $ mulGPow $ crtInv' x) \\ witness entailEqT x
+
+-- crtInv . crt == id
+prop_crt_inv :: _ => t m r -> Test '(t,m,r)
+prop_crt_inv x = test $ fromMaybe (error "no CRT in prop_crt_inv") $ do
+  crt' <- crt
+  crtInv' <- crtInv
+  return $ (crtInv' $ crt' x) == x \\ witness entailEqT x
+
+-- lInv . l == id
+prop_l_inv :: _ => t m r -> Test '(t,m,r)
+prop_l_inv x = test $ (lInv $ l x) == x \\ witness entailEqT x
+
+-- scalarCRT = crt . scalarPow
+prop_scalar_crt :: forall t m r . (Tensor t, Fact m, _) => r -> Test '(t,m,r)
+prop_scalar_crt r = test $ fromMaybe (error "no CRT in prop_scalar_crt") $ do
+  scalarCRT' <- scalarCRT
+  crt' <- crt
+  return $ (scalarCRT' r :: t m r) == (crt' $ scalarPow r)
+  \\ proxy entailEqT (Proxy::Proxy (t m r))
+
+-- tests that twace . embed == id in the Pow basis
+prop_trem_pow :: forall t m m' r . (Fact m, Fact m', _) => t m r -> Test '(t,m,m',r)
+prop_trem_pow x = test $ (twacePowDec $ (embedPow x :: t m' r)) == x \\ witness entailEqT x
+
+-- tests that twace . embed == id in the Dec basis
+prop_trem_dec :: forall t m m' r . (Fact m, Fact m', _) => t m r -> Test '(t,m,m',r)
+prop_trem_dec x = test $ (twacePowDec $ (embedDec x :: t m' r)) == x \\ witness entailEqT x
+
+-- tests that twace . embed == id in the CRT basis
+prop_trem_crt :: forall t m m' r . (Fact m, Fact m', _) => t m r -> Test '(t,m,m',r)
+prop_trem_crt x = test $ fromMaybe (error "no CRT in prop_trem_crt") $
+  (x==) <$> (twaceCRT <*> (embedCRT <*> pure x :: Maybe (t m' r))) \\ witness entailEqT x
+
+-- embedDec == lInv . embedPow . l
+prop_embed_dec :: forall t m m' r . (Fact m, Fact m', _) => t m r -> Test '(t,m,m',r)
+prop_embed_dec x = test $ (embedDec x :: t m' r) == (lInv $ embedPow $ l x)
+  \\ proxy entailEqT (Proxy::Proxy (t m' r))
+
+-- embedCRT = crt . embedPow . crtInv
+prop_embed_crt :: forall t m m' r . (Fact m, Fact m', _) => t m r -> Test '(t,m,m',r)
+prop_embed_crt x = test $ fromMaybe (error "no CRT in prop_embed_crt") $ do
+  crt' <- crt
+  crtInv' <- crtInv
+  embedCRT' <- embedCRT
+  return $ (embedCRT' x :: t m' r) == (crt' $ embedPow $ crtInv' x)
+    \\ proxy entailEqT (Proxy::Proxy (t m' r))
+
+-- twacePowDec = lInv . twacePowDec . l
+prop_twace_dec :: forall t m m' r . (Fact m, Fact m', _) => t m' r -> Test '(t,m,m',r)
+prop_twace_dec x = test $ (twacePowDec x :: t m r) == (lInv $ twacePowDec $ l x)
+  \\ proxy entailEqT (Proxy::Proxy (t m r))
+
+-- twaceCRT = crt . twacePowDec . crtInv
+prop_twace_crt :: forall t m m' r . (Fact m, Fact m', _) => t m' r -> Test '(t,m,m',r)
+prop_twace_crt x = test $ fromMaybe (error "no CRT in prop_trace_crt") $ do
+  twaceCRT' <- twaceCRT
+  crt' <- crt
+  crtInv' <- crtInv
+  return $ (twaceCRT' x :: t m r) == (crt' $ twacePowDec $ crtInv' x)
+    \\ proxy entailEqT (Proxy::Proxy (t m r))
+
+prop_twEmID :: forall t m r . _ => t m r -> Test '(t,m,r)
+prop_twEmID x = test $
+  ((twacePowDec x) == x) &&
+  (((fromMaybe (error "twemid_crt") twaceCRT) x) == x) &&
+  ((embedPow x) == x) &&
+  ((embedDec x) == x) &&
+  (((fromMaybe (error "twemid_crt") embedCRT) x) == x) \\ witness entailEqT x
+
+-- twace mhat'/g' = mhat*totm'/totm/g (Pow basis)
+prop_twace_invar1_pow :: forall t m m' r . _ => Test '(t,m,m',r)
+prop_twace_invar1_pow = test $ fromMaybe (error "could not divide by G in prop_twace_invar1_pow") $ do
+  let mhat = proxy valueHatFact (Proxy::Proxy m)
+      mhat' = proxy valueHatFact (Proxy::Proxy m')
+      totm = proxy totientFact (Proxy::Proxy m)
+      totm' = proxy totientFact (Proxy::Proxy m')
+  output :: t m r <- divGPow $ scalarPow $ fromIntegral $ mhat * totm' `div` totm
+  input :: t m' r <- divGPow $ scalarPow $ fromIntegral mhat'
+  return $ (twacePowDec input) == output \\ proxy entailEqT (Proxy::Proxy (t m r))
+
+-- twace mhat'/g' = mhat*totm'/totm/g (Dec basis)
+prop_twace_invar1_dec :: forall t m m' r . _ => Test '(t,m,m',r)
+prop_twace_invar1_dec = test $ fromMaybe (error "could not divide by G in prop_twace_invar1_dec") $ do
+  let mhat = proxy valueHatFact (Proxy::Proxy m)
+      mhat' = proxy valueHatFact (Proxy::Proxy m')
+      totm = proxy totientFact (Proxy::Proxy m)
+      totm' = proxy totientFact (Proxy::Proxy m')
+  output :: t m r <- divGDec $ lInv $ scalarPow $ fromIntegral $ mhat * totm' `div` totm
+  input :: t m' r <- divGDec $ lInv $ scalarPow $ fromIntegral mhat'
+  return $ (twacePowDec input) == output \\ proxy entailEqT (Proxy::Proxy (t m r))
+
+-- twace mhat'/g' = mhat*totm'/totm/g (CRT basis)
+prop_twace_invar1_crt :: forall t m m' r . _ => Test '(t,m,m',r)
+prop_twace_invar1_crt = test $ fromMaybe (error "no CRT in prop_twace_invar1_crt") $ do
+  let mhat = proxy valueHatFact (Proxy::Proxy m)
+      mhat' = proxy valueHatFact (Proxy::Proxy m')
+      totm = proxy totientFact (Proxy::Proxy m)
+      totm' = proxy totientFact (Proxy::Proxy m')
+  scalarCRT1 <- scalarCRT
+  scalarCRT2 <- scalarCRT
+  divGCRT1 <- divGCRT
+  divGCRT2 <- divGCRT
+  twaceCRT' <- twaceCRT
+  let output :: t m r = divGCRT1 $ scalarCRT1 $ fromIntegral $ mhat * totm' `div` totm
+      input :: t m' r = divGCRT2 $ scalarCRT2 $ fromIntegral mhat'
+  return $ (twaceCRT' input) == output \\ proxy entailEqT (Proxy::Proxy (t m r))
+
+-- twace preserves scalars in Pow/Dec basis
+prop_twace_invar2_powdec :: forall t m m' r . (Tensor t, Fact m, Fact m', Ring r, _) => Test '(t,m,m',r)
+prop_twace_invar2_powdec = test $
+  let output = scalarPow $ one :: t m r
+      input = scalarPow $ one :: t m' r
+  in (twacePowDec input) == output \\ proxy entailEqT (Proxy::Proxy (t m r))
+
+-- twace preserves scalars in Pow/Dec basis
+prop_twace_invar2_crt :: forall t m m' r . (Tensor t, Fact m, Fact m', Ring r, _) => Test '(t,m,m',r)
+prop_twace_invar2_crt = test $ fromMaybe (error "no CRT in prop_twace_invar2_crt") $ do
+  scalarCRT1 <- scalarCRT
+  scalarCRT2 <- scalarCRT
+  let input = scalarCRT1 one :: t m' r
+      output = scalarCRT2 one :: t m r
+  return $ (twacePowDec input) == output \\ proxy entailEqT (Proxy::Proxy (t m r))
+
+{-
+-- tests that gSqNormDec of two "random-looking" vectors agrees for RT and CT
+-- t is a dummy param
+prop_gsqnorm :: forall (t :: Factored -> * -> *) m r . _ => r -> Test '(t,m,r)
+prop_gsqnorm x = test $
+  let crtCT = fromJust crt
+      crtRT = fromJust crt
+      -- not mathematically meaningful, we just need some "random" coefficients
+      ct = fmapT lift (mulGDec $ lInv $ crtCT $ scalarPow x :: CT m r)
+      rt = fmapT lift (mulGDec $ lInv $ crtRT $ scalarPow x :: RT m r)
+  in gSqNormDec ct == gSqNormDec rt
+
+-- we can't include a large modulus here because there is not enough
+-- precision in Doubles to handle the error
+{-type MRExtCombos = '[
+  '(F7, Zq 29),
+  '(F1, Zq 17),
+  '(F2, Zq 17),
+  '(F4, Zq 17),
+  '(F8, Zq 17),
+  '(F21, Zq 8191),
+  '(F42, Zq 8191),
+  '(F42, ZQ1),
+  '(F42, ZQ2),
+  '(F89, Zq 179)
+  ]-}
+
+type MM'RCombos = '[
+
+--type ExtParams = ( '(,) <$> Tensors) <*> MRExtCombos
+
+type NormParams = ( '(,) <$> '[RT]) <*> (Filter Liftable MRCombos)
+
+-}
diff --git a/Crypto/Lol/Tests/ZqTests.hs b/Crypto/Lol/Tests/ZqTests.hs
new file mode 100644
--- /dev/null
+++ b/Crypto/Lol/Tests/ZqTests.hs
@@ -0,0 +1,94 @@
+{-|
+Module      : Crypto.Lol.Tests.ZqTests
+Description : Tests for modular arithmetic.
+Copyright   : (c) Eric Crockett, 2011-2017
+                  Chris Peikert, 2011-2017
+License     : GPL-2
+Maintainer  : ecrockett0@email.com
+Stability   : experimental
+Portability : POSIX
+
+Tests for modular arithmetic.
+-}
+
+{-# LANGUAGE DataKinds             #-}
+{-# LANGUAGE GADTs                 #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE NoImplicitPrelude     #-}
+{-# LANGUAGE PartialTypeSignatures #-}
+{-# LANGUAGE RebindableSyntax      #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeOperators         #-}
+{-# LANGUAGE UndecidableInstances  #-}
+
+{-# OPTIONS_GHC -fno-warn-partial-type-signatures #-}
+
+module Crypto.Lol.Tests.ZqTests where
+
+import Crypto.Lol
+import Crypto.Lol.CRTrans
+import Crypto.Lol.Tests
+import Crypto.Lol.Utils.ShowType
+
+import Control.Applicative
+import Control.Monad.Random
+
+import qualified Test.Framework as TF
+
+-- | Tests for 'ZqBasic'
+zqTests :: _ => Proxy r -> TF.Test
+zqTests p = testGroup (showType p) $ ($ p) <$> [
+  genTestArgs "(+)" prop_add,
+  genTestArgs "(*)" prop_mul,
+  genTestArgs "^-1" prop_recip,
+  genTestArgs "extension ring (*)" prop_mul_ext
+  ]
+
+prop_add :: forall r . (Ring r, Eq r) => LiftedMod r -> LiftedMod r -> Test r
+prop_add (LMod x) (LMod y) = test $ fromIntegral (x + y) == (fromIntegral x + fromIntegral y :: r)
+
+prop_mul :: forall r . (Ring r, Eq r) => LiftedInvertible r -> LiftedInvertible r -> Test r
+prop_mul (LInv x) (LInv y) = test $ fromIntegral (x * y) == (fromIntegral x * fromIntegral y :: r)
+
+prop_recip :: (Field r, Eq r) => Invertible r -> Test r
+prop_recip (Invertible x) = test $ one == (x * recip x)
+
+-- tests that multiplication in the extension ring matches CRT multiplication
+prop_mul_ext :: (CRTEmbed r, Eq r) => Invertible r -> Invertible r -> Test r
+prop_mul_ext (Invertible x) (Invertible y) = test $
+  let z = x * y
+      z' = fromExt $ toExt x * toExt y
+  in z == z'
+
+data LiftedMod r where
+  LMod :: (ToInteger (ModRep r)) => ModRep r -> LiftedMod r
+
+instance (Mod r, Random (ModRep r), ToInteger (ModRep r))
+  => Random (LiftedMod r) where
+  random =
+    let q = proxy modulus (Proxy::Proxy r)
+    in \g -> let (x,g') = randomR (0,q-1) g in (LMod x, g')
+  randomR = error "randomR not defined for `LiftedMod`"
+
+
+data LiftedInvertible r where
+  LInv :: (ToInteger (ModRep r)) => ModRep r -> LiftedInvertible r
+
+instance (Mod r, Random (ModRep r), PID (ModRep r), ToInteger (ModRep r))
+  => Random (LiftedInvertible r) where
+  random =
+    let q = proxy modulus (Proxy::Proxy r)
+    in \g -> let (x,g') = randomR (1,q-1) g
+             in if gcd x q == 1 then (LInv x, g') else random g'
+  randomR = error "randomR not defined for `LiftedInvertible`"
+
+newtype Invertible r = Invertible r
+
+instance (Random (LiftedInvertible r), Ring r, ToInteger (ModRep r))
+  => Random (Invertible r) where
+  random g =
+    let (LInv x :: LiftedInvertible r, g') = random g
+    in (Invertible $ fromIntegral x, g')
+  randomR = error "randomR not defined for `Invertible`"
diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,339 @@
+             GNU GENERAL PUBLIC LICENSE
+                Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                     Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+             GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                     NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+              END OF TERMS AND CONDITIONS
+
+     How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/README b/README
new file mode 100644
--- /dev/null
+++ b/README
@@ -0,0 +1,6 @@
+This library contains modules for testing Lol. Primarily, this can be used to
+verify third-party 'Tensor' instances, but it also includes some useful tools
+for writing crypto application tests.
+
+Unless you are writing your own tests, you shouldn't explicitly need this
+package.
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/exec/LolTestsMain.hs b/exec/LolTestsMain.hs
new file mode 100644
--- /dev/null
+++ b/exec/LolTestsMain.hs
@@ -0,0 +1,21 @@
+{-|
+Module      : LolTestsMain
+Description : Main driver for Zq tests.
+Copyright   : (c) Eric Crockett, 2011-2017
+                  Chris Peikert, 2011-2017
+License     : GPL-2
+Maintainer  : ecrockett0@email.com
+Stability   : experimental
+Portability : POSIX
+
+Main driver for Zq tests.
+-}
+
+module LolTestsMain where
+
+import Crypto.Lol.Tests.Standard
+import Test.Framework
+
+main :: IO ()
+main = flip defaultMainWithArgs ["--threads=1","--maximum-generated-tests=100"]
+  [zqTs]
diff --git a/lol-tests.cabal b/lol-tests.cabal
new file mode 100644
--- /dev/null
+++ b/lol-tests.cabal
@@ -0,0 +1,63 @@
+name:                lol-tests
+-- The package version.  See the Haskell package versioning policy (PVP)
+-- for standards guiding when and how versions should be incremented.
+-- http://www.haskell.org/haskellwiki/Package_versioning_policy
+-- PVP summary:      +-+------- breaking API changes
+--                   | | +----- non-breaking API additions
+--                   | | | +--- code changes with no API change
+version:             0.0.0.1
+synopsis:            A library for testing <https://hackage.haskell.org/package/lol Λ ∘ λ>.
+homepage:            https://github.com/cpeikert/Lol
+Bug-Reports:         https://github.com/cpeikert/Lol/issues
+license:             GPL-2
+license-file:        LICENSE
+author:              Eric Crockett <ecrockett0@gmail.com>, Chris Peikert <cpeikert@alum.mit.edu>
+maintainer:          Eric Crockett <ecrockett0@gmail.com>
+copyright:           Eric Crockett, Chris Peikert
+category:            Crypto
+stability:           experimental
+build-type:          Simple
+extra-source-files:  README, CHANGES.md
+cabal-version:       >= 1.10
+description:
+    This library contains code to test <https://hackage.haskell.org/package/lol Λ ∘ λ (Lol)>.
+    It is designed so that third-party tensors can be easily tested using the same framework.
+    For examples of how to use this library, see the tests for
+    <https://hackage.haskell.org/package/lol-cpp lol-cpp>.
+source-repository head
+  type: git
+  location: https://github.com/cpeikert/Lol
+
+library
+  default-language: Haskell2010
+  ghc-options: -fwarn-dodgy-imports -O2
+
+  exposed-modules:
+    Crypto.Lol.Tests
+    Crypto.Lol.Tests.CycTests
+    Crypto.Lol.Tests.Standard
+    Crypto.Lol.Tests.TensorTests
+    Crypto.Lol.Tests.ZqTests
+
+  build-depends:
+    base >= 4.9 && < 5,
+    lol >= 0.6.0.0,
+    MonadRandom,
+    test-framework,
+    test-framework-quickcheck2,
+    QuickCheck
+
+-- EAC: This really belongs in lol.cabal, but due to a cabal/stack bug, it can't right now.
+test-suite test-lol
+  type:               exitcode-stdio-1.0
+  default-language:   Haskell2010
+  main-is:            LolTestsMain.hs
+  ghc-options:        -main-is LolTestsMain
+  hs-source-dirs:     exec
+  ghc-options: -threaded -O2
+
+  build-depends:
+    base >= 4.9 && < 5,
+    lol >= 0.6.0.0,
+    lol-tests,
+    test-framework
