Joint Resource Allocation in Secure OFDM Two-Way Untrusted Relay System

The security issue of wireless communication is a common concern because of its broadcast nature, especially when the relay becomes an eavesdropper. In the orthogonal frequency division multiplexing (OFDM) relay system, when the relay is untrusted, the security of the system faces serious threats. Although there exist some resource allocation schemes in a single-carrier system with untrusted relaying, it is difficult to apply them to the multi-carrier system. Hence, a resource allocation scheme for the multi-carrier system is needed. Compared to the one-way relay system, a two-way relay system can improve the data transmission efficiency. In this paper, we consider joint secure resource allocation for a two-way cooperative OFDM system with an untrusted relay. The joint resource allocation problem of power allocation and subcarrier pairing is formulated to maximize the sum secrecy rate of the system under individual power constraints. To solve the non-convex problem efficiently, we propose an algorithm based on the alternative optimization method. The proposed algorithm is evaluated by simulation results and compared with the benchmarks in the literature. According to the numerical results, in a high signal-to-noise ratio (SNR) scenario, the proposed algorithm improves the achievable sum secrecy rate of the system by more than 15% over conventional algorithms.


Introduction
Due to the broadcast nature of wireless communication, the threats of eavesdropping and information leakages have increased sharply and the security issue becomes a common concern. The traditional encryption technology uses cryptographic methods in the upper layer of the system, which is crackable and insufficient with the rapid growth of computing power. Therefore, secure communication in the lower layer of the system has been studied and the physical layer security has become a frontier research. Unlike cryptographic methods, the principle of physical layer security technology is to use the difference between the legal channel and the eavesdropping channel to achieve secure communication of the system, which is also its advantage [1,2]. The concept of physical layer security is first introduced by Wyner in a one-hop communication system [3]. With the wide application of relays, many researchers have extended this technology to relay systems [4][5][6][7]. In order to utilize the limited resource of the communication system to maximize the secrecy rate, efficient resource allocation is essential in physical layer security.
The two-way relay communication systems has attracted much attention in the past few years due to its ability in combating the half-duplex constraint of relay nodes and improving the data transmission efficiency [8][9][10]. Due to the advantages of physical layer security, many studies on two-way cooperative communication systems have considered security issue from a physical layer perspective. The research scenarios can be divided into two cases: (1) External eavesdropper [11,12], in which an illegitimate eavesdropper that does not belong to the network tries to decode the confidential information, and (2) untrusted relay [13][14][15][16][17][18][19], in which the relay is assumed to be untrustworthy and acts as an eavesdropper.
In the two-way untrusted relay system, the physical security was first studied in [13], in which the authors proved this system can achieve secure communication without external friendly jammer. The authors in [14] employed artificial noise and studied power allocation in the two-way untrusted relay system with channel estimation errors. Ref. [15] studied the power allocation in the two-way system with multiple untrusted relays. In the two-way untrusted relay system with multi-antenna, the authors in [16] proposed a joint beamforming and suboptimal power allocation scheme to maximize the sum secrecy rate of the system. The problem of optimal power allocation for two-way untrusted relaying networks with an external jammer was examined in [17]. In [18], the authors studied secure relay selection for two-way untrusted relaying networks. Secure beamforming for full-duplex multiple-input-multiple-output (MIMO) two-way untrusted relay systems was considered in [19]. In other scenarios, the authors in [20] proposed machine learning techniques to conserve the position confidentiality of roaming position-based services (PBSs) users. In [21], the authors proposed a whale optimization algorithm to solve the resource allocation problem in an Internet of Things (IoT) system to reduce the total communication cost.
The above related works are all based on the single-carrier system, so the resources that need to be allocated in the system are the transmission power only. In two-way relay assisted orthogonal frequency division multiplexing (OFDM) systems, channel gains of one subcarrier in one hop differ from another hop, and system capacity can be maximized by subcarrier pairing and power allocation [22]. The joint resource allocation in the secure OFDM one-way system was studied in some previous works [23][24][25]; however, due to the differences in system models, the existing resource allocation schemes cannot be applied in an OFDM two-way untrusted relay system. A summary of related work is presented in Table 1. To the best of the authors' knowledge, secure resource allocation jointly considering subcarrier pairing and power allocation for a two-way cooperative OFDM system with untrusted relaying has not been studied in the literature. In this paper, our main innovation is to study the secure resource allocation jointly considering subcarrier pairing and power allocation for a two-way cooperative OFDM system with untrusted relaying, including constructing the system model, formulating the optimization problem, and proposing an effective algorithm to solve the non-convex problem. Our goal is to achieve the secure communication in the OFDM two-way communication system with untrusted relaying. We use resource allocation to enhance the security performance of the system by maximizing the sum secrecy rate of the system under individual power constraints of each transmit node. The key idea of our resource allocation algorithm is to decouple the non-convex optimization problem into several brief subproblems and relax them to convex ones.
The major contribution of this paper are twofold: 1. We introduce a two-way cooperative OFDM system with an untrusted relay and formulate the resource allocation problem to maximize the sum secrecy rate under individual power constraints, which include the subcarrier pairing and power allocation.
2. To solve the problem, we propose a joint resource allocation algorithm based on alternative optimization method. The problem is solved by divided into four subproblems. In particular, we show that the complexity of the solution is polynomial in the number of subcarriers. According to the numerical results, in a high signal-to-noise ratio (SNR) scenario, the proposed algorithm improves the achievable sum secrecy rate of the system by more than 15% over conventional algorithms.
The remainder of this paper is organized as follows. Section 2 describes the system model and derives the formulation of the sum secrecy rate. Section 3 formulates the optimization problem and presents an efficient joint resource allocation algorithm based on alternative optimization (AO). Section 4 demonstrates the simulation results to illustrate the performance of the proposed algorithm. Finally, this paper is concluded in Section 5.

