Two things first:
- Even in 1955, Nash's encryption algorithm (I'll call it NEA) was rejected by the NSA because they deemed it not secure enough. So do not use it in real life.
- Like eg. AES, NEA is not based on any of the usual hard algorithms like factorization etc.
NEA is a symmetric stream cipher, ie. there's just one key for both encrypting and decrypting, and there's no minimum block size: One input bit becomes one output bit.
NEA needs one (possibly) public parameter, a key with several parts, and an IV (initilization vector) for each message.
The public parameter first:
- A natural number N, larger is better for security. 256 is a usual value.
A key consists of:
- Two random permutations P for N values. Ie. P to P[N-1] are the numbers from 0 to N-1 but in some random order, and P to P[N-1] too but in a completely different random order.
- Two random N-bit numbers, B to B[N-1] and B to B[N-1]
A IV is a random N-bit number just like B or B above.
Encrypting/Decrypting a message M with L bit to the ciphertext C, as pseudocode:
//N, P, B, and IV are given
//S is a N-bit memory
R = S[P[X][N-1]]
for all i from N-2 down to 0
S[P[X][i+1]] = S[P[X][i]] xor B[X][i];
S[P[X]] = X
S = IV
C = M xor Permut(0)
for all i from 1 to L
C[i] = M[i] xor Permut(C[i-1])