The Byzantine generals algorithm solves the consensus problem specified by the requirements of validity, agreement and termination (see Distributed Consensus). The algorithm, created by Pease et al., allows correct (i.e., non-faulty) agents to reach a consensus even if faulty agents halt, lie, and send different messages to different agents. The FLP theorem says that in an asynchronous system no algorithm can guarantee consensus if even one agent may halt. Byzantine consensus assumes that agents operate synchronously, and the FLP theorem does not apply under this assumption.
The assumption of synchronous rounds Byzantine consensus algorithms are synchronous. The algorithm proceeds in rounds: every message sent by a correct agent to a correct agent in a round is received when the next round begins.
The implementation of rounds is unspecified. There are many ways to implement rounds. A central clock can send signals to agents to start rounds. Or each agent starts a round when its local clock reaches a multiple of T, where T is larger than the maximum message delay plus the maximum difference between local clocks.
The consensus problem is to come to consensus on a value. We will assume that the value is a single bit. To get consensus on a 64-bit value, the brute-force way is to run the algorithm 64 times; however, there are more efficient ways, which you can determine for yourselves.
Faulty agents need not be malicious. A sensor with a failing chip can report different readings to different receivers; an agent in an office can be hacked; a buggy agent can give different answers to different peers. In each case an agent tells different listeners different things — exactly the fault this lecture tolerates. Blockchains face the same problem with participants nobody trusts.
The Byzantine Generals Problem is faced by an army in which the general and some lieutenants may be traitors. The problem is to develop an algorithm by which loyal lieutenants come to a consensus on whether to attack or retreat. We use the term source for the general and agent for a lieutenant. We use the term faulty for a source or agent that does not obey the specified protocol, and correct for one that does.
A correct source sends the same command to every agent. The command is either retreat (0) or attack (1). A faulty source may send different commands to different agents, and may send no command at all to some agents.
The fault bound t
You are given t, an upper bound on the number of
faulty participants, the source included.
For example, if t = 1, then either the source is faulty
and all the agents are correct, or the source is correct and at most
one of the agents is faulty.
We are not told whether the source is faulty, nor
which, if any, of the agents are faulty. The problem
is to design a consensus protocol that has the following specification.
For an agent x, let x.v be the local value of x: its decision when the algorithm terminates. Let S be the source, and S.v be the value of the source.
The specification does not require that faulty agents be identified. Without the validity requirement, the solution is trivial: all correct agents retreat. Without the agreement requirement, the solution is trivial: obey the source. The problem is non-trivial because both requirements must hold at once.
Example 1. Suppose the agents decide by majority vote, and the source and one of five agents are faulty. The source sends attack to two of the correct agents and retreat to the other two, so the faulty agent can swing the decision of each correct agent either way.
Example 2. Majority voting fails however many agents there are. Consider a faulty source, one faulty agent, and 999,999 correct agents. The source sends attack to 499,999 of them and retreat to the other 500,000.
If messages are encrypted, then a faulty agent can make copies of the message and forward copies to other agents, but it cannot change the message. When messages are unencrypted, a faulty agent can change the message and forge signatures. In both cases, a faulty agent can choose to send nothing to some agents. The problem with encrypted messages is called the "Written Message" problem, and the problem with unencrypted messages is called the "Oral Message" problem.
A digital signature is computed from the message and a secret key that only the signer holds; anyone can check it with the signer’s public key. It guarantees two things: the signer produced it, and the message has not changed since. It does not hide the message — that is encryption, a different tool. The algorithm needs signatures, not secrecy; this lecture says “encrypted” as shorthand for “signed”.
M signed by agent
X and received by agent Y can be
forwarded by Y, but Y cannot change
the message or forge X’s signature.The rest of this document considers the encrypted message case. Oral messages are not covered in this lecture. Note that for oral messages, when there can be up to t faulty agents (source included), the number of correct agents must exceed 2t for consensus to be possible. For written messages there is no such bound.
Messages are sent in rounds: a message sent in round
k is received at the start of round k+1.
An agent that sends a message can sign it with its own
signature, and an agent that reads the message can verify the signature.
One simplification, used throughout In a round an agent sends 0, 1, or nothing. Treat a 0‑message as equivalent to no message. Then, every message in the algorithm is a 1‑message, and the absence of a message stands for either a 0 or no message.
Let S.sign be the signature of the source, and x.sign the signature of agent x. A message is a set of signatures: the source’s message is {S.sign}.
Round 0: the source sends {S.sign} to some, all, or none
of the agents. In this
algorithm, if a correct agent x receives {S.sign} in
round k, then it sets x.v = 1 and broadcasts
{S.sign} to all agents in round k; these messages are
received at the start of round k+1.
# code for agent x; K is determined later x.v = 0 for k in 1..K: if x receives {S.sign} in round k: x.v = 1 broadcast {S.sign}
Can K be 1? If the source is correct, it sends
{S.sign} to every agent in round 0, and every correct agent
y receives it at the start of round 1 and sets
y.v = 1. But the source may be faulty.
The counterexample
a faulty source, and correct agents y and z.
y, and nothing to z.y receives it, sets
y.v = 1 and broadcasts it; z receives
nothing. The algorithm stops before y’s
broadcast reaches z.
At the end of round 1, y.v = 1 and
z.v = 0. Agreement is violated, so K = 1 does
not work.
And no K works
A faulty source sends {S.sign} only to a faulty agent
x. x stays silent until round
K−1 and then sends it to y and not to
z. y sets y.v = 1 in round
K, but its broadcast arrives in round K+1,
after the algorithm stops.
How can you modify the algorithm so that it stops with a consensus after some round K?
In the algorithm, every message is a set of signatures that
includes S.sign.
In the code, m + x.sign = m UNION {x.sign}.
The rule
If a correct agent x receives, in round k, a message m
that contains S.sign and has at least k signatures,
then x sets x.v = 1 and broadcasts
m + x.sign.
# code for the source S, in round 0 if S.v == 1: send {S.sign} to every agent # code for agent x; K is determined later x.v = 0 for k in 1..K: if message m is received where S.sign in m and len(m) >= k: x.v = 1 broadcast m + x.sign
len(m) = 2 < 3, so
B does not set B.v = 1 and does not broadcast.
B and C still agree.
len(m) = 2 ≥ 2, so B sets
B.v = 1 and broadcasts {S.sign, A.sign, B.sign}.
Round 3: C receives B’s message;
len(m) = 3 ≥ 3, so C sets
C.v = 1. B and C agree.
A.v = B.v = C.v = 0.
Round 3: B receives {S.sign, u.sign, v.sign};
len(m) = 3 ≥ 3, so B sets
B.v = 1 and sends {S.sign, u.sign, v.sign, B.sign} to
A and C. Round 4: A and C
receive it; len(m) = 4 ≥ 4, so A and
C set A.v = 1 and C.v = 1.
If K = t+1, the algorithm satisfies termination,
agreement and validity.
Termination holds because the algorithm runs for K
rounds.
Case 1: the source is correct. Agreement and validity follow from observations 1 and 2.
Case 2: the source is faulty, and there exist k ≤ t and a correct agent x such that x.v changes from 0 to 1 in round k. By observation 3, for all correct agents y, y.v = 1 by the end of round k+1 ≤ t+1. So the agreement requirement is satisfied. Validity holds trivially because the source is faulty.
Case 3: the source is faulty, and for all rounds k ≤ t and all correct agents x, x.v = 0. In rounds 1 to t, no correct agent signs a message, because a correct agent x signs only after setting x.v = 1. The source is faulty, so at most t−1 agents are faulty. So every message received at the start of round t+1 has at most t signatures: the source’s and those of at most t−1 faulty agents. That is not enough for a correct agent y to set y.v = 1 in round t+1. So, for all correct agents y, y.v = 0 at the end of round t+1, and the agreement requirement is satisfied. Figure 7 shows this case.
The answer The algorithm stops after round t+1. Each correct agent x attacks if x.v = 1 and retreats if x.v = 0.
t = 3
and the algorithm stops after round t+1 = 4.
A, B and C are correct. In round 0 the source
sends {S.sign} to u and v only.
Round 2: A.v = B.v = C.v = 0.
Round 3: u and v send
{S.sign, u.sign, v.sign} to A, B and C.
Round 4: A, B and C receive the
message, but len(m) = 3 < 4, so their values stay 0.
The counterexample
t = 3: a faulty source and faulty agents u and
v; correct agents A, B and C; and
K = t = 3.
3 ≥ 3 signatures, sets A.v = 1 and
broadcasts {S.sign, u.sign, v.sign, A.sign}. That broadcast
arrives in round 4, after the algorithm stops.
A.v = 1 but B.v = C.v = 0:
agreement is violated. With K = t+1 = 4,
B and C receive A’s message in round 4,
with 4 ≥ 4 signatures, and agree. Try it in
figure 8.
Choose which participants are faulty and what the faulty ones do, then read off what each correct agent decides. The faulty participants collude: they can sign for one another, so a faulty agent can send {S.sign} together with every faulty agent’s signature.
K = t+1 no choice of faults breaks agreement; with
K = t, look for one that does.
| Paxos | Byzantine consensus, signed messages | |
|---|---|---|
| Timing | Asynchronous: messages may be delayed or lost | Synchronous rounds |
| Faults | Agents may halt | Faulty participants may do anything except forge signatures |
| Fault bound | A majority of acceptors must be reachable | Any number t of faulty participants, if t is known |
| Termination | Not guaranteed (FLP) | Guaranteed: t+1 rounds |
No algorithm that tolerates t faulty participants can always finish in fewer than t+1 rounds (Fischer and Lynch, 1982), so this algorithm is as fast as possible in the worst case.
t = 1 in which the algorithm violates agreement or
validity.x.v = 1.K = t and find a choice of faults
that violates agreement. Then explain why no choice works with
K = t+1.