Solving a Bazeries Xenocrypt cipher

In the July-August 2021 issue of The Cryptogram, the magazine of the American Cryptogram Association (ACA), the Xenocrypt section contained a Spanish language Bazeries cipher to be solved. A crib was provided as a possible entry. I was able to solve it relatively easily with some computer programs I have. I’ll explain how. If you’re strictly a paper-and-pencil solver, this post will probably not be of much use to you, which is why I’m putting it on my blog instead of submitting it to the magazine as an article.

If you are not familiar with the Bazeries cipher, as implemented by the ACA, I suggest reading the description here. Etienne Bazeries invented or improved on other ciphers as well, but this article refers only to the ACA version. The term Xenocrypt simply means a cipher in a foreign language. A crib is just a section of the original plaintext known to appear somewhere in the text.

First, consider how to solve a Bazeries cipher using a computer if you know the language of the plaintext, English, for example. It is a relatively simple matter for a programmer to write a program that takes every number from 1 to 999,999, the key, convert it to text form using a conversion table or module, use that as a simple substitution key, and use the numerical key to transpose the resulting text back to its original form. The transposition can take place before or after the substitution step. The results will be the same. The decryptions can be tested to see if they resemble English, or, if you have a crib, test to see if the crib appears in a trial decryption.  I have a program that does that. I also have Spanish language tetragram frequency data in a file I can substitute for my English data. However, that won’t break this cipher. Why not? Because I don’t have the Spanish conversion table for the numbers. I don’t know how to write large numbers in Spanish, so the program won’t convert to proper plaintext.

It’s possible for me to look up how to convert those numbers in Spanish and to write a conversion table, of course, but that’s a lot of work and likely to be error-filled. Instead, here’s the method I used.

Step 1: I reversed the ciphertext. Every computer language has a simple command for that. Reversal is critical to the next step because a hillclimber relies on on tetragrams (or other n-grams) to be in order. As long as one or more digits larger than 3 appear in the key, there will be many tetragrams in the right order.

Step 2: I input the reversed ciphertext to my simple substitution hillclimber with the test language set to Spanish. The output was jumbled due to the transposition operation of the Bazeries, but parts of the crib appeared in the best decryptions.

Here’s the crib: no se conforma a
Here’s a section of the best-scoring trial decrypt: …asdelpenormsn formaala con sedelque noualctiaint…

It’s easy to see that is the section containing the crib. The program found what appeared to be the best substitution and I could see where in the decryption the crib appeared. However, several different transposition keys could produce segments like this, even if the substitution was not 100% correct.

Step 3: I then reversed the new text, and saved it, what was now plaintext Spanish with short reversals of varying length. The ciphertext was then back in its original order, except it had been translated letter-for letter, although I couldn’t be certain it was 100% correct.

Step 4. I ran my regular Bazeries program with one small subroutine added. After each transposition step I commanded it to search for a 13-letter stretch of text that has the same pattern of repeats as the crib. I used pattern search instead of searching for the exact crib because I couldn’t be certain the substitution was correct. The pattern should still appear even if one or two letters were substituted incorrectly. If the pattern was found, it printed on the screen the complete decryption (without any conversion/substitution step since it had already been substituted). However, it turned out that too many incorrect keys produced stretches with that pattern, but did not contain the crib or a valid plaintext. So I looked back at the best decryption in Step 2 to see approximately where in the text the crib appeared. I was able to narrow down the possible starting point to a very small range. I then re-ran the Bazeries program limiting it to that part of the decryption. But then it found no solutions!

Step 5. I realized that I had counted the crib position from the top in step 4, but the text I was looking at from step 2 had been reversed. Therefore I should have counted from the bottom. I did that and adjusted the range to search the new ciphertext. When I ran it again, the program found the pattern in the right spot and printed out exactly one decryption:  – the complete, correct decryption!

 

5 thoughts on “Solving a Bazeries Xenocrypt cipher

  1. William Sanderson

    I read with great interest your article concerning the Spanish Bazeries cipher. I am having trouble in solving it needless to say. I am in the process of converting numbers into Spanish Text. It is proving a long and arduous process. But in order for me to proceed I need the Spanish Tetragram. I have searched the Internet to try and find it but with no success. Could you please point me in the right direction so that I may download it. Many thanks for your help
    kind regards
    Wm Sanderson
    aka Welsh Wizard

  2. Russ Post author

    Welsh Wizard, you should download some Spanish language books in text form and process them to obtain the tetragram frequencies. A good source for the books is gutenberg.org. There are hundreds of free books in Spanish there, but you only need to process two or three long ones, like Don Quixote. Remove all the spaces and punctuation and count up the tetragrams and you have your data.

  3. Russ Post author

    Good job, John. It looks like you’re going to have to do it again on X11 in the new issue. That one was harder for me because the crib was so much shorter. It looked like the crib could fit in several places, and the pattern certainly did.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.