Happy New Year Water Tiger 2022 (almost)!
Happy New Year Water Tiger 2022 (almost)!
How about a challenge? Author: Bradley Klee.
The purpose of this notebook is to define the standard of an encryption algorithm, which takes 16x16x16 trigrams and puts them into either 32x32x32 minimal encoding or 64x64x64 symmetric encoding. Locking is accomplished by adding in a 3D Autoglyph as a one time pad mod 5. The Autoglyphs are automatically generated from 160-bit private keys. A challenge is posed by encrypting the 360 symbols of a Chinese calendar, which was given by Frederick Wu. Can you decrypt and return a correct permutation restoring cyclic order to the blockchain? If yes, proceed to the prize box. Depending on Autoglyph symmetry type, it may be possible to encode two symbols to one 64x64x64 block without diluting symmetry type. We give one example which intends to protect secret codes until Water Tiger Year 2022.
Trigram Create Functions
Trigram Create Functions
In[]:=
PadIm[bitmap_,len_,delta_]:=With[{FixWidth=Join[Table[0,{i,Floor[delta[[2]]/2]}],#,Table[0,{i,Ceiling[delta[[2]]/2]}]]&/@bitmap},Join[Table[0,{i,Ceiling[delta[[1]]/2]},{j,len}],FixWidth,Table[0,{i,Floor[delta[[1]]/2]},{j,len}]]]
In[]:=
RastToBitmap[im_,len_]:=With[{rect=Map[Mod[Round[Mean[#]]+1,2]&,ImageData[ImageCrop[im]],{2}]},PadIm[rect,len,{len,len}-Dimensions[rect]]]
In[]:=
Hexagram[code_]:=Append[ReplacePart[Table[If[OddQ[i],If[MemberQ[Complement[Range[16],{2,15}],j],1,0],If[MemberQ[{1,16},j],1,0]],{i,15},{j,16}],Join[{{1,2}1,{1,15}1,{15,2}1,{15,15}1},Flatten[Outer[{1+2#1,#2}0&,Position[code,0][[All,1]],{8,9}]]]],Table[0,{i,16}]]
In[]:=
Partials[gram1_,gram2_,gram3_,len_]:=With[{dat123=Position[Outer[gram1[[#1,#2]]gram2[[#2,#3]]gram3[[#3,#1]]&,Range[len],Range[len],Range[len],1],1]},MapIndexed[Function[{grams,ind},Complement[RotateRight[#,ind]&/@Position[Outer[grams[[1,#1,#2]]grams[[2,#2,#3]]&,Range[len],Range[len],Range[len],1],1],dat123]][#1,#2[[1]]-1]&,Partition[{gram1,gram2,gram3},2,1,1]]]
In[]:=
imDat[partials_,len_]:=Outer[Image[ReplacePart[Table[1,{i,1,len},{j,1,len}],#0&/@#1[[All,#2]]]]&,partials[[{2,3,1}]],{{1,2},{2,3},{3,1}},1]
In[]:=
Superpose[mat_]:=Map[ImageMultiply@mat[[Complement[Range[3],{#}],#]]&,Range[3]]
In[]:=
CheckProj[TrigramDat_,len_]:=Mod[MapThread[ImageSubtract,{Superpose@imDat[Partials[Sequence@@TrigramDat,len],len],Image[Mod[#+1,2]]&/@TrigramDat}],2]
3D Views and Projections
3D Views and Projections
In[]:=
Trigram[TrigramMatrix_]:=With[{parts=Position[TrigramMatrix,#]&/@{1,2,3,4}},Graphics3D[{EdgeForm[None],Transpose[{{Blue,Red,Green,Yellow},Map[Cuboid,parts,{2}]}]},ViewProjection"Orthographic",SphericalRegionTrue,ViewPoint{1,1,1},BoxedFalse,PlotRangeAll]]
In[]:=
RGBRep=Join[MapThread[Rule,{RotateLeft@Range[3],IdentityMatrix[3]}],{0{1,1,1},4{1,1,0}}];BWRep=RotateLeft[List[Alternatives@@Position[IdentityMatrix[3][[#]],0][[All,1]]1,Position[IdentityMatrix[3][[#]],1][[1,1]]0,40]&/@Range[3]];
In[]:=
OrthoProj[TrigramMatrix_,size_:128]:=With[{projections=TrigramProjMatrix[TrigramMatrix,Length[TrigramMatrix],#]&/@Range[3]},GraphicsGrid[Map[Show[#,ImageSizesize]&,{Image[projections[[#]]/.RGBRep]&/@Range[3],Image[Mod[Plus[projections[[#]]/.BWRep[[#]],1],2]]&/@Range[3]},{2}]]]
In[]:=
RGBBWResults[TrigramMatrix_]:=GraphicsRow[Map[Show[#,ImageSize400]&,{Trigram[TrigramMatrix],OrthoProj[TrigramMatrix]}]]
In[]:=
TrigramMatrix[TrigramDat_,len_]:=With[{rep=Flatten[MapIndexed[Function[{loc},Rule[loc,#2[[1]]]]/@#1&,Partials[Sequence@@TrigramDat,16]]]},ReplacePart[Table[0,{i,len},{j,len},{k,len}],rep]]
In[]:=
TrigramProjMatrix[TrigramMatrix_,len_,dir_]:=With[{parts=Position[TrigramMatrix,#]&/@{1,2,3,4}},Table[Replace[Position[parts,Switch[Length[#],0,{0,0,0},_,#[[-1]]]],{}{{0}}][[1,1]]&@Sort[Cases[parts,RotateRight[{i,j,x_},dir-1]RotateRight[{i,j,x},dir-1],Infinity]],{i,len},{j,len}]]
Trigram Test Data
Trigram Test Data
In[]:=
SeedRandom["crypto"]coupling=Hexagram[RandomSample[Tuples[{0,1},6],1][[1]]];augmenting=Hexagram[Reverse@RandomSample[Tuples[{0,1},6],1][[1]]];Image[Mod[#+1,2],ImageSize128]&/@{coupling,augmenting}
Out[]=
RandomGeneratorState
Out[]=
,
In[]:=
TestSyms="道行火土信心銘";TestSymBitmaps=RastToBitmap[Rasterize[Style[#,Medium]],16]&/@Characters[TestSyms];
In[]:=
Dimensions/@TestSymBitmaps
Out[]=
{{16,16},{16,16},{16,16},{16,16},{16,16},{16,16},{16,16}}
In[]:=
TestTrigrams={Append[TestSymBitmaps[[1;;2]],coupling],Append[TestSymBitmaps[[3;;4]],augmenting],TestSymBitmaps[[5;;7]]};
In[]:=
(*Notethesedonotlookwrong,diff.viewset,skiptodata.*)Show[Image[Mod[#+1,2]],ImageSize64]&/@Flatten[TestTrigrams,1]
Out[]=
,
,
,
,
,
,
,
,
In[]:=
GraphicsRow@{Map[Show[Image[Mod[#+1,2]],ImageSize64]&,TestTrigrams,{2}]//GraphicsGrid,GraphicsGrid[Map[Show[#,ImageSize64]&,CheckProj[#,16]&/@TestTrigrams,{2}]]}
Out[]=
In[]:=
(*FAILCASES*)
In[]:=
(*Thisisasomewhatimportantcallcomparingdatatypes*)SameQ[Partials[Sequence@@TestTrigrams[[1]],16],Position[TrigramMatrix[TestTrigrams[[1]],16],#]&/@{1,2,3}]
Out[]=
True
Note: We should have primitives here.
Due to differences between OS and version,
instead we will need to decrypt.
Due to differences between OS and version,
instead we will need to decrypt.
Autoglyph 3D Functions
Autoglyph 3D Functions
New Green Trip. Plus Plus Plus!
New Green Trip. Plus Plus Plus!
Symmetry Analysis
Symmetry Analysis
Layer 1. Permutation Public Key
Layer 1. Permutation Public Key
Layer 2. One Time Pad Mod 5 via Secret Key
Layer 2. One Time Pad Mod 5 via Secret Key
Layer 3. + + + Symmetry
Layer 3. + + + Symmetry
Brute Force Example 1
Brute Force Example 1
Brute Force Example 2
Brute Force Example 2
Proves index map 3 → 8. What is the entire permutation matching AGs with symCGs?