PeaceFounder.Model
Primitives
PeaceFounder.Model.AckConsistency
— Typestruct AckConsistency{T}
proof::ConsistencyProof
commit::Commit{T}
end
Represents an ackknowledgment from the issuer that a root is permanetly included in the ledger. This acknowledgemnt assures that ledger up to index(ack)
is included in the current ledger which has has index index(commit(ack))
. This is useful in a combination with AckInclusion
to privatelly update it's validity rather than asking an explicit element. Also ensures that other elements in the ledger are not being tampered with.
PeaceFounder.Model.AckInclusion
— Typestruct AckInclusion{T}
proof::InclusionProof
commit::Commit{T}
end
Represents an acknowldgment from the issuer that a leaf is permanently included in the ledger. In case the ledger is tampered with this acknowledgement acts as sufficient proof to blame the issuer.
PeaceFounder.Model.Commit
— TypeCommit{T}
state::T
seal::Seal
end
Represents a commited ledger state to which issuer can be held accountable for integrity. It is assumed that T
implements index
and root
necessaary to fix a ledger state.
PeaceFounder.Model.CryptoSpec
— Typestruct CryptoSpec
hasher::Hash
group::Spec
generator::Generator
end
Specification of cryptographic parameters which are used for public key cryptography, message hashing and authetification codes.
PeaceFounder.Model.Digest
— Typestruct Digest
data::Vector{UInt8}
end
A message digest obtained applying a hash function on a message or a document. See method digest
.
PeaceFounder.Model.Generator
— Typestruct Generator
data::Vector{UInt8}
end
Datatype which stores cryptogrpahic group point in standart octet form intended to be used as a base. See also Pseudonym
.
PeaceFounder.Model.HMAC
— Typestruct HMAC
key::Vector{UInt8}
hasher::Hash
end
Represent a hash message authetification code authorizer.
PeaceFounder.Model.Hash
— Typestruct Hash
spec::String
end
A specification for a hasher. See method digest
.
PeaceFounder.Model.Pseudonym
— Typestruct Pseudonym
pk::Vector{UInt8}
end
A datatype which stores public key in canonical standart octet form.
PeaceFounder.Model.Seal
— Typestruct Seal
pbkey::Pseudonym
sig::Signature
end
A wrapper type for a signature which adds a public key of signature issuer. See seal
method.
PeaceFounder.Model.Signer
— Typestruct Signer
spec::CryptoSpec
pbkey::Pseudonym
key::BigInt
end
A signer type. See a method generate(Signer, spec)
for initialization.
Interface: pseudonym
, id
, sign
, seal
, approve
HistoryTrees.leaf
— Methodleaf(ack::AckInclusion)
Access a leaf diggest for which the acknowledgment is made.
HistoryTrees.root
— Methodroot(x::AckConsistency)
Access a root diggest for which the acknowledgment is made.
HistoryTrees.root
— Methodroot(x)::Digest
Return a ledger root hash.
PeaceFounder.Model.commit
— Methodcommit(x)
Access a commit of an object x
.
PeaceFounder.Model.digest
— Methoddigest(message::Vector{UInt8}, hasher::Hash)::Digest
digest(document, spec) = digest(canonicalize(message)::Vector{UInt8}, hasher(spec)::Hash)
Return a resulting digest applying hasher on the given message. When message is not octet string a canonicalize
method is applied first.
PeaceFounder.Model.digest
— Methoddigest(bytes::Vector{UInt8}, hasher::Hash)::Digest
digest(x, spec) = digest(canonicalize(x)::Vector{UInt8}, hasher(spec)::Hash)
Compute a hash digest. When input is not in bytes the canonicalize
method is applied first.
PeaceFounder.Model.generate
— Methodgenerate(Signer, spec::CryptoSpec)::Signer
Generate a unique private key and return a Signer object.
PeaceFounder.Model.generator
— Methodgenerator(crypto::CryptoSpec)::Generator
Return a generator of the specification.
PeaceFounder.Model.generator
— Methodgenerator(spec::Spec)::Generator
Return a generator of spec
.
PeaceFounder.Model.hasher
— Methodhasher(spec)::Hash
Access a hasher function from a given specification.
PeaceFounder.Model.index
— Methodindex(ack::AckConsistency)
Return an index for a root at which the consistency proof is made. To obtain the current ledger index use index(commit(ack))
.
PeaceFounder.Model.index
— Methodindex(ack::AckInclusion)::Int
Return an index at which the leaf is recorded in the ledger. To obtain the current ledger index use index(commit(ack))
.
PeaceFounder.Model.index
— Methodindex(x)::Int
Return an index of a ledger state.
PeaceFounder.Model.isbinding
— Methodisbinding(x, y, spec::Hash)::Bool
isbinding(x, y, spec) = isbinding(x, y, hasher(spec)::Hash)
Check binding of two objects x
and y
. Some general examples:
- Check that a document is bound to it's signature.
- Check that a record is included in the ledger.
- Check that a given object is consistent with a ledger.
PeaceFounder.Model.issuer
— Methodissuer(x)
In case an object x
is cryptographically signed return an issuer of who have issued the signature. See also id
.
PeaceFounder.Model.key
— Methodkey(x)
Access a secret key of an object x
.
PeaceFounder.Model.seal
— Methodseal(message::Vector{UInt8}[, generator::Generator], signer::Signer)::Seal
Sign a bytestring message
with signer's private key and specification and return a signature as a Seal
. When generator is provided it is used as a base for the signature. See also sign
.
PeaceFounder.Model.sign
— Methodsign(digest::Digest[, generator::Generator], signer::Signer)::Signature
Sign a digest as an integer with signer's private key and specification. This method avoids running hashing twice when that is done externally. When generator is provided it is used as a base for the signature.
PeaceFounder.Model.sign
— Methodsign(message::Vector{UInt8}[, generator::Generator], signer::Signer)::Signature
Sign a bytestring message
with signer's private key and specification. When generator is provided it is used as a base for the signature.
PeaceFounder.Model.state
— Methodstate(commit::Commit{T})::T
Return a ledger state. T
implements index
and root
.
PeaceFounder.Model.canonicalize
— FunctionToDo: a well specified encoding is essential here. Binary tree encoding may suffice here. More fancy approach would be to use a DER encoding. Meanwhile JSON shall be used.
PeaceFounder.Model.pseudonym
— Functionpseudonym(signer::Signer, [generator])::Pseudonym
Return a pseudonym of a signer
at a given relative generator
. If generator is not passed returns identity pseudonym. (See also id
)
pseudonym(seal::Seal)::Pseudonym
Return a pseudonym of a seal. Note that it is not equal to identity when the signature is issued on a relative generator.
pseudonym(vote::Vote)::Pseudonym
Return a pseudonym used to seal the vote.
PeaceFounder.Model.id
— Functionid(document)::Pseudonym
Return identity pseudonym of a document
issuer.
id(signer)::Pseudonym
Return identity pseudonym of a signer
.
PeaceFounder.Model.verify
— Functionverify(message, seal::Seal, [generator::Generator], crypto::CryptoSpec)::Bool
verify(message, pk::Pseudonym, sig::Signature, [generator::Generator], crypto::CryptoSpec)::Bool
Verify the cryptographic signature of the message
returning true
if valid. An optional generator
can be given when signature is issued on a relative generator differing from a base specification crypto
.
verify(document[, generator::Generator], crypto::CryptoSpec)::Bool
Verify a cryptographic signature of the document
returning true
if valid.
verify(braidwork::BraidWork, crypto::CryptoSpec)::Bool
Verify a braider issued cryptographic signature for the braidwork
and a zero knowledge proofs. Returns true if both checks succeed.
Admission
PeaceFounder.Model.Admission
— Typestruct Admission
ticketid::TicketID
id::Pseudonym
timestamp::DateTime
approval::Union{Seal, Nothing}
end
Represents an admission certificate for a pseudonym id
.
Interface: approve
, issuer
, id
, ticket
, isadmitted
PeaceFounder.Model.Ticket
— Typemutable struct Ticket
const ticketid::TicketID
timestamp::DateTime
salt::Vector{UInt8}
auth_code::Digest
token::Digest
admission::Union{Admission, Nothing}
end
Represents a ticket state for ticket with ticketid
. timestamp
represents time when the ticket have been issued by a recruiter client in authorization system of choice, for instance, Recruiters.jl; salt
contains a random bytestring generated by the server from which the reccruiter client can derive a token
as token(ticketid, salt, hmac)
. auth_code
is a server generated authetification code for a given salt
and current metadata. Lastly admission
contains a certified member pseudonym which was authetificated by the user with token
.
PeaceFounder.Model.TicketID
— Typestruct TicketID
id::Vector{UInt8}
end
Represents a unique identifier for which a recruit tooken is issued. In case of necessity id
can contain a full document, for instance, registration form, proof of identity and etc. In case a privacy is an issue the id
can contain a unique identifier which can be matched to an identity in an external database.
PeaceFounder.Model.TicketStatus
— Typestruct TicketStatus ticketid::TicketID timestamp::DateTime admission::Union{Nothing, Admission} end
Represents a public state of a ticket. See ticket_status
and isadmitted
methods.
PeaceFounder.Model.TokenRecruiter
— Typestruct TokenRecruiter
metadata::Ref{Vector{UInt8}}
tickets::Vector{Ticket}
signer::Signer
hmac::HMAC
end
Represents a state for token recruiter 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(TokenRecruiter, spec)
.
Metadata is used as means to securelly deliver to the client most recent server specification.
Interface: select
, hmac
, hasher
, key
, id
, tickets
, in
, set_metadata!
, enlist!
, admit!
, isadmitted
, ticket_status
Base.in
— Methodin(ticketid::TicketID, recruiter::TokenRecruiter)::Bool
Return true if there already is a ticket with ticketid
.
PeaceFounder.Model.admit!
— Methodadmit!(recruiter::TokenRecruiter, id::Pseudonym, ticketid::TicketID, auth_code::Digest)::Admission
Attempt to admit an identity pseudonym id
for ticket ticketid
with provided authorization code. This function retrieves a ticket with given ticketid
and uses it's recorded token
to check whether the request is binding. In the case of success an admnission certificate is formed with provided indenty pseudonym id
and is signed by the recruter's private key. Otherwise when either of checks fail an error is raised. In the case ticket is already addmitted, returns previously stored admission.
PeaceFounder.Model.approve
— Methodapprove(x::T, signer::Signer)::T
Cryptographically sign a document x::T
and returns a signed document with the same type. To check whether a document is signed see issuer
method.
PeaceFounder.Model.auth
— Methodauth(id::Pseudonym, hmac::HMAC)::Digest
auth(id::Pseudonym, token::Digest, hasher::Hash) = auth(id, HMAC(bytes(token), hasher))
Compute a hash authorization code for identity pseudonym using token
as a key.
PeaceFounder.Model.auth
— Methodauth(ticketid::TicketID, time::DateTime, hmac::HMAC)::Digest
Compute a hash authorization code for ticketid
at given time
. The message needs to reach token recruiter within a 60 second window before it is obseleted.
PeaceFounder.Model.auth
— Methodauth(metadata::Vector{UInt8}, ticketid::TicketID, salt::Vector{UInt8}, hmac::HMAC)::Digest
Compute a hash authorization code for a metadata
, salt
from which a token is derived. Metadata can be configured to contain most recent server specification DemeSpec
; ticketid
takes session identifier role.
PeaceFounder.Model.enlist!
— Methodenlist!(recruiter::TokenRecruiter, ticketid::TicketID, timestamp::DateTime, ticket_auth_code::Digest)::Tuple{Vector{UInt8}, Vector{UInt8}, Digest}
Attempt to enlist a ticket with given ticketid
authetificated by a recruit client at timestmap
. This function checks the age of the request which need to be less than 60 seconds to be considered. Then the hash authorization code is checked after which a triplet of metadata
, salt
and reply_auth_code
is returned. If either of theses checks fail an error is raised and needs to be dealt by the user. See a token
method on how the token is derived.
PeaceFounder.Model.generate
— Methodgenerate(TokenRecruiter, spec::CryptoSpec)
Generate a new token recruiter with unique signer and athorization key.
PeaceFounder.Model.hmac
— Methodhmac(x)::HMAC
Return HMAC authorizer from a given object.
PeaceFounder.Model.isadmitted
— Methodisadmitted(ticketid::TicketID, recruiter::TokenRecruiter)
Check whether a ticket is already admitted. Returns false when either ticket is nonexistent or it's admission is nothing.
PeaceFounder.Model.isadmitted
— Methodisadmitted(status::TicketStatus)
Check whether ticket is addmitted.
PeaceFounder.Model.isbinding
— Methodisbinding(id::Pseudonym, auth_code::Digest, token::Digest, hasher::Hash)
Check whether a request for a new identity pseudonym admission is authetificated. The token is delivered to a user by recruit client.
PeaceFounder.Model.isbinding
— Methodisbinding(ticketid::TicketID, timestamp::DateTime, auth_code::Digest, hmac::HMAC)
Check whether request for a new ticketid is authorized by recruit client. Note that freshness of the request is not considered within this method.
PeaceFounder.Model.isbinding
— Methodisbinding(metadata::Vector{UInt8}, ticketid::TicketID, salt::Vector{UInt8}, auth_code::Digest, hmac::HMAC)
Check whether a reply for a new ticketid is authorized by the recruit server.
PeaceFounder.Model.select
— Methodselect(Admission, ticketid::TicketID, recruiter::TokenRecruiter)::Union{Admission, Nothing}
Return admission for a ticket with given a given identity pseudonym from recruiter
. If no ticket with given id
is found OR ticket is not yet admitted returns nothing.
PeaceFounder.Model.select
— Methodselect(Admission, ticketid::TicketID, recruiter::TokenRecruiter)::Union{Admission, Nothing}
Return admission for a ticket with given ticketid
from recruiter
. If no ticket with given ticketid
is found OR ticket is not yet admitted returns nothing.
PeaceFounder.Model.select
— Methodselect(T, predicate::Function, recruiter::TokenRecruiter)::Union{T, Nothing}
From a list of all recruiter
tickets return T <: Union{Ticket, Admission}
for which predicate is true. If none succeds returns nothing.
PeaceFounder.Model.set_metadata!
— Methodset_metadata!(recruiter::TokenRecruiter, metadata::Vector{UInt8})
Replace metadata for a recruiter. Note when data is replaced all unfinalized tokens need to be flushed.
PeaceFounder.Model.ticket
— Methodticket(x::Admission)
Return a TicketID which is admitted.
PeaceFounder.Model.ticket_status
— Methodticket_status(ticketid::TicketID, recruiter::TokenRecruiter)::Union{TicketStatus, Nothing}
Return a ticket status for a ticketid. In case ticket is not found return nothing.
PeaceFounder.Model.tickets
— Methodtickets(recruiter::TokenRecruiter)::Vector{TicketID}
Return a list of registered ticket ids.
PeaceFounder.Model.token
— Methodtoken(ticketid::TicketID, salt::Vector{UInt8}, hmac::HMAC)
Compute a recruit token for a given ticket with provided salt
.
BraidChain
PeaceFounder.Model.BraidChain
— Typestruct BraidChain
members::Set{Pseudonym}
ledger::Vector{Transaction}
spec::DemeSpec
generator::Generator
tree::HistoryTree
commit::Union{Commit{ChainState}, Nothing}
end
Represents 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
, roll
, constituents
, generator
, commit
, commit_index
, ledger
, leaf
, root
, ack_leaf
, ack_root
, members
, commit!
PeaceFounder.Model.ChainState
— Typestruct ChainState
index::Int
root::Digest
generator::Generator
member_count::Int
end
Represents a chain state metadata which is sufficient for integrity checks.
PeaceFounder.Model.DemeSpec
— Typestruct DemeSpec <: Transaction
uuid::UUID
title::String
crypto::CryptoSpec
guardian::Pseudonym
recorder::Pseudonym
recruiter::Pseudonym
braider::Pseudonym
proposer::Pseudonym
collector::Pseudonym
timestamp::Union{DateTime, Nothing} = nothing
signature::Union{Signature, Nothing} = nothing
end
Represents a deme configuration parameters issued by the guardian.
uuid::UUID
an unique random generated community identifier;title::String
a community name with which deme is represented;crypto::CryptoSpec
cryptographic parameters for the deme;guardian::Pseudonym
an issuer for this demespec file. Has authorithy to set a roster:recorder::Pseudonym
an authorithy which has rights to add new transactions and is responsable for braidchain's ledger integrity. IssuesCommit{ChainState}
;recruiter::Pseudonym
an authorithy which has rights to authorize new admissions to the deme. SeeAdmission
andMember
;braider::Pseudonym
an authorithy which can do a legitimate braid jobs for other demes. SeeBraidWork
;proposer::Pseudonym
an authorithy which has rights to issue a proposals for the braidchain. SeeProposal
;collector::Pseudonym
an authorithy which is repsonsable for collecting votes for proposals. This is also recorded in the proposal itself.
timestamp::Union{DateTime, Nothing}
time when signature is being issued;signature::Union{Signature, Nothing}
a guardian issued signature.
PeaceFounder.Model.Member
— Typestruct Member <: Transaction
admission::Admission
generator::Generator
pseudonym::Pseudonym
approval::Union{Signature, Nothing}
end
A new member certificate which rolls in (anouances) it's pseudonym
at current generator signed with identity pseudonym certified with admission certificate issued by registrar. This two step process is necessary as a checkpoint in situations when braidchain ledger get's locked during a new member resgistration procedure.
PeaceFounder.Model.Transaction
— TypeTransaction
Represents an abstract record type which can be stored in the braidchain ledger.
Base.push!
— Methodpush!(ledger::BraidChain, t::Transaction)
Add an element to the BraidChain 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::BraidChain, N::Int)::Digest
Return a ledger's element digest at given index.
HistoryTrees.root
— Methodroot(ledger::BraidChain[, N::Int])::Digest
Return a ledger root digest. In case when index is not given a current index is used.
PeaceFounder.Model.ack_leaf
— Methodack_leaf(ledger::BraidChain, index::Int)::AckInclusion
Return a proof for record inclusion with respect to a current braidchain ledger history tree root.
PeaceFounder.Model.ack_root
— Methodack_root(ledger::BraidChain, index::Int)
Return a proof for the ledger root at given index with respect to the current braidchain ledger history tree root.
PeaceFounder.Model.approve
— Methodapprove(member::Member, signer::Signer)::Member
Sign a member certificate and return it with approval
field filled.
PeaceFounder.Model.commit!
— Methodcommit!(ledger::BraidChain, signer::Signer)
Commit a current braidchain ledger state with a signer's issued cryptographic signature.
PeaceFounder.Model.commit
— Methodcommit(ledger::BraidChain)
Return a current commit for a braichain.
PeaceFounder.Model.constituents
— Methodconstituents(ledger::BraidChain)::Set{Pseudonym}
Return all member identity pseudonyms.
PeaceFounder.Model.generator
— Methodgenerator(ledger[, index])
Return a generator at braidchain ledger row index. If index
is omitted return the current state value.
PeaceFounder.Model.generator
— Methodgenerator(ledger::BraidChain)
Return a current relative generator for a braidchain ledger.
PeaceFounder.Model.generator
— Methodgenerator(member::Member)::Generator
Generator at which member tries to roll in the braidchain.
PeaceFounder.Model.id
— Methodid(member::Member)::Pseudonym
Identity pseudonym for a member.
PeaceFounder.Model.isbinding
— Methodisbinding(admission::Admission, spec::DemeSpec)
Check whether issuer of admission
is a recruiter set in spec
.
PeaceFounder.Model.isbinding
— Methodisbinding(record::Transaction, ack::AckInclusion{ChainState}, crypto::CryptoSpec)
A generic method checking whether transaction is included in the braidchain.
PeaceFounder.Model.issuer
— Methodissuer(member::Member)::Pseudonym
The identiy of registrar who signed admission.
PeaceFounder.Model.list
— Methodlist(T, ledger::BraidChain)::Vector{Tuple{Int, T}}
List braidchain elements with a given type together with their index.
PeaceFounder.Model.members
— Methodmembers(ledger::BraidChain[, index::Int])::Set{Pseudonym}
Return a set of member pseudonyms at relative generator at braidchain ledger row index. If index
is omitted return a current state value.
PeaceFounder.Model.pseudonym
— Methodpseudonym(member::Member)::Pseudonym
Pseudonym for a member at the generator(member)
.
PeaceFounder.Model.reset_tree!
— Methodreset_tree!(ledger::BraidChain)
Recompute a chain tree hash.
PeaceFounder.Model.roll
— Methodroll(ledger::BraidChain)::Vector{Member}
Return all member certificates from a braidchain ledger.
PeaceFounder.Model.select
— Methodselect(T, predicate::Function, ledger::BraidChain)::Union{T, Nothing}
Return a first element from a ledger with a type T
which satisfies a predicate.
PeaceFounder.Model.state
— Methodstate(ledger::BraidChain)
Return a current braidchain ledger state metadata.
PeaceFounder.Model.ticket
— Methodticket(member::Member)
Ticket for a member admission certificate.
PeaceFounder.Model.BraidWork
— Typestruct BraidWork <: Transaction
braid::Simulator
consumer::DemeSpec
producer::DemeSpec
approval::Union{Seal, Nothing}
end
Represents a braider's computation which is supported with zero knowledge proof of shuffle and decryption assuring it's corectness stored in a braid
field; consumer
denotes a deme for which the braid is intended and producer
denotes a deme where the braid is made. To assert latter the the braider signs the braidwork and stores that in the aproval
field. See a braid
method.
Interface: approve
, verify
, input_generator
, input_members
, output_generator
, output_members
PeaceFounder.Model.approve
— Methodapprove(braid::BraidWork, braider::Signer)
Sign a braidwork with a braider. Throws an error if braider is not in the producer
demespec.
PeaceFounder.Model.braid
— Methodbraid(generator::Generator, members::Union{Vector{Pseudonym}, Set{Pseudonym}}, consumer::DemeSpec, producer::DemeSpec; verifier = (g) -> ProtocolSpec(; g))
Selects a private exponent x
at random and computes a new generator $g' = g^x$ and $member_i'=member_i^x$ returns the latter in a sorted order and provides a zero knowledge proof that all operations have been performed honestly. In partucular, not including/droping new member pseudonyms in the process. consumer
attributes are necessary to interepret generator and pseudonym group elements with which the computation is performed.
By default a Verificatum compatable verifier is used for performing reencryption proof of shuffle
A verifier can be configured with a keyword argument. By default a Verificatum compatable verifier for a proof of shuffle is used.
PeaceFounder.Model.input_generator
— Methodinput_generator(braid::BraidWork)
Return input generator of the braid.
PeaceFounder.Model.input_members
— Methodinput_members(braid::BraidWork)
Return input member pseudonyms of the braid at provided input generator. See input_generator
PeaceFounder.Model.output_generator
— Methodoutput_generator(braid::BraidWork)
Return output genertor of the braid.
PeaceFounder.Model.output_members
— Methodoutput_members(braid::BraidWork)
Return output member pseudonyms of the braid at a resulting output generator. See output_generator
PeaceFounder.Model.verify
— Methodverify(braid::BraidWork, crypto::CryptoSpec)
Verifies a braid approval and then it's zero knowledge proofs. A crypto
argument is provided to avoid downgrading attacks.
Ballot Box
PeaceFounder.Model.Ballot
— Typestruct Ballot
options::Vector{String}
end
Represents a simple ballot form for multiple choice question.
PeaceFounder.Model.BallotBox
— Typemutable struct BallotBox
proposal::Proposal
voters::Set{Pseudonym} # better than members
collector::Pseudonym
seed::Union{Digest, Nothing}
crypto::CryptoSpec # on the other hand the inclusion of a vote should be binding enough as it includes proposal hash.
queue::Vector{Vote}
ledger::Vector{CastRecord}
tree::HistoryTree
commit::Union{Commit{BallotBoxState}, Nothing}
end
Represents 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
, members
, ledger
, spine
, index
, seed
, leaf
, root
, record
, receipt
, commit
, tally
, set_seed!
, ack_leaf
, ack_root
, ack_cast
, commit_index
, commit_state
, push!
, state
, validate
, record!
, commit!
PeaceFounder.Model.BallotBoxState
— Typestruct BallotBoxState
proposal::Digest
seed::Digest
index::Int
root::Digest
tally::Union{Nothing, Tally}
view::Union{Nothing, BitVector} #
end
Represents a public ballot box state. Contains an immutable proposal and seed digest; a current ledger index
, history tree root
. When ellections end a tally
is included in the state and a view
is added listing all counted votes. Note that the view
attribute is important for a client to know whether it's key have leaked and somone lese havbe superseeded it's vote by revoting.
PeaceFounder.Model.CastAck
— Typestruct CastAck
receipt::CastReceipt
ack::AckInclusion{BallotBoxState}
end
Represents a reply to a voter when a vote have been included in the ballotbox ledger. Contains a receipt and inlcusion acknowledgment. In future would also include a blind signature in the reply for a proof of participation. To receive this reply (with a blind signature in the future) a voter needs to send a vote which is concealed during ellections and thus tagging votes with blind signatures from reply to monitor revoting would be as hard as monitoring the submitted votes.
PeaceFounder.Model.CastReceipt
— Typestruct CastReceipt
vote::Digest
timestamp::DateTime
end
Represents a ballotbox ledger receipt which is hashed for a history tree. It's sole purpose is to assure voters that their vote is included in the ledger while also adding additional metadata as timestamp and. In contrast to CastRecord
it does not reveal how voter have voted thus can be published during ellections without violating fairness property. For some situations it may be useful to extend the time until the votes are published as that can disincentivice coercers and bribers as they would not know whether their coerced vote have been superseeded in revoting. See receipt
method for it's construction from a CastRecord
.
Note that a blind signature could be commited as H(signature|H(vote))
to avoid tagging the use of pseudonym during ellections while collector could issue only a one blind signature for a voter. Note that members whoose private key could have been stolen could not obtain a valid signature for participation and that could be a good thing!
PeaceFounder.Model.CastRecord
— Typestruct CastRecord
vote::Vote
timestamp::DateTime
end
Represents a ballotbox ledger record. Adds a timestamp when the vote have been recorded. In future, the record will also contain a blind signature with which members could prove to everyone that they had cast their vote without revealing the link to the vote.
PeaceFounder.Model.PollingStation
— Typestruct PollingStation
halls::Vector{BallotBox}
crypto::CryptoSpec
end
Represents a pooling station which hosts ballotbox ledgers for every proposal collector manages.
Interface: add!
, ballotbox
, record!
, commit!
, commit
, ack_leaf
, ack_root
, ack_cast
, record
, receipt
, spine
, ledger
, tally
, set_seed!
PeaceFounder.Model.Proposal
— Typestruct Proposal <: Transaction
uuid::UUID
summary::String
description::String
ballot::Ballot
open::DateTime
closed::DateTime
collector::Union{Pseudonym, Nothing} #
anchor::Union{ChainState, Nothing}
approval::Union{Seal, Nothing}
end
Represents a proposal for a ballot specyfing voting window, unique identifier, summary, description. Set's the collector identity which collects votes and issues vote inclusion receipts and is responsable for maintaining the ledger's integrity. The proposal also includes an anchor
which sets a relative generator with which members vote anonymously. To be considered valid is signed by proposer
authorizing vote to take place.
PeaceFounder.Model.Selection
— Typestruct Selection
option::Int
end
Represents voter's selection for a Ballot
form.
PeaceFounder.Model.Tally
— Typestruct Tally
data::Vector{Int}
end
Represent a tally for Ballot
form obtained aftert counting multiple voter's Selection
forms.
PeaceFounder.Model.Vote
— Typestruct Vote
proposal::Digest
seed::Digest
selection::Selection
seq::Int
approval::Union{Seal, Nothing}
end
Represents a vote for a proposal issued by a member. The proposal
is stored as hash digest ensuring that member have voted on an untampered proposal. seed
contains a randon string issued by collector at the moment when a vote starts to eliminate early voting / shortening a time at which coercers could act uppon. selection
contians voter's preference;
seq
is a serquence number counting a number of votes at which vote have been approved for a given proposal. It starts at 1 and is increased by one for every single signature made on the proposal. This is an important measure which allows to detect possible leakage of a member's private key. Also provides means for revoting ensuring that latest vote get's counted.
The vote is considered valid when it is sealed by a member's private key at a relative generator stored in the proposal.
Base.length
— Methodlength(ledger::BallotBox)
Return a total length of the ledger including uncommited records in the queue.
Base.push!
— Methodpush!(ledger::BallotBox, 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::BallotBox, N::Int)::Digest
Return a record digest used to form a history tree.
HistoryTrees.root
— Methodroot(ledger::BallotBox[, N::Int])::Digest
Calculate a root for history tree at given index N
. If index is not specified returns the current value.
HistoryTrees.root
— Methodroot(state::BallotBoxState)
Return a history tree root for a current ballotbox ledger state.
PeaceFounder.Model.ack_cast
— Methodack_cast(ledger::BallotBox, index::Int)::CastAck
Compute an acknowledgment for record inclusion at index
.
PeaceFounder.Model.ack_cast
— Methodack_cast(station::PollingStation, uuid::UUID, N::Int)::CastAck
Return inclusion proof with receipt and current tree commit for a leaf at index N
and ballotbox with uuid
.
PeaceFounder.Model.ack_leaf
— Methodack_leaf(ledger::BallotBox, index::Int)::AckInclusion
Compute an inclusion proof ::AckInclusion
for record element at given index
.
PeaceFounder.Model.ack_leaf
— Methodack_leaf(station::PollingStation, uuid::UUID, N::Int)::AckInclusion
Return history tree inclusion proof for a tree leaf at index N
in ballotbox with uuid
.
PeaceFounder.Model.ack_root
— Methodack_root(ledger::BallotBox, index::Int)::AckConsistency
Compute a history tree consistency proof at index
.
PeaceFounder.Model.ack_root
— Methodack_root(station::PollingStation, uuid::UUID, N::Int)::AckConsistency
Return history tree consitency proof tree root at index N
in ballotbox with uuid
.
PeaceFounder.Model.add!
— Methodadd!(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.Model.ballotbox
— Methodballotbox(station::PollingStation, uuid::UUID)::BallotBox
Return a ballotbox ledger with a provided UUID. If none is found throws an error.
PeaceFounder.Model.ballotbox
— Methodballotbox(station::PollingStation, proposal::Digest)::BallotBox
Return a ballotbox which has proposal with provided digest.
PeaceFounder.Model.commit!
— Methodcommit!(ledger::BallotBox[, 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.Model.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.Model.commit
— Methodcommit(ledger::BallotBox)
Return a commit for the ballotbox ledger.
PeaceFounder.Model.commit
— Methodcommit(ack::CastAck)
Return a commit from a CastAck
.
PeaceFounder.Model.commit
— Methodcommit(station::PollingStation, uuid::UUID)::Commit
Return a ballotbox commit.
PeaceFounder.Model.commit_index
— Methodcommit_index(ledger::BallotBox)::Union{Index, Nothing}
PeaceFounder.Model.commit_state
— Methodcommit_state(ledger::BallotBox)
Return a committed state for a ballotbox ledger.
PeaceFounder.Model.generator
— Methodgenerator(ledger::BallotBox)
Return a relative generator which members use to sign votes anchored by the proposal.
PeaceFounder.Model.generator
— Methodgenerator(proposal::Proposal)
A relative generator for at which memebers sign votes for this proposal.
PeaceFounder.Model.index
— Methodindex(state::BallotBoxState)
Return an index for a current ballotbox ledger state.
PeaceFounder.Model.index
— Methodindex(ledger::BallotBox)
Return the current index of the ledger. See also length
.
PeaceFounder.Model.isbinding
— Methodisbinding(chain::BraidChain, state::ChainState)::Bool
Check that chain state is consistent with braidchain ledger.
PeaceFounder.Model.isbinding
— Methodisbinding(ack::CastAck, proposal::Proposal, hasher::Hash)::Bool
Check that acknowledgment is legitimate meaning that it is issued by a collector listed in the proposal.
PeaceFounder.Model.isbinding
— Methodisbinding(receipt::CastReceipt, ack::AckInclusion, hasher::Hash)::Bool
Check that cast receipt is binding to received inclusion acknowledgment.
PeaceFounder.Model.isbinding
— Methodisbinding(receipt::CastReceipt, vote::Vote, hasher::Hash)::Bool
Check that the receipt is bidning to a vote.
PeaceFounder.Model.isbinding
— Methodisbinding(vote::Vote, ack::CastAck, hasher)
Check whether acknowledgment is bound to the provided vote.
PeaceFounder.Model.isbinding
— Methodisbinding(vote::Vote, proposal::Proposal, crypto::CryptoSpec)
Check that the vote is bound to a proposal..
PeaceFounder.Model.isconsistent
— Methodisconsistent(selection::Selection, ballot::Ballot)
Verifies that voter's selection is consistent with ballot form. For instance, whether selection is withing the range of ballot options.
PeaceFounder.Model.issuer
— Methodissuer(proposal::Proposal)
Issuer of approval for the proposal.
PeaceFounder.Model.ledger
— Methodledger(ballotbox::BallotBox)::Vector{CastRecord}
Return all records from a ballotbox ledger.
PeaceFounder.Model.ledger
— Methodledger(station::PollingStation, uuid::UUID)::Vector{CastRecord}
Return a vector of records from a ballotbox with uuid
.
PeaceFounder.Model.members
— Methodmembers(ledger::BallotBox)
Return a list of member pseudonyms with which members authetificate their votes.
PeaceFounder.Model.pseudonym
— Methodpseudonym(vote::Vote)::Union{Pseudonym, Nothing}
Return a pseudonym with which vote is sealed.
PeaceFounder.Model.receipt
— Methodreceipt(ledger::BallotBox, index::Int)::CastReceipt
Return a receipt for a ledger element.
PeaceFounder.Model.receipt
— Methodreceipt(record::CastRecord, hasher::Hash)::CastReceipt
Construct a CastReceipt from a CastRecord with a provided hasher function.
PeaceFounder.Model.receipt
— Methodreceipt(station::PollingStation, uuid::UUID, N::Int)::CastReceipt
Return a receipt for a record with index N
at ballotbox with uuid
.
PeaceFounder.Model.record!
— Methodrecord!(ledger::BallotBox, 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.Model.record!
— Methodrecord!(ledger::BallotBox, 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.Model.record!
— Methodrecord!(station::PollingStation, uuid::UUID, vote::Vote)::Int
Records a vote
in a ballotbox with provided proposal UUID. Throws an error if a ballotbox can't be found.
PeaceFounder.Model.record!
— Methodrecord!(station::PollingStation, uuid::UUID, vote::Vote)::Int
Record a vote
in a ballotbox found by proposal diggest stored in the vote. Throws an error if a ballotbox can't be found.
PeaceFounder.Model.record
— Methodrecord(ledger::BallotBox, index::Int)::CastRecord
Return a ledger record at provided index
.
PeaceFounder.Model.record
— Methodrecord(station::PollingStation, uuid::UUID, N::Int)::CastRecord
Return a record with an index N
at ballotbox with uuid
.
PeaceFounder.Model.reset_tree!
— Methodreset_tree!(ledger::BallotBox)
Recompute history tree root and cache from the elements in the ledger. This is a useful for loading the ledger all at once.
PeaceFounder.Model.seed
— Methodseed(ledger::BallotBox)::Union{Digest, Nothing}
Return a random selected seed used in the voting.
PeaceFounder.Model.set_seed!
— Methodset_seed!(ledger::BallotBox, seed::Digest)
Set's a seed of the ballotbox.
PeaceFounder.Model.set_seed!
— Methodset_seed!(station::PollingStation, uuid::UUID, seed::Digest)
Sets a seed for a ballotbox with provided uuid
.
PeaceFounder.Model.spine
— Methodspine(ledger::BallotBox)::Vector{Digest}
Return a history tree leaf vector.
PeaceFounder.Model.spine
— Methodspine(station::PollingStation, uuid::UUID)::Vector{Digest}
Return a leaf vector for a ballotbox with proposal uuid
.
PeaceFounder.Model.state
— Methodstate(ledger::BallotBox; with_tally::Union{Nothing, Bool} = nothing)::BallotBoxState
Return a state metadata for ballotbox ledger.
PeaceFounder.Model.state
— Methodstate(proposal::Proposal)::ChainState
A braidchain ledger state which is used to anchor a relative generator for members.
PeaceFounder.Model.tally
— Methodtally(ballot::Ballot, ballots::AbstractVector{Selection})::Tally
Count ballots, check that they are filled consistently and return a final tally.
PeaceFounder.Model.tally
— Methodtally(ledger::BallotBox)
Compute a tally for a ballotbox ledger.
PeaceFounder.Model.tally
— Methodtally(station::PollingStation, uuid::UUID)
Compute a tally from ledger records a ballotbox with uuid
.
PeaceFounder.Model.uuid
— Methoduuid(ledger::BallotBox)
Return a UUID of the proposal.
PeaceFounder.Model.uuid
— Methoduuid(proposal::Proposal)::UUID
UUID for a proposal. Issued by proposer and it's purpose is to croslink to an external system durring the proposal dreafting stage.
PeaceFounder.Model.validate
— Methodvalidate(ledger::BallotBox, 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.
PeaceFounder.Model.verify
— Methodverify(ack::CastAck, crypto::CryptoSpec)::Bool
Verify the cast acknowledgment cryptographic signature.
PeaceFounder.Model.vote
— Methodvote(proposal::Proposal, seed::Digest, selection::Selection, member::Signer; seq = 1)
Issue a vote on a proposal and provided collector seed
for a member's selection
.