One Simple Way to Stop Sign Stealing in Baseball

No technology needed, baseball purists. This encryption scheme is simple enough to do in your head and yet strong enough to confound the opposition.

Back when sports still made headlines there was a major scandal rocking the baseball world. The Houston Astros, the winner of the 2017 World Series and contestant in the 2019 World Series, had been using a creative scheme to gain a competitive edge.

They used cameras to decode the signs being sent between pitcher and catcher so their hitters would know the type of pitch they were about to see. Knowing which pitch is coming can be a huge advantage, allowing batters to better gauge when to swing for a big hit. Such undercover, unsportsmanlike behavior obviously upset a lot of people throughout the baseball world. But is there a way to combat cheating and level the playing field? You’re about to find out.

Encrypting Baseball Signs with Simple Math

Teams can maintain their competitive edge—without cheating—by encrypting their signs with a secret code. In this post, we’ll go over how to use an encryption algorithm (a type of stream cipher) to make it much more difficult to decode the signs.

Now, when people think encryption, they usually think of something like the enigma machine used by Germany during World War II. (Try sneaking that into the clubhouse—I wonder what would happen?)

But this type of encryption requires no machinery at all. While there is some math involved, it’s simple to calculate in your head using only addition and multiplication of small numbers. I’ll introduce the scheme first, then will describe the math behind it. Ready? Play ball!

How baseball sign encryption works

Suppose you have a pitcher that can throw the following pitches:

  • Fastball
  • High fastball
  • Changeup
  • Slider
  • Curve
  • Cutter

Let’s map each pitch to a unique number between 1-6. The numbers we assign to the pitches constitute one part of the secret “key.” This is the usual starting point for sign communication schemes. (An analysis of several other variants of pitch encryption can be found here.)

Obviously, this by itself isn’t enough security, as repeated signs will correspond to the same pitches. A sign you haven’t seen before in a sequence is a clue that it’s a new pitch, and probably not a fastball. All this allows opponents to quickly learn the signs, and before you know it, you’ll hear people banging on trash cans.

So, let’s throw a curve ball: what if we changed the signs after every pitch? With only a little bit of mental arithmetic, the pitcher and catcher can stay in-sync on the shifting signs. Then, a catcher can throw down a “1” for one pitch, meaning fastball. Then, it might so happen that on the next pitch, “1” means change-up. If you thought you were dealing with the usual sign scheme, you’d be wrong. In this case, you could broadcast the signs on the JumboTron and it wouldn’t matter. The pitcher could call the signs in plain view and the batter wouldn’t be able to predict the next pitch. No extra technology (or trash cans) required.

What does this look like for the batter and for the pitcher/catcher?

The math behind sign encryption

Here’s what the battery-mates do:

Letter y a b u a’ b’
MEANINGEncoded signFirst secret number Second secret numberActual signUpdated secretUpdated secret

First, they agree on the mapping between pitches and numbers, in this case numbers 1-6. Then, they agree on two magic starting numbers between 1-6, called a and b.

Then, they pick a pitch! Let’s say the pitch is numbered u = 3. To send a sign, encode u as follows:

y=3(a+b+u) \mod 7

To decode the pitch from seeing the sign y:

u=5y-a-b \mod 7

The equations look pretty simple, besides the “mod 7” part. Modular arithmetic is central to nearly every encryption algorithm. It asks you to compute the remainder after dividing by 7. One way to think about this is by using a clock, which is “mod 12.” If it’s 2:00 now, then after 15 hours, it will be what? Well, after 12 hours, it’s 2:00 again. Then, we have three more hours to get to our total 15 hours, so it will be 5:00.

These equations are (theoretically) simple enough to do in one’s head, just multiplying by small numbers, adding, and then finding a remainder after dividing by 7. Sure, modular arithmetic can be confusing at first and teams would need to practice it a bit but it’s a solid encryption system that’s worth the effort.

Putting the encryption system into play

Previously, I said we’d change the signs every pitch. So, after one pitch, the secret numbers a and b get updated. They are updated in such a way that the observations of the pitch cannot reveal enough information to reverse-engineer the secret values.  

a'=a+2b+2u \mod 7
b'=2a+b+u \mod 7

An opponent would need to know the numbers a and b to decode the sign u. But every pitch changes a and b, making the signs a moving target.

This scheme so far seems very arbitrary. Why did I claim that the pitches do not reveal enough information to reveal the secrets a and b (without brute-force guesswork)? Time for some more math!

Specifically, let’s use some linear algebra.

The “state” is the shared secret between pitcher and catcher. It is a 2-dimensional vector:


The “plaintext” sign is u, and is just a single number.

The state gets updated after every pitch by a couple matrix-vector operations:

x'=Ax + Bu

And the output equation, to generate the encoded sign, is:


The variables A, B, and C are matrices. They look like this:

A=\left[\begin{array}{cc} 1& 2\\ 2& 1\end{array}\right], B=\left[\begin{array}{c}2 \\ 1\end{array}\right], and C=\left[\begin{array}{cc}1 & 1\end{array}\right]

Look at a sequence of outputs:

y_1 = C(Ax_0 + Bu_1)
y_2 = C(A^2x_0 + ABu_1 + Bu_2)
y_3 = C(A^3x_0 + A^2Bu_1 + ABu_2 + Bu_3)

The output matrix C is throwing away information by adding the values of two dimensions together. Watching the output is like watching the shadow of an object on a wall and trying to figure out where that object is in the room.

Let’s say after every pitch the batter was able to deduce every value of u correctly—that still wouldn’t be enough information to determine x0 and thereby crack the code for the next pitch! The key there is the sequence C, CA, CA2, CA3which is:

[1, 1]
3 * [1, 1]
2 * [1, 1]
6 * [1, 1]
4 * [1, 1]
5 * [1, 1]
[1, 1]

Therefore, the only observation of x0 ends up being the same sum of its two values over and over. There’s no way to tell exactly which two values constitute the sum, which is necessary to determine the code for the next pitch. That information is mathematically secured from all except guesswork! In the realm of dynamical systems, this is called an “unobservable” system, meaning there is no way to determine the initial state after a finite number of observations.

While in this case, there aren’t many numbers to guess from, imagine what the scheme might be like when working with bigger numbers and with a bigger state variable. This kind of stream cipher is an approximation to the only known unbreakable encryption scheme, the one-time pad. So, while this simple example works for baseball, the possible applications can go far beyond sports, too.

Our Data Team weighs in frequently on different data topics, from why LinkedIn recommends you connect with an ex to how to understand Python data types. Sign up for our newsletter to make sure you don’t miss out.
