Duet

The Feistel Network uses 2 bit keys K0 and K1.
The plaintext is input in left and right halves L0 and R0.


Two Bit Cipher Block Diagram .jpg Image

The outputs are called L5 and R3.

Duet uses two bit keys and two bit block sizes for plain and cipher text. This builds upon the Linear Cryptanalysis workbench that was started with the Solo cipher. The Feistel network is used to split the input block in halves. Then left and right halves are swapped in four rounds. The advantage of this splitting of the block is that decryption uses the same software as encryption if the key schedule is reversed. The block diagram of the cipher is available here, with Java code:
http://popcryspri11.blogspot.com/p/duet.html

TRUTH TABLE FOR DUET
/* Rev 18 Duet Two Bit Cipher in Feistel Network
p is 2 bit plain text, k is key, c is cipher text, p' is decrypted 2 bits
Electronic Code Book (ECB) with four columns:
plaintext, key, ciphertext, and decrypted plaintext p'

p k c p'
0 0 0 0
1 0 3 3
2 0 2 2
3 0 1 1
0 1 1 3
1 1 2 0
2 1 3 1
3 1 0 2
0 2 3 1
1 2 0 2
2 2 1 3
3 2 2 0
0 3 2 2
1 3 1 1
2 3 0 0
3 3 3 3

March 7, 2012 Java Eclipse IDE
REV18

Java Code Snippet for Decryption
// Begin with L0 and R0 left and right bits of a two bit block c
// Four ROUNDS OF DECRYPTION using reversed key schedule in Feistel Network
L1=K1^R0;
R1=L1^L0;
L2=K0^R1;
R2=L2^R0;
L3=K1^R2;
R3=L3^R1;
L4=K0^R3;
L5=L4^R2;

The result of decryption is p' = L5 + R3 where + means concatenation
The input key k = K1+ K0
ciphertext input is c = L0 + R0
Those two bit variables are shown as numbers 0-3 in the table.

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

The linked Java program verified that decryption performs as advertised for a balanced Feistel network. This means that the same block diagram is used for encryption and decryption, but with reversed key schedules. There is no reversed logic to decrypt a block. All encryption and decryption logic goes in a forward direction with no reversed steps to decrypt blocks, as shown in the block diagram .jpg image. in that block diagram, the key bits K0 and K1 are shown for encryption. For decryption, reverse the key bit schedule in this block diagram. The truth table shows that decryption is accurate. For an encryption example, the truth table entry for p=2 and k=1 gives c=3. The decryption shows that p=c=3 and k=1 gives p'=2 in the Truth Table. That means that decryption logic using a reversed key schedule is correct for a Feistel Network. Check it out.

There are only 16 states in this two bit cipher. Two key bits and two plain text bits define the sixteen states, so the Electronic Code Book is short enough to print out. The next project with 4 bit blocks will have a 256 entry ECB, also small enough for brute force attacks and obvious ways to break the code with algebra.

The linear cryptanalysis will be attempted on this two bit cipher. Success is assured.



import java.io.BufferedReader;
import java.io.InputStreamReader;

public class duet18 {

public static void main(String[] args) {
int plain = 0;
int key = 0;
int K0;
int K1;
int p0;
int p1, L1, L2, L3, L4, L5, R1, R2, R3;
// plaintext p0 p1 bits for Duet Cipher 3/6/2012 af REV 18
// key k0 k1 two bits for Feistel Network and key reversal for enc-dec
System.out.println("Try Duet decryption 16 times ");
for (key=0; key<4; key++) { for (plain=0; plain<4; plain++) { // key k0 k1 two bits for Feistel Network // use one binary bit at lsb in an integer in storage K0 = (key & 0x0001); K1=(key &0x0002) >>> 1;
p0 = (plain & 0x0001);
p1=(plain &0x0002) >>> 1;

int L0=p1;
int R0=p0;

// Four ROUNDS OF DECRYPTION reversed key schedule
L1=K1^R0;
R1=L1^L0;
L2=K0^R1;
R2=L2^R0;
L3=K1^R2;
R3=L3^R1;
L4=K0^R3;
L5=L4^R2;

System.out.println("decrypted cipher text bits are k p L5 R3 " + key +plain + " " + L5 + R3);
}
}
// end of for is above








/* Rev 18 Duet 2 bit cipher in Feistel Network
p is 2 bit plaintext, k is key, c is ciphertext, p' is decrypted 2 bits

p k c p'
0 0 0 0
1 0 3 3
2 0 2 2
3 0 1 1
0 1 1 3
1 1 2 0
2 1 3 1
3 1 0 2
0 2 3 1
1 2 0 2
2 2 1 3
3 2 2 0
0 3 2 2
1 3 1 1
2 3 0 0
3 3 3 3

March 7, 2012 Java Eclipse IDE
REV 18
*/


}
}