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

Safe HaskellNone
LanguageHaskell2010

Protocol.Election

Contents

Synopsis

Type Encryption

data Encryption q Source #

ElGamal-like encryption. Its security relies on the Discrete Logarithm problem.

Because (groupGen ^encNonce ^secKey == groupGen ^secKey ^encNonce), knowing secKey, one can divide encryption_vault by (encryption_nonce ^secKey) to decipher (groupGen ^clear), then the clear text must be small to be decryptable, because it is encrypted as a power of groupGen (hence the "-like" in "ElGamal-like") to enable the additive homomorphism.

NOTE: Since (encryption_vault * encryption_nonce == encryption_nonce ^ (secKey + clear)), then: (logBase encryption_nonce (encryption_vault * encryption_nonce) == secKey + clear).

Constructors

Encryption 

Fields

Instances
Eq (Encryption q) Source # 
Instance details

Defined in Protocol.Election

Methods

(==) :: Encryption q -> Encryption q -> Bool #

(/=) :: Encryption q -> Encryption q -> Bool #

Show (Encryption q) Source # 
Instance details

Defined in Protocol.Election

SubGroup q => Additive (Encryption q) Source #

Additive homomorphism. Using the fact that: groupGen ^x * groupGen ^y == groupGen ^(x+y).

Instance details

Defined in Protocol.Election

Type EncryptionNonce

encrypt :: Monad m => RandomGen r => SubGroup q => PublicKey q -> E q -> StateT r m (EncryptionNonce q, Encryption q) Source #

(encrypt pubKey clear) returns an ElGamal-like Encryption.

WARNING: the secret encryption nonce (encNonce) is returned alongside the Encryption in order to prove the validity of the encrypted clear text in proveEncryption, but this secret encNonce MUST be forgotten after that, as it may be used to decipher the Encryption without the secret key associated with pubKey.

Type Proof

data Proof q Source #

Proof of knowledge of a discrete logarithm: (secret == logBase base (base^secret)).

Constructors

Proof 

Fields

Instances
Eq (Proof q) Source # 
Instance details

Defined in Protocol.Election

Methods

(==) :: Proof q -> Proof q -> Bool #

(/=) :: Proof q -> Proof q -> Bool #

Show (Proof q) Source # 
Instance details

Defined in Protocol.Election

Methods

showsPrec :: Int -> Proof q -> ShowS #

show :: Proof q -> String #

showList :: [Proof q] -> ShowS #

Type ZKP

newtype ZKP Source #

Zero-knowledge proof

DOC: Mihir Bellare and Phillip Rogaway. Random oracles are practical: A paradigm for designing efficient protocols. In ACM-CCS’93, 1993.

DOC: Pierrick Gaudry. Some ZK security proofs for Belenios, 2017.

Constructors

ZKP ByteString 

Type Challenge

Type Oracle

type Oracle list q = list (Commitment q) -> Challenge q Source #

prove :: Monad m => RandomGen r => SubGroup q => Functor list => E q -> list (Commitment q) -> Oracle list q -> StateT r m (Proof q) Source #

(prove sec commitBases oracle) returns a Proof that sec is known.

The Oracle is given the commitBases raised to the power of the secret nonce of the Proof, as those are the commitBases that the verifier will obtain when composing the proof_challenge and proof_response together (in commit).

NOTE: sec is secKey in signature_proof or encNonce in proveEncryption.

WARNING: for prove to be a so-called strong Fiat-Shamir transformation (not a weak): the statement must be included in the hash (not only the commitments).

NOTE: a random nonce is used to ensure each prove does not reveal any information regarding the secret sec.

Type Commitment

commit :: SubGroup q => Proof q -> G q -> G q -> Commitment q Source #

(commit proof base basePowSec) returns a Commitment from the given Proof with the knowledge of the verifier.

Type Disjunction

type Disjunction = G Source #

A Disjunction is an inversed (groupGen ^opinion) it's used in proveEncryption to generate a Proof that an encryption_vault contains a given (groupGen ^opinion),

Type Opinion

type Opinion = E Source #

Index of a Disjunction within a list of them. It is encrypted as an Exponent by encrypt.

Type DisjProof

newtype DisjProof q Source #

A list of Proofs to prove that the Opinion within an Encryption is indexing a Disjunction within a list of them, without revealing which Opinion it is.

Constructors

DisjProof [Proof q] 
Instances
Eq (DisjProof q) Source # 
Instance details

Defined in Protocol.Election

Methods

(==) :: DisjProof q -> DisjProof q -> Bool #

(/=) :: DisjProof q -> DisjProof q -> Bool #

Show (DisjProof q) Source # 
Instance details

Defined in Protocol.Election

proveEncryption :: forall m r q. Monad m => RandomGen r => SubGroup q => PublicKey q -> ZKP -> ([Disjunction q], [Disjunction q]) -> (EncryptionNonce q, Encryption q) -> StateT r m (DisjProof q) Source #

(proveEncryption elecPubKey voterZKP (prevDisjs,nextDisjs) (encNonce,enc)) returns a DisjProof that enc encrypts the Disjunctions between prevDisjs and nextDisjs.

A NIZK Disjunctive Chaum Pedersen Logarithm Equality is used.

Hashing

encryptionCommitments :: SubGroup q => PublicKey q -> Encryption q -> (Disjunction q, Proof q) -> [G q] Source #

(encryptionCommitments elecPubKey enc (disj,proof)) returns the Commitments with only the knowledge of the verifier.

