Research Article

Secrecy in Wireless Information and Power Transfer for One-Way and Two-Way Untrusted Relaying with Friendly Jamming

Algorithm 1

Power allocation algorithm in two-way relay case.
INPUT: initial value , step value , convergence rate ,
numbers of channel blocks
OUTPUT: optimal power allocation
STEPS:
() Based on , and , calculates and
() Repeat:
() calculate and
() find and
() If ,
() calculate and for updating power allocation
() Else
() the channel state completes the power allocation,
() until: the condition where the rate is convergent.