Using FHE in a binary ring Encryption and Decryption with BLE Nano kit microcontroller

An integrated circuit (IC) that can be programmed to perform a series of functions to control a range of electronic devices is a microcontroller. What makes the microcontroller special is that it is programmable. In this article, we're going to try to rely on the mbed platform, the most common open source microcontroller development platform; we use completely homomorphic encryption in a binary number ring to ensure the data protection feature. Let us compare the time it takes to perform encryption and decryption on a Visual Studio С ++ and a Bluetooth Low Energy (BLE) Nano kit microcontroller. Experimental results show that the device can complete a fully homomorphic encryption in a binary number ring in 64.2 microseconds, which is reasonable in a real application scenario and illustrates the feasibility of implementing a more complex cryptographic system using a microcontroller.


Introduction
Microcontroller can be easily adopted in various applications with a variety of peripherals due to its merits of small size, simple architecture. One kind of microcontroller with an open source platform is the BLE Nano Kit [1][2]. The smallest BLE production board on the market is the BLE Nano.
In short, due to its low cost, cross-OS scalability, open source and easy use features, BLE Nano Kit has a wide developing future [3][4]. As a consequence, on this framework, different multifunctional applications can be created. The aim of a scientific article is to perform on the microcontroller of the BLE Nano Kit on a Windows block cipher and modern cryptographic algorithms on the mbed platform and Visual Studio C++, such as completely homomorphic encryption in a binary number ring. The execution time of various algorithms in the microcontroller and the personal computer is then compared.
As follows, the rest of the paper is organized. In Section 2, we summarize the key features and applicability of a binary number ring for both block cipher and completely homomorphic encryption. We present the running time of various algorithms in our microcontroller and PC (personal computer) and problems in Section 3, as well as address the adoption of the strategy. Finally, we are reporting the final findings of the paper in Section 4.

Cryptographic backgrounds
The key features and benefits of block cipher and completely homomorphic encryption in a binary number ring, both proposed technologies, are briefly discussed in this section.

Block cipher
A block cipher is a deterministic algorithm in cryptography that operates on fixed-length groups of bits, called blocks, with an unvarying transformation identified by a symmetric key. In the design of many cryptographic protocols, block ciphers are significant elementary components and are commonly used to enforce bulk data encryption.
We selected the commonly used Advanced Encryption Standard (AES) encryption [5] from the symmetric block cipher algorithm. In both software and hardware, AES is based on a design concept known as a substitution-permutation network, a combination of both substitution and permutation, and is fast (Fig.1). The block cipher uses the four following operations in each round: • SubBytes: A nonlinear substitution box called the AES S-Box transforms each byte of the sequence. The S-Box has been carefully designed in the Block cipher and the cipher uses only one S-Box in the encryption process. • ShiftRows: A transposition step that ensures that a different number of byte positions are transferred to the last three rows of the array. • MixColumns: To generate even more diffusion, mix every column in the series.
• Addkey: Using bitwise XOR, each array byte is mixed with a sub-key material byte, often called round-key. The sub-key is generated by "key expansion" and is extracted using a Rijndael key-schedule from the main cipher key. Encryption method: Begins with AddKey with Key0. Then go to the loop and do SubBytes, ShiftRows, MixColumns, Addkey, each circle with different circle keys in that order for 9 circles. Then go to the final circle (circle 10) and repeat, except for MixColumns, the same previous feature in the loop.
Decryption method: in every stage it is reverse of the encryption process, which implies that the first circle of decryption is the tenth circle of the encryption and it uses the invers functions of MixColumns, SubBytes, ShiftRows and us. You should assume the arrangement of keys and reverse it as it begins with Addkey10 instead of Addkey0 as it was in the encryption phase. 2. Key generation.
In order to generate enough keys for each circle in the encryption, decryption process, RotWord, SubBytes and XOR bitwise operation are needed. Each circle operates with different keys created by the method of key generation.

Fully homomorphic encryption in a binary number ring
Homomorphic encryption is a type of encryption on encrypted data that performs arbitrary computations. We may keep our confidential data in encrypted format in cloud storage, but if you want to do some calculation on cipher text, the key must be shared with cloud service providers who may allow our data to be abused. Instead, the Homomorphic Encryption approach is used to prevent sharing the key with cloud service providers. Searching, sorting, addition, multiplications performed on cipher text involves the computations.
Homomorphic encryption has drawn widespread attention from scholars for its specific success among so many cryptographies [6][7]. Popular cryptography cannot explicitly measure encrypted data, but homomorphic encryption will automatically encrypt the operational results of homomorphic encryption. In the fields of secure multi-party computing, electronic voting, cipher text scanning, encrypted mail filtering, mobile cipher, the application prospect of homomorphic encryption is broad and cheerful. Finally, security analysis is reviewed and more testing methods are highlighted.
In this encryption method, homomorphic encryption seeks to support by enabling unique types of computations to be performed on cipher text that produces an encrypted result that is also in cipher text. The product of operations performed on the plaintext is the product. Case in point, one person might add two encrypted numbers and then another person might decrypt the outcome without the significance of the individual numbers being able to be identified by any of them.
By using ideal lattices, Craig Gentry introduced completely homomorphic encryption based on bootstrapping over partially homomorphic encryption. It is restricted because, in some way, any cipher text is noisy, and this noise grows as one ad and multiplies cipher texts. Gentry have shown that a self-eMbedding recursion can turn any boot trappable Somewhat Homomorphic Encryption scheme into a Completely Homorphic Encryption. The bootstrapping procedure effectively "updates" the cipher text in the case of Gentry's "noisy" scheme by applying the decryption procedure homomorphically to it, thereby obtaining a new cipher text that encrypts the same value as before but has a lower instance of noise [8]. Whenever the noise becomes too complicated, the cipher text is regularly "refreshed." Fully homomorphic encryption in a binary number ring. The scheme of completely homomorphic encryption, which Gentry suggested, can be considered using the example of calculations in " [9][10][11][12][13]. Encryption The data encryption method can be interpreted as follows: 1. We pick an arbitrary strange number = 2 + 1, which is a secret parameter. Let ∈ {0,1}. 2. The number ∈ " is compiled such that = 2 + , where is an arbitrary number. This means that = 2 3. In the encryption method, each m is associated with the number = + , where is chosen arbitrarily. Thus, = 2 + + (2 + 1) * . It is easy to see that 2 = ( + ) 2 and therefore an attacker can determine only the parity of the output of encryption.

Decryption
Let it be known about the encrypted number c and the secret p. The method of decrypting the information should then include the following actions:

Performance
Here, on the mbed platform, we will implement fully homomorphic encryption in a binary ring on a BLE Nano Kit microcontroller.
How does programming operate?
The mbed microcontroller is connected to our PC via USB (Universal Serial Bus), it looks like a USB flash drive. This small disk is represented by the mbed interface and allows you to save the BLE Nano kit microcontroller hexadecimal files that we want to run directly on mbed without the need for a driver. It is not automatically loaded into the flash memory of the internal microcontroller when saving the .hex file on the mbed disk.
The mbed searches at the disk for the most recent .hex file it can find when we hit reset. If a new file exists, it uses the JTAG interface to load it into the internal FLASH memory of the microcontroller. If the current binary has already been loaded, it will not be loaded again. It then begins working the microcontroller.
How does a serial USB work?
The USB serial / com interface is also reflected by the mbed interface. Basically, this is a UART-USB bridge which connects to the UART interface. Therefore, if we send characters from the target microcontroller's UART, they will be read and transferred via USB using the mbed interface.
We use the terminal emulator "Tera Term" for programming devices.
For the connection of microcontroller and terminal, there are two main points needed to be paid more attentions.
1) Serial Communications: Serial Communications is the first stage. For each 8 bits of data transfer, in microcontroller serial communications with a contact style UART interface with even parity bit and 2 stop bits.
2) Protocol Parameter Selection and Baud Rate: The serial baud rate of the microcontroller contact form is regulated by an external oscillator's clock signal. There are two external oscillators for the BLE Nano Kit microcontroller. The slow clock has a frequency of 32,768 kHz. The frequency of the main clock is 16 MHz and the baud rate is about 9,600 bps. Table 1 presents our experimental findings for selected strategies to protect privacy. On the devices used, we calculate the performance overhead and we estimate overhead memory/communication. We concentrate on the duration of primary activities/phases, such as the duration of encryption, the time of decryption. All time values are determined from 10 iterations as mean values. The efficiency overhead of selected privacy protection techniques on the microcontroller and PC is shown in Figure 4.

Fig. 4. Running Time of Different Algorithms in microcontroller BLE Nano Kit and PC
Using terminal Tera Term to submit data and cypher keys from a computer, the encryption was checked. We would then run a series of exams. We compare the findings with the Visual Studio C++ operations directly invoked from a Windows 7 x64 device environments and the BLE Nano microcontroller package using C++ on the mbed framework. Table 1 and figure 4 display the effects. From the observations, it can be shown that the output of the microcontroller is comparable to the output. The only variation in the transmission protocol that is not well configured in our implementation is caused by overhead.

Conclusion
This work presents the performance and memory limitations on different types of devices that can be used in IoT for existing cryptographic primitives and schemes. Symmetric ciphers and hash functions can now be easily integrated into IoT services using restricted devices. In this paper, in terms of speed, flexibility and protection, the use of hardware platforms to create a real-life application has proved satisfactory and promising. We have used the mbed platform's strong compatibility with the microcontroller in our research work. As one of the most popular BLE Nano Kit microcontrollers, different security features can be used in the application. However, compared to Visual Studio C++ from a Windows 7x64 computer environment due to the limited processing power and memory of the microcontroller BLE Nano Kit, BLE Nano Kit yields a fairly poor performance, especially when AES algorithms are involved with FHE in a binary ring.