hjugement-protocol-0.0.10.20191104: A cryptographic protocol for the Majority Judgment.

Safe HaskellNone
LanguageHaskell2010

Voting.Protocol.Tally

Contents

Synopsis

Type Tally

data Tally crypto v c Source #

Constructors

Tally 

Fields

Instances
Eq (G crypto c) => Eq (Tally crypto v c) Source # 
Instance details

Defined in Voting.Protocol.Tally

Methods

(==) :: Tally crypto v c -> Tally crypto v c -> Bool #

(/=) :: Tally crypto v c -> Tally crypto v c -> Bool #

(Show (G crypto c), Show (G crypto c)) => Show (Tally crypto v c) Source # 
Instance details

Defined in Voting.Protocol.Tally

Methods

showsPrec :: Int -> Tally crypto v c -> ShowS #

show :: Tally crypto v c -> String #

showList :: [Tally crypto v c] -> ShowS #

Generic (Tally crypto v c) Source # 
Instance details

Defined in Voting.Protocol.Tally

Associated Types

type Rep (Tally crypto v c) :: Type -> Type #

Methods

from :: Tally crypto v c -> Rep (Tally crypto v c) x #

to :: Rep (Tally crypto v c) x -> Tally crypto v c #

(Reifies v Version, CryptoParams crypto c) => ToJSON (Tally crypto v c) Source # 
Instance details

Defined in Voting.Protocol.Tally

Methods

toJSON :: Tally crypto v c -> Value #

toEncoding :: Tally crypto v c -> Encoding #

toJSONList :: [Tally crypto v c] -> Value #

toEncodingList :: [Tally crypto v c] -> Encoding #

(Reifies v Version, CryptoParams crypto c) => FromJSON (Tally crypto v c) Source # 
Instance details

Defined in Voting.Protocol.Tally

Methods

parseJSON :: Value -> Parser (Tally crypto v c) #

parseJSONList :: Value -> Parser [Tally crypto v c] #

NFData (G crypto c) => NFData (Tally crypto v c) Source # 
Instance details

Defined in Voting.Protocol.Tally

Methods

rnf :: Tally crypto v c -> () #

type Rep (Tally crypto v c) Source # 
Instance details

Defined in Voting.Protocol.Tally

type Rep (Tally crypto v c) = D1 (MetaData "Tally" "Voting.Protocol.Tally" "hjugement-protocol-0.0.10.20191104-EAw7qkvTkg3AkEmPDQjrRv" False) (C1 (MetaCons "Tally" PrefixI True) ((S1 (MetaSel (Just "tally_countMax") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Natural) :*: S1 (MetaSel (Just "tally_encByChoiceByQuest") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (EncryptedTally crypto v c))) :*: (S1 (MetaSel (Just "tally_decShareByTrustee") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 [DecryptionShare crypto v c]) :*: S1 (MetaSel (Just "tally_countByChoiceByQuest") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 [[Natural]]))))

Type EncryptedTally

type EncryptedTally crypto v c = [[Encryption crypto v c]] Source #

Encryption by choice by Question.

encryptedTally :: CryptoParams crypto c => [Ballot crypto v c] -> (EncryptedTally crypto v c, Natural) Source #

(encryptedTally ballots) returns the sum of the Encryptions of the given ballots, along with the number of Ballots.

emptyEncryptedTally :: CryptoParams crypto c => (EncryptedTally crypto v c, Natural) Source #

The initial EncryptedTally which tallies no Ballot.

insertEncryptedTally :: CryptoParams crypto c => Ballot crypto v c -> (EncryptedTally crypto v c, Natural) -> (EncryptedTally crypto v c, Natural) Source #

(insertEncryptedTally ballot encTally) returns the EncryptedTally adding the votes of the given (ballot) to those of the given (encTally).

Type DecryptionShareCombinator

type DecryptionShareCombinator crypto v c = EncryptedTally crypto v c -> [DecryptionShare crypto v c] -> Except ErrorTally [[DecryptionFactor crypto c]] Source #

proveTally :: CryptoParams crypto c => (EncryptedTally crypto v c, Natural) -> [DecryptionShare crypto v c] -> DecryptionShareCombinator crypto v c -> Except ErrorTally (Tally crypto v c) Source #

verifyTally :: CryptoParams crypto c => Tally crypto v c -> DecryptionShareCombinator crypto v c -> Except ErrorTally () Source #

Type DecryptionShare

newtype DecryptionShare crypto v c Source #

A decryption share is a DecryptionFactor and a decryption Proof, by choice by Question. Computed by a trustee in proveDecryptionShare.

Constructors

DecryptionShare 

Fields

Instances
Eq (G crypto c) => Eq (DecryptionShare crypto v c) Source # 
Instance details

Defined in Voting.Protocol.Tally

Methods

(==) :: DecryptionShare crypto v c -> DecryptionShare crypto v c -> Bool #

(/=) :: DecryptionShare crypto v c -> DecryptionShare crypto v c -> Bool #

Show (G crypto c) => Show (DecryptionShare crypto v c) Source # 
Instance details

Defined in Voting.Protocol.Tally

Methods

showsPrec :: Int -> DecryptionShare crypto v c -> ShowS #

show :: DecryptionShare crypto v c -> String #

showList :: [DecryptionShare crypto v c] -> ShowS #

Generic (DecryptionShare crypto v c) Source # 
Instance details

Defined in Voting.Protocol.Tally

Associated Types

type Rep (DecryptionShare crypto v c) :: Type -> Type #

Methods

from :: DecryptionShare crypto v c -> Rep (DecryptionShare crypto v c) x #

to :: Rep (DecryptionShare crypto v c) x -> DecryptionShare crypto v c #

(Reifies v Version, ToJSON (G crypto c)) => ToJSON (DecryptionShare crypto v c) Source # 
Instance details

Defined in Voting.Protocol.Tally

Methods

toJSON :: DecryptionShare crypto v c -> Value #

toEncoding :: DecryptionShare crypto v c -> Encoding #

toJSONList :: [DecryptionShare crypto v c] -> Value #

toEncodingList :: [DecryptionShare crypto v c] -> Encoding #

(Reifies v Version, CryptoParams crypto c) => FromJSON (DecryptionShare crypto v c) Source # 
Instance details

Defined in Voting.Protocol.Tally

Methods

parseJSON :: Value -> Parser (DecryptionShare crypto v c) #

parseJSONList :: Value -> Parser [DecryptionShare crypto v c] #

NFData (G crypto c) => NFData (DecryptionShare crypto v c) Source # 
Instance details

Defined in Voting.Protocol.Tally

Methods

rnf :: DecryptionShare crypto v c -> () #

type Rep (DecryptionShare crypto v c) Source # 
Instance details

Defined in Voting.Protocol.Tally

type Rep (DecryptionShare crypto v c) = D1 (MetaData "DecryptionShare" "Voting.Protocol.Tally" "hjugement-protocol-0.0.10.20191104-EAw7qkvTkg3AkEmPDQjrRv" True) (C1 (MetaCons "DecryptionShare" PrefixI True) (S1 (MetaSel (Just "unDecryptionShare") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [[(DecryptionFactor crypto c, Proof crypto v c)]])))

Type DecryptionFactor

proveDecryptionShare :: Reifies v Version => CryptoParams crypto c => Key crypto => Monad m => RandomGen r => EncryptedTally crypto v c -> SecretKey crypto c -> StateT r m (DecryptionShare crypto v c) Source #

proveDecryptionFactor :: Reifies v Version => CryptoParams crypto c => Key crypto => Monad m => RandomGen r => SecretKey crypto c -> Encryption crypto v c -> StateT r m (DecryptionFactor crypto c, Proof crypto v c) Source #

Type ErrorTally

data ErrorTally Source #

Constructors

ErrorTally_NumberOfQuestions

The number of Questions is not the one expected.

ErrorTally_NumberOfChoices

The number of choices is not the one expected.

ErrorTally_NumberOfTrustees

The number of trustees is not the one expected.

ErrorTally_WrongProof

The Proof of a DecryptionFactor is wrong.

ErrorTally_CannotDecryptCount

Raised by proveTally when the discrete logarithm of groupGen ^count cannot be computed, likely because tally_countMax is wrong, or because the EncryptedTally or DecryptionShares have not been verified.

Instances
Eq ErrorTally Source # 
Instance details

Defined in Voting.Protocol.Tally

Show ErrorTally Source # 
Instance details

Defined in Voting.Protocol.Tally

Generic ErrorTally Source # 
Instance details

Defined in Voting.Protocol.Tally

Associated Types

type Rep ErrorTally :: Type -> Type #

NFData ErrorTally Source # 
Instance details

Defined in Voting.Protocol.Tally

Methods

rnf :: ErrorTally -> () #

type Rep ErrorTally Source # 
Instance details

Defined in Voting.Protocol.Tally

type Rep ErrorTally = D1 (MetaData "ErrorTally" "Voting.Protocol.Tally" "hjugement-protocol-0.0.10.20191104-EAw7qkvTkg3AkEmPDQjrRv" False) ((C1 (MetaCons "ErrorTally_NumberOfQuestions" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "ErrorTally_NumberOfChoices" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "ErrorTally_NumberOfTrustees" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "ErrorTally_WrongProof" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "ErrorTally_CannotDecryptCount" PrefixI False) (U1 :: Type -> Type))))

verifyDecryptionShare :: Reifies v Version => CryptoParams crypto c => Monad m => EncryptedTally crypto v c -> PublicKey crypto c -> DecryptionShare crypto v c -> ExceptT ErrorTally m () Source #

(verifyDecryptionShare encTally trusteePubKey trusteeDecShare) checks that trusteeDecShare (supposedly submitted by a trustee whose PublicKey is trusteePubKey) is valid with respect to the EncryptedTally encTally.

verifyDecryptionShareByTrustee :: Reifies v Version => CryptoParams crypto c => Monad m => EncryptedTally crypto v c -> [PublicKey crypto c] -> [DecryptionShare crypto v c] -> ExceptT ErrorTally m () Source #