PeaceFounder.Server.Controllers
Registrar
PeaceFounder.Server.Controllers.Registrar — Typestruct Registrar
metadata::Ref{Vector{UInt8}}
tickets::Vector{Ticket}
signer::Signer
hmac::HMAC
endRepresents a state for token registrar service. To initialize the service it's necessary to create a signer who can issue a valid admisssion certificates and a secret key with which a recruit client can exchange authorized messages. See also method generate(Registrar, spec).
Metadata is used as means to securelly deliver to the client most recent server specification.
Interface: hmac, hasher, key, id, tickets, in, enlist!, admit!, isadmitted
PeaceFounder.Server.Controllers.Ticket — Typemutable struct Ticket
const ticketid::TicketID
timestamp::DateTime
attempt::UInt8
token::Digest
tokenid::String #
admission::Union{Admission, Nothing}
endRepresents a ticket state for ticket with ticketid. timestamp represents time when the ticket have been issued by a registrar client in authorization system of choice, for instance, Registrars.jl; attempt is a counter with which token can be reset which is calculated with token(ticketid, attempt, hmac). Lastly admission contains a certified member pseudonym which was authetificated by the user with token.
Base.in — Methodin(ticketid::TicketID, registrar::Registrar)::BoolReturn true if there already is a ticket with ticketid.
PeaceFounder.Core.Model.generate — Methodgenerate(Registrar, spec::CryptoSpec)Generate a new token registrar with unique signer and athorization key.
PeaceFounder.Core.ProtocolSchema.isadmitted — Methodisadmitted(ticketid::TicketID, registrar::Registrar)Check whether a ticket is already admitted. Returns false when either ticket is nonexistent or it's admission is nothing.
PeaceFounder.Server.Controllers.admit! — Methodadmit!(registrar::Registrar, id::Pseudonym, ticketid::TicketID)::AdmissionAttempt to admit an identity pseudonym id for ticket ticketid. Authorization is expected to happen at the service layer using provided token in the invite. If a ticket is already registered return admission if it matches the provided id. Otherwise throe an error.
PeaceFounder.Server.Controllers.enlist! — Methodenlist!(registrar::Registrar, ticketid::TicketID, timestamp::DateTime; route::URI=registrar.route)::InviteRegisters a new ticket with given TicketID and returns an invite. If ticket is already registered the same invite is returned. Throws an error when ticket is already registered.
PeaceFounder.Server.Controllers.hmac — Methodhmac(x)::HMACReturn HMAC authorizer from a given object.
PeaceFounder.Server.Controllers.set_demehash! — Methodset_demespec!(registrar::Registrar, spec::Union{Digest, DemeSpec})Replace metadata for a registrar. Note when data is replaced all unfinalized tokens need to be flushed.
PeaceFounder.Server.Controllers.tickets — Methodtickets(registrar::Registrar)::Vector{TicketID}Return a list of registered ticket ids.
PeaceFounder.Server.Controllers.token — Methodtoken(ticketid::TicketID, hmac::HMAC)Compute a recruit token for a given ticketid. Calculates it as token=Hash(Hash(0|key)|attempt|ticketid) where attempt is a counter for which token is issued.
Note: the token generation from key is made in order to support it's local computation on a remote server where QR code for registration is shown within organization website.
BraidChain
PeaceFounder.Server.Controllers.BraidChainController — Typestruct BraidChain
members::Set{Pseudonym}
ledger::BraidChainLedger
spec::DemeSpec
generator::Generator
tree::HistoryTree
commit::Union{Commit{ChainState}, Nothing}
endRepresents a braidchain ledger with it's associated state. Can be instantitated with a demespec file using BraidChain(::DemeSpec) method.
Interface: push!, record!, state, length, list, select, generator, commit, commit_index, ledger, leaf, root, ack_leaf, ack_root, members, commit!
Base.push! — Methodpush!(ledger::BraidChainController, t::Transaction)Add an element to the BraidChainController bypassing transaction verification with the chain. This should only be used when the ledger is loaded from a trusted source like a local disk or when final root hash is validated with a trusted source.
HistoryTrees.leaf — Methodleaf(ledger::BraidChainController, N::Int)::DigestReturn a ledger's element digest at given index.
HistoryTrees.root — Methodroot(ledger::BraidChainController[, N::Int])::DigestReturn a ledger root digest. In case when index is not given a current index is used.
PeaceFounder.Core.Model.commit — Methodcommit(ledger::BraidChainController)Return a current commit for a braichain.
PeaceFounder.Core.Model.generator — Methodgenerator(ledger[, index])Return a generator at braidchain ledger row index. If index is omitted return the current state value.
PeaceFounder.Core.Model.generator — Methodgenerator(ledger::BraidChainController)Return a current relative generator for a braidchain ledger.
PeaceFounder.Core.Model.isbinding — Methodisbinding(chain::BraidChainController, state::ChainState)::BoolCheck that chain state is consistent with braidchain ledger.
PeaceFounder.Core.Model.members — Methodmembers(chain::BraidChainController, [n::Int])::SetReturn a set of member pseudonyms which at given anchor index can participate in voting or braiding.
PeaceFounder.Core.Model.select — Methodselect(T, predicate::Function, ledger::BraidChainController)::Union{T, Nothing}Return a first element from a ledger with a type T which satisfies a predicate.
PeaceFounder.Server.Controllers.ack_leaf — Methodack_leaf(ledger::BraidChainController, index::Int)::AckInclusionReturn a proof for record inclusion with respect to a current braidchain ledger history tree root.
PeaceFounder.Server.Controllers.ack_root — Methodack_root(ledger::BraidChainController, index::Int)Return a proof for the ledger root at given index with respect to the current braidchain ledger history tree root.
PeaceFounder.Server.Controllers.commit! — Methodcommit!(ledger::BraidChainController, signer::Signer)Commit a current braidchain ledger state with a signer's issued cryptographic signature.
PeaceFounder.Server.Controllers.list — Methodlist(T, ledger::BraidChainController)::Vector{Tuple{Int, T}}List braidchain elements with a given type together with their index.
PeaceFounder.Server.Controllers.reset_tree! — Methodreset_tree!(ledger::BraidChainController)Recompute a chain tree hash.
BallotBox and PollingStation
PeaceFounder.Server.Controllers.BallotBoxController — Typemutable struct BallotBoxController
ledger::BallotBoxLedger
voters::Set{Pseudonym} # better than members
collector::Pseudonym
seed::Union{Digest, Nothing}
queue::Vector{Vote}
tree::HistoryTree
commit::Union{Commit{BallotBoxState}, Nothing}
endRepresents a ballot box for a proposal. Contains proposal, a set of eligiable voters a collector who collects the votes and a seed which is selected at random when the voting starts. queue contains a list of valid votes which yet to be comitted to a ledger. A history tree is built on leafs of ledger's receipts (see a receipt method). A commit contains a collector seal on the current ballotbox state.
Interface: reset_tree!, generator, uuid, ledger, spine, index, seed, leaf, root, receipt, commit, tally, set_seed!, ack_leaf, ack_root, ack_cast, commit_index, commit_state, push!, state, validate, record!, commit!
PeaceFounder.Server.Controllers.PollingStation — Typestruct PollingStation
halls::Vector{BallotBoxController}
crypto::CryptoSpec
endRepresents a pooling station which hosts ballotbox ledgers for every proposal collector manages.
Interface: init!, record!, commit!, commit, ack_leaf, ack_root, ack_cast, receipt, spine, ledger, tally, set_seed!
Base.get — Methodget(station::PollingStation, uuid::UUID)::BallotBoxControllerReturn a ballotbox ledger with a provided UUID. If none is found throws an error.
Base.get — Methodget(station::PollingStation, proposal::Digest)::BallotBoxControllerReturn a ballotbox which has proposal with provided digest.
Base.getindex — Methodgetindex(ledger::BallotBoxController, index::Int)::CastRecordReturn a ledger record at provided index.
Base.length — Methodlength(ledger::BallotBoxController)Return a total length of the ledger including uncommited records in the queue.
Base.push! — Methodpush!(ledger::BallotBoxController, record::CastRecord)Push a record to the ledger bypassing integrity checks. Used when loading the ledger from a trusted source such as local disk or an archive with a signed root cheksum.
HistoryTrees.leaf — Methodleaf(ledger::BallotBoxController, N::Int)::DigestReturn a record digest used to form a history tree.
HistoryTrees.root — Methodroot(ledger::BallotBoxController[, N::Int])::DigestCalculate a root for history tree at given index N. If index is not specified returns the current value.
PeaceFounder.Core.Model.commit — Methodcommit(ledger::BallotBoxController)Return a commit for the ballotbox ledger.
PeaceFounder.Core.Model.commit — Methodcommit(station::PollingStation, uuid::UUID)::CommitReturn a ballotbox commit.
PeaceFounder.Core.Model.generator — Methodgenerator(ledger::BallotBoxController)Return a relative generator which members use to sign votes anchored by the proposal.
PeaceFounder.Core.Model.index — Methodindex(ledger::BallotBoxController)Return the current index of the ledger. See also length.
PeaceFounder.Core.Model.isbinding — Methodisbinding(vote::Vote, ack::CastAck, hasher)Check whether acknowledgment is bound to the provided vote.
PeaceFounder.Core.Model.receipt — Methodreceipt(ledger::BallotBoxController, index::Int)::CastReceiptReturn a receipt for a ledger element.
PeaceFounder.Core.Model.receipt — Methodreceipt(station::PollingStation, uuid::UUID, N::Int)::CastReceiptReturn a receipt for a record with index N at ballotbox with uuid.
PeaceFounder.Core.Model.seed — Methodseed(ledger::BallotBoxController)::Union{Digest, Nothing}Return a random selected seed used in the voting.
PeaceFounder.Core.Model.tally — Methodtally(station::PollingStation, uuid::UUID)Compute a tally from ledger records a ballotbox with uuid.
PeaceFounder.Core.Model.uuid — Methoduuid(ledger::BallotBoxController)Return a UUID of the proposal.
PeaceFounder.Core.Model.voters — Methodvoters(ledger::BallotBoxController)Return a list of member pseudonyms with which members authetificate their votes.
PeaceFounder.Server.Controllers.ack_cast — Methodack_cast(ledger::BallotBoxController, index::Int)::CastAckCompute an acknowledgment for record inclusion at index.
PeaceFounder.Server.Controllers.ack_cast — Methodack_cast(station::PollingStation, uuid::UUID, N::Int)::CastAckReturn inclusion proof with receipt and current tree commit for a leaf at index N and ballotbox with uuid.
PeaceFounder.Server.Controllers.ack_leaf — Methodack_leaf(ledger::BallotBoxController, index::Int)::AckInclusionCompute an inclusion proof ::AckInclusion for record element at given index.
PeaceFounder.Server.Controllers.ack_leaf — Methodack_leaf(station::PollingStation, uuid::UUID, N::Int)::AckInclusionReturn history tree inclusion proof for a tree leaf at index N in ballotbox with uuid.
PeaceFounder.Server.Controllers.ack_root — Methodack_root(ledger::BallotBoxController, index::Int)::AckConsistencyCompute a history tree consistency proof at index.
PeaceFounder.Server.Controllers.ack_root — Methodack_root(station::PollingStation, uuid::UUID, N::Int)::AckConsistencyReturn history tree consitency proof tree root at index N in ballotbox with uuid.
PeaceFounder.Server.Controllers.commit! — Methodcommit!(ledger::BallotBoxController[, timestamp::DataTime], signer::Signer; with_tally=nothing)Flushes ballotbox ledger's queue and creates a commit for a current ballotbox ledger state with provided timestamp and signer. A keyword argument with_tally has three values true|false to include or exclude a tally from a commited state and nothing which uses a previous commit preference.
PeaceFounder.Server.Controllers.commit! — Methodcommit!(station::PollingStation, uuid::UUID, collector::Signer; with_tally = nothing)Select a ballotbox with provided uuid and commit it's state with collector.
PeaceFounder.Server.Controllers.commit_index — Methodcommit_index(ledger::BallotBoxController)::Union{Index, Nothing}PeaceFounder.Server.Controllers.commit_state — Methodcommit_state(ledger::BallotBoxController)Return a committed state for a ballotbox ledger.
PeaceFounder.Server.Controllers.init! — Methodinit!(station::PollingStation, proposal::Proposal, voters::Set{Pseudonym}[, collector::Pseudonym])Creates a new ballotbox for given proposal with provided member pseudonyms at a relative generator anchored in the proposal. A collector is optional and provided only when it differs from one specified in the proposal.
PeaceFounder.Server.Controllers.ledger — Methodledger(ballotbox::BallotBoxController)::Vector{CastRecord}Return all records from a ballotbox ledger.
PeaceFounder.Server.Controllers.ledger — Methodledger(station::PollingStation, uuid::UUID)::Vector{CastRecord}Return a vector of records from a ballotbox with uuid.
PeaceFounder.Server.Controllers.record! — Methodrecord!(ledger::BallotBoxController, record::CastRecord)Check the vote in the record for validity and include that in the ledger directly bypassing queue. This method is useful for replaying and debugging ballotbox ledger state changes. See also record!
PeaceFounder.Server.Controllers.record! — Methodrecord!(ledger::BallotBoxController, vote::Vote)Check the vote for validity and pushes it to the queue. Returns an index N at which the vote will be recorded in the ledger. See also push!
PeaceFounder.Server.Controllers.record! — Methodrecord!(station::PollingStation, uuid::UUID, vote::Vote)::IntRecords a vote in a ballotbox with provided proposal UUID. Throws an error if a ballotbox can't be found.
PeaceFounder.Server.Controllers.record! — Methodrecord!(station::PollingStation, uuid::UUID, vote::Vote)::IntRecord a vote in a ballotbox found by proposal diggest stored in the vote. Throws an error if a ballotbox can't be found.
PeaceFounder.Server.Controllers.reset_tree! — Methodreset_tree!(ledger::BallotBoxController)Recompute history tree root and cache from the elements in the ledger. This is a useful for loading the ledger all at once.
PeaceFounder.Server.Controllers.set_seed! — Methodset_seed!(ledger::BallotBoxController, seed::Digest)Set's a seed of the ballotbox.
PeaceFounder.Server.Controllers.set_seed! — Methodset_seed!(station::PollingStation, uuid::UUID, seed::Digest)Sets a seed for a ballotbox with provided uuid.
PeaceFounder.Server.Controllers.spine — Methodspine(ledger::BallotBoxController)::Vector{Digest}Return a history tree leaf vector.
PeaceFounder.Server.Controllers.spine — Methodspine(station::PollingStation, uuid::UUID)::Vector{Digest}Return a leaf vector for a ballotbox with proposal uuid.
PeaceFounder.Server.Controllers.validate — Methodvalidate(ledger::BallotBoxController, vote::Vote)Check that vote can be included in the ballotbox. Is well formed, signed by a member pseudonym and cryptographic signature is valid. Raises error if either of checks fail.