# Understanding an encryption technique algorithm

I have trouble understanding steps for Key set generation mentioned in an article titled as "An optimized encryption technique using an arbitrary matrix with probabilistic encryption". The steps are:

1. Consider the sequence for 0 to n-1 values for a source text of size n = pow (p, p) characters.
2. Convert each element of the sequence into a form with base p.
3. Represent the values of step 2 in a matrix form A of order n x p.
4. Subtract 1 from each element of A.
5. Consider a random matrix B of size p x p.
6. Multiply the matrix A with B to generate a result matrix R.
7. Substitute all positive integers of R with +1, negative integers to -1 and zero by 0 using a substitute function.
8. Increment each element of R by 1.
9. Convert each row of R, from the base p to decimal to generate the key sequence set.

I can't understand how this works. Can you explain these steps with an example? Or pseudocode?

• pow(a,b) is not standard mathematical notation. – kodlu Jun 1 '17 at 1:37
• Somewhere in the paper saying that "the algorithms are implemented using C". @kodlu – Warjeh Jun 1 '17 at 13:28

To be honest, this paper looks like garbage. It refers to Base64 as an "encryption algorithm" in section 2.2. Figures 1 and 2 were created by a moron. But anyway...

1. Consider the sequence for 0 to n-1 values for a source text of size n = pow (p, p) characters.

If $p = 4$, then $n = p^p = 256$ and we'll be working with a block of 256 bytes. But for brevity, I'll consider the simpler case where $p = 3$ and restrict the cipher alphabet to the 26 letters of the alphabet plus the space character.

Presumably the pass phrase will have to be padded to the block size before applying this algorithm, but the paper doesn't describe how to do this. Let's assume we're starting with the 27-character keyphrase THIS IS MY SECRET KEYPHRASE.

2. Convert each element of the sequence into a form with base p.

If ' '=000, 'A'=001, 'B'=002 and so on, up to 'Z'=222, we get the following:

202 022 100 201 000 100 201 000 111 221 000 201 012 010 200 012 202 000
102 012 221 121 022 200 001 201 012

3. Represent the values of step 2 in a matrix form A of order n x p.

$$A = \begin{bmatrix} 2&0&2&0&2& \dots &0&0&1&1&1\\ 2&2&1&0&0& \dots &0&2&0&0&0\\ 1&0&2&0&1& \dots &0&1&0&1&2\\\end{bmatrix}$$

4. Subtract 1 from each element of A.

$$A = \begin{bmatrix} 1&-1&1&-1&1& \dots &-1&-1&0&0&0\\ 1&1&0&-1&-1& \dots &-1&1&-1&-1&-1\\ 0&-1&1&-1&0& \dots &-1&0&-1&0&1\\\end{bmatrix}$$

5. Consider a random matrix B of size p x p.

This is under-specified. But let's assume the elements of $B$ are all in the range from $0$ to $n-1$:

$$B = \begin{bmatrix} 21&16&5\\ 15&23&8\\ 3&10&10\\\end{bmatrix}$$

6. Multiply the matrix A with B to generate a result matrix R.

$$R = B \times A = \begin{bmatrix} 37&-10&26&-42&5&\dots&-42&-5&-21&-16&-11\\ 38&0&23&-46&-8&\dots&-46&8&-31&-23&-15\\ 13&-3&13&-23&-7&\dots&-23&7&-20&-10&0\\\end{bmatrix}$$

7. Substitute all positive integers of R with +1, negative integers to -1 and zero by 0 using a substitute function.

$$R = \begin{bmatrix} 1&-1&1&-1&1&\dots&-1&-1&-1&-1&-1\\ 1&0&1&-1&-1&\dots&-1&1&-1&-1&-1\\ 1&-1&1&-1&-1&\dots&-1&1&-1&-1&0\\\end{bmatrix}$$

Wait a minute; if $p > 3$, then isn't matrix $R$ going to consist mostly of ones? Maybe $B$ should also include negative values? Who knows?

8. Increment each element of R by 1.

$$R = \begin{bmatrix} 2&0&2&0&2&\dots&0&0&0&0&0\\ 2&1&2&0&0&\dots&0&2&0&0&0\\ 2&0&2&0&0&\dots&0&2&0&0&1\\\end{bmatrix}$$

9. Convert each row of R, from the base p to decimal to generate the key sequence set.

This can't be right. Although $p=3$ in this example, the elements of $R$ consist of the values 0, 1 and 2 for any value of $p$. However, according to the encryption algorithm discussed later in the paper, we're supposed to end up with a set of $n$ values. So I guess we just replace each group of $p$ elements in $R$ with the result of interpreting them as digits in base $p$:

$$K = \begin{bmatrix} 20&8&18&20&0&18&11&9&0\\ 23&1&18&2&0&18&2&20&0\\ 20&2&18&8&6&18&2&20&1\\\end{bmatrix}$$

When flattened into a string of characters from the cipher alphabet, this is the result:

THRT RKI WARB RBT TBRHFRBTA


I'll probably lose the will to live if I start wading through the encryption algorithm, so I'll stop here.

• I think that we've been had. Look at this 4 page doozy from the same journal: sciencedirect.com/science/article/pii/S1877050915019109 It's (allegedly) a recent trend in Captcha development consisting of distorted letters on a fuzzy background. Recent eh? I suspect that this journal isn't published by the same people who print Nature. – Paul Uszak Jun 1 '17 at 11:47
• @PaulUszak Perhaps it's all part of an elaborate hoax. – r3mainer Jun 1 '17 at 12:24
• "India emerged as the world's largest base for fee-charging open-access publishing" - the paper's Indian. In view of this and the gross errors you've found, I'm going to flag this for a little moderation. – Paul Uszak Jun 1 '17 at 13:05
• I have the feeling I'm missing something … how did we get from * "An Optimized Encryption Technique using an Arbitrary Matrix with Probabilistic Encryption"* at researchgate to *["Designing a Secure Text-based CAPTCHA" at sciencedirect? Was the later just linked to underline your statement about "Procedia Computer Science" n general, or are those two papers somehow related to each other beyond the fact they seem to have both been published via Procedia? – e-sushi Jun 1 '17 at 18:30
• @e-sushi: Yes, they're both from Procedia Computer Science, and presumably Paul linked to the latter as (another) example of obvious crap published in that journal. ResearchGate and ScienceDirect are both just aggregators; you can find both articles through either of them. – Ilmari Karonen Jun 2 '17 at 13:24