Documentation
¶
Index ¶
- func AccumulatorKey(proposalID, decision uint32) uint64
- func AppendCeremonyLog(round *types.VoteRound, blockHeight uint64, msg string)
- func FindAckInRoundCeremony(round *types.VoteRound, valAddr string) (int, bool)
- func FindContributionInRound(round *types.VoteRound, valAddr string) (*types.DKGContribution, bool)
- func FindValidatorInRoundCeremony(round *types.VoteRound, valAddr string) (*types.ValidatorPallasKey, bool)
- func HalfAcked(round *types.VoteRound) bool
- func NewMsgServerImpl(keeper *Keeper) types.MsgServer
- func NewQueryServerImpl(keeper *Keeper) types.QueryServer
- func StripNonAckersFromRound(round *types.VoteRound)
- func ThresholdForN(n int) (int, error)
- func ValidateEntryBounds(round *types.VoteRound, proposalId, voteDecision uint32) error
- type BankKeeper
- type Keeper
- func (k *Keeper) AddToTally(kvStore store.KVStore, roundID []byte, proposalID, decision uint32, ...) error
- func (k *Keeper) AppendCommitment(kvStore store.KVStore, roundID, commitment []byte) (uint64, error)
- func (k *Keeper) CheckAndSetNullifier(kvStore store.KVStore, nfType types.NullifierType, roundID, nullifier []byte) error
- func (k *Keeper) CheckNullifiersUnique(ctx context.Context, nfType types.NullifierType, roundID []byte, ...) error
- func (k *Keeper) CollectNonEmptyAccumulators(kvStore store.KVStore, round *types.VoteRound) (map[[2]uint32]bool, error)
- func (k *Keeper) ComputeTreeRoot(kvStore store.KVStore, roundID []byte, nextIndex, blockHeight uint64) ([]byte, error)
- func (k *Keeper) CountPartialDecryptionValidators(kvStore store.KVStore, roundID []byte) (int, error)
- func (k Keeper) DeletePallasKeyReverse(kvStore store.KVStore, pallasPk []byte) error
- func (k *Keeper) ExportGenesis(kvStore store.KVStore) (*types.GenesisState, error)
- func (k *Keeper) FindFirstPendingRound(kvStore store.KVStore, ceremonyStatus types.CeremonyStatus) (*types.VoteRound, error)
- func (k *Keeper) GetAllTallyResults(kvStore store.KVStore, roundID []byte) ([]*types.TallyResult, error)
- func (k *Keeper) GetAuthority() string
- func (k *Keeper) GetBlockLeafIndex(kvStore store.KVStore, roundID []byte, height uint64) (startIndex, count uint64, found bool, err error)
- func (k *Keeper) GetCeremonyState(kvStore store.KVStore) (*types.CeremonyState, error)
- func (k *Keeper) GetCommitmentLeaves(kvStore store.KVStore, roundID []byte, fromHeight, toHeight uint64) ([]*types.BlockCommitments, error)
- func (k *Keeper) GetCommitmentRootAtHeight(kvStore store.KVStore, roundID []byte, height uint64) ([]byte, error)
- func (k *Keeper) GetCommitmentTreeState(kvStore store.KVStore, roundID []byte) (*types.CommitmentTreeState, error)
- func (k Keeper) GetEligibleValidators(ctx context.Context, kvStore store.KVStore) ([]*types.ValidatorPallasKey, error)
- func (k *Keeper) GetMinCeremonyValidators(kvStore store.KVStore) (uint32, error)
- func (k Keeper) GetPallasKey(kvStore store.KVStore, valoperAddr string) (*types.ValidatorPallasKey, error)
- func (k Keeper) GetPallasKeyOwner(kvStore store.KVStore, pallasPk []byte) (string, error)
- func (k *Keeper) GetPartialDecryption(kvStore store.KVStore, roundID []byte, ...) (*types.PartialDecryptionEntry, error)
- func (k *Keeper) GetPartialDecryptionsForRound(kvStore store.KVStore, roundID []byte) (map[uint64][]PartialDecryptionWithIndex, error)
- func (k *Keeper) GetPendingRoundWithCeremony(kvStore store.KVStore, roundID []byte, wantCeremony types.CeremonyStatus) (*types.VoteRound, error)
- func (k *Keeper) GetProposalTally(kvStore store.KVStore, roundID []byte, proposalID uint32) (map[uint32][]byte, error)
- func (k *Keeper) GetShareCount(kvStore store.KVStore, roundID []byte, proposalID, decision uint32) (uint64, error)
- func (k *Keeper) GetTally(kvStore store.KVStore, roundID []byte, proposalID, decision uint32) ([]byte, error)
- func (k *Keeper) GetTallyResult(kvStore store.KVStore, roundID []byte, proposalID, decision uint32) (*types.TallyResult, error)
- func (k *Keeper) GetVoteManagers(kvStore store.KVStore) (*types.VoteManagerSet, error)
- func (k *Keeper) GetVoteRound(kvStore store.KVStore, roundID []byte) (*types.VoteRound, error)
- func (k *Keeper) GetVoteSummary(kvStore store.KVStore, roundID []byte) (*types.QueryVoteSummaryResponse, error)
- func (k *Keeper) HasNullifier(ctx store.KVStore, nfType types.NullifierType, roundID, nullifier []byte) (bool, error)
- func (k Keeper) HasPallasKey(kvStore store.KVStore, valoperAddr string) (bool, error)
- func (k *Keeper) HasPartialDecryptionsFromValidator(kvStore store.KVStore, roundID []byte, validatorIndex uint32) (bool, error)
- func (k *Keeper) HasPendingRound(kvStore store.KVStore) (bool, error)
- func (k *Keeper) IncrementShareCount(kvStore store.KVStore, roundID []byte, proposalID, decision uint32) error
- func (k *Keeper) InitGenesis(kvStore store.KVStore, genesis *types.GenesisState) error
- func (k *Keeper) IsValidator(ctx context.Context, address string) bool
- func (k *Keeper) IsValidatorInPendingCeremony(kvStore store.KVStore, valAddr string) (bool, error)
- func (k *Keeper) IsVoteManager(ctx context.Context, addr string) (bool, error)
- func (k *Keeper) IterateActiveRounds(kvStore store.KVStore, cb func(round *types.VoteRound) bool) error
- func (k Keeper) IterateAllPallasKeys(kvStore store.KVStore, cb func(vpk *types.ValidatorPallasKey) bool) error
- func (k *Keeper) IterateAllRounds(kvStore store.KVStore, cb func(round *types.VoteRound) bool) error
- func (k *Keeper) IteratePendingRounds(kvStore store.KVStore, cb func(round *types.VoteRound) bool) error
- func (k *Keeper) IterateTallyingRounds(kvStore store.KVStore, cb func(round *types.VoteRound) bool) error
- func (k *Keeper) Logger() log.Logger
- func (k *Keeper) OpenKVStore(ctx context.Context) store.KVStore
- func (k Keeper) RegisterPallasKeyCore(kvStore store.KVStore, valAddr string, pallasPk []byte) error
- func (k Keeper) RotatePallasKeyCore(kvStore store.KVStore, valAddr string, newPallasPk []byte) (oldPallasPk []byte, err error)
- func (k *Keeper) SetBlockLeafIndex(kvStore store.KVStore, roundID []byte, height, startIndex, count uint64) error
- func (k *Keeper) SetCeremonyState(kvStore store.KVStore, state *types.CeremonyState) error
- func (k *Keeper) SetCommitmentRootAtHeight(kvStore store.KVStore, roundID []byte, height uint64, root []byte) error
- func (k *Keeper) SetCommitmentTreeState(kvStore store.KVStore, roundID []byte, state *types.CommitmentTreeState) error
- func (k *Keeper) SetMinCeremonyValidators(kvStore store.KVStore, val uint32) error
- func (k *Keeper) SetNullifier(ctx store.KVStore, nfType types.NullifierType, roundID, nullifier []byte) error
- func (k Keeper) SetPallasKey(kvStore store.KVStore, vpk *types.ValidatorPallasKey) error
- func (k *Keeper) SetPartialDecryptions(kvStore store.KVStore, roundID []byte, validatorIndex uint32, ...) error
- func (k *Keeper) SetTallyResult(kvStore store.KVStore, result *types.TallyResult) error
- func (k *Keeper) SetVoteManagers(kvStore store.KVStore, set *types.VoteManagerSet) error
- func (k *Keeper) SetVoteRound(kvStore store.KVStore, round *types.VoteRound) error
- func (k *Keeper) UpdateVoteRoundStatus(kvStore store.KVStore, roundID []byte, newStatus types.SessionStatus) error
- func (k *Keeper) ValidateProposalId(kvStore store.KVStore, roundID []byte, proposalId uint32) error
- func (k *Keeper) ValidateProposerIsCreator(ctx context.Context, creator, msgName string) error
- func (k *Keeper) ValidateRoundActive(ctx context.Context, roundID []byte) error
- func (k *Keeper) ValidateRoundForTally(ctx context.Context, roundID []byte) error
- func (k *Keeper) ValidateRoundForVoting(ctx context.Context, roundID []byte) error
- func (k *Keeper) ValidateTallyCompleteness(kvStore store.KVStore, round *types.VoteRound, entries []*types.TallyEntry) error
- func (k *Keeper) ValidateVoteDecision(kvStore store.KVStore, roundID []byte, proposalId, voteDecision uint32) error
- func (k *Keeper) ValidateVoteManagerOnly(ctx context.Context, creator string) error
- type PartialDecryptionWithIndex
- type StakingKeeper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccumulatorKey ¶
AccumulatorKey packs a (proposalID, decision) pair into a single uint64 for use as a map key. proposalID occupies the high 32 bits.
func AppendCeremonyLog ¶
AppendCeremonyLog appends a timestamped entry to the round's ceremony log. The entry is prefixed with the block height for chronological context.
func FindAckInRoundCeremony ¶
FindAckInRoundCeremony returns the index and true if valAddr has an ack entry in the round's ceremony, or (-1, false) otherwise.
func FindContributionInRound ¶ added in v0.4.0
FindContributionInRound returns the DKGContribution and true if valAddr has already submitted a contribution in this round, or (nil, false) otherwise.
func FindValidatorInRoundCeremony ¶
func FindValidatorInRoundCeremony(round *types.VoteRound, valAddr string) (*types.ValidatorPallasKey, bool)
FindValidatorInRoundCeremony returns the ValidatorPallasKey and true if valAddr is found in the round's ceremony_validators list, or (nil, false) otherwise. Callers that need the original Shamir evaluation point must use the returned validator's ShamirIndex field rather than the array position, which changes after StripNonAckersFromRound removes non-acking validators.
func HalfAcked ¶
HalfAcked returns true if at least 1/2 of round ceremony validators have acknowledged. Uses integer arithmetic: acks * 2 >= validators.
func NewMsgServerImpl ¶
NewMsgServerImpl returns an implementation of the vote MsgServer interface.
func NewQueryServerImpl ¶
func NewQueryServerImpl(keeper *Keeper) types.QueryServer
NewQueryServerImpl returns an implementation of the vote QueryServer interface.
func StripNonAckersFromRound ¶
StripNonAckersFromRound removes non-acking validators from the round's CeremonyValidators and DkgContributions. After this call, only validators with a matching ack remain.
func ThresholdForN ¶ added in v0.3.1
ThresholdForN computes the required threshold t = ceil(n/2) for n validators. This matches the ack requirement (HalfAcked) so that the set of validators that survives ceremony stripping is always large enough to reconstruct the EA key during tally.
For n = 1 returns t = 1 (trivial single-share scheme with no threshold security — used for local testing). Returns an error if n < 1.
func ValidateEntryBounds ¶
ValidateEntryBounds checks that proposalId and voteDecision are within the valid ranges for the given round. Unlike ValidateProposalId and ValidateVoteDecision, this takes the already-loaded round to avoid redundant KV lookups in hot loops (SubmitTally, SubmitPartialDecryption).
Types ¶
type BankKeeper ¶
type BankKeeper interface {
GetBalance(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin
SendCoins(ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error
}
BankKeeper defines the bank module interface needed by the vote module. Used by MsgAuthorizedSend to move coins; standard bank.MsgSend is blocked at the ante handler so all transfers flow through this path.
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper of the vote module store.
KV Store Layout:
0x01 || type || round_id || nf -> []byte{1} (nullifier set, scoped by type+round)
0x14 || round_id || 0x02 || uint64 index -> commitment_bytes (per-round commitment tree)
0x14 || round_id || 0x03 || uint64 height -> root_bytes (per-round tree roots)
0x04 || round_id -> VoteRound protobuf (vote round data)
0x05 || round_id || proposal_id || decision -> []byte (64 bytes: ElGamal ciphertext)
0x14 || round_id || 0x06 -> CommitmentTreeState protobuf (per-round tree metadata)
Uses google.golang.org/protobuf/proto for binary marshal (our types are generated by protoc-gen-go, not gogoproto).
func NewKeeper ¶
func NewKeeper( storeService store.KVStoreService, authority string, logger log.Logger, stakingKeeper StakingKeeper, bankKeeper BankKeeper, ) *Keeper
NewKeeper creates a new vote module keeper.
func (*Keeper) AddToTally ¶
func (k *Keeper) AddToTally(kvStore store.KVStore, roundID []byte, proposalID, decision uint32, encShareBytes []byte) error
AddToTally accumulates an ElGamal ciphertext (encShareBytes, 64 bytes) into the tally for a (round, proposal, decision) tuple using HomomorphicAdd.
func (*Keeper) AppendCommitment ¶
func (k *Keeper) AppendCommitment(kvStore store.KVStore, roundID, commitment []byte) (uint64, error)
AppendCommitment appends a commitment to a round's tree and returns its index.
func (*Keeper) CheckAndSetNullifier ¶
func (k *Keeper) CheckAndSetNullifier(kvStore store.KVStore, nfType types.NullifierType, roundID, nullifier []byte) error
CheckAndSetNullifier atomically checks that a nullifier has not been recorded and then records it. Returns ErrDuplicateNullifier if already spent.
func (*Keeper) CheckNullifiersUnique ¶
func (k *Keeper) CheckNullifiersUnique(ctx context.Context, nfType types.NullifierType, roundID []byte, nullifiers [][]byte) error
CheckNullifiersUnique verifies that none of the provided nullifiers have already been recorded in the type-scoped, round-scoped nullifier set. This runs on every check including RecheckTx, because nullifiers may have been consumed by the newly committed block.
func (*Keeper) CollectNonEmptyAccumulators ¶
func (k *Keeper) CollectNonEmptyAccumulators(kvStore store.KVStore, round *types.VoteRound) (map[[2]uint32]bool, error)
CollectNonEmptyAccumulators returns the set of (proposalID, decision) pairs that have non-empty tally accumulators for the given round. Used by SubmitTally and ProcessProposal to verify that a tally submission covers every accumulator — preventing a malicious proposer from finalizing a round with missing entries.
func (*Keeper) ComputeTreeRoot ¶
func (k *Keeper) ComputeTreeRoot(kvStore store.KVStore, roundID []byte, nextIndex, blockHeight uint64) ([]byte, error)
ComputeTreeRoot returns the Poseidon Merkle root for a round's tree at the given block height.
On cold start (handle == nil) the behaviour depends on state.Height:
- Height > 0 (restart): shard data exists in KV. Handle is created at nextIndex and ShardTree restores lazily from KV — O(1).
- Height == 0 (first boot): no shard data yet. Handle is created at 0 and all leaves are replayed via AppendFromKV — O(N) but unavoidable.
On subsequent calls only the delta leaves added since the last call are appended — O(k) per block where k = new leaves that block.
A checkpoint is created only when delta leaves were actually appended. Cold start and no-new-leaves blocks skip the checkpoint; latest_checkpoint is restored from KV on handle creation so Root() is always correct.
func (*Keeper) CountPartialDecryptionValidators ¶
func (k *Keeper) CountPartialDecryptionValidators( kvStore store.KVStore, roundID []byte, ) (int, error)
CountPartialDecryptionValidators returns the number of distinct validators that have submitted partial decryptions for the given round. Used by the tally combiner to check whether the threshold t has been reached.
func (Keeper) DeletePallasKeyReverse ¶ added in v0.4.1
DeletePallasKeyReverse removes the reverse-lookup index entry for the given Pallas public key. Used during key rotation to clean up the old PK's entry.
func (*Keeper) ExportGenesis ¶
ExportGenesis returns the current vote module genesis state by iterating all KV prefixes. The exported state can be imported by InitGenesis to fully restore the module.
func (*Keeper) FindFirstPendingRound ¶
func (k *Keeper) FindFirstPendingRound(kvStore store.KVStore, ceremonyStatus types.CeremonyStatus) (*types.VoteRound, error)
FindFirstPendingRound returns the first VoteRound with status PENDING and the given CeremonyStatus, or nil if none found.
func (*Keeper) GetAllTallyResults ¶
func (k *Keeper) GetAllTallyResults(kvStore store.KVStore, roundID []byte) ([]*types.TallyResult, error)
GetAllTallyResults retrieves all finalized tally results for a vote round. Results are returned in key order (proposal_id, then decision).
func (*Keeper) GetAuthority ¶
GetAuthority returns the module's authority address.
func (*Keeper) GetBlockLeafIndex ¶
func (k *Keeper) GetBlockLeafIndex(kvStore store.KVStore, roundID []byte, height uint64) (startIndex, count uint64, found bool, err error)
GetBlockLeafIndex returns the (start_index, count) for leaves appended at the given block height for a round. Returns (0, 0, false) if no mapping exists.
func (*Keeper) GetCeremonyState ¶
GetCeremonyState retrieves the singleton ceremony state from the KV store. Returns nil, nil if no ceremony has been initialized yet.
func (*Keeper) GetCommitmentLeaves ¶
func (k *Keeper) GetCommitmentLeaves(kvStore store.KVStore, roundID []byte, fromHeight, toHeight uint64) ([]*types.BlockCommitments, error)
GetCommitmentLeaves returns the commitment leaves that were appended during blocks from fromHeight to toHeight (inclusive) for a round.
func (*Keeper) GetCommitmentRootAtHeight ¶
func (k *Keeper) GetCommitmentRootAtHeight(kvStore store.KVStore, roundID []byte, height uint64) ([]byte, error)
GetCommitmentRootAtHeight returns the commitment tree root stored at a specific height for a round.
func (*Keeper) GetCommitmentTreeState ¶
func (k *Keeper) GetCommitmentTreeState(kvStore store.KVStore, roundID []byte) (*types.CommitmentTreeState, error)
GetCommitmentTreeState returns the current state of the commitment tree for a round.
func (Keeper) GetEligibleValidators ¶
func (k Keeper) GetEligibleValidators(ctx context.Context, kvStore store.KVStore) ([]*types.ValidatorPallasKey, error)
GetEligibleValidators returns all bonded validators that have a registered Pallas PK. Used when creating a round to snapshot the ceremony participants.
func (*Keeper) GetMinCeremonyValidators ¶ added in v0.2.0
GetMinCeremonyValidators reads the minimum ceremony validator count from KV. Returns defaultMinCeremonyValidators (1) if the key has not been set.
func (Keeper) GetPallasKey ¶
func (k Keeper) GetPallasKey(kvStore store.KVStore, valoperAddr string) (*types.ValidatorPallasKey, error)
GetPallasKey retrieves a validator's Pallas PK from the global registry. Returns nil, nil if the key has not been registered.
func (Keeper) GetPallasKeyOwner ¶ added in v0.4.0
GetPallasKeyOwner returns the validator address that registered the given Pallas public key, or "" if the key is not registered.
func (*Keeper) GetPartialDecryption ¶
func (k *Keeper) GetPartialDecryption( kvStore store.KVStore, roundID []byte, validatorIndex, proposalID, decision uint32, ) (*types.PartialDecryptionEntry, error)
GetPartialDecryption retrieves a single stored partial decryption entry. Returns nil, nil if no entry exists for the given key.
func (*Keeper) GetPartialDecryptionsForRound ¶
func (k *Keeper) GetPartialDecryptionsForRound( kvStore store.KVStore, roundID []byte, ) (map[uint64][]PartialDecryptionWithIndex, error)
GetPartialDecryptionsForRound returns all stored partial decryptions for a round, grouped by accumulator. The map key is AccumulatorKey(proposalID, decision). Each slice element carries the validator_index and the D_i point bytes so the tally combiner can build shamir.PartialDecryption values directly.
func (*Keeper) GetPendingRoundWithCeremony ¶
func (k *Keeper) GetPendingRoundWithCeremony(kvStore store.KVStore, roundID []byte, wantCeremony types.CeremonyStatus) (*types.VoteRound, error)
GetPendingRoundWithCeremony loads a vote round and verifies it is PENDING with the specified ceremony status. Used by Deal (REGISTERING) and Ack (DEALT).
func (*Keeper) GetProposalTally ¶
func (k *Keeper) GetProposalTally(kvStore store.KVStore, roundID []byte, proposalID uint32) (map[uint32][]byte, error)
GetProposalTally returns all tallied ciphertexts for a (round, proposal) pair, keyed by decision ID. Iterates over the tally prefix 0x05 || round_id || proposal_id to collect all decision → ciphertext entries.
func (*Keeper) GetShareCount ¶
func (k *Keeper) GetShareCount(kvStore store.KVStore, roundID []byte, proposalID, decision uint32) (uint64, error)
GetShareCount returns the number of shares revealed for a (round, proposal, decision) tuple. Returns 0 if no shares have been revealed.
func (*Keeper) GetTally ¶
func (k *Keeper) GetTally(kvStore store.KVStore, roundID []byte, proposalID, decision uint32) ([]byte, error)
GetTally returns the accumulated ciphertext tally for a (round, proposal, decision) tuple. Returns nil if no tally exists for this tuple.
func (*Keeper) GetTallyResult ¶
func (k *Keeper) GetTallyResult(kvStore store.KVStore, roundID []byte, proposalID, decision uint32) (*types.TallyResult, error)
GetTallyResult retrieves a finalized tally result for one (round, proposal, decision) tuple.
func (*Keeper) GetVoteManagers ¶ added in v0.5.8
GetVoteManagers retrieves the vote-manager set from the KV store. Returns nil, nil if no vote-manager set has been installed yet.
func (*Keeper) GetVoteRound ¶
GetVoteRound retrieves a vote round by its ID.
func (*Keeper) GetVoteSummary ¶
func (k *Keeper) GetVoteSummary(kvStore store.KVStore, roundID []byte) (*types.QueryVoteSummaryResponse, error)
GetVoteSummary builds a denormalized QueryVoteSummaryResponse for a vote round, including proposals with option labels, ballot counts, and (if finalized) totals.
func (*Keeper) HasNullifier ¶
func (k *Keeper) HasNullifier(ctx store.KVStore, nfType types.NullifierType, roundID, nullifier []byte) (bool, error)
HasNullifier checks if a nullifier has already been recorded in the given type-scoped, round-scoped nullifier set.
func (Keeper) HasPallasKey ¶
HasPallasKey returns true if the validator has a registered Pallas PK.
func (*Keeper) HasPartialDecryptionsFromValidator ¶
func (k *Keeper) HasPartialDecryptionsFromValidator( kvStore store.KVStore, roundID []byte, validatorIndex uint32, ) (bool, error)
HasPartialDecryptionsFromValidator returns true if the given validator has already submitted any partial decryption entries for this round. Uses a prefix scan over 0x12 || round_id || validator_index.
func (*Keeper) HasPendingRound ¶
HasPendingRound returns true if any stored VoteRound has status PENDING.
func (*Keeper) IncrementShareCount ¶
func (k *Keeper) IncrementShareCount(kvStore store.KVStore, roundID []byte, proposalID, decision uint32) error
IncrementShareCount atomically increments the share reveal count for a (round, proposal, decision) tuple. If no count exists yet, writes 1.
func (*Keeper) InitGenesis ¶
InitGenesis initializes the vote module state from a genesis state.
func (*Keeper) IsValidator ¶
IsValidator checks whether the given address is a bonded validator.
func (*Keeper) IsValidatorInPendingCeremony ¶ added in v0.4.1
IsValidatorInPendingCeremony returns true if the given validator address appears in the ceremony_validators list of any PENDING round. Used to block Pallas key rotation while the validator is participating in an active ceremony.
func (*Keeper) IsVoteManager ¶ added in v0.5.8
IsVoteManager reports whether addr is a current vote manager. Comparison is on the canonical bech32 form; invalid bech32 returns (false, nil).
func (*Keeper) IterateActiveRounds ¶
func (k *Keeper) IterateActiveRounds(kvStore store.KVStore, cb func(round *types.VoteRound) bool) error
IterateActiveRounds iterates over rounds with SESSION_STATUS_ACTIVE.
func (Keeper) IterateAllPallasKeys ¶
func (k Keeper) IterateAllPallasKeys(kvStore store.KVStore, cb func(vpk *types.ValidatorPallasKey) bool) error
IterateAllPallasKeys iterates over all entries in the global Pallas PK registry. The callback receives each ValidatorPallasKey; returning true stops iteration.
func (*Keeper) IterateAllRounds ¶
func (k *Keeper) IterateAllRounds(kvStore store.KVStore, cb func(round *types.VoteRound) bool) error
IterateAllRounds iterates over all stored VoteRounds and calls the callback for each round. The callback receives a pointer to the round; returning true stops iteration.
This performs a full prefix scan of VoteRoundPrefix. This is acceptable because the expected cardinality is low (a handful of rounds).
func (*Keeper) IteratePendingRounds ¶
func (k *Keeper) IteratePendingRounds(kvStore store.KVStore, cb func(round *types.VoteRound) bool) error
IteratePendingRounds iterates over rounds with SESSION_STATUS_PENDING.
func (*Keeper) IterateTallyingRounds ¶
func (k *Keeper) IterateTallyingRounds(kvStore store.KVStore, cb func(round *types.VoteRound) bool) error
IterateTallyingRounds iterates over rounds with SESSION_STATUS_TALLYING.
func (*Keeper) OpenKVStore ¶
OpenKVStore opens the module's KV store from a context.
func (Keeper) RegisterPallasKeyCore ¶
RegisterPallasKeyCore validates, deduplicates, and stores a Pallas PK for the given validator address. Shared by RegisterPallasKey and CreateValidatorWithPallasKey.
Uniqueness is enforced in two dimensions:
- A validator address may only register once (forward index).
- A Pallas public key may only be registered by one validator (reverse index).
Rejecting duplicate PKs prevents colluding validators from sharing a secret key and breaking threshold security during DKG.
func (Keeper) RotatePallasKeyCore ¶ added in v0.4.1
func (k Keeper) RotatePallasKeyCore(kvStore store.KVStore, valAddr string, newPallasPk []byte) (oldPallasPk []byte, err error)
RotatePallasKeyCore replaces a validator's registered Pallas PK with a new one. The validator must already have a registered key (use RegisterPallasKeyCore for first-time registration). The new PK must differ from the current one and pass global uniqueness checks. Returns the old PK for audit logging.
func (*Keeper) SetBlockLeafIndex ¶
func (k *Keeper) SetBlockLeafIndex(kvStore store.KVStore, roundID []byte, height, startIndex, count uint64) error
SetBlockLeafIndex records the range of commitment leaves that were appended during a specific block height for a round.
func (*Keeper) SetCeremonyState ¶
SetCeremonyState stores the singleton ceremony state in the KV store.
func (*Keeper) SetCommitmentRootAtHeight ¶
func (k *Keeper) SetCommitmentRootAtHeight(kvStore store.KVStore, roundID []byte, height uint64, root []byte) error
SetCommitmentRootAtHeight stores the commitment tree root for a specific height and round.
func (*Keeper) SetCommitmentTreeState ¶
func (k *Keeper) SetCommitmentTreeState(kvStore store.KVStore, roundID []byte, state *types.CommitmentTreeState) error
SetCommitmentTreeState stores the commitment tree state for a round.
func (*Keeper) SetMinCeremonyValidators ¶ added in v0.2.0
SetMinCeremonyValidators writes the minimum ceremony validator count to KV as a 4-byte big-endian uint32.
func (*Keeper) SetNullifier ¶
func (k *Keeper) SetNullifier(ctx store.KVStore, nfType types.NullifierType, roundID, nullifier []byte) error
SetNullifier records a nullifier as spent in the given type-scoped, round-scoped nullifier set.
func (Keeper) SetPallasKey ¶
SetPallasKey stores a validator's Pallas PK in the global registry and writes the reverse-lookup index (PK -> validator address) used to enforce cross-validator key uniqueness.
func (*Keeper) SetPartialDecryptions ¶
func (k *Keeper) SetPartialDecryptions( kvStore store.KVStore, roundID []byte, validatorIndex uint32, entries []*types.PartialDecryptionEntry, ) error
SetPartialDecryptions stores all entries from a MsgSubmitPartialDecryption. Each entry is keyed by (roundID, validatorIndex, proposalID, decision). Returns an error if any individual write fails; the caller is responsible for transactional behaviour (the Cosmos SDK store is transactional per block).
func (*Keeper) SetTallyResult ¶
SetTallyResult stores a finalized tally result for one (round, proposal, decision) tuple.
func (*Keeper) SetVoteManagers ¶ added in v0.5.8
SetVoteManagers stores the vote-manager set in the KV store. Addresses are normalized and deduplicated before persist so every read returns canonical bech32, even if callers passed mixed-case or uncanonical forms.
func (*Keeper) SetVoteRound ¶
SetVoteRound stores a vote round.
func (*Keeper) UpdateVoteRoundStatus ¶
func (k *Keeper) UpdateVoteRoundStatus(kvStore store.KVStore, roundID []byte, newStatus types.SessionStatus) error
UpdateVoteRoundStatus reads a vote round, sets its status, and writes it back.
func (*Keeper) ValidateProposalId ¶
ValidateProposalId checks that proposalId is valid for the round (1-indexed). This 1-indexed value is passed directly to the ZKP circuit as the bit-position in the proposal_authority bitmask. The circuit's non-zero gate rejects 0, aligning on-chain validation with circuit semantics.
func (*Keeper) ValidateProposerIsCreator ¶
ValidateProposerIsCreator checks that a proposer-injected message is only submitted during block execution (not via mempool) and that creator matches the current block proposer. msgName is used in error messages for diagnostics (e.g. "MsgContributeDKG").
func (*Keeper) ValidateRoundActive ¶
ValidateRoundActive checks that a vote round exists and has not expired. Deprecated: Use ValidateRoundForVoting instead. Kept as a thin wrapper to minimize churn in existing callers.
func (*Keeper) ValidateRoundForTally ¶
ValidateRoundForTally checks that a vote round exists and is in TALLYING state.
func (*Keeper) ValidateRoundForVoting ¶
ValidateRoundForVoting checks that a vote round exists, has ACTIVE status, and has not expired (belt-and-suspenders: EndBlocker may not have run yet this block).
func (*Keeper) ValidateTallyCompleteness ¶
func (k *Keeper) ValidateTallyCompleteness(kvStore store.KVStore, round *types.VoteRound, entries []*types.TallyEntry) error
ValidateTallyCompleteness checks that a set of tally entries covers every non-empty accumulator in the round. Returns ErrTallyMismatch with the first missing (proposal, decision) pair if incomplete.
func (*Keeper) ValidateVoteDecision ¶
func (k *Keeper) ValidateVoteDecision(kvStore store.KVStore, roundID []byte, proposalId, voteDecision uint32) error
ValidateVoteDecision checks that voteDecision is a valid option index for the given proposal within the round. Proposals are 1-indexed; vote decisions are 0-indexed into the proposal's options list.
type PartialDecryptionWithIndex ¶
type PartialDecryptionWithIndex struct {
ValidatorIndex uint32 // 1-based Shamir evaluation point (matches Share.Index)
PartialDecrypt []byte // 32-byte compressed Pallas point: D_i = share_i * C1
DleqProof []byte // reserved for Step 2; empty in Step 1
}
PartialDecryptionWithIndex pairs a validator's 1-based Shamir index with the partial decryption data for one (proposal_id, vote_decision) accumulator. Returned by GetPartialDecryptionsForRound to give the tally combiner direct access to (index, D_i) without requiring it to re-parse KV keys.
type StakingKeeper ¶
type StakingKeeper interface {
GetValidator(ctx context.Context, addr sdk.ValAddress) (stakingtypes.Validator, error)
GetValidatorByConsAddr(ctx context.Context, consAddr sdk.ConsAddress) (stakingtypes.Validator, error)
Jail(ctx context.Context, consAddr sdk.ConsAddress) error
Unjail(ctx context.Context, consAddr sdk.ConsAddress) error
}
StakingKeeper defines the staking module interface needed by the vote module.
Source Files
¶
- debug_verify_stub.go
- genesis.go
- keeper.go
- keeper_ceremony.go
- keeper_min_validators.go
- keeper_pallas_registry.go
- keeper_partial_decrypt.go
- keeper_tally.go
- keeper_vote_managers.go
- keeper_voting.go
- msg_server.go
- msg_server_ceremony.go
- msg_server_send.go
- msg_server_tally_decrypt.go
- query_server.go
- tree_root_poseidon.go