About this book
A Course in Number Theory and Cryptography is a mathematics textbook. Neal Koblitz published it with Springer in 1987, in the yellow-covered Graduate Texts in Mathematics series, and a revised second edition appeared in 1994. It is short for a book of its kind, a little over two hundred pages in the second edition, and it does one thing with great economy: it teaches the parts of number theory that public-key cryptography depends on, and then shows how cryptography uses them.
The book was written at a turning point. For most of its history number theory had been the purest of pure mathematics, studied for its beauty and for its own deep problems, with almost no practical use. In 1976 Whitfield Diffie and Martin Hellman published the idea of public-key cryptography, and in 1977 Ron Rivest, Adi Shamir and Leonard Adleman proposed the RSA system. Suddenly questions about prime numbers, remainders and the difficulty of factoring were questions about whether banks, governments and later everyone else could communicate securely. Number theorists found that their subject had become applied mathematics almost overnight.
Koblitz was in an unusual position to explain this. He was a number theorist by training, the author of two earlier graduate texts in pure number theory, and in 1985 he had proposed, independently of Victor Miller at IBM, that the groups of points on elliptic curves over finite fields could be used to build cryptographic systems. That proposal became elliptic curve cryptography, now one of the most widely deployed forms of public-key cryptography in the world. This book was among the first to present it in a teaching text.
The intended reader is someone with a little mathematical training: an advanced undergraduate or beginning graduate student in mathematics, or a computer scientist or engineer comfortable with proofs. Koblitz assumes some familiarity with basic algebra, such as groups and fields, though he reviews what is needed. He does not assume any number theory beyond what a curious school student might know. Each section ends with exercises, and answers to many of them appear at the back.
The question the book sets out to answer can be stated plainly. What mathematics lies under modern public-key cryptography, and how does that mathematics turn into working systems? Koblitz answers it by building the number theory from the ground up, with constant attention to how long computations take, and by bringing in cryptographic applications as soon as the mathematics can support them.
For a reader interested in blockchains, the book has a special interest. Every Bitcoin and Ethereum transaction is authorised by a digital signature built on an elliptic curve, and the security of every wallet rests on the difficulty of a problem that Koblitz helped to put at the centre of cryptography. This book is where one can learn, with real proofs and real calculations, why that problem is believed to be hard and what that belief rests on.
The author
Neal Koblitz was born in 1948 in the United States. He studied mathematics at Harvard and took his doctorate at Princeton in 1974, working under Nicholas Katz on questions in arithmetic algebraic geometry. He spent most of his career at the University of Washington in Seattle. His early research was in pure number theory, especially p-adic analysis and modular forms, areas far from any practical application at the time.
Before this book he had already written two graduate texts for the same Springer series. The first, on p-adic numbers, p-adic analysis and zeta functions, appeared in 1977. The second, an introduction to elliptic curves and modular forms, appeared in 1984 and was organised around an ancient problem about which whole numbers can be the areas of right triangles with rational sides. Both books are known for clarity and for teaching through concrete problems. The elliptic curves book in particular gave him the background that led to his cryptographic proposal a year later.
His 1985 idea was that the group structure on the points of an elliptic curve over a finite field could replace the multiplicative group of a finite field in discrete logarithm cryptosystems. Victor Miller had the same idea independently at about the same time. Both published in 1985 and 1987. The advantage, they argued, was that the best known general attacks on the discrete logarithm problem in finite fields did not seem to apply to elliptic curves, so much smaller keys might give the same security. It took more than a decade for industry to adopt the idea, but by the early twenty-first century elliptic curves were standard in web security, mobile devices and cryptocurrencies. Koblitz later proposed hyperelliptic curves, a generalisation, for the same purpose.
Koblitz is also known for activities outside research. With his wife, the historian Ann Hibner Koblitz, he founded a fund in honour of the nineteenth-century Russian mathematician Sofia Kovalevskaia to support women in science in developing countries. He has written and spoken widely on mathematics education and on political questions, and spent time teaching and working in countries including Vietnam and in Central America. He published a memoir, Random Curves, in 2008, which describes his mathematical life alongside his political engagements.
In later years, often working with Alfred Menezes, one of the authors of the Handbook of Applied Cryptography on this shelf, Koblitz wrote a series of critical papers on the methods of theoretical cryptography, questioning how much confidence so-called proofs of security really give. That later scepticism is worth keeping in mind when reading this book. Koblitz always cared about the gap between what mathematics proves and what practitioners believe, and the textbook is careful in the same way.
The shape of the argument
The book is built as a ladder. It starts with ideas that need almost no background and climbs toward ideas that need everything below them. The lower rungs are elementary number theory: divisibility, greatest common divisors, congruences, and the famous theorems of Fermat and Euler. The middle rungs are algebraic structures, especially finite fields, together with the theory of squares and square roots modulo a prime. The upper rungs are the cryptographic systems themselves and the algorithms used to attack them, with elliptic curves at the top.
Running beside the mathematics is a second thread: the cost of computation. From the start, Koblitz asks not only whether something is true but how long it takes to compute. How many bit operations does it take to multiply two numbers, to find a greatest common divisor, to raise a number to a large power modulo another? This thread is what turns pure number theory into cryptography. A cryptosystem is secure when some computation that would break it takes impossibly long, while the computations needed to use it are quick.
Cryptography itself enters in stages. First come classical ciphers, the kind a spy or schoolchild might use, which serve as a gentle introduction to the language of keys, encryption and decryption and to the idea of breaking a cipher by frequency analysis or algebra. Then comes the public-key idea, which changes the whole subject. The book presents several public-key systems, each resting on a different hard problem, and explains what is known about attacking them.
Two further topics are treated in depth because they are the practical heart of the matter. One is primality testing and factoring: how to find large primes quickly, and how hard it is to split a large number into primes. The other is elliptic curves: what they are, why their points form a group, how to compute with them over finite fields, and how they can be used both to build cryptosystems and, surprisingly, to factor numbers.
The method throughout is to state a result, prove it or explain why it holds, compute small examples, and then set exercises that ask the reader to compute more. The book trusts the reader to learn by doing. It is not a survey to be read in an armchair. A reader who skips the exercises will understand much less than one who works them, and that is by design.
Easy one way, hard the other
The central idea of public-key cryptography is an asymmetry in computation. Some operations are fast to perform and very slow to reverse. Multiplying two large primes takes a computer a fraction of a second. Finding those primes again, given only their product, can take longer than the age of the universe with the best known methods, if the primes are large enough. The whole subject depends on finding and using such asymmetries.
An everyday analogy is mixing paint. Mixing a particular blue and yellow to get a green is easy. Given the green, working out exactly which blue and which yellow went in, and in what proportions, is much harder. The analogy is imperfect, since paint mixing is not precise, but it captures the feeling. A public-key system arranges matters so that encrypting is like mixing and decrypting without the key is like unmixing, while the holder of the key has a shortcut that makes unmixing easy.
To make this precise, Koblitz introduces the basic language of computational complexity. He counts the number of bit operations needed for arithmetic on numbers of a given length, and he uses the notation that describes how running time grows with input size. An algorithm whose time grows like a fixed power of the number of digits is called polynomial time, and is regarded as efficient. An algorithm whose time grows like a fixed power of the number itself, or exponentially in the number of digits, is regarded as infeasible for large inputs. Between these extremes lie subexponential algorithms, which matter a great deal for factoring.
This idea is often confused with a proof of security. Nobody has proved that factoring is hard, or that the discrete logarithm problem is hard. Mathematicians believe it because many able people have tried for decades to find fast methods and have failed. Security rests on that experience, not on a theorem. Indeed, it is not even known whether there exist any one-way functions in the strict mathematical sense. Koblitz is careful to make this clear, and a reader should carry the distinction everywhere: easy and hard mean easy and hard with the methods we know.
This idea leads directly to the question of how big numbers must be. If the best attack on a problem takes a certain time for a given key size, then choosing the key size is a matter of making that time unreachable. As computers grow faster and algorithms improve, key sizes must grow. The history of recommended key lengths for RSA, which have risen from a few hundred bits to two thousand bits and more, is a direct consequence of this way of thinking.
It also leads to the threat of quantum computers. In 1994, the year the second edition appeared, Peter Shor showed that a large quantum computer could factor numbers and compute discrete logarithms in polynomial time. If such machines are built, the asymmetries on which RSA and elliptic curve systems rest would disappear. The book predates practical concern with this, but its framework, of security as a gap between easy and hard computations, is exactly what one needs to understand why the quantum threat matters and why new systems based on different problems are now being standardised.
Arithmetic on a clock
Modular arithmetic is the arithmetic of remainders. Pick a number n, called the modulus. Two whole numbers are congruent modulo n if they leave the same remainder when divided by n. On a twelve-hour clock, fifteen o'clock is three o'clock, because fifteen and three leave the same remainder when divided by twelve. Addition and multiplication modulo n work just as on the clock: compute as usual, then take the remainder. This simple idea is the setting for almost all of the book.
Why does cryptography use it? Because it keeps numbers bounded. However many multiplications one performs, the result modulo n is always less than n. This makes it possible to raise a number to an enormous power, say a power with hundreds of digits, while keeping every intermediate result small. The technique, called repeated squaring, computes a large power by squaring and reducing over and over, taking a number of steps proportional to the number of digits in the exponent rather than to the exponent itself. Without this, public-key cryptography would be impossible in practice.
The other basic tool is the Euclidean algorithm, one of the oldest algorithms in mathematics, found in Euclid's Elements. It computes the greatest common divisor of two numbers by repeatedly replacing the larger with its remainder on division by the smaller. Run carefully, it also finds numbers that express the greatest common divisor as a combination of the two inputs. That extended version is how one finds an inverse modulo n: a number which, multiplied by a given number, leaves remainder one. Inverses are needed constantly, for instance to compute the private key in RSA.
Three classical theorems sit on top of these tools. Fermat's little theorem says that if p is prime, then raising any number not divisible by p to the power p minus one leaves remainder one modulo p. Euler generalised this to any modulus, using a function that counts how many numbers below n share no factor with it. The Chinese remainder theorem says that if one knows a number's remainders modulo several moduli with no common factors, one can reconstruct its remainder modulo their product. Each theorem has a direct use: Fermat's for primality testing, Euler's for RSA, the Chinese remainder theorem for speeding up computation.
A frequent confusion is to treat modular arithmetic as a trick or a programming detail. It is a full number system with its own algebra, and when the modulus is prime it is a field, meaning that every nonzero element has an inverse and division always works. That fact makes it possible to do linear algebra, solve equations and build curves inside it, which is what the later parts of the book do.
The best way to absorb this idea is by calculation. Take a small prime, say thirteen, and compute the powers of two modulo thirteen until they repeat. Do the same with three. Notice that some numbers run through every nonzero remainder before repeating and some do not. Those that do are called primitive roots, or generators, and they are exactly what discrete logarithm cryptography needs. Ten minutes of such work teaches more than an hour of reading.
Finite fields
A field is a number system in which one can add, subtract, multiply and divide by anything except zero, with the usual rules holding. The rational numbers and the real numbers are fields. The remainders modulo a prime p form a field with exactly p elements. A natural question is whether there are other finite fields. The answer, worked out in the nineteenth century and attached especially to the name of Evariste Galois, is that there is exactly one finite field of each size that is a power of a prime, and none of any other size.
Fields whose size is a prime power but not a prime are built in a way that resembles building the complex numbers from the real numbers. One takes polynomials with coefficients modulo p and works modulo a polynomial that cannot be factored, much as one works modulo a prime. The result is a field with p raised to the degree of that polynomial elements. Fields with a power of two elements are especially useful in computing, because their elements can be stored as strings of bits and their addition is just the exclusive-or operation.
The most important fact about finite fields for cryptography is that their nonzero elements form a cyclic group under multiplication. This means there is always some element, a generator, whose powers run through every nonzero element of the field. Once one has a generator, every nonzero element is some power of it. Finding which power is the discrete logarithm problem, discussed below. The cyclic structure is what makes the problem well-defined and what makes it useful.
An analogy for the cyclic group is a circular track with a fixed number of positions and a runner who always takes the same stride. If the stride is chosen well, the runner eventually lands on every position before returning to the start. Telling where the runner is after a given number of strides is easy if one can count quickly. Telling how many strides it took to reach a given position, when the track is huge and the positions are scrambled, is the hard direction.
A common confusion is between the size of the field and the size of the numbers one computes with. In the field with p elements, numbers are less than p. In a field with p to the power k elements, elements are polynomials of degree less than k, and arithmetic is on polynomials, not on large integers. Some attacks work better in one kind of field than another, which is why the choice of field matters. Koblitz is careful to separate these cases.
Finite fields lead naturally to elliptic curves, because an elliptic curve over a finite field is a set of solutions to an equation whose coefficients and unknowns lie in that field. They also lead to error-correcting codes, to the design of block ciphers such as the Advanced Encryption Standard, whose inner workings use the field with two hundred and fifty-six elements, and to many other parts of computing. Learning finite fields properly is one of the most useful things a reader can take from the book.
Squares and square roots modulo a prime
Which numbers are perfect squares modulo a prime? Modulo seven, squaring the numbers from one to six gives remainders one, four, two, two, four, one. So one, two and four are squares, and three, five and six are not. The squares are called quadratic residues and the others quadratic nonresidues. For any odd prime, exactly half of the nonzero remainders are residues. The study of which numbers are residues modulo which primes is one of the classical topics of number theory.
The tool for deciding is the Legendre symbol, a notation that records whether a number is a residue modulo a prime. Euler found a criterion for computing it with a single modular exponentiation. Deeper still is the law of quadratic reciprocity, first proved by Gauss, which relates whether p is a square modulo q to whether q is a square modulo p, for distinct odd primes p and q. Reciprocity allows one to compute the Legendre symbol quickly by a process resembling the Euclidean algorithm, without ever finding the square root itself.
Why does this matter for cryptography? There are several reasons. Some primality tests, such as the Solovay-Strassen test, rely on a generalisation of the Legendre symbol called the Jacobi symbol. Some cryptosystems, including one proposed by Michael Rabin, rest on the difficulty of finding square roots modulo a composite number, which turns out to be as hard as factoring it. And many factoring algorithms work by finding numbers whose squares are congruent modulo n in a nontrivial way, which immediately reveals a factor.
An analogy: imagine a city where every house number is either painted red or blue, and a rule tells you the colour of house a in district b if you know the colour of house b in district a. Reciprocity is such a rule. It sounds like magic until one works through enough cases, at which point it begins to feel like a hidden symmetry of the integers. Gauss called it the golden theorem, and he gave several proofs of it over his career.
A confusion to avoid is thinking that because deciding whether a number is a square modulo a prime is easy, finding the square root must also be easy. For a prime modulus, square roots can indeed be found efficiently, though the algorithm is less obvious than one might expect. For a composite modulus whose factors are unknown, finding square roots is believed to be hard. The difference between prime and composite moduli is the source of a great deal of cryptography.
This topic leads, in the wider subject, to zero-knowledge proofs, coin-flipping by telephone and other protocols that were invented in the 1980s and that the book touches on. Quadratic residuosity was the basis of the first probabilistic encryption scheme, proposed by Shafi Goldwasser and Silvio Micali, which introduced modern definitions of what it means for encryption to be secure.
Classical ciphers as a first language
Before public-key cryptography, every cipher was symmetric. The same secret key was used to encrypt and to decrypt, and both parties had to share it in advance. Koblitz introduces cryptography through such ciphers, treating messages as numbers and ciphers as functions on those numbers. The simplest shifts each letter by a fixed amount. A slightly more elaborate kind multiplies and then shifts, modulo the size of the alphabet. Another groups letters into blocks and treats each block as a vector, multiplying it by a matrix modulo the alphabet size.
These ciphers are weak, and part of the point is to see why. A shift cipher can be broken by trying every key. A multiply-and-shift cipher can be broken by noticing which letters are most frequent in the ciphertext and matching them to the most frequent letters of the language. A matrix cipher can be broken if an attacker knows a few blocks of plaintext and their encryptions, since that gives a system of linear equations for the key. Each attack is an exercise in the number theory just learned, and each shows that a cipher can look scrambled while still leaking its structure.
The vocabulary set up here carries through the rest of the subject. Plaintext is the message, ciphertext is its encrypted form, the key is the secret parameter, and an enciphering transformation maps plaintext to ciphertext. An attacker who sees only ciphertext is in a weaker position than one who also knows some plaintext, and much weaker than one who can choose plaintexts and see their encryptions. These attack models, introduced informally here, are the starting point of the formal definitions used in modern cryptography.
An analogy is learning chess openings with a beginner. The positions are simple, the mistakes obvious, and the lessons general. Someone who has broken a matrix cipher with pencil and paper understands, in a concrete way, why modern ciphers are designed to make every output bit depend on every input bit in complicated ways.
A confusion to avoid is thinking that classical cryptography is merely of historical interest. Symmetric ciphers remain the workhorses of practice. When you load a secure web page, public-key methods are used only to agree on a shared key, and the bulk of the data is encrypted with a fast symmetric cipher. Public-key cryptography solved the problem of key distribution, not the problem of fast encryption. The two kinds of system work together.
For readers who want the longer story of classical cryptography, this shelf holds The Codebreakers by David Kahn and The Code Book by Simon Singh. Koblitz's treatment is brief and mathematical. Those books supply the history, the personalities and the wars.
The public-key idea and RSA
The idea of public-key cryptography is that encryption and decryption can use different keys. One key is published so that anyone can use it to encrypt a message. The other is kept secret by its owner and is the only practical way to decrypt. The two keys are mathematically linked, but computing the secret one from the public one is infeasible. This removes the need for parties to meet or to trust a courier before they can communicate privately. It also makes digital signatures possible: the owner can use the secret key to produce something that anyone can check with the public key but nobody else could have produced.
An analogy is a padlock sold open. Anyone can take one of your open padlocks, put a message in a box and snap the lock shut. Only you have the key to open it. You can hand out as many open padlocks as you like without endangering your secret. A signature reverses the picture: imagine a seal that only you can stamp but that anyone can compare with a public sample.
RSA realises the idea with modular arithmetic. Choose two large primes and multiply them to get the modulus. Choose an encryption exponent. Using Euler's theorem and the extended Euclidean algorithm, compute a decryption exponent that undoes it. Publish the modulus and encryption exponent; keep the primes and the decryption exponent secret. To encrypt, raise the message to the encryption exponent modulo the modulus. To decrypt, raise the result to the decryption exponent. Euler's theorem guarantees that one gets the message back.
Anyone who can factor the modulus can compute the decryption exponent, so RSA is at most as hard as factoring. Whether breaking RSA is exactly as hard as factoring is not known in general; there might in principle be some other way to take roots modulo a composite without factoring. This is one of the honest gaps in the theory that the book helps a reader see. In practice, every known way of breaking well-implemented RSA amounts to factoring.
The common confusion here is to think that textbook RSA, as described, is how RSA is used. It is not. Raw RSA has weaknesses: the same message always encrypts to the same ciphertext, small messages can be recovered by simple algebra, and the multiplicative structure can be exploited. Real systems add carefully designed padding and randomness before encryption and use hashing before signing. Koblitz's book teaches the mathematics; for the engineering, a reader should turn to Applied Cryptography, Cryptography Engineering or Serious Cryptography on this shelf.
RSA leads naturally to the search for other hard problems. It also teaches a pattern that recurs throughout the subject: a trapdoor, a secret piece of information that makes a hard problem easy for its holder. In RSA the trapdoor is the factorisation. Other systems use other trapdoors, and some, like Diffie-Hellman, use no trapdoor at all but a different kind of asymmetry.
The discrete logarithm problem
In ordinary arithmetic, a logarithm answers the question of what power one must raise a base to in order to get a given number. In a finite cyclic group, the discrete logarithm asks the same question: given a generator g and an element h, find the exponent x such that g raised to x equals h. Computing g to the power x is easy by repeated squaring. Finding x from h is, in well-chosen groups, believed to be very hard. That asymmetry is the second great source of public-key cryptography.
The Diffie-Hellman key exchange shows how it is used. Two parties agree publicly on a group and a generator. Each picks a secret exponent and sends the other the generator raised to that exponent. Each then raises what they received to their own secret exponent. Both arrive at the same value, the generator raised to the product of the two secrets. An eavesdropper sees the two public values but, without solving a discrete logarithm or some closely related problem, cannot compute the shared secret. The two parties now share a key they can use with a fast symmetric cipher.
Other systems follow the same pattern. The ElGamal system uses discrete logarithms for encryption and for signatures. The Digital Signature Algorithm, a United States standard, is a variant of the ElGamal signature. The elliptic curve version of that standard, ECDSA, is the signature used in Bitcoin and Ethereum. Koblitz presents several such schemes in a common framework, so that a reader can see which parts are essential and which are design choices.
How hard the discrete logarithm is depends on the group. In the additive group of remainders modulo n, it is trivial: it amounts to division, which the Euclidean algorithm handles. In the multiplicative group of a finite field, it is hard, but there are subexponential attacks called index calculus methods, which exploit the fact that field elements can be factored into small primes in a meaningful way. In the group of points on a well-chosen elliptic curve, no such factoring structure is known, and the best general attacks take roughly the square root of the group size. This is why elliptic curve keys can be much shorter.
A common confusion is to think that a discrete logarithm problem is hard simply because the group is large. Size is necessary but not sufficient. If the group size has only small prime factors, the Pohlig-Hellman method breaks the problem into small pieces and solves each quickly. Special structure of other kinds can also be exploited. Choosing a group therefore requires knowing the attacks, and the book gives a reader enough of them to understand why standards specify groups so carefully.
The discrete logarithm idea leads to the elliptic curve chapter, which is the book's distinctive contribution. It also leads to a broad set of later constructions, from zero-knowledge proofs of knowledge, in which one proves one knows an exponent without revealing it, to the signature aggregation schemes used in some modern blockchains.
Signatures, identity and proof without disclosure
Encryption keeps a message secret. A signature does something different: it proves who sent a message and that it has not been changed. In everyday life a handwritten signature does this badly, since it can be copied and does not depend on the document. A digital signature depends on both the signer's secret key and the exact content of the message. Change a single bit of the message and the signature no longer checks. Copy the signature onto another message and it fails.
Koblitz explains how public-key systems give signatures. In RSA, the owner applies the secret exponent to a message, or in practice to a short digest of it, and anyone can apply the public exponent to check the result. In discrete logarithm systems the construction is less direct. The signer picks a fresh random number for each signature, combines it with the secret key and the message digest, and publishes values that let anyone verify a certain equation in the group. Only someone who knows the secret exponent could have produced values that satisfy it.
The fresh random number in discrete logarithm signatures is a point worth dwelling on, because it is a classic source of disaster. If the same random number is ever used to sign two different messages, simple algebra recovers the secret key from the two signatures. This is not a weakness in the mathematics but in its use, and it has happened in real systems. A games console maker once used a fixed value in its signatures and had its signing key extracted. Bitcoin wallets have lost funds when faulty random number generators on phones repeated values. A reader who has worked the algebra in Koblitz's framework sees at once why this happens.
Signatures need a one-way hash function, which turns a message of any length into a short fixed-length digest in such a way that finding two messages with the same digest is infeasible. Koblitz discusses hash functions briefly, as a tool rather than a subject. Their design is a separate field, closer to symmetric cipher design than to number theory. In blockchains, hash functions do even more work than signatures: they link blocks into a chain, build the trees that summarise transactions, and in Bitcoin's case define the proof of work that miners compete to solve.
An analogy for the whole arrangement is a wax seal pressed with a ring. The seal shows who closed the letter, and a broken seal shows tampering. A digital signature is a seal whose pattern depends on the letter's contents, which no forger can press without the ring, and which anyone can compare with a publicly known impression.
The book also touches on a more surprising idea: that one can prove knowledge of a secret without revealing it. In a zero-knowledge proof, a prover convinces a verifier that a statement is true, for example that the prover knows the discrete logarithm of a public element, while the verifier learns nothing else. The classic examples are interactive: the verifier issues random challenges, and the prover can answer all of them only if the prover truly knows the secret. Since the book appeared, such proofs have become central to blockchain privacy and scaling, and many modern systems use elliptic curve groups in exactly the way Koblitz describes to build them. The mathematics in this book is the entry point.
A confusion to avoid is thinking that a signature proves who a person is. It proves only that the holder of a particular secret key signed. Linking a key to a real person or organisation requires something outside the mathematics: certificates, registries, or in blockchains simply the convention that whoever controls the key controls the funds. This is why lost keys mean lost money, and stolen keys mean stolen money, in systems that have no other notion of identity.
Primes are easy, factors are hard
To use RSA one needs large primes, hundreds of digits long. How does one find them? Primes are plentiful: the prime number theorem says that near a large number N, roughly one number in every natural logarithm of N is prime. So a random search will hit a prime fairly soon. The question is how to recognise one. Trying every possible divisor is hopeless for large numbers. The answer is that there are fast tests that decide primality without finding any factors.
The simplest starts from Fermat's little theorem. If n is prime, then a raised to the power n minus one is congruent to one modulo n for every a not divisible by n. If this fails for some a, n is certainly composite. If it holds, n might be prime, or it might be a composite that happens to pass for that a, called a pseudoprime to base a. Some composites, the Carmichael numbers, pass for every base coprime to them, so the plain Fermat test is not enough. Stronger tests, such as the one developed by Gary Miller and Michael Rabin, look more closely at the square roots of one that arise during the computation. A composite passes this strong test for at most a quarter of possible bases. Repeating the test with many random bases makes the chance of error as small as one likes.
Such tests are called probabilistic. They can say with certainty that a number is composite, but only with overwhelming likelihood that it is prime. For practical purposes the distinction hardly matters: one can make the error probability smaller than the chance of a hardware fault. In 2002, after this book, Manindra Agrawal, Neeraj Kayal and Nitin Saxena at the Indian Institute of Technology Kanpur showed that primality can be decided with certainty in polynomial time. Their result settled a long-standing theoretical question, though probabilistic tests remain faster in practice.
Factoring is a different story. The book surveys several methods. Pollard's rho method finds small factors quickly using a random walk that eventually cycles. Methods based on factor bases, including the continued fraction method and the quadratic sieve, look for many numbers whose squares modulo n factor completely over a set of small primes, then combine them by linear algebra to find two squares that are congruent modulo n, which often yields a factor. Lenstra's elliptic curve method, discovered in 1985, uses elliptic curves to find factors of moderate size. The fastest general method known today, the number field sieve, grew from the same circle of ideas.
An analogy for the gap between testing and factoring is a locked safe. A primality test is like weighing the safe to tell whether it contains anything. Factoring is like opening it. One can learn a great deal about the contents without being able to get at them.
A common confusion is to think that if one can test primality quickly, one can factor quickly by testing candidate divisors. But testing a candidate divisor is just trial division, and there are far too many candidates. Primality tests work by checking a property primes have, not by searching for factors. That is why they can say a number is composite without revealing any of its factors, which can seem paradoxical at first.
Elliptic curves
An elliptic curve, for the purposes of this book, is the set of solutions to an equation in which y squared equals a cubic polynomial in x, together with one extra point thought of as lying at infinity. The name is historical: such curves arose in computing the arc length of ellipses, though they are not ellipses. Over the real numbers the curve looks like a smooth wave, sometimes in one piece and sometimes in two. Over a finite field it is a scattered set of points, finite in number.
The remarkable fact is that the points of an elliptic curve can be added. Given two points, draw the line through them. It meets the curve in exactly one more point. Reflect that third point across the horizontal axis, and the result is defined to be their sum. To add a point to itself, use the tangent line. The point at infinity serves as zero. With these rules, the points form a group, satisfying all the usual laws of addition. The geometric picture over the real numbers translates into algebraic formulas that work over any field, including finite ones.
Over a finite field, the group of points is finite. Hasse's theorem says that the number of points is close to the number of elements of the field, within twice its square root. Within that range, the exact count depends on the curve, and computing it efficiently was an important problem, solved in principle by René Schoof in 1985 and later improved. Once the size is known, one can choose curves whose group has a large prime-order subgroup, which is what cryptography needs.
The cryptographic use follows the discrete logarithm pattern, written additively. Adding a point to itself k times gives a point called k times P. Computing it from k and P is fast, using a doubling-and-adding method that mirrors repeated squaring. Recovering k from P and k times P is the elliptic curve discrete logarithm problem. For well-chosen curves, no attack substantially better than generic square-root methods is known. A curve over a field of about two hundred and fifty-six bits therefore gives roughly one hundred and twenty-eight bits of security, comparable to an RSA modulus of about three thousand bits. Smaller keys mean faster computation, smaller signatures and less bandwidth, which is why elliptic curves dominate in mobile devices, web connections and blockchains.
In Bitcoin, a private key is simply a random number k. The public key is the point k times G on a specific curve called secp256k1, where G is a fixed base point. Signatures use ECDSA on that curve. Ethereum uses the same curve. Everything about the security of a wallet reduces to the claim that nobody can recover k from the public point. Reading Koblitz, one can follow that claim down to the arithmetic of a cubic equation over a finite field.
A confusion to avoid is thinking that every elliptic curve is equally good. Some are not. In the early 1990s, Alfred Menezes, Tatsuaki Okamoto and Scott Vanstone showed that for certain curves, including the so-called supersingular curves, the elliptic curve discrete logarithm can be transferred to a finite field, where index calculus methods apply. Later work found that curves whose number of points equals the field size can be broken easily. Standards therefore exclude such curves. The book's second edition reflects the state of knowledge of its time on these points; a reader should consult later sources for current recommendations.
Elliptic curves lead in several directions. They give Lenstra's factoring method, in which one hopes to stumble on a curve whose group size modulo an unknown prime factor has only small factors. They underlie pairing-based cryptography, developed after this book, which turned the attack of Menezes, Okamoto and Vanstone into a tool for new protocols such as short signatures used in some modern blockchains. And they connect cryptography to some of the deepest mathematics of the twentieth century, including the proof of Fermat's Last Theorem, which rests on the theory of elliptic curves.
The tradition around it
Number theory is one of the oldest branches of mathematics. Euclid proved that there are infinitely many primes and gave the algorithm for greatest common divisors. Fermat, Euler, Lagrange, Legendre and Gauss built the classical theory of congruences and quadratic forms in the seventeenth to nineteenth centuries. Gauss's Disquisitiones Arithmeticae of 1801 set out modular arithmetic in essentially its modern form. For a long time the subject was admired precisely because it seemed useless. The English mathematician G. H. Hardy, writing in 1940, took pride in the fact that number theory had no military application.
That changed in the 1970s. Diffie and Hellman's 1976 paper and the RSA paper of 1977 created public-key cryptography. Within a few years, mathematicians including Carl Pomerance, Hendrik Lenstra and many others turned to factoring and primality testing with new urgency. Koblitz's book was one of the first textbooks to gather the mathematics and the cryptography together in one place for students. It helped define a new course that many universities now teach.
On this shelf, the books around it divide into three groups. The history of the subject appears in The Codebreakers by David Kahn, The Code Book by Simon Singh, and Crypto by Steven Levy, which tells how Diffie, Hellman, the RSA team and others brought public-key cryptography into being. Engineering practice appears in Applied Cryptography by Bruce Schneier, Cryptography Engineering by Ferguson, Schneier and Kohno, and Serious Cryptography by Jean-Philippe Aumasson. Rigorous theory appears in Introduction to Modern Cryptography by Katz and Lindell and in the Handbook of Applied Cryptography by Menezes, van Oorschot and Vanstone, which covers much of the same number theory as Koblitz in reference form.
For the blockchain books in the bay, Koblitz supplies the foundation. Mastering Bitcoin and Mastering Ethereum explain how keys, addresses and signatures are used, and refer to elliptic curve cryptography without deriving it. Bitcoin and Cryptocurrency Technologies by Narayanan and colleagues treats the cryptographic primitives more formally. Reading Koblitz first, or alongside, turns those references from black boxes into understood machinery.
After this book, the field moved quickly. Koblitz himself wrote Algebraic Aspects of Cryptography in 1998, which covers hyperelliptic curves and other topics. Many textbooks now treat elliptic curve cryptography at length, and the theory of pairings, isogenies and lattice-based cryptography has grown into large areas of research. The present book remains a compact entry point to the classical core.
Questions and criticisms
The main limitation of the book for a modern reader is its age. The second edition dates from 1994. Recommended key sizes, the best known factoring records, the set of curves considered safe and the standards in use have all changed since. The number field sieve, which became the fastest general factoring method in the early 1990s, receives less attention than the quadratic sieve. Pairing-based cryptography, side-channel attacks and post-quantum cryptography are absent or barely present. A reader should treat the book as a foundation and look elsewhere for the current state of the art.
A second criticism is that the book is mathematically demanding in places for its stated audience. Koblitz moves quickly, and some proofs are left as exercises or sketched. Readers without experience in abstract algebra may find the sections on finite fields and elliptic curves hard going. This is partly a feature: the book is meant to be worked, not read. But self-taught readers may want a gentler companion text on groups and fields.
A third concerns what the book does not do. It does not define security in the formal sense that later theoretical cryptography uses, with precise games between attacker and challenger and reductions to hard problems. Koblitz has, in later writings, been sceptical of how much those formal proofs actually guarantee, and the book's informal approach reflects his view that understanding the attacks matters more than formal definitions. Readers who want the formal approach should turn to Katz and Lindell. Reading both is instructive, because they represent two honest views of what cryptographic security means.
What has held up? The mathematics, entirely. Theorems do not age. The account of modular arithmetic, finite fields, quadratic reciprocity, primality testing and elliptic curve arithmetic is as correct now as in 1994, and the exercises remain valuable. The basic framework of public-key cryptography, with its reliance on hard problems and the careful choice of groups, is still how the subject is organised. And the elliptic curve proposal, still fairly new when the book was written, has become one of the great success stories of applied mathematics.
What later work has changed is mostly in the direction of danger and opportunity. Shor's quantum algorithm threatens both RSA and elliptic curve systems if large quantum computers are built, and new standards based on lattices and hash functions are being adopted in response. At the same time, elliptic curves have found uses far beyond what the book imagines, in zero-knowledge proof systems, threshold signatures and the internal machinery of blockchains. The book prepares a reader to understand both developments.
Why it is on this shelf
This bay holds books on cryptography, blockchain and crypto. Many of them describe what systems do. This one explains why they work. It is the place on the shelf where the mathematics is done properly, with proofs and calculations, by one of the two people who first proposed the elliptic curves now used to sign every Bitcoin and Ethereum transaction.
We keep it for its foundations. A reader who can compute a modular inverse, test a number for primality, carry out a Diffie-Hellman exchange by hand and add two points on a small elliptic curve understands the core of public-key cryptography at a level no popular account can give. That understanding makes the engineering books in the bay much easier to read, and it protects against the confusion and overclaiming that often surround the subject.
We also keep it for what it shows about mathematics. Number theory was studied for centuries with no thought of use, and then became the basis of digital security. A shelf that also holds Jyotish, with its ancient arithmetic of cycles and periods, and Vedanta, with its search for what is invariant beneath change, has room for a book about cyclic groups and the hidden regularities of whole numbers. The patterns that a calculator of planetary periods or a student of the remainders of large powers learns to see are of a kindred sort: structure that holds exactly, however large the numbers grow.
Finally, it is a model of teaching. It is short, exact and honest about what is proved and what is merely believed. That combination is rare and worth having on any shelf.
How to read it
Do not read this book; work it. Keep paper and a pencil, and preferably a computer with a language or system that handles large integers, such as Python or a computer algebra system. Plan on several weeks at a few hours a week for a first serious pass.
Begin with the elementary number theory. Work the material on divisibility, the Euclidean algorithm, congruences and the theorems of Fermat and Euler slowly, doing a good share of the exercises. Write your own short programs for the extended Euclidean algorithm and for modular exponentiation by repeated squaring. Do not move on until computing an inverse modulo a prime feels routine.
Next, read the material on finite fields and quadratic residues. If abstract algebra is new to you, read with a basic algebra text open beside you for the definitions of group, ring and field. On a first pass you may skim the proof of quadratic reciprocity, but do compute Legendre symbols by hand for small primes until reciprocity feels natural.
Then read the classical cryptography and the public-key systems. For RSA, generate a toy key with primes of two or three digits, encrypt and decrypt by hand, and then break it by factoring the modulus. For Diffie-Hellman, carry out an exchange with a friend using a small prime. These exercises fix the ideas permanently.
Read the material on primality and factoring next. Implement the Fermat test and then the strong test, and find a Carmichael number that fools the first but not the second. Try Pollard's rho method on numbers of ten or twelve digits. On a first pass you may skim the details of the quadratic sieve and come back to them later.
Finally, take the elliptic curve material slowly. Draw a curve over the real numbers and add points geometrically. Then pick a small prime, list every point on a curve over that field, and verify the group law by computation. Compute multiples of a point until you return to zero. This is the single most valuable exercise in the book for a reader interested in blockchains, because it shows exactly what a public key is.
For what to read next from this shelf, go to Serious Cryptography for modern practice, Introduction to Modern Cryptography for formal definitions, and Mastering Bitcoin for how the elliptic curve keys you have just learned are used in a real system. The Handbook of Applied Cryptography is a reference to keep at hand for algorithms and further detail.
Questions to carry
- What does it mean for a computation to be easy in one direction and hard in the other, and is any such asymmetry actually proved?
- Why does repeated squaring make modular exponentiation fast, and what would public-key cryptography look like without it?
- How does the extended Euclidean algorithm produce a modular inverse?
- Why must the size of a finite field be a power of a prime?
- What does it mean that the nonzero elements of a finite field form a cyclic group, and why does cryptography need that?
- Why is breaking RSA at most as hard as factoring, and why is it not known to be exactly as hard?
- How can a primality test declare a number composite without finding any factor of it?
- What role does the factorisation of the group size play in the difficulty of a discrete logarithm problem?
- Why do index calculus methods work in finite fields but not, as far as is known, on general elliptic curves?
- How is the sum of two points on an elliptic curve defined, and why does it satisfy the laws of addition?
- Why can elliptic curve keys be so much shorter than RSA keys for the same security?
- What exactly would a large quantum computer break, and what would it leave standing?
- When a wallet's security is said to rest on the elliptic curve discrete logarithm problem, what belief is being relied on, and how was it formed?
Words to know
- Carmichael number: A composite number that passes the Fermat primality test for every base sharing no factor with it.
- Chinese remainder theorem: A result that reconstructs a number modulo a product from its remainders modulo pairwise coprime factors.
- Congruence: The relation between two integers that leave the same remainder on division by a given modulus.
- Diffie-Hellman: A method for two parties to agree on a shared secret over a public channel, based on the discrete logarithm problem.
- Discrete logarithm: Given a generator and an element of a cyclic group, the exponent that produces the element from the generator.
- ECDSA: The elliptic curve version of the Digital Signature Algorithm, used for signatures in Bitcoin and Ethereum.
- Elliptic curve: The set of solutions to an equation of the form y squared equals a cubic in x, plus a point at infinity; its points form a group.
- Euclidean algorithm: An ancient method for finding the greatest common divisor of two integers by repeated division.
- Euler's theorem: A generalisation of Fermat's little theorem to any modulus, using Euler's totient function.
- Factor base: A set of small primes used in factoring and index calculus methods to build numbers that split completely.
- Fermat's little theorem: For a prime p and a number a not divisible by p, a to the power p minus one leaves remainder one modulo p.
- Finite field: A number system with finitely many elements in which addition, subtraction, multiplication and division by nonzero elements all work.
- Generator: An element of a cyclic group whose powers, or multiples, produce every element of the group.
- Hasse's theorem: The bound stating that the number of points on an elliptic curve over a finite field is close to the field size.
- Index calculus: A family of subexponential algorithms for discrete logarithms in finite fields, using factor bases.
- Legendre symbol: A notation indicating whether a number is a square modulo an odd prime.
- Modular exponentiation: Raising a number to a power modulo n, done quickly by repeated squaring.
- Polynomial time: Running time that grows like a fixed power of the input length; the usual meaning of efficient.
- Primitive root: A generator of the multiplicative group of remainders modulo a prime.
- Pseudoprime: A composite number that passes a given primality test for a given base.
- Public-key cryptography: Cryptography in which the encryption or verification key is public and only the decryption or signing key is secret.
- Quadratic reciprocity: Gauss's law relating whether p is a square modulo q to whether q is a square modulo p.
- Quadratic residue: A number that is a perfect square modulo a given modulus.
- RSA: The public-key system of Rivest, Shamir and Adleman, whose security rests on the difficulty of factoring.
- Trapdoor: Secret information that makes an otherwise hard computation easy for its holder.
A note on this edition
This is a study edition written for the shelf in our own words. It explains what Koblitz's book covers and why it matters, but it does not reproduce his text, his proofs or his exercises, and the examples here are our own. The book itself is in copyright and remains available from Springer and in many university libraries. It is worth getting and working through with a pencil, which is the only way its mathematics can really be learned.