{-# LANGUAGE OverloadedStrings #-} module HUnit.FFC where import GHC.Natural (minusNaturalMaybe) import Data.Maybe (fromJust) import Test.Tasty.HUnit import Voting.Protocol import Utils hunit :: TestTree hunit = testGroup "FFC" [ testGroup "inv" [ testGroup "WeakParams" [ testCase "groupGen" $ reify weakFFC $ \(Proxy::Proxy c) -> inv (groupGen @c) @?= groupGen ^ E (fromJust $ groupOrder @c `minusNaturalMaybe` one) ] , testGroup "BeleniosParams" [ testCase "groupGen" $ reify beleniosFFC $ \(Proxy::Proxy c) -> inv (groupGen @c) @?= groupGen ^ E (fromJust $ groupOrder @c `minusNaturalMaybe` one) ] ] , testGroup "hash" [ testGroup "WeakParams" $ reify weakFFC $ \(Proxy::Proxy c) -> [ testCase "[groupGen]" $ hash "start" [groupGen @c] @?= fromNatural 100 , testCase "[groupGen, groupGen]" $ hash "start" [groupGen @c, groupGen] @?= fromNatural 16 ] , testGroup "BeleniosParams" $ reify beleniosFFC $ \(Proxy::Proxy c) -> [ testCase "[groupGen]" $ hash "start" [groupGen @c] @?= fromNatural 1832875488615060263192702367259 , testCase "[groupGen, groupGen]" $ hash "start" [groupGen @c, groupGen] @?= fromNatural 2495277906542783643199702546512 ] ] ]