summaryrefslogtreecommitdiff
path: root/tests/QuickCheck/Trustee.hs
blob: 82cfe14213ad129805b01b73756d0d0d0aba7df5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{-# OPTIONS -fno-warn-orphans #-}
module QuickCheck.Trustee where

import Test.Tasty.QuickCheck

import Voting.Protocol
import Voting.Protocol.Trustee.Indispensable

import Utils
import QuickCheck.Election ()

quickcheck :: TestTree
quickcheck =
	testGroup "Trustee"
	 [ testGroup "verifyIndispensableTrusteePublicKey" $
		 [ testIndispensableTrusteePublicKey @WeakParams
		 , testIndispensableTrusteePublicKey @BeleniosParams
		 ]
	 ]

testIndispensableTrusteePublicKey :: forall q. Params q => TestTree
testIndispensableTrusteePublicKey  =
	testGroup (paramsName @q)
	 [ testProperty "Right" $ \seed ->
		isRight $ runExcept $
			(`evalStateT` mkStdGen seed) $ do
				trusteeSecKey :: SecretKey q <- randomSecretKey
				trusteePubKey <- proveIndispensableTrusteePublicKey trusteeSecKey
				lift $ verifyIndispensableTrusteePublicKey trusteePubKey
	 ]

instance SubGroup q => Arbitrary (TrusteePublicKey q) where
	arbitrary = do
		trustee_PublicKey <- arbitrary
		trustee_SecretKeyProof <- arbitrary
		return TrusteePublicKey{..}