Categorical Criptography
Categorical Criptography
Dusko Pavlovic⋆
Email: dusko.pavlovic@rhul.ac.uk
1 Introduction
1.1 Idea
For a long time, mathematics was subdivided into geometry and arithmetic, later
algebra. The obvious difference between the two was that the geometric reasoning
was supported by pictures and diagrams, whereas the algebraic reasoning relied
upon the equations and abstract text. For various reasons, the textual reasoning
seemed dominant in XX century mathematics: there were relatively few pictures
in the mathematical publications, and even the formal systems for geometry
were presented as lists of formulas. But as the algebraic constructions grew
more complex, the task to stratify and organize them grew into a mathematical
problem on its own. Category theory was proposed as a solution for this problem.
The earliest categorical diagrams expanded the textual reasoning from exact
⋆
Recent primary affiliation: University of Hawaii at Manoa. Email: dusko@hawaii.edu
sequences to matrices of exact exact sequences [22,7]. The technique of diagram
chasing seem to have emerged around the time of Lambek’s classic ”Lectures on
Rings and Modules” [19], where it was used not just as a convenient visualization
of lists of equations, but also as a geometric view of universal constructions.
This unassuming idea then proceeded to form a germ of geometric reasoning
in category theory, uncovering the geometric patterns behind abstract logical
structures [23]. Other forms of geometric reasoning emerged in various forms of
categorical research [14,12,6, to mention just a few], providing some of the most
abstract algebraic structures with some of the most concrete geometric tools.
The present paper reports about the beginnings of an exploration towards apply-
ing categorical diagrams in a young and exciting area of mathematics: modern
cryptography. Initiated in the late 1970s [3] by introducing algorithmic hardness
as a tool of security, modern cryptography developed a rich conceptual and tech-
nical apparatus in a relatively short period of time. The increasing complexity
of its proofs and constructions, usually presented in a textual, ”command line”
mode, akin to low-level programming, occasionally engendered doubts that its
formalisms may sometimes conceal as many errors as they prevent [16,15,17].
Would a high level categorical view help?
1.2 Background
2
x produces an output y is estimated by counting for how many values of the
random seed ρ it takes that value, i.e.
– M of plaintexts
– C of ciphertexts
– K of keys
plus a set of random seeds, that we leave implicit. They are all given with their
bitstring representations. The structure of the crypto-system consists of three
feasible functions
PPT
– key generation k, k : 1 −−−→ K × K,
PPT
– encryption E : K × M −−−→ C, and
DP T
– decryption D : K × C −−−→ M,
This secrecy is in fact what cryptography is all about. Even defining it took a
while.
3
The earliest formal definition of secrecy is due to Shannon [29]. His idea was
to require that the ciphertext discloses nothing about the plaintext. He viewed
the attacker as a statistician, who knows the precise frequency distribution of
the language M, i.e. knows for every m ∈ M the probability Pr(m M) that
random sampling from M will yield m. Shannon’s requirement was that knowing
the encryption c = E(r, k, m) of m should not make it any easier to guess m, i.e.
that
Shannon wrote this in a different, but equivalent form1 , and called it perfect
security.
When the age of modern cryptography broke out, the concept of secrecy got
refined by considering the feasibility of the encryption and decryption operations,
and moreover strengthened by requiring that the attacker is unlikely to guess
not only the plaintext m, but even a single bit from it. Otherwise, the concept of
secrecy would miss the possibility that the plaintext is hard to guess as a whole,
but that it may be easy to guess bit by bit. The original formalization of this
requirement is due to Goldwasser and Micali [9,10] under the name semantic
security, but it was later somewhat simplified to the form of chosen plaintext
indistinguishability (IND-CPA), which looks something like this:
1
Pr b A1 (m0 , m1 , c, s) c E(k, mb ), b 2, m0 , m1 , s A0 ∼ (2)
2
The attacker consists of two PPTs, A0 and A1 , which communicate through a
tape. She tests the crypto system as follows. First A0 chooses and announces
two plaintexts m0 and m1 . She may also convey to A1 a part of her state,
by writing s on their shared tape. Then the crypto system tosses a fair coin
b, computes the encryption c E(k, mb ) of one of the chosen plaintexts, and
gives it to the attacker. The attacker A1 is now supposed to guess which of the
two plaintexts was encrypted. The system is secure if knowing c does not give
him any advantage in this, i.e. if his chance to guess b is indistinguishable from
Pr(b 2) = 12 .
The point that I am trying to make is that this is mouthful of a definition.
Especially when we are defining secrecy, which is one of the most basic concepts
of cryptography. The upshot is that the most basic cryptographic proofs need
to show that some crypto system satisfies the above property.
It is, of course, not unheard of that the fundamental concepts tend to be subtle,
and require complicated formal definitions. In cryptography, however, this phe-
nomenon seems to be escalating. First of all, the above definition of secrecy as
chosen plaintext indistinguishability turns out to be too weak, and too simple.
In reality, the attacker can usually access a decryption oracle, which she can
consult before she chooses any plaintexts, and also after she receives back the
1
Except that the encryption was not randomized at the time.
4
encryption of one of them, but before she attempts to guess which one it is. So
the attacker actually consists of four PPTs, A0 , A1 , A2 and A3 , where A0 begins
with choosing some ciphertexts, which it submits to the decryption oracle, etc.
A reader who is not a cryptographer may enjoy decyphering the interactions
between the crypto system and the attacker from the formula below, describing
the chosen ciphertext indistinguishability (IND-CCA2), due to Rackoff and Si-
mon [28]. The PPTs again share a tape, which they can use to pass each other
a part of the state, denoted s0 , s1 etc.
Pr b e s2 )
A3 (c0 , m, m0 , m1 , c, c1 , m,
m = D(k, c0 ), c0 , s0 A0 , !
1
c E(k, mb ), b 2, m0 , m1 , s1 A1(c0 , m, s0 ) ∼ (3)
2
e = D(k, c1 ), c1 , s2 A2 (c0 , m, m0 , m1 , c6= , s1 )
m
Section 2 presents a symbolic model of a crypto system, and a very crude sym-
bolic definition of secrecy. These definitions can be stated in any relational calcu-
lus, and thus also in the category of relations. Section 3 presents an information
theoretic model of a crypto system. The symbolic definition of secrecy refines
here to Shannon’s familiar definition of perfect security. We formalize it all in the
category of sets and stochastic operators between them. And finally, Section 4
introduces a category where the modern cryptographic concepts can be formal-
ized, such as (IND-CPA) and (IND-CCA2). The upshot of this development is to
2
The attacker may submit, e.g. two very large plaintexts, say video blocks, as m0 and
m1 . After she receives the encryption c of one of them, she can then flip just one
bit of it, and make that into c1 , which is submitted back for decryption. Although
c and c1 differ in a single bit, the decryption of c1 should not disclose even a single
bit of information about c0 .
5
show how the incremental approach, refining the crude abstract concepts, while
enriching the categorical structures, motivates the conceptual development and
provides technical tools. Section 5 invites for further work.
2 Symbolic cryptography
In [5,4], Dolev, Yao, Even and Karp describe public key cryptosystems using an
algebraic theory — roughly what mathematicians would call bicyclic semigroups
[11].
– encryption E : A × A −→ A,
– decryption D : A × A −→ A, and
– key pairing (−) : A −→ A,
– a message algebra
– a set M ⊆ A of well-formed plaintexts;
– the hiding condition: ”knowing E(k, m) does not reveal anything about m”
Remarks. The above definitions are close in spirit to Dolev and Yao’s definitions,
but deviate in details from their presentation. First of all, Dolev and Yao do not
present the encryption and decryption operations as binary operations, but as
families of unary operations indexed by the keys. More importantly, their results
also require the encryption equation
E k, D(k, c) = c
that should hold for all keys k and all ciphertexts c. Nowadays even toy crypto
systems do not satisfy this, so we allow that E(k, −) may not be surjective.
Restricted to its image, of course, the decryption equation implies the encryption
6
equation; but not generally. Finally, Dolev and Yao do not take M ⊆ A as a part
of the structure. Intuitively, if A is the set of character strings in some alphabet,
then M can be construed as the set of words meaningful in some language.
For a cryptanalyst, being able to distinguish the meaningful words from the
meaningless ones is often critical for recognizing a decryption. The set M ⊆ A
is thus a first, very crude step towards the concepts of source redundancy and
frequency distribution, which are of course crucial for cryptanalysis.
The main challenge left behind Dolev and Yao’s analysis is that the hiding
condition, which is clearly the heart of the matter, is left completely informal.
At the first sight, there seem to be many ways to make it precise. We present one
in the next section. Its conceptual analogy with the more familiar information
theoretic and computational notions of secrecy are clear, but its technical utility
seems limited.
An attacker sees a ciphertext c and wants to know the plaintext m, such that
E(k, m) = c. But since she does not know the key k, she can only form the set
of possible3 plaintexts m that may correspond to c
e = {m ∈ M | ∃k. E(k, m) = c}
cD (4)
One way to formalize the hiding condition is to require that any well-formed
e
message m must be a candidate for a decryption of c, and thus lie in cD.
m ∈ M ∧ ∃k ∈ A. E(k, m) = c ⇐⇒ m ∈ M (5)
shows that this is a ”possibilistic” version of (1). The following lemma says that
this captures the intended requirement that the set cD e does not tell anything
about m.
e
cDm ⇐⇒ m ∈ M (6)
3
I.e., this is the only thing that she can do in the possibilistic world of mere relations.
In the probabilistic world of stochastic relations, she can of course do more, and that
will be discussed in the next section.
7
A convenient framework to work with algebraic security is the category Rel of
sets and binary relations
|Rel| = |Set|
Rel(A, B) = {0, 1}A×B
R S
with the usual relational composition of A −
→ B and B −
→C
! !×A
1 /A
M
where
!
– A−→ 1 denotes the total relation, i.e. x!0 holds for all x and 1 = {0}, and
eM is by definition c E
– E eM (k, m) ⇐⇒ m ∈ M ∧ E(k, m) = c.
To begin, Shannon introduced into analysis mixed crypto systems, in the form
R = pS + (1 − p)T where S and T can be thought of as two Dolev-Yao crypto
8
systems, and p ∈ [0, 1]. The idea is that the system R behaves like S with
probability p, and like T with probability 1−p. In summary, Shannon considered
message algebras A
But (b) makes it convenient to draw the keys from the convex hull of A
n X o
∆A = κ : A −→ [0, 1] #ςκ < ∞ ∧ κ(x) = 1
x∈ςκ
Condition (a) similarly suggests that a plaintext, or the available partial infor-
mation about it, should also be viewed as a stochastic vector µ ∈ ∆A. A crypto
system is now an algebra in the category of sets and stochastic operators
|Sto| = |Set|
n X o
Sto(M, N ) = Φ ∈ [0, 1]M×N #ςΦ < ∞ ∧ Φij = 1
i∈ςΦ
Indeed, the encryption and the decryption operations are now stochastic op-
erators Eκ , Dκ ∈ Sto(A, A); whereas the mixed plaintexts are the points µ ∈
Sto(1, A).
This time, the formal definition of the hiding condition available, and well known.
9
3.2 Perfect security
Shannon [29] considers an attacker who makes a probabilistic model of the ob-
served crypto system. More precisely, when she observes a cyphtertext c, instead
e ⊆ M of possible decryptions, like in Sec. 2.2, she now tries
of forming the set cD
to compute the conditional distribution Pr(m|c) ≥ Pr(m) of the probable de-
cryptions of c.
But now the ciphertext c is a random variable γ = Pr(c), which can be viewed
Pr(c)
as an arrow 1 −−−→ A in Sto. An observation of a ciphertext thus provides
knowledge about the distribution of Pr(c). We assume that the attacker knows
the distribution κ = Pr(k) of the keys, and the frequency distribution µ = Pr(m).
Aligning definitions 2.3 and 3.2 shows that algebraic perfect security is an alge-
braic approximation of Shannon’s probabilistic perfect security [29, II.10]. The
following proposition shows that the connection extends to the categorical char-
acterizations.
! !×A
1 /A
µ
where
! 1
– A−
→ 1 is the row vector of #ςA ,
µ
– 1−
→ A is the distribution µ viewed as a column vector,
!×A
– A × A −−−→ A is the stochastic matrix with the entries
(
1
if i = k
(! × A)i(jk) = #ςA
0 otheriwise
10
e is the stochastic matrix with the entries
– E
(
e c(km) = κ(k) · µ(m) if c = E(k, m)
E
0 otherwise
4 Computational cryptography
Effective functions Suppose that every set is given with an encoding: e.g.,
each element is encoded as a bitstring. A function between encoded sets can
then be considered feasible if it is realized by a feasible boolean function on the
codes.
Let us begin with a crude realization of this idea, just to get a feeling for it.
∗
Let R = (2∗ )2 be the monoid of boolean functions and F ⊆ R a submonoid
of functions that we call feasible. For concreteness, we could assume that the
functions from F are just those realized by some suitable family of boolean
circuits or Turing-machines. The category SetF of F -computable functions is
then defined
X
|SetF | = |Set/2∗ | = {J−KA : A −→ 2∗ }
A∈|Set|
11
Effective substochastic operators Now we want to refine the category SetF
effective functions to a category of randomized effective functions. The step is
analogous to the step from Set to Sto. So randomized effective functions will
actually be effective stochastic operators. But since feasible functions may not
be total, we will actually work with effective substochastic operators.
The first task is to define the monoid of randomized boolean functions that will
operate on the codes. Consider the set of partial functions
where f (x) ↓ asserts that the partial function f is defined at x, and |ξ| denotes
the length of the bitstring ξ. The set R forms a monoid (R, ◦, ι) where
and ι(hi, x) = x, where hi denotes the empty string. This monoid was previously
used in [26]. Let F ⊆ R be a submonoid of functions that we consider feasible.
An example are the functions realized by DPT machines. The category StoF of
effective substochastic operators is now defined as follows
X
|StoF | = |Set/2∗ | = {J−KA : A −→ 2∗ }
A∈|Set|
A×B
StoF (A, B) = Φ ∈ [0, 1] | ∃ϕ ∈ F ∀a ∈ A ∀b ∈ B.
Φab = Pr (JbKB ϕJaKA )}
k < ℓ =⇒ ψk = ψℓ ↾(2r(k) ×2s(k) ) ∧ r(k) < r(ℓ) ∧ s(k) < s(ℓ) ∧ t(k) < t(ℓ)
12
consists of the components
F
(ϑ ◦ ψ)ℓ = ϑℓ ◦ ψℓ : 2u(ℓ) × 2v(ℓ) −→ 2t(ℓ)
where
where
# ρ ∈ 2r(ℓ) | JbKt(ℓ) = ψℓ ρ, JaKs(ℓ)
Pr JbK ψℓ (JaK) =
2r(ℓ)
In the special case when F ω consists of the actions of PPT machines, we get the
category EnsPPT , where the morphisms are the extensional views of PPTs. More
precisely, a morphism is a sequence of substochastic matrices Ψ = {Ψ ℓ }ℓ∈ω such
that there is a PPT Π and the ab-entry of Ψ ℓ is Ψab ℓ
= Pr(b Πℓ a), where ℓ is
the security parameter.
So EnsF comes close to providing an abstract view of the universe in which the
cryptographers work. The view is abstract in the sense that F does not have
to be realized by PPTs, but can be any submonoid of R. By taking F to be
the PPT realized stochastic operations we get the usual probabilistic algorithms
— except that those that are indistinguishable, because their difference is a
negligible function still correspond to different morphisms in EnsPPT .
Indistinguishability Note, first of all, that [0, 1] is not only a monoid, but an
ordered semiring4 . The semiring structure lifts to [0, 1]ω . A semi-ideal in an or-
dered semiring is a lower closed subset closed under addition and multiplication.
Since it is lower closed, it contains 0, but generally not 1.
Let Υ ⊆ [0, 1]ω be a semi-ideal. The canonical example is the semi-ideal of
negligible functions [8]. A function ν : ω −→ [0, 1] is called negligible if ν(x) <
4
A semiring is a structure (R, +, ·, 0, 1) such that (R, +, 0) and (R, ·, 1) are commu-
tative monoids such that a(b + c) = ab + ac and a0 = 0.
13
1
q(x) holds eventually, for every positive polynomial q. Any semi-ideal Υ induces
on [0, 1]ω the equivalence relation
and we define EnsΥF to be the category with the same objects as EnsF , but
EnsΥF (A, B) = EnsF (A, B) ∼
Υ
EnsΥF (A, B) = Ψ ∈ JΥA×B | ∃ψ ∈ F ω ∀ℓ ∈ ω ∀a ∈ A ∀b ∈ B.
ℓ
Ψab = Pr (JbK ψℓ JaK)
The usual definition of a crypto system from the Introduction can now be stated
abstractly, in a categorical form. While the definition follows the pattern of
Def. 2.2 and Def. 3.1, this time we revert to the usual multi-sorted specification,
where the plaintexts, the ciphertexts and the keys are drawn from different sets.
The upshot of it all. The abstract versions of the hiding conditions, such as
(IND-CPA) and (IND-CCA2), described in the Introduction, boil down to com-
mutative diagrams in EnsΥF . We illustrate this fact for (IND-CPA).
14
this category. Such a crypto system is semantically secure, i.e. it satisfies (IND-
CPA), as defined by (2), if and only if the following diagram commutes for all
arrows A0 and A1 in EnsνPPT .
hidK ,A0 i π E×id
K / K × M2 × S / K × M × M2 × S / C × M2 × S
! A1
1 /2
b
5 Further work
References
1. Kim-Kwang Raymond Choo, Colin Boyd, and Yvonne Hitchcock. Errors in com-
putational complexity proofs for protocols. In Bimal K. Roy, editor, ASIACRYPT,
volume 3788 of Lecture Notes in Computer Science, pages 624–643. Springer, 2005.
15
2. Alexander W Dent. Fundamental problems in provable security and cryptography.
Philosophical Transactions of the Royal Society A: Mathematical, Physical and
Engineering Sciences, 364(1849):3215–3230, 2006.
3. Whitfield Diffie and Martin E. Hellman. New directions in cryptography. IEEE
Transactions on Information Theory, IT-22(6):644–654, 1976.
4. Danny Dolev, Shimon Even, and Richard M. Karp. On the security of ping-pong
protocols. In CRYPTO, pages 177–186, 1982.
5. Danny Dolev and Andrew C. Yao. On the security of public key protocols. IEEE
Transactions on Information Theory, 29(2):198–208, 1983.
6. Dusko Pavlovic. Geometry of abstraction in quantum computation. Proceedings
of Symposia in Applied Mathematics, 71:233–267, 2012. arxiv.org:1006.1010.
7. Peter Freyd. Abelian Categories: an Introduction to the Theory of Functors. Harper
and Row, 1964.
8. Oded Goldreich. Foundations of Cryptography. Cambridge University Press, 2000.
9. Shafi Goldwasser and Silvio Micali. Probabilistic encryption & how to play mental
poker keeping secret all partial information. In STOC ’82: Proceedings of the
fourteenth annual ACM symposium on Theory of computing, pages 365–377, New
York, NY, USA, 1982. ACM Press.
10. Shafi Goldwasser and Silvio Micali. Probabilistic encryption. J. Comput. Syst.
Sci., 28(2):270–299, 1984.
11. Pierre Antoine Grillet. Semigroups: an introduction to the structure theory. Marcel
Dekker, Inc., 1995.
12. André Joyal and Ross Street. The geometry of tensor calculus I. Adv. in Math.,
88:55–113, 1991.
13. Jonathan Katz and Yehuda Lindell. Introduction to Modern Cryptography. Chap-
man & Hall/CRC Series in Cryptography and Network Security. Chapman &
Hall/CRC, 2007.
14. Gregory Max Kelly. On clubs and doctrines. In Gregory Max Kelly, editor, Cate-
gory Seminar. Sydney 1972/73, pages 181–256. Springer-Verlag, Berlin, 1974.
15. Neal Koblitz and Alfred Menezes. Another look at ”Provable Security”. II. In Rana
Barua and Tanja Lange, editors, INDOCRYPT, volume 4329 of Lecture Notes in
Computer Science, pages 148–175. Springer, 2006.
16. Neal Koblitz and Alfred Menezes. Another look at ”Provable Security”. J. Cryp-
tology, 20(1):3–37, 2007.
17. Neal Koblitz and Alfred Menezes. The brave new world of bodacious assumptions
in cryptography. Notices of the American Mathematical Society, 57(3):357–365,
March 2010.
18. Joachim Lambek. How to program an infinite abacus. Canad. Math. Bull.,
4(3):295–302, 1961.
19. Joachim Lambek. Lectures on Rings and Modules. Blaisdell Publishing Co., 1966.
20. Joachim Lambek. From types to sets. Adv. in Math., 36:113–164, 1980.
21. Joachim Lambek and Philip J. Scott. Introduction to higher order categorical logic,
volume 7 of Cambridge Stud. Adv. Math. Cambridge University Press, New York,
NY, USA, 1986.
22. Saunders Mac Lane. Homology. Springer-Verlag, 1963.
23. Dusko Pavlovic. Maps II: Chasing diagrams in categorical proof theory. J. of the
IGPL, 4(2):1–36, 1996.
24. Dusko Pavlovic. Categorical logic of names and abstraction in action calculus.
Math. Structures in Comp. Sci., 7:619–637, 1997.
25. Dusko Pavlovic. Monoidal computer I: Basic computability by string diagrams.
Information and Computation, 2013. to appear; arxiv:1208.5205.
16
26. Dusko Pavlovic and Catherine Meadows. Bayesian authentication: Quantifying
security of the Hancke-Kuhn protocol. E. Notes in Theor. Comp. Sci., 265:97 –
122, 2010.
27. Dusko Pavlovic and Vaughan Pratt. The continuum as a final coalgebra. Theor.
Comp. Sci., 280(1–2):105–122, 2002.
28. Charles Rackoff and Daniel R. Simon. Non-interactive zero-knowledge proof of
knowledge and chosen ciphertext attack. In Joan Feigenbaum, editor, CRYPTO,
volume 576 of Lecture Notes in Computer Science, pages 433–444. Springer, 1991.
29. Claude E. Shannon. Communication theory of secrecy systems. Bell Systems
Technical Journal, 28:656–715, 1949.
30. Victor Shoup. OAEP reconsidered. In Proceedings of the 21st Annual International
Cryptology Conference on Advances in Cryptology, CRYPTO ’01, pages 239–259,
London, UK, 2001. Springer-Verlag.
17