ouroboros-consensus
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.Committee.Class

Description

Generic interface used by implementations of voting committees.

Synopsis

Voting committee interface

data family VotingCommittee crypto committee Source #

Structure storing the voting committee context

NOTE: This data family is defined outside of the CryptoSupportsVotingCommittee class so that it can be instantiated for the HFC block without having to provide an instance of the whole class (because for HFC, we dispatch to a concrete era first so none of the methods/types of the class would actually be used).

Instances

Instances details
CanHardFork xs ⇒ FromCBOR (VotingCommittee (OneEraPerasCrypto xs) (OneEraPerasVotingCommitteeScheme xs)) Source #

Hand-written rather than deriving via SerialiseNS: that derivation needs All (Compose Serialise WrapPerasVotingCommittee) xs, which GHC cannot solve from the CanHardFork xs (i.e. All SingleEraBlock xs) context for an abstract xs. We instead build the per-era codecs with hcpure proxySingle, where each era's Serialise (WrapPerasVotingCommittee blk) is reachable from SingleEraBlock blk via its StateSupportsPerasEpochContext superclass, and feed them to encodeNS and decodeNS, producing the same wire format a SerialiseNS derivation would.

Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.AcrossEras

Typeable blk ⇒ FromCBOR (VotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Void

(Typeable crypto, FromCBOR (PublicKey crypto))FromCBOR (VotingCommittee crypto EveryoneVotes) Source # 
Instance details

Defined in Ouroboros.Consensus.Committee.EveryoneVotes

(Typeable crypto, FromCBOR (PublicKey crypto))FromCBOR (VotingCommittee crypto WFALS) Source # 
Instance details

Defined in Ouroboros.Consensus.Committee.WFALS

CanHardFork xs ⇒ ToCBOR (VotingCommittee (OneEraPerasCrypto xs) (OneEraPerasVotingCommitteeScheme xs)) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.AcrossEras

Typeable blk ⇒ ToCBOR (VotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Void

(Typeable crypto, ToCBOR (PublicKey crypto))ToCBOR (VotingCommittee crypto EveryoneVotes) Source # 
Instance details

Defined in Ouroboros.Consensus.Committee.EveryoneVotes

(Typeable crypto, ToCBOR (PublicKey crypto))ToCBOR (VotingCommittee crypto WFALS) Source # 
Instance details

Defined in Ouroboros.Consensus.Committee.WFALS

Methods

toCBORVotingCommittee crypto WFALSEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (VotingCommittee crypto WFALS) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [VotingCommittee crypto WFALS] → Size Source #

CanHardFork xs ⇒ Eq (VotingCommittee (OneEraPerasCrypto xs) (OneEraPerasVotingCommitteeScheme xs)) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.AcrossEras

Eq (VotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Void

Eq (PublicKey crypto) ⇒ Eq (VotingCommittee crypto EveryoneVotes) Source # 
Instance details

Defined in Ouroboros.Consensus.Committee.EveryoneVotes

Eq (PublicKey crypto) ⇒ Eq (VotingCommittee crypto WFALS) Source # 
Instance details

Defined in Ouroboros.Consensus.Committee.WFALS

Methods

(==)VotingCommittee crypto WFALSVotingCommittee crypto WFALSBool #

(/=)VotingCommittee crypto WFALSVotingCommittee crypto WFALSBool #

Generic (VotingCommittee (OneEraPerasCrypto xs) (OneEraPerasVotingCommitteeScheme xs)) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.AcrossEras

Associated Types

type Rep (VotingCommittee (OneEraPerasCrypto xs) (OneEraPerasVotingCommitteeScheme xs)) 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.AcrossEras

type Rep (VotingCommittee (OneEraPerasCrypto xs) (OneEraPerasVotingCommitteeScheme xs)) = D1 ('MetaData "VotingCommittee" "Ouroboros.Consensus.HardFork.Combinator.AcrossEras" "ouroboros-consensus-4.0.0.0-inplace" 'True) (C1 ('MetaCons "OneEraPerasVotingCommittee" 'PrefixI 'True) (S1 ('MetaSel ('Just "getOneEraPerasVotingCommittee") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NS WrapPerasVotingCommittee xs))))
Generic (VotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Void

Generic (VotingCommittee crypto EveryoneVotes) Source # 
Instance details

Defined in Ouroboros.Consensus.Committee.EveryoneVotes

Associated Types

type Rep (VotingCommittee crypto EveryoneVotes) 
Instance details

Defined in Ouroboros.Consensus.Committee.EveryoneVotes

type Rep (VotingCommittee crypto EveryoneVotes) = D1 ('MetaData "VotingCommittee" "Ouroboros.Consensus.Committee.EveryoneVotes" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "EveryoneVotesVotingCommittee" 'PrefixI 'True) ((S1 ('MetaSel ('Just "extWFAStakeDistr") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (ExtWFAStakeDistr (PublicKey crypto))) :*: S1 ('MetaSel ('Just "candidateSeats") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map PoolId SeatIndex))) :*: (S1 ('MetaSel ('Just "numActiveVoters") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NumPoolsWithPositiveStake) :*: S1 ('MetaSel ('Just "totalActiveStake") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 TotalStake))))
Generic (VotingCommittee crypto WFALS) Source # 
Instance details

Defined in Ouroboros.Consensus.Committee.WFALS

Associated Types

type Rep (VotingCommittee crypto WFALS) 
Instance details

Defined in Ouroboros.Consensus.Committee.WFALS

type Rep (VotingCommittee crypto WFALS) = D1 ('MetaData "VotingCommittee" "Ouroboros.Consensus.Committee.WFALS" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "WFALSVotingCommittee" 'PrefixI 'True) ((S1 ('MetaSel ('Just "extWFAStakeDistr") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (ExtWFAStakeDistr (PublicKey crypto))) :*: (S1 ('MetaSel ('Just "candidateSeats") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map PoolId SeatIndex)) :*: S1 ('MetaSel ('Just "persistentCommitteeSize") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PersistentCommitteeSize))) :*: ((S1 ('MetaSel ('Just "nonPersistentCommitteeSize") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NonPersistentCommitteeSize) :*: S1 ('MetaSel ('Just "totalPersistentStake") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 TotalPersistentStake)) :*: (S1 ('MetaSel ('Just "totalNonPersistentStake") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 TotalNonPersistentStake) :*: S1 ('MetaSel ('Just "epochNonce") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Nonce)))))

Methods

fromVotingCommittee crypto WFALSRep (VotingCommittee crypto WFALS) x #

toRep (VotingCommittee crypto WFALS) x → VotingCommittee crypto WFALS #

CanHardFork xs ⇒ Show (VotingCommittee (OneEraPerasCrypto xs) (OneEraPerasVotingCommitteeScheme xs)) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.AcrossEras

Show (VotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Void

Show (PublicKey crypto) ⇒ Show (VotingCommittee crypto EveryoneVotes) Source # 
Instance details

Defined in Ouroboros.Consensus.Committee.EveryoneVotes

Show (PublicKey crypto) ⇒ Show (VotingCommittee crypto WFALS) Source # 
Instance details

Defined in Ouroboros.Consensus.Committee.WFALS

Methods

showsPrecIntVotingCommittee crypto WFALSShowS #

showVotingCommittee crypto WFALSString #

showList ∷ [VotingCommittee crypto WFALS] → ShowS #

CanHardFork xs ⇒ NoThunks (VotingCommittee (OneEraPerasCrypto xs) (OneEraPerasVotingCommitteeScheme xs)) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.AcrossEras

NoThunks (VotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Void

NoThunks (PublicKey crypto) ⇒ NoThunks (VotingCommittee crypto EveryoneVotes) Source # 
Instance details

Defined in Ouroboros.Consensus.Committee.EveryoneVotes

NoThunks (PublicKey crypto) ⇒ NoThunks (VotingCommittee crypto WFALS) Source # 
Instance details

Defined in Ouroboros.Consensus.Committee.WFALS

data VotingCommittee crypto EveryoneVotes Source # 
Instance details

Defined in Ouroboros.Consensus.Committee.EveryoneVotes

data VotingCommittee crypto WFALS Source # 
Instance details

Defined in Ouroboros.Consensus.Committee.WFALS

newtype VotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Void

newtype VotingCommittee (OneEraPerasCrypto xs) (OneEraPerasVotingCommitteeScheme xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.AcrossEras

type Rep (VotingCommittee (OneEraPerasCrypto xs) (OneEraPerasVotingCommitteeScheme xs)) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.AcrossEras

type Rep (VotingCommittee (OneEraPerasCrypto xs) (OneEraPerasVotingCommitteeScheme xs)) = D1 ('MetaData "VotingCommittee" "Ouroboros.Consensus.HardFork.Combinator.AcrossEras" "ouroboros-consensus-4.0.0.0-inplace" 'True) (C1 ('MetaCons "OneEraPerasVotingCommittee" 'PrefixI 'True) (S1 ('MetaSel ('Just "getOneEraPerasVotingCommittee") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NS WrapPerasVotingCommittee xs))))
type Rep (VotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme) Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Void

type Rep (VotingCommittee crypto EveryoneVotes) Source # 
Instance details

Defined in Ouroboros.Consensus.Committee.EveryoneVotes

type Rep (VotingCommittee crypto EveryoneVotes) = D1 ('MetaData "VotingCommittee" "Ouroboros.Consensus.Committee.EveryoneVotes" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "EveryoneVotesVotingCommittee" 'PrefixI 'True) ((S1 ('MetaSel ('Just "extWFAStakeDistr") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (ExtWFAStakeDistr (PublicKey crypto))) :*: S1 ('MetaSel ('Just "candidateSeats") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map PoolId SeatIndex))) :*: (S1 ('MetaSel ('Just "numActiveVoters") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NumPoolsWithPositiveStake) :*: S1 ('MetaSel ('Just "totalActiveStake") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 TotalStake))))
type Rep (VotingCommittee crypto WFALS) Source # 
Instance details

Defined in Ouroboros.Consensus.Committee.WFALS

type Rep (VotingCommittee crypto WFALS) = D1 ('MetaData "VotingCommittee" "Ouroboros.Consensus.Committee.WFALS" "ouroboros-consensus-4.0.0.0-inplace" 'False) (C1 ('MetaCons "WFALSVotingCommittee" 'PrefixI 'True) ((S1 ('MetaSel ('Just "extWFAStakeDistr") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (ExtWFAStakeDistr (PublicKey crypto))) :*: (S1 ('MetaSel ('Just "candidateSeats") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map PoolId SeatIndex)) :*: S1 ('MetaSel ('Just "persistentCommitteeSize") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PersistentCommitteeSize))) :*: ((S1 ('MetaSel ('Just "nonPersistentCommitteeSize") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NonPersistentCommitteeSize) :*: S1 ('MetaSel ('Just "totalPersistentStake") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 TotalPersistentStake)) :*: (S1 ('MetaSel ('Just "totalNonPersistentStake") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 TotalNonPersistentStake) :*: S1 ('MetaSel ('Just "epochNonce") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Nonce)))))

class CryptoSupportsVoteSigning crypto ⇒ CryptoSupportsVotingCommittee crypto committee where Source #

Interface for voting committee schemes.

This class is parametrized by the crypto primitives and the committee selection data structure. Instances define how to check whether a party should vote and how to compute the voting weight of a committee member.

Associated Types

data VotingCommitteeInput crypto committee Source #

Input information needed to construct a voting committee

data VotingCommitteeError crypto committee Source #

Errors that can occur when operating on a voting committee

data EligibilityWitness crypto committee Source #

Witness attesting that a party is eligible to vote in a given election

NOTE: this is not necessarily the same as the cryptographic proof of eligibility used in concrete votes and certificates sent over the wire.

data Vote crypto committee Source #

Abstract vote cast by a committee member in a given election

data Cert crypto committee Source #

Abstract certificate attesting the winner of a given election

Methods

voteTargetVote crypto committee → (ElectionId crypto, VoteCandidate crypto) Source #

Project the target (election and candidate) from an abstract vote

compareVotesByIdVote crypto committee → Vote crypto committee → Ordering Source #

Compare votes by ID, where EQ means that two votes have the same ID and are either total duplicates, or are equivocating (i.e., they have the same ID but a different target)

mkVotingCommitteeVotingCommitteeInput crypto committee → Either (VotingCommitteeError crypto committee) (VotingCommittee crypto committee) Source #

Construct a voting committee

checkShouldVoteVotingCommittee crypto committee → PoolIdPrivateKey crypto → ElectionId crypto → Either (VotingCommitteeError crypto committee) (Maybe (EligibilityWitness crypto committee)) Source #

Check whether we should vote in a given election

forgeVoteEligibilityWitness crypto committee → PrivateKey crypto → ElectionId crypto → VoteCandidate crypto → Vote crypto committee Source #

Forge a vote for a given election and candidate

verifyVoteVotingCommittee crypto committee → Vote crypto committee → Either (VotingCommitteeError crypto committee) (EligibilityWitness crypto committee) Source #

Verify a vote cast by a committee member in a given election

eligiblePartyVoteWeightVotingCommittee crypto committee → EligibilityWitness crypto committee → VoteWeight Source #

Compute the (relative) voting power of an eligibile party

WARNING: there is a key difference between the "Ledger stake" and the "Vote weight" of a given voter. On one hand, the ledger stake is the stake as reflected directly by the ledger stake distribution under consideration (in its corresponding absolute unit). On the other hand, the "Vote weight" refers to the relative (i.e. normalised) voting power of that voter w.r.t. the rest of the committee.

It is up to the implementation of the voting committee to decide how to compute this value, but it should be implemented so that detecting a quorum can be done by comparing the total vote weight of the votes received against a fixed threshold, e.g., "a quorum is reached if the total weight of the votes received exceeds 75% or 0.75 (of the total voting stake)".

forgeCertUniqueVotesWithSameTarget crypto committee → Either (VotingCommitteeError crypto committee) (Cert crypto committee) Source #

Forge a certificate attesting the winner of a given election

verifyCertVotingCommittee crypto committee → Cert crypto committee → Either (VotingCommitteeError crypto committee) (NE [EligibilityWitness crypto committee]) Source #

Verify a certificate attesting the winner of a given election

Instances

Instances details
(Ord (ElectionId crypto), CryptoSupportsAggregateVoteSigning crypto)CryptoSupportsVotingCommittee crypto EveryoneVotes Source # 
Instance details

Defined in Ouroboros.Consensus.Committee.EveryoneVotes

(CryptoSupportsAggregateVoteSigning crypto, CryptoSupportsBatchVRFVerification crypto, Ord (ElectionId crypto))CryptoSupportsVotingCommittee crypto WFALS Source # 
Instance details

Defined in Ouroboros.Consensus.Committee.WFALS

Associated Types

data VotingCommitteeInput crypto WFALS 
Instance details

Defined in Ouroboros.Consensus.Committee.WFALS

data VotingCommitteeError crypto WFALS 
Instance details

Defined in Ouroboros.Consensus.Committee.WFALS

data EligibilityWitness crypto WFALS 
Instance details

Defined in Ouroboros.Consensus.Committee.WFALS

data Vote crypto WFALS 
Instance details

Defined in Ouroboros.Consensus.Committee.WFALS

data Cert crypto WFALS 
Instance details

Defined in Ouroboros.Consensus.Committee.WFALS

data Cert crypto WFALS = WFALSCert !(ElectionId crypto) !(VoteCandidate crypto) !(NE (Map SeatIndex (Maybe (VRFOutput crypto)))) !(AggregateVoteSignature crypto)
CryptoSupportsVotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme Source # 
Instance details

Defined in Ouroboros.Consensus.Peras.Void

Methods

voteTargetVote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme → (ElectionId (VoidPerasCrypto blk), VoteCandidate (VoidPerasCrypto blk)) Source #

compareVotesByIdVote (VoidPerasCrypto blk) VoidPerasVotingCommitteeSchemeVote (VoidPerasCrypto blk) VoidPerasVotingCommitteeSchemeOrdering Source #

mkVotingCommitteeVotingCommitteeInput (VoidPerasCrypto blk) VoidPerasVotingCommitteeSchemeEither (VotingCommitteeError (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme) (VotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme) Source #

checkShouldVoteVotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeSchemePoolIdPrivateKey (VoidPerasCrypto blk) → ElectionId (VoidPerasCrypto blk) → Either (VotingCommitteeError (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme) (Maybe (EligibilityWitness (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme)) Source #

forgeVoteEligibilityWitness (VoidPerasCrypto blk) VoidPerasVotingCommitteeSchemePrivateKey (VoidPerasCrypto blk) → ElectionId (VoidPerasCrypto blk) → VoteCandidate (VoidPerasCrypto blk) → Vote (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme Source #

verifyVoteVotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeSchemeVote (VoidPerasCrypto blk) VoidPerasVotingCommitteeSchemeEither (VotingCommitteeError (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme) (EligibilityWitness (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme) Source #

eligiblePartyVoteWeightVotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeSchemeEligibilityWitness (VoidPerasCrypto blk) VoidPerasVotingCommitteeSchemeVoteWeight Source #

forgeCertUniqueVotesWithSameTarget (VoidPerasCrypto blk) VoidPerasVotingCommitteeSchemeEither (VotingCommitteeError (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme) (Cert (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme) Source #

verifyCertVotingCommittee (VoidPerasCrypto blk) VoidPerasVotingCommitteeSchemeCert (VoidPerasCrypto blk) VoidPerasVotingCommitteeSchemeEither (VotingCommitteeError (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme) (NE [EligibilityWitness (VoidPerasCrypto blk) VoidPerasVotingCommitteeScheme]) Source #

Votes with same target

data UniqueVotesWithSameTarget crypto committee Source #

Collection of unique votes all targeting the same election and candidate

getElectionIdFromVotesUniqueVotesWithSameTarget crypto committee → ElectionId crypto Source #

Get the election identifier targeted by a collection of votes

getVoteCandidateFromVotesUniqueVotesWithSameTarget crypto committee → VoteCandidate crypto Source #

Get the vote candidate targeted by a collection of votes

getRawVotesUniqueVotesWithSameTarget crypto committee → NE [Vote crypto committee] Source #

Get the raw votes from a collection of votes with the same target.

NOTE: this returns votes in ascending seat index order.

data UniqueVotesWithSameTargetError vote Source #

Errors when votes do not all target the same election and candidate

Constructors

DuplicateVotes (NE [vote]) 
TargetMismatch vote (NE [vote]) 

ensureUniqueVotesWithSameTarget Source #

Arguments

(Eq (ElectionId crypto), Eq (VoteCandidate crypto)) 
⇒ (Vote crypto committee → (ElectionId crypto, VoteCandidate crypto))

How to project the target from an abstract vote

→ (Vote crypto committee → Vote crypto committee → Ordering)

How to compare votes by ID, where EQ means that two votes have the same ID and are either total duplicates, or are equivocating (i.e., they have the same ID but a different target)

NE [Vote crypto committee]

Collection of votes to check

Either (UniqueVotesWithSameTargetError (Vote crypto committee)) (UniqueVotesWithSameTarget crypto committee) 

Check that a non-empty list of votes all target the same election and candidate and there are no duplicates.

NOTE: duplicates are reported in preference to target mismatches.

unsafeUniqueVotesWithSameTarget Source #

Arguments

(CryptoSupportsVotingCommittee crypto committee, Eq (ElectionId crypto), Eq (VoteCandidate crypto)) 
NE [Vote crypto committee]

Collection of votes to check

UniqueVotesWithSameTarget crypto committee 

Same as ensureUniqueVotesWithSameTarget but turns the invariant checks into assertions.

WARNING: asserts become a no-op if the code is compiled with optimizations, thus this function should only be used in production when the caller can guarantee that the input votes satisfy the contract.

checkUniqueVotesWithSameTarget Source #

Arguments

(Eq (ElectionId crypto), Eq (VoteCandidate crypto)) 
Proxy crypto 
→ (vote → (ElectionId crypto, VoteCandidate crypto))

How to project the target an abstract vote

→ (vote → vote → Ordering)

How to compare votes by ID, where EQ means that two votes have the same ID and are either total duplicates, or are equivocating (i.e., they have the same ID but a different target)

NE [vote]

Collection of votes to check

Either (UniqueVotesWithSameTargetError vote) () 

Validate that a non-empty collection of votes is well-formed for certificate forging: all votes target the same election and candidate (per getTarget), and no two votes are equal under cmpVotes.

Equality (EQ) is treated as evidence of a duplicate or equivocating vote and is reported via DuplicateVotes in preference to any TargetMismatch.

NOTE: this is exposed for testing; production code should use ensureUniqueVotesWithSameTarget or unsafeUniqueVotesWithSameTarget.