]> Git — Sourcephile - majurity.git/blob - hjugement-protocol/tests/QuickCheck/Trustee.hs
protocol: add encryptedTally
[majurity.git] / hjugement-protocol / tests / QuickCheck / Trustee.hs
1 {-# OPTIONS -fno-warn-orphans #-}
2 module QuickCheck.Trustee where
3
4 import Test.Tasty.QuickCheck
5
6 import Voting.Protocol
7 import Voting.Protocol.Trustees.All
8
9 import Utils
10 import QuickCheck.Election ()
11
12 quickcheck :: TestTree
13 quickcheck =
14 testGroup "Trustee"
15 [ testGroup "verifyTrusteePublicKey" $
16 [ testTrusteePublicKey @WeakParams
17 , testTrusteePublicKey @BeleniosParams
18 ]
19 ]
20
21 testTrusteePublicKey :: forall q. Params q => TestTree
22 testTrusteePublicKey =
23 testGroup (paramsName @q)
24 [ testProperty "Right" $ \seed ->
25 isRight $ runExcept $
26 (`evalStateT` mkStdGen seed) $ do
27 trustSecKey :: SecretKey q <- randomSecretKey
28 trustPubKey <- proveTrusteePublicKey trustSecKey
29 lift $ verifyTrusteePublicKey trustPubKey
30 ]
31
32 instance SubGroup q => Arbitrary (TrusteePublicKey q) where
33 arbitrary = do
34 trustee_PublicKey <- arbitrary
35 trustee_SecretKeyProof <- arbitrary
36 return TrusteePublicKey{..}