]> Git — Sourcephile - majurity.git/blob - hjugement-protocol/tests/HUnit/FFC.hs
cli: init registrar and trustee commands
[majurity.git] / hjugement-protocol / tests / HUnit / FFC.hs
1 {-# LANGUAGE OverloadedStrings #-}
2 module HUnit.FFC where
3
4 import GHC.Natural (minusNaturalMaybe)
5 import Data.Maybe (fromJust)
6 import Test.Tasty.HUnit
7 import Voting.Protocol
8 import Utils
9
10 hunit :: TestTree
11 hunit = testGroup "FFC"
12 [ testGroup "inv"
13 [ testGroup "WeakParams"
14 [ testCase "groupGen" $
15 reify weakFFC $ \(Proxy::Proxy c) ->
16 inv (groupGen @c) @?=
17 groupGen ^ E (fromJust $ groupOrder @c `minusNaturalMaybe` one)
18 ]
19 , testGroup "BeleniosParams"
20 [ testCase "groupGen" $
21 reify beleniosFFC $ \(Proxy::Proxy c) ->
22 inv (groupGen @c) @?=
23 groupGen ^ E (fromJust $ groupOrder @c `minusNaturalMaybe` one)
24 ]
25 ]
26 , testGroup "hash"
27 [ testGroup "WeakParams" $
28 reify weakFFC $ \(Proxy::Proxy c) ->
29 [ testCase "[groupGen]" $
30 hash "start" [groupGen @c] @?=
31 fromNatural 62
32 , testCase "[groupGen, groupGen]" $
33 hash "start" [groupGen @c, groupGen] @?=
34 fromNatural 31
35 ]
36 , testGroup "BeleniosParams" $
37 reify beleniosFFC $ \(Proxy::Proxy c) ->
38 [ testCase "[groupGen]" $
39 hash "start" [groupGen @c] @?=
40 fromNatural 75778590284190557660612328423573274641033882642784670156837892421285248292707
41 , testCase "[groupGen, groupGen]" $
42 hash "start" [groupGen @c, groupGen] @?=
43 fromNatural 28798937720387703653439047952832768487958170248947132321730024269734141660223
44 ]
45 ]
46 ]