System Model
We consider a two-way cooperative OFDM system with untrusted relaying, as shown in Figure 1, where two users, denoted as A and B, wish to exchange confidential information via an untrusted relay R. The two-way relay operates in a half-duplex mode using the amplify-and-forward (AF) protocol. All communication nodes are assumed to be equipped with a single antenna. We assume that there are no direct links between A and B due to the long distance between them. The users-to-relay channels are considered to be reciprocal, occupying the same bandwidth and experiencing frequency-selective fading. Each OFDM channel is composed of N orthogonal subcarriers.
Particularly, the relay is assumed trusted at the service level and untrusted at the data level, as in [26]. Service-level trust entails following the AF protocol as expected. This involves for relays to feedback true CSI, adapt their power according to system schedule, and forward the amplified version of received signal without modification. Since the relay is data-level untrusted, the source imposes security constraints on relays. This is to prevent the untrusted relay from extracting useful information from its received signal.

Signal Transmission
Signal Forward

Signal Transmission
Signal Forward The transmission from the users to the relay is on a timeframe basis with each frame consisting of multiple OFDM symbols. Each frame is further divided into two time slots. In the first time slot, both A and B send signals to R simultaneously on all subcarriers. We denote the channel coefficients of A to R and B to R on the i-th subcarrier as h i,A and h i,B , respectively, for i ∈ {1, ..., N}. We further assume that the transmit powers of A and B on the i-th subcarrier are P i,A and P i,B , respectively. Then, the received signal at R on the i-th subcarrier in the first time slot can be given by where w i,A and w i,B denote symbol of A and B's signal on the i-th subcarrier, respectively. n i,R denotes the additive white Gaussian noise (AWGN) signal at the relay on the i-th subcarrier and the noise power is σ 2 n . In the second time slot, R amplifies the received signals y i,R on the i-th subcarrier with a constant gain and forwards them to both A and B on the i -th subcarrier. Note that the subcarrier index i may not be as same as i and they form a subcarrier pair (i, i ), and each subcarrier in A to R is paired with only one subcarrier in B to R. Since each subcarrier has different channel gains, subcarrier pairing can utilize subcarrier diversity to enhance system performance. We denote the transmit power of R on the i -th subcarrier as P i ,R . Let β i,i represent the power gain at R to normalize the power of the signal transmitted, i.e., (2) Following that, the received signal at A and B from R on the i -th subcarrier in the second time slot can be given by and where n i ,A and n i ,B denote the AWGN at A and B on the i -th subcarrier with variances σ 2 n . Assuming that both user A and B can perfectly estimate the channel state information (CSI) for channels h i ,A and h i,B , the self-interference terms can be eliminated perfectly at both users (first term in (3) and second term in (4)). Therefore, the received signal at A and B can be expressed as Then, the resultant SNR at A and B on the subcarrier pair (i, i ) can be represented as and where α i,A = |h i,A | 2 /σ 2 n and α i,B = |h i,B | 2 /σ 2 n are effective channel coefficients. Then, the transmission rate at A and B on the subcarrier pair (i, i ) can be expressed as , respectively. As mentioned before, the relay is considered to be untrusted and tries to eavesdrop on the confidential signal. The untrusted relay employs successive the interference cancellation (SIC) method to decode the mixed signal, which requires the relay to decode one user's signal and remove it from the mixed signals before decoding another user's signal. This creates two situations that we need to discuss separately: (1) The SIC is successful, which means the relay successfully decodes one user's signal. In this case, the relay will not experience interference while it decodes another user's signal. Since the signal will weaken in the transmission of relay forward to the user, the eavesdropping rate of relay must be greater than the transmission rate of the user, so the system cannot achieve secure communication and the resource allocation is meaningless. (2) The SIC is unsuccessful, then the untrusted relay decodes one of the users' signals by treating the other user as noise, which is called the single-user decode mode [27]. In this case, the resource allocation can achieve secure communication of the system. Therefore, in the following derivation, the untrusted relay adopts the single-user decode mode. The eavesdropping rate at R on A and B over the i-th subcarrier can be computed from (1) and is given by and Therefore, the sum secrecy rate of the system on subcarrier pair (i, i ) can be formulated as where (x) + = max(x, 0). In this paper, our aim is to jointly design the resource allocation scheme of power allocation and subcarrier pairing to maximize the sum secrecy rate of the system, with the constraints of individual power budgets per node. We define P = {P i,A , P i,B , P i ,R } as the set of power allocation scheme, and it satisfies the individual power constraints, which are where P A , P B , and P R denote the transmitting power budgets on the user A, the user B, and the relay R, respectively. In addition to the power constraints, the system must also satisfy the subcarrier pairing constraint that guarantees that each subcarrier is paired strictly with one subcarrier. We define ρ = {ρ i,i } as the set of subcarrier pairing scheme; ρ i,i = 1 indicates that the i-th subcarrier in the first slot is paired with the i -th subcarrier in the second slot. The subcarrier pairing constraint can be given by

