Group Abstract Group Abstract

Message Boards Message Boards

Developing Chinese crypto in the Voxelverse.

Posted 4 years ago
POSTED BY: Brad Klee
5 Replies
Posted 4 years ago

enter image description here A Scrambled Calendar Ticker

Welcome to 2022, let the decode contest begin! Raw data files are available at github, 180 cubes for the calendar descramble, and one extra prize cube with stronger encipherment. The main rule is no peeping at the secret keys. In the first challenge, a win condition is finding a permutation that sorts calendar frames back into normal order. The second challenge win condition is reporting and interpreting six hidden characters. An even stronger win would be to return all secret keys. Here is a final form reference implementation, which obtains decodes from known secret keys: available on the cloud. Now I will give a few more helpful comments.

Here is an important function for importing data files (since we still don't have standard vox format):

importAG3D[file_] := Map[Partition[#, 64] &,
  Partition[Flatten[Map[ToExpression, Characters /@ StringSplit[
       Import[file], "\n"]]], 64*64]]  

Example Imports

CalCryptograms = importAG3D[
     "https://raw.githubusercontent.com/bradklee/CryptoAssets/master/ExCrypt4/CalCryptogram" <> StringPadLeft[ToString[#], 4, "0"] <> ".txt"
     ] & /@ Range[nMax]; 
Trigram@CalCryptograms[[1]]; 

cal 1

Challenge =   importAG3D[
   "https://raw.githubusercontent.com/bradklee/CryptoAssets/master/PrizeBox/Secret2021.txt"]; 

Trigram@Challenge; 

challenge

The calendar cipher uses a one time pad, with no Feistel mixing, and the key stream is a known function of an unknown initial value. Even then, if we try to decode a frame using a wrong key or no key, the output is typically nonsense:

nonsense

And worse can be expected for the challenge problem, which uses four layer parity symmetric Feistel mixing, for example:

enter image description here

The fact that there is only one box probably indicated symmetry mismatch between right and wrong key. Here is another dissection plot of the Challenge box:

challenge block

This secret seems fairly well protected, but trust me, it is worth wondering about. I don't think anyone will crack it, but who knows maybe. Later after Chinese New Year, I will release the secret message. Before then, it looks like we have a whole upcoming study group on cryptography in Wolfram Language. And yes, Dariia Porechna will be talking about the Feistel Scheme on Wednesday Feb. 9!

Happy New Years Eve! ~~Brad

POSTED BY: Brad Klee
Posted 4 years ago
POSTED BY: Brad Klee
Posted 4 years ago
POSTED BY: Brad Klee
Posted 4 years ago
POSTED BY: Brad Klee
Posted 4 years ago

Before going on to the contest data, we also give relatively simple code for two-dimensional encryption, this time using English characters. This code should be easier to analyze. If Autoglyphs are not random enough, then a breakthrough in 2D could lead to similar results in 3D. The other possibility is that no one will win the contest, and we will all have to wait for answers to be given out months later in February.

During the holiday season, "LOVE" is a simple and typical message, which many people will want to include with their season's greetings cards. Stacking letters into a typographic square has already been done by numerous designers, but usually not with crypto.

CUT = 0.7;
LOVEdat = Map[RastToBitmap[
     Round[CUT*Rasterize[Style[#, 20, Bold, FontFamily -> "Times"]]
      ], 16] &, Characters["LOVE"]];
LOVEmat = ArrayFlatten[Partition[LOVEdat, 2]];
OOChar = {#, Reverse /@ #} &@RastToBitmap[Round[CUT*Rasterize[
       Rotate[Style["O", 20, Bold, FontFamily -> "Times"], -Pi/4]]], 16];
Image[Mod[# + 1, 2], ImageSize -> 64] & /@ LOVEdat
Image[Mod[LOVEmat + 1, 2], ImageSize -> 128]
Image[Mod[# + 1, 2], ImageSize -> 64] & /@ OOChar

inputs

We have four letters, but preserving symmetry, we have only have two slots per ambigram. Luckily, mod 5 padding gives more than enough space to double up on slots, this time using bigrams rather than trigrams,

BigramMatrices = Plus[#[[1]], 2 #[[2]]] & /@ Append[Partition[LOVEdat, 2], OOChar];
Image[# /. RGBRep, ImageSize -> 128] & /@ BigramMatrices

bigrams

We can add this data into any 2D Autoglyph, defined as a 3D autoglyph with always $z=1$:

AutoGlyphM2D[aVal_] := With[{mod = Mod[aVal, 11] + 5},
  Outer[v[xyz[#1, aVal], xyz[#2, Floor[aVal/2]], 1, mod] &,
   Range[0, SIZE - 1], Range[0, SIZE - 1], 1]]

Symmetry from the same $8$ seeds used previously carries over, but instead of a simple representation of Octahedral symmetry, we find at most square dihedral symmetry, with a four-group acting on corner parts. This can all be ascertained by partitioning and visual analysis:

AbsoluteTiming[AGTests = AutoGlyphM2D[#] & /@ CharacteristicSeeds;]
Grid[Partition[Image[# /. RGBRep, ImageSize -> 256] & /@ AGTests, 2], 
 Frame -> All]  

AG 2Ds

The first six we can use for four letter encoding. The later two have more symmetry, so will only work to encode two letters. Now, the nice part of using only two dimensions is that the public key encoded by "Loc2Locs" is much easier than in 3D:

(* map to checkerboard *)
Loc2Locs[loc_, 1] := 2 loc - # & /@ {{0, 0}}
Loc2Locs[loc_, 2] := 2 loc - # & /@ {{0, 0}, {1, 1}}

In fact, to totally construct the permutation key, we also need to know the chosen ordering implied by the calling functions

HideRule[data_, locsI_, locsO_] := With[{vals = data[[Sequence @@ #]] & /@ locsI},
  MapThread[Rule, {locsO, vals}]]    
ValRep[data_, loc_] := With[{symPerm = Sort[Permutations[loc]]},
  HideRule[data, symPerm, Loc2Locs[loc, Length[symPerm]]]]

In this case the maybe extra Sort applied to permutations is not extra, and forces consistency between locations $(i,j)$ and $(j,i)$. The same is true in 3D, but with six rather than two possible index permutations, in three equivalence classes. When this is well understood and programmed, we force transpose symmetry in $32 \times 32$ blocks:

Image[SquareEncode[#] /. RGBRep, ImageSize -> 128] & /@ BigramMatrices

public encrypt

This is already difficult to read, but not fully encrypted. Using the complete set of functions in the cloud notebook, we produce potentially-private encrypted outputs:

private encrypt

Now the code breaker question is: Assuming ignorance of the secret keys, can anyone take the output grid and guess the patterns of the first input well enough to create a mod 5 difference, which decrypts to plain text, or even to plain text with some error?

Here's an "analysis" that shows a weakness similar to the well-known ECB Failure, as demonstrated by this picture of tux (also mentioned in Tanja's lectures, and for relevance this article on zoom).

The easy stupid idea almost works. Just skip pad subtraction,

dat = Join[Show[ResultsBW[{CubeDecode[encodes[[#, 1 ;; 32, 1 ;; 32]]],
        CubeDecode[encodes[[#, 1 ;; 32, Reverse[Range[32, 64]]]]]}],
      ImageSize -> 256] & /@ Range[4],
   Show[ResultsBW[{CubeDecode[encodes[[#, 1 ;; 32, 1 ;; 32]]],
        CubeDecode[encodes[[#, Reverse[Range[32, 64]], 1 ;; 32]]]}],
      ImageSize -> 256] & /@ Range[5, 6]];

Grid[Partition[dat, 3], Frame -> All]

partial decrypt

Anyone of these images taken alone would strongly suggest identity of the hidden message, but imagine if eavesdropping Eve intercepts the six similar messages, sent to six of your family members. Then Eve can simply average outputs and find that:

Image[Mean[ImageData /@ dat], ImageSize -> 256]

Good Decrypt

Measuring conditional probability, we find this image recovers the original with about 90% accuracy. Just imagine how Eve feels, and what she will think to do, since she didn't even get a holiday card this year, much less one with a cryptogram for "LOVE"! And add to that, what if she's sick of hearing the Rudolph joke every year?

Next question. Does the same tactic yield results on 3D test data? If yes, we may need to apply another layer of randomization to the input data, or to the pads.

POSTED BY: Brad Klee
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard