Stream entropy for the Vernam cipher. Android Studio JAVA
 Vernam cipher Android JAVA

# Stream entropy

Inventing is interesting

The Vernam cipher is a symmetric encryption system invented in 1917 by Gilbert Vernam.
A cipher is a type of one-time pad cryptosystem. It uses the Boolean XOR function.
The Vernam cipher is an example of a system with absolute cryptographic strength.
One of the disadvantages of using such a cipher is the need to have the same cipher pads at two points - transmitting and receiving.
Those. first you need to create and deliver a notebook with one-time encryption pages to both points, and only then you can exchange information.
In modern commercial conditions, this is not very convenient.
If quantum technologies had reached a sufficient level of development and terabytes of quantum entangled particles could be stored in smartphones, the problem of updating encryption pages would become insignificant.
However, this is still a long way off.
However, one can try to develop a system for synchronous generation of random numbers at two points (at any number of points) without directly exchanging synchronization information.
The principle of operation is as follows: the application listens to a digital stream (or several streams) of Internet radio and waits for a predefined digital sequence (a set of bytes) to appear. After that, N bytes are written to be used as a cipherpad page. Here N is the number of bytes in the encrypted message.
This is the simplest kind of technology - a demonstration of the fundamental possibility and a stand for obtaining statistics.
The process of selecting bytes to write from a stream can be greatly complicated.
A separate task is to synchronize the receipt of a code page on the transmitting and receiving side without exchanging synchronization information.

Part 1 Selecting a fragment of a digital stream for recording.
Let's create an Android Studio Java project to get N bytes for a ciphertext page.

In this form, the application found two matches in 5 minutes.
A sequence of bytes was searched in the buffer
public static byte[] efind = {0,1,5,3,7,3,6,12,4,3,7}; // We are looking for an array of bytes in the buffer. If found - write to Log

This is the simplest test array of bytes to look up in the stream. A more interesting variant with "holes" - not significant byte positions in the array.
For example, you can hold down the following array in the search
public static byte[] efind = {0,1,x,5,3,7,x,3,6,x,12,4,x,3,7};
Where the "x" position can be anything and does not affect the search result.

After the given array of bytes is found in the stream (in this example, efind), N bytes of the stream are written to a separate array - the ciphertext page. Where N is equal to the number of bytes in the encrypted message.
Moreover, the bytes of the encryption page can also be read from the stream not in a row, but according to a predetermined algorithm (for example, skipping bytes).
In this way, one of the shortcomings of the classic Vernam cipher is immediately overcome - we can get the encryption key of the required length.

The ability to listen to the digital stream on the side of the sender and receiver allows you to overcome another drawback of the classic Vernam cipher. You can receive a cipherpad page independently on both the sender and recipient sides.
There is no need for a transmission channel for encryption notebooks.
But! In order to get the same sequence of numbers for encryption / decoding from the sender and recipient, two application instances must start listening to the digital Internet stream at the same time.
Otherwise, different points of coincidence with the given array can be found and, accordingly, different arrays are written for encryption.

How to synchronize the moment of obtaining keys from the Internet stream, if there is no (for stealth) synchronizing channel?
If you do not perform special manipulations with the Internet radio data stream (transmission of the synchronization code), then the problem can be solved in the following way.
An array of bytes with a larger length is set in the search in the digital radio stream. For example, for this case, you can choose this:

public static byte[] efindnn = {0,1,5,3,7,3,6,12,4,3,7,5,1,4};

Such a sequence will have to wait much longer. It may be several days or weeks. Immediately after such a sequence is found,
the stream is searched for a shorter sequence and the cipher page is written. With a very high probability, it will be the same on both sides - transmitting and receiving.

This is a commercially viable encryption mechanism.
Internet radio can be listened to by anyone, and, in theory, "interested" clients can be identified. To increase the secrecy of the exchange of information, you can
use a digital satellite TV channel.
For projects with more serious encryption reliability by the Vernam code, a satellite noise channel should be used - a digital noise stream based on a hardware source (for example, thermal noise of a diode, etc.).
In principle, it is possible to obtain absolute strength of encryption without the classic shortcomings of the Vernam code - the difficulties of obtaining and distributing by cipher pads.
At the same time, it is impossible to track who receives the code from the satellite stream. To exclude the use of noise satellite channel technology for obtaining encryption keys by outside clients, you can use encryption of the noise stream with a strong asymmetric algorithm.

If a special noise satellite channel is used, it is possible to synchronize the process of obtaining a cipher page in another way. In a noisy digital stream, certain combinations of numbers are excluded. The appearance of such combinations in a digital stream is an element of synchronization for all parties involved in the transmission and receipt of encrypted information.

Stream Encryption Project with Vernam Algorithm

The Vernam cipher is very fast and does not require a lot of hardware resources. It is possible to build a stream encryption system based on a special noise satellite channel.

On the Internet, technology can be used in other ways. A distributed network of servers-sources of noise digital streams for public commercial encryption can be created.
For more serious cryptography, you can create hidden noise streams that are encapsulated in public data.

JAVA Application Prototypes

Android Studio SOURCE CODE (03.06.2023)

MainActivity.java

activity_main.xml

AndroidManifest.xml

Next PAGE >>  Thread splitting >>  Use noise channels >>

An application prototype with a full set of functions listens to a digital stream of Internet radio, after a given sequence of bytes, selects a block of bytes from the stream equal to the length of the encrypted message, performs XOR operations, sends an encrypted message via SMS to itself, receives the SMS message and decodes it.
If two instances of the application are launched simultaneously on different smartphones and the number of bytes to search in the stream is increased by 2, then two absolutely identical keys for the Vernam cipher will be selected from the Internet radio stream. If you replace the phone number with the recipient's number, then the message will be encrypted, transmitted, received and correctly decoded
In a real application, you need to add SMS sender verification so that the application does not process SMS from third-party senders. This is not the most convenient way to securely transfer information. But very reliable.

Android Studio SOURCE CODE (04.08.2023) on GitHUB.com

MainActivity.java

activity_main.xml

AndroidManifest.xml

The next project is a prototype of an application that uses speech synthesis in the Android OS to encrypt messages (generate keys)

Speech to sound crypto keys gen

We will invent something else
For example. How to use noise channels to transmit information or "analog speech" in cryptography.

## Vernam entropy

 Vernam cipher project Android STUDIO JAVA
Stream generation of cipher-notebooks