Resource Allocation for Sum Secrecy Rate Maximization
The optimization problem can be formulated as The optimization problem in (16) is a non-convex mixed-integer programming, which is NP-hard. Since there exist four optimization variables, i.e., P i,A , P i,B , P i ,R , and ρ i,i in (16), we can decompose the primal problem into four subproblems by using the alternating optimization (AO) method, which is widely used in research related to resource allocation [28][29][30]. In the AO method, the optimal resource allocation scheme of the optimization problem is obtained by solving the subproblems in sequence, which are discussed in the following subsections.

Power Allocation Scheme for User A
Assuming that the other optimization variables, i.e., P i,B , P i ,R , and ρ i,i , are given, and we define the i as the given subcarrier index in the second time slot paired with the i-th subcarrier in the first time slot, then the subproblem of power allocation for user A can be given as which is still a non-convex problem. Since most of the impact caused by the power allocation for the user A is reflected in the transmission rate from the user A to the user B and the eavesdropping rate at R on B, we can approximate the optimization problem in (17) as (18) is convex.

Proof. See Appendix A.
Therefore, we can solve the convex problem in (18) by dual method [31]. We denote λ A ≥ 0 as the dual variable associated with the power constraints in the user A. The dual function can be defined as where the Lagrangian is where a A , b A and c A are coefficients determined by the channel gains as Computing the dual function g(λ A ) requires us to determine the optimal P i,A at the given dual variable λ A . In the following we present the derivations in detail.
3.1.1. Optimizing the Primal Variables P i,A for Given λ A By applying Karush-Kuhn-Tucker (KKT) conditions [32], we can obtain the optimal power allocation scheme P * i,A (λ A ). Specifically, P * i,A (λ A ) is the non-negative real root of the following cubic equation: where A A , B A , C A , and D A are coefficients determined by the channel gains and the dual variable λ A as Then the dual function can be further written as 3.1.2. Optimizing the Dual Variable λ A After computing g(λ A ), we now solve the standard dual optimization problem which is Since the dual function is always convex [32], the dual optimization problem in (23) can be solved by subgradient-based methods with global convergence. The subgradient of g(λ A ) can be derived as The dual variable can be updated as λ A + (l) λ A , where l is the number of iterations and (l) is the diminishing update step size to guarantee the convergence of the subgradient method.

Power Allocation Scheme for User B
Keeping the given and obtained variables, i.e., P * i,A , P i ,R , and ρ i,i , the subproblem of power allocation for user B can be given as which is still a non-convex problem. Since most of the impact caused by the power allocation for the user B is reflected in the transmission rate from the user B to the user A and the eavesdropping rate at R on A, we can approximate the optimization problem in (25) as (26) is convex.

Proof. See Appendix B.
Therefore, the subproblem in (26) can be similarly solved as problem in (18) by the dual method. We denote λ B ≥ 0 as the dual variable associated with the power constraints in the user B. After similar derivations, P * i,B (λ B ) is the non-negative real root of the following cubic equation: where A B , B B , C B , and D B are coefficients determined by the channel gains and the dual variable λ B as where a B , b B and c B are coefficients determined by the channel gains as The dual variable λ B can be obtained by subgradient-based methods with global convergence as the solution of the problem in (23).

Power Allocation Scheme for Relay R
Keeping the given and obtained variables, i.e., P * i,A , P * i,B , and ρ i,i , the subproblem of power allocation for relay R can be given as (28) is convex.

Proof. See Appendix C.
Therefore, the subproblem in (28) can be similarly solved as the problem in (18) by the dual method. We denote λ R ≥ 0 as the dual variable associated with the power constraints in the relay R. After similar derivations, P * i ,R (λ R ) is the non-negative real root of the following quartic equation: where A R , B R , C R , and D R are coefficients determined by the channel gains and the dual variable λ R as where a R , b R , c R , and d R are coefficients determined by the channel gains as The dual variable λ R can be obtained by subgradient-based methods with global convergence as the solution of the problem in (23).

