# Barrel Shifter Physical Unclonable Function Based Encryption
## 7 Modeling Attack  
According to [29], all examined strong PUFs under a given size can be modeled with machine learning with success rates above their stability in silicon. Stability in silicon captures the rate at which a response can be reproduced faithfully for a given challenge. It models the native noise inherent in a PUF design. Modeling attacks cannot overcome the inherent design noise. Consider the barrel shifter in our encryption protocol to be a black box. Attackers know nothing about the key and physical delay of the barrel shifter. An attacker should not be able to model the relationship between input and output bits. Such a model provides an eavesdropper information about the plaintext given a ciphertext. To investigate the resilience of BS-PUFs against modeling attacks, various ciphertexts are generated with different keys and plaintexts for training and cross-validation. Logistic Regression (LR) [30] and Evolution Strategies (ES) [31; 32] are commonly used to model PUF output. ES is specialized to model PUFs under noisy conditions [29]. It does not apply when voltage supply and temperature are fixed and known. Thus, only LR modeling is performed. Since the error rate of machine learning prediction decreases with the size of training set, LR modeling is tested for 2 nd LSB of the response with various training set sizes. Monte Carlo Sampling [33] utilizes randomness to generate \(n\) challenge response pairs (CRP). \(n\) random keys, \(K=\{K_{0},K_{1},\ldots,K_{n}\}\) are generated. Responses, \(R\), are generated by entangling plaintext, \(P\), using these keys, \(R_{i}=BS\)-\(PUF(K_{i},P)\). The adversary is interested in extracting the delay from the response. Hence, we generate only the delay component in the Monte Carlo samples keeping the same plaintext. This random CRP sample is assumed to be representative of the distribution of all CRPs. Simulating \(BS\)-\(PUF(K_{i},P)\) requires computationally expensive Cadence Spectre simulations. An efficient method for computing \(R_{i}\) given \(K_{i}\) is needed. Thus, we apply Monte Carlo Sampling to create a delay matrix, \(D\), modeling the delay of all shift paths. The delay of each shift unit is recorded. Path delay is then computed by: (1) summing the delay of all shift units along a path, (2) dividing it by 4 ns capture logic resolution, and (3) extracting 2 nd LSB (as discussed in Section 6, 2 nd LSB is the best candidate). Thus, \(D\) enables computations of path delays given \(K_{i}\). For example, Equation (1) is a sample delay matrix for a 4-input, two-stage BS-PUF. \(d_{i,j}\) represents exact delay values of top and bottom transmission gates in the \(i\)th row, \(j\)th column shift unit:  
\[D= \begin{bmatrix}(d_{0,0,t},d_{0,0,b})&(d_{0,1,t},d_{0,1,b})\\ (d_{1,0,t},d_{1,0,b})&(d_{1,1,t},d_{1,1,b})\\ (d_{2,0,t},d_{2,0,b})&(d_{2,1,t},d_{2,1,b})\\ (d_{3,0,t},d_{3,0,b})&(d_{3,1,t},d_{3,1,b})\end{bmatrix} . \tag{1}\]  
Plaintext-ciphertext pairs (PCP) are computed using \(D\). For the delay matrix in Equation (1) using a \(key=\{1,0\}\) encoding for right shift in the first stage, the plaintext \((i_{0},i_{1},i_{2},i_{3})\) generates the response in Equation (2):  
\[R= \begin{bmatrix}i_{3}\oplus((d_{0,0,b}+d_{0,1,t})/4)_{m}\\ i_{0}\oplus((d_{1,0,b}+d_{1,1,t})/4)_{m}\\ i_{1}\oplus((d_{2,0,b}+d_{2,1,t})/4)_{m}\\ i_{2}\oplus((d_{3,0,b}+d_{3,1,t})/4)_{m}\end{bmatrix} . \tag{2}\]  
This process makes extraction of all possible PCPs feasible. For a BS-PUF with an input message length of 256-bit, there are 256 possible input messages. There are eight stages with 2\({}^{8}\) possible keys. It is infeasible to generate all 2\({}^{264}\) PCPs. Linear Regression(LR) is performed with a training set of size \(n=\{10,100,1000\}\) PCPs per key. To obtain a representative sample of PCPs, responses are computed with \(100\) keys and \(10,000\) plaintexts. PCPs not part of the training set are used for cross-validation.