The Proof comes from prove of fakeProof in proveEncryption.

Type ErrorValidateEncryption

Type Question

data Question q Source #

Instances
Eq (Question q) Source # 
Instance details

Defined in Protocol.Election

Methods

(==) :: Question q -> Question q -> Bool #

(/=) :: Question q -> Question q -> Bool #

Show (Question q) Source # 
Instance details

Defined in Protocol.Election

Methods

showsPrec :: Int -> Question q -> ShowS #

show :: Question q -> String #

showList :: [Question q] -> ShowS #

Type Answer

data Answer q Source #

Constructors

Answer 

Fields

Instances
Eq (Answer q) Source # 
Instance details

Defined in Protocol.Election

Methods

(==) :: Answer q -> Answer q -> Bool #

(/=) :: Answer q -> Answer q -> Bool #

Show (Answer q) Source # 
Instance details

Defined in Protocol.Election

Methods

showsPrec :: Int -> Answer q -> ShowS #

show :: Answer q -> String #

showList :: [Answer q] -> ShowS #

encryptAnswer :: Monad m => RandomGen r => SubGroup q => PublicKey q -> ZKP -> Question q -> [Bool] -> StateT r (ExceptT ErrorAnswer m) (Answer q) Source #

(encryptAnswer elecPubKey zkp quest opinions) returns an Answer validable by verifyAnswer, unless an ErrorAnswer is returned.

Type ErrorAnswer

data ErrorAnswer Source #

Error raised by encryptAnswer.

Constructors

ErrorAnswer_WrongNumberOfOpinions Natural Natural

When the number of opinions is different than the number of choices (question_choices).

ErrorAnswer_WrongSumOfOpinions Natural Natural Natural

When the sum of opinions is not within the bounds of question_mini and question_maxi.

Instances
Eq ErrorAnswer Source # 
Instance details

Defined in Protocol.Election

Show ErrorAnswer Source # 
Instance details

Defined in Protocol.Election

Type Election

data Election q Source #

Instances
Eq (Election q) Source # 
Instance details

Defined in Protocol.Election

Methods

(==) :: Election q -> Election q -> Bool #

(/=) :: Election q -> Election q -> Bool #

Show (Election q) Source # 
Instance details

Defined in Protocol.Election

Methods

showsPrec :: Int -> Election q -> ShowS #

show :: Election q -> String #

showList :: [Election q] -> ShowS #

Type Hash

newtype Hash Source #

Constructors

Hash Text 
Instances
Eq Hash Source # 
Instance details

Defined in Protocol.Election

Methods

(==) :: Hash -> Hash -> Bool #

(/=) :: Hash -> Hash -> Bool #

Ord Hash Source # 
Instance details

Defined in Protocol.Election

Methods

compare :: Hash -> Hash -> Ordering #

(<) :: Hash -> Hash -> Bool #

(<=) :: Hash -> Hash -> Bool #

(>) :: Hash -> Hash -> Bool #

(>=) :: Hash -> Hash -> Bool #

max :: Hash -> Hash -> Hash #

min :: Hash -> Hash -> Hash #

Show Hash Source # 
Instance details

Defined in Protocol.Election

Methods

showsPrec :: Int -> Hash -> ShowS #

show :: Hash -> String #

showList :: [Hash] -> ShowS #

Type Ballot

encryptBallot :: Monad m => RandomGen r => SubGroup q => Election q -> Maybe (SecretKey q) -> [[Bool]] -> StateT r (ExceptT ErrorBallot m) (Ballot q) Source #

(encryptBallot elec (Just secKey) opinionsByQuest) returns a Ballot signed by secKey (the voter's secret key) where opinionsByQuest is a list of Opinions on each question_choices of each election_questions.

Type Signature

data Signature q Source #

Schnorr-like signature.

Used by each voter to sign his/her encrypted Ballot using his/her Credential, in order to avoid ballot stuffing.

Constructors

Signature 

Fields

Hashing

signatureStatement :: Foldable f => SubGroup q => f (Answer q) -> [G q] Source #

(signatureStatement answers) returns the encrypted material to be signed: all the encryption_nonces and encryption_vaults of the given answers.

Type ErrorBallot

data ErrorBallot Source #

Error raised by encryptBallot.

Constructors

ErrorBallot_WrongNumberOfAnswers Natural Natural

When the number of answers is different than the number of questions.

ErrorBallot_Answer ErrorAnswer

When encryptAnswer raised an ErrorAnswer.

Instances
Eq ErrorBallot Source # 
Instance details

Defined in Protocol.Election

Show ErrorBallot Source # 
Instance details

Defined in Protocol.Election

Type DecryptionShare

data DecryptionShare q Source #

A decryption share. It is computed by a trustee from his/her private key share and the encrypted tally, and contains a cryptographic Proof that he/she didn't cheat.

Constructors

DecryptionShare 
Instances
Eq (DecryptionShare q) Source # 
Instance details

Defined in Protocol.Election

Show (DecryptionShare q) Source # 
Instance details

Defined in Protocol.Election

Type DecryptionFactor

Type ErrorDecryptionShare

checkDecryptionShare :: Monad m => SubGroup q => RandomGen r => [[Encryption q]] -> PublicKey q -> DecryptionShare q -> ExceptT ErrorDecryptionShare m Bool Source #

(checkDecryptionShare encTally pubKey decShare) checks that decShare (supposedly submitted by a trustee whose public key is pubKey) is valid with respect to the encrypted tally encTally.