Cubic cipher

advertisement
Cubic cipher
key generation
First, form a Keystring like Playfair
E.g. Keyword=COLUMBIA
Keystring=COLUMBIADEFGHJKNPQRSTV
WXYZ
key generation
• Then wrap keystring around a 3X3X3
cube, but leave center empty.
• 2D and 3D views:
z=0
COL
UMB
IAD
z=1
EFG
H J
KNP
z=2
QRS
TVW
XYZ
encryption
• Basic idea: for a cleartext letter, ciphertext
= pair of letters around it on a straight line
• E.g. FEG and VRY
COL EFG QRS
UMB H J TVW
IAD KNP XYZ
• Since there’re multiple adjacent pairs,
there’re multiple ways to encrypt.
Encryption
• Adjacent pairs can go beyond the cube
and “wrap back” to it (or think of the cube
as being surrounded by copies of itself)
• E.g. CLO is also a valid encryption
LCOL EFG QRS
UMB H J TVW
IAD KNP XYZ
encryption
• Two other examples:
CIU
CDM
encryption
• A less intuitive example: CPV
COL EFG QRS
UMB H J TVW
IAD KNP XYZ
encryption
• 13 such symmetric pairs (above/below, left/right,
in front/behind, in front-above/behind-below, …)
• Mathematically… (x, y, z = coordinates of letter)
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
x+1
y+1
z+1
x+1,
x+1,
x+1,
x+1,
y+1,
x+1,
x+1,
x+1,
x+1,
y-1
y+1
y+1,
z+1
y+1,
y+1,
y-1,
y-1,
z-1
z+1
z-1
and
z+1
z-1
z+1
z-1
and
and
and
and
and
and
and
and
and
and
and
and
x-1
y-1
z-1
x-1,
x-1,
x-1,
x-1,
y-1,
x-1,
x-1,
x-1,
x-1,
y+1
y-1
z+1
z-1
y-1,
z-1
y-1,
y-1,
y+1,
y+1,
z+1
z-1
z+1
z-1
z+1
encryption
• Each pair has two directions
• E.g. COL or LO
• So, total of 13X2 = 26 pairs
Encryption
• But 2 of them involve the empty space in
the middle, so drop them.
• Overall, 24 possible encryptions for
each letter.
encryption
• Which of the 24 encryptions to pick?
• Use a distribution function to decide
• Right now, distribution function simply
returns random integer from 0 to 24
All 24 encryptions have equal chance
• More on this later.
decryption
• Basic idea: take the two ciphertext
characters, find the letter that forms a
straight line with them.
• Technical term? Zeph: “It’s called Cubic
projection… or something like that.”
• Very simple, but not sure how to describe
in English.
decryption
• Use 2D as example. Only 2 possibilities
• Case 1: lie on the same x-coordinate
• That means cleartext lies on the same
coordinate also
decryption
• Case 2: lie on different x-coordinates
• That means cleartext lies on the third,
unoccupied x-coordinate
decryption
• For our case, basically repeat the above
for all 3 planes (xy, xz, yz) of the cube
nulls
• Nulls = meaningless
characters in the
ciphertext to confuse
cryptanalyst
• In my cipher, you can
produce nulls by
encrypting the
empty space in the
middle
nulls
• E.g. EP/PE and MV/VM are adjacent
pairs of the empty space.
COL EFG QRS
UMB H J TVW
IAD KNP XYZ
COL EFG QRS
UMB H J TVW
IAD KNP XYZ
• So, when decrypted, EP, PE, MV, and VM
conveniently become the empty character
and disappear: EP’ ‘
nulls
• Some examples:
MVEPVMVMPEVMMVEP
VMMVVMMVOLMVMVMVC
PEEPLOPEEPOLPEEPCC
• The cipher sprinkles nulls at random
throughout the ciphertext
nulls
• (Note: since the adjacent pairs of the
empty space cannot contain the empty
space itself, all adjacent pairs are valid. So
there are 26 possible nulls, not just 24.)
• (Another note: because of nulls, ciphertext
is in general more than twice as long as
cleartext)
Sample encryptions
• Cleartext:
“If one examines dialectic materialism, one is faced with a choice:
either accept textual neocultural theory or conclude that narrative is
created by the masses. Many narratives concerning the role of the
observer as reader exist.” (From Postmodernism Generator)
• Ciphertext:
YUNENIQMBITVHESQKOJOHEXFHGFNNZPXZAWYXJQOTVRNQIHEUYTXGELWCXVPBIATR
VTRMTXFCFBKNIUXEHOUPVZAQXDVBVNRYXIDNKYWIGTQRACIHMPZGNZDXFOWWYAQ
UOWGOSSHEHZYANUOBQSDOWYMDJTOEHMLARANMGPDLMQWWLUKWVPSGRKZAULB
FBDIYVGYJRSLZIGXLMRWBICWTAHZZDWYVIHEUAXBXUIHGXJCMZCBPSHSWYQFWLPOP
LSDMDPVHWIZQIFXMXUOZKAZEPRNGONFMFPYSHWKPVYQEIHZSHRXTSNFLTOKGBIDG
BMGSOQXGEUCTJEHHZXUEQGOUTKYKOHSBEHOFNYJYMJMJTPZZRTAVPTJNOZSSBVE
CIYXUTWHUEDHWKEUSCCXIDAMHETVQLYNQXIBHWSUXRMGMDWLDALSYXGFPXWKBQ
SPUNQGVRKIIQ
Further development?
• As I mentioned, right now all 24 (26 for
null) ciphers for each letter have equal
probability.
• Dist.Func. just returns random int in [0, 25]
int distFunc(char X) {
return rand.nextInt(26);
}
Further development?
• But can make it more complicated by
limiting the choices for some letters to less
than 24
• E.g. frequency balancing for homophony
• Or the opposite: “unbalance” it (make the
ciphertext for ‘Z’ the most frequency
bigraph) to throw people off (Shane’s
suggestion)
Further development?
• Encrypt the ciphertext again using the
same key or some key derived from it?
• Instead of adjacent pairs, use weirder
pairs (or perhaps determine what to use
by looking at the keyword)
Weaknesses
• subject to bigraph frequency analysis,
although nulls and 1-to-24 help a little
• too simple?
Thanks!
All Hail the Fu
Download