Subcarrier Pairing Scheme
Keeping the obtained variables P * i,A , P * i,B , and P * i ,R , we next determine the subcarrier pairing scheme, which is which is an integer programming. Defining a N × N cost matrix R = [R S i,i ], ∀i, i ∈ {1, ...N}, the solution of problem (30) is finding an optimal assignment of N elements in the cost matrix to maximize the cost. The subscript of each selected element in R is corresponding to the subcarrier-pair (i, i ), where the row represents the subcarrier index i and the column represents the subcarrier index i . Particularly, this selection is a standard linear assignment problem and we can solve it by the Hungarian method [33] with O((N 3 ) complexity. We define µ(i) as the optimal subcarrier index in the second slot paired with subcarrier i in the first slot, and the optimal subcarrier pairing variable can be given by The µ(i) is obtained by the Hungarian method and (31) is the subcarrier mapping pattern, where the subcarrier mapping scale is N × N. For more details on the Hungarian method, see Appendix D.

Alternating Optimization
In the above subsections, the subproblems are solved and the corresponding optimization variables are obtained. Then, we use the AO method to solve the primal optimization problem of joint resource allocation in (16). The initial variable values for the algorithm are P i,A = P A /N, P i,B = P B /N, P i ,R = P R /N, i = i, ∀i, i ∈ {1, ..., N}. Then, in the first loop, we obtain P * i,A , P * i,B , P * i,R and ρ * i,i by solving the subproblems sequentially. Note that when solving a subproblem, the solution of the previous subproblem is used as its initial variable value. In the next loop, the initial power allocation and subcarrier pairing scheme inherit the results in the previous loop. The loop ends when the iteration count exceeds a threshold. The whole resource allocation algorithm is given in Algorithm 1. The flowchart of the proposed algorithm is shown in Figure 2.
Since the sum secrecy rate of the system increases after each loop and has an upper bound due to the limited power budgets, the sum secrecy rate achieved by the AO algorithm finally converges. Defining the iteration count as γ, the complexity of the AO algorithm is O((N 3γ ). Algorithm 1 Proposed algorithm for problem (16) 1: Initialize P i,A = P A /N, P i,B = P B /N, P i ,R = P R /N, i = i, ∀i, i ∈ {1, ..., N} ; 2: Initialize µ A , µ B , µ R ; 3: for x=1 to γ do 4: Power Allocation for User A: 5: repeat 6: obtain P * i,A (µ A ) using (21); 7: update µ A ; 8: until µ A converges.

Start
Creating an initial resource allocation set P,ρ

Remark 1.
There are only two cases for the respective secrecy rate of the user A and B: both 0 or both positive. Particularly, in this optimization algorithm, if P i,A = 0, then P i,B = 0, and vice versa. This is because when P i,A = 0, according to (9), there is no interference to the relay eavesdropping on user A. Therefore, the R S i,i ,A = 0, which means that user B does not need to allocate power on the i-th subcarrier, i.e., P i,B = 0.

Simulation Results
In simulation, the signal fading follows the Rayleigh distribution. For simplicity, the power constraints of the users and relay are assumed to be the same. The distance between user A and B is 2 km, and the relay is located at the center of their connection. Three degraded benchmarks, namely, the channel-based power allocation with subcarrier pairing (CBA with SP), equal power allocation with subcarrier pairing (EPA with SP), and equal power allocation without subcarrier pairing (EPA without SP), are considered for comparisons. Since the computational complexity of the algorithms is a polynomial of the number of subcarriers, the sorting scale of the simulation depends on the number of subcarriers, and we perform simulations with subcarriers ranging from 4 to 32.
The CBA with SP algorithm first allocates power according to the equivalent channel coefficient of each subcarrier, with more power allocated to subcarriers with better channels. Then, the algorithm uses the Hungarian method for subcarrier pairing. Differently, the EPA with SP algorithm first allocates power equally on subcarriers and then uses the Hungarian method for subcarrier pairing. The EPA without SP algorithm only allocates power equally on subcarriers, where the subcarrier index for pairing is the same, i.e., i = i .
Two conventional algorithms are also presented for comparison. The first algorithm is the SNR-based allocation (SBA) scheme proposed in [7]. This algorithm defines an SNR threshold and assumes that when the eavesdropping SNR of the relay is less than the threshold, the untrusted relay cannot decode the confidential signals, so the eavesdropping rate is 0. Then, the primal non-convex problem can be simplified to a convex problem. The second algorithm is the derivative algorithm (DA) proposed in [17]. This algorithm splits the primal multiple-variable problem into several univariate problems and obtains the solution of these problems by derivation.
In all resource allocation schemes, a central controller acts as service provider, which is assumed to have perfect knowledge of all CSI. The users, as service requesters, provide their own power budgets and CSI to the service provider, and the service provider utilizes this information for subcarrier pairing and power allocation in order to ensure secure communication for users.
The sum secrecy rate achieved by different algorithms is shown in Figure 3. The numerical results are based on average of 200 Monte Carlo simulations. We can see that the proposed algorithm achieves higher sum secrecy rate than the three benchmarks. In a high SNR regime, the proposed algorithm improves the achievable sum secrecy rate of the system by more than 15% over the three degraded benchmarks and two conventional algorithms. Figure 3 also shows that the CBA algorithm performs better than the EPA algorithm, which indicates that the subcarrier pairing can effectively improve secrecy performance of the system. The SBA algorithm has the worst performance, because in the two-way untrusted relay system, the small eavesdropping SNR of the relay will result in the decrease of the transmission rate of the users. Hence, the sum secrecy rate of the system will also be reduced. The performance of the DA algorithm is between the CBA algorithm and the EBA algorithm, because the optimization problem is non-convex and the DA algorithm is only suitable for convex problems.  Figure 4 compares the sum secrecy rate achieved by different algorithms with respect to the number of subcarriers. It can be seen that the proposed algorithm significantly outperforms other schemes, especially with more subcarriers. This is because the conventional algorithms in benchmarks cannot make efficient use of the diversity of subcarriers. Furthermore, since the power and bandwidth of the system are limited, the sum secrecy rate will increase with the growth of the number of subcarriers at first, and finally converge. Therefore, the slope of Figure 4 will gradually decrease.  Figure 5 shows the power allocation scheme on different subcarriers by the proposed algorithm. The corresponding effective channel coefficients of subcarriers are presented in Table 2. It can be seen that for the same subcarrier, if P A = 0, then P B = 0, which proves our remark in Section 3. We can also see that the proposed algorithm tends to allocate more power to subcarriers with similar channel gains on A to R and B to R. This is because the untrusted relay decodes one of the users' signals by treating the other user as noise. Therefore, the allocated power on the subcarrier with similar channel gains on A to R and B to R can more effectively reduce the eavesdropping rate and increase the sum secrecy rate. Table 2. Effective channel coefficients of simulation in Figure 5.  Figure 6 compares the sum secrecy rate achieved by different algorithms with respect to the distance from the user to the relay. The proposed algorithm has better performance than algorithms in the benchmarks at any location of the relay. Particularly, from Figure 6, it can be seen that the sum secrecy rate achieved by all algorithms reaches the maximum when the distance from the relay R to the user A is 1 km, i.e., the distance from A to R is equal to the distance from B to R. This is because when the distances from A to R and B to R are closer, the channel fading parameters of the subcarriers on A to R and B to R become similar. As mentioned above, the allocated power on the subcarrier with similar channel gains on A to R and B to R can more effectively reduce the eavesdropping rate and increase the sum secrecy rate. Therefore, the sum secrecy rate of the system increases as the distances between the relay and the two users become closer. Particularly, when the untrusted relay is not cooperative and could alter the power to undermine the strategy, the proposed algorithm can still effectively allocate resource, because the power allocation of the untrusted relay is decoupled from the primal problem in the proposed algorithm. Therefore, the proposed algorithm still works well with the variation of the relay power. In Figure 7, we limit the user's power to 20 dBm, and the untrusted relay can alter its transmit power. Since the untrusted relay is not cooperative, it will always allocate power equally to each subcarrier. Figure 7 compares the sum secrecy rate achieved by different algorithms in this scenario. It can be seen that our proposed algorithm has the best performance, which also confirms our analysis.

Conclusions
In this paper, we introduced an OFDM two-way untrusted relay system and formulated a subcarrier-pair-based secure resource allocation problem to maximize the sum secrecy rate of the system. A joint resource allocation algorithm based on the AO method was proposed to solve the non-convex optimization problem. We show that the primal NP-hard problem can be solved in polynomial time by decomposing into several subproblems. Furthermore, we show that in this system, there is no situation where one user can achieve secure communication and another user cannot. The simulation results show that the proposed algorithm outperforms other existing algorithms significantly, especially in a high-SNR regime with more subcarriers.
For the future extension, we will consider the smart untrusted relay in the OFDM two-way communication system. This means the relay can use pilot spoofing to alternate channel estimates, masquerading the eavesdropping channel as in [34], so the CSI is imperfect. Effective channel estimators should be used to combat the pilot spoofing attacks.

Data Availability Statement:
The data presented in this study are available on request from the corresponding author. The data are not publicly available due to confidentiality.

Conflicts of Interest:
The authors declare no conflict of interest.

Abbreviations
The following abbreviations are used in this manuscript:

Appendix A
For simplicity, we replace R S i,i ,A by R a , R S i,i ,B by R b , R S i,i by R s , P i,A by P a , P i ,R by P r , P i,B by P b , α i,A by α a , α i ,A by α a , α i,B by α b , and α i ,B by α b in the proof, respectively.
(1) When R b = 0, R b is a concave function of P a .
It can be calculated that when 0 < P a < P a , ∂R b ∂P a > 0, when P a > P a , ∂R b ∂P a < 0, where Since our target is to maximize R b , the optimal solution P * a will always satisfy P * a ≤ P a . Hence, the domain of P a can be reduced to [0, P a ]. The optimization problem in (18) is equivalent to the problem below, which can be given by The second derivative of R S (P s ) is ∂ 2 R b ∂P 2 a = 1 2 ln 2(a a P a + b a ) 2 (P 2 a + c a P a + b a ) 2 · −2(a a P a + b a ) 2 (P 2 a + c a P a + b a ) +[a a P 2 a + 2b a P a − b a (a a − c a )] · [3a a P 2 a + 2(b a + a a c a )P a + b a (a a + c a )] .
When P a ≤ P a , a a P 2 a + 2b a P a − b a (a a − c a ) ≤ 0, ∂ 2 R b ∂P 2 a ≤ 0. Thus, we prove R b is a concave function of P a when P a ∈ [0, P a ]. Therefore, the problem in (A3) is convex and the optimization problem in (18) is also convex.
If less than n lines are required, continue with Step 4.
Step 4: Create additional zeros Find the smallest element (call it k) that is not covered by a line in Step 3. Subtract k from all uncovered elements, and add k to all elements that are covered twice.