## 3 Design
### Parallel File Encryption in Distributed Architecture  
**Procedure:** Figure 4 describes how our proposed scheme performs parallel file encryption across distributed slaves. After key transmission, the master calculates the start offset for each slave based on the total file size and the number of participating slaves. Each slave uses this offset information to perform file encryption independently. As shown in the figure, each slave from 0 to N reads its assigned file segments from offset_start to offset_end in a streaming manner. The file is read in fixed-size subset units, and each subset is encrypted using AES-CTR within the AES Encrypt. The encrypted subsets are placed into a dedicated Cipher Queue on each slave. When the queue reaches the predefined batch size, encrypted subsets are grouped into a batch and asynchronously sent to the master using MPI_Isend(). This overlapping of encryption and communication enables continuous processing without idle resources. After receiving encrypted subsets, the master appends them to the Receive Queue. Each slave sends multiple subsets in a batch, and the master collects them. Receive Queue manages incoming batches from all slaves. Subsets in the queue are then forwarded to the Cipher Sorter, which performs global reordering based on subset index sequence. For example, subsets (e.g., 1-0, 1-1 from slave 1 and N-0, N-1 from slave N) may arrive out of order, but Cipher Sorter restores the correct sequence before decryption. The sorted subsets are then processed in the Decryption. The AES key for decryption is reconstructed by first unmasking the PQC secret key using the QKD session key. The recovered secret key is then used to decapsulate the PQC ciphertext, yielding the AES key. This key is then used to decrypt all subsets in parallel using a thread pool. Figure 4: The procedure of offset-based parallel processing and transmission in distributed AES encryption. **Execution model:** Algorithm 1 shows the overlapped execution model used by each slave node for AES encryption and subset transmission. Our proposed scheme separates file reading and subset sending into two concurrent paths, enabling encryption and communication to proceed in parallel. This design maximizes I/O throughput by minimizing idle time between subset production and transmission, and supports scalable performance even as the number of nodes or data size increases. ```
1:FunctionSlaveProcess(filepath,offset_start,offset_end,aes_key)
2:\(current\gets offset\_start,\ subst\_idx\gets offset\_start/subset\_size\)
3:InitCipherQueue(\(\leftarrow\) dedicatedqueue, StopToken(\(\leftarrow\)object())
4:SpawnThreadAESReaderThread()
5:functionAESReaderThread
6:Open file in binary mode
7:whilecurrent\(<offset\_end\)do
8:\(read\_size\leftarrow min(subset\_size,offset\_end-current)\)
9:\(data\leftarrow\)read(\(read\_size\))
10:\(enc\_subset\)\(\leftarrow\)AES_Encrypt(\(data\),aes_key)
11:CipherQueue.put(\(subset\_idx\),enc_subset)
12:\(current\gets current+read\_size,\ subst\_idx\gets subset\_idx+1\)
13:endwhile
14:CipherQueue.put(StopToken)
15:endfunction
16:InitBatchBuffer\(\leftarrow\)empty list, PendingRequests\(\leftarrow\)empty list
17:whileTrue do
18:\((i,\ c)\leftarrow\)CipherQueue.get()
19:if\((i,\ c)==\)StopToken then
20:break
21:endif
22:BatchBuffer.append(\(i,\ c\))
23:iflen(BatchBuffer) == batch_size then
24:\(r\leftarrow\)MPI.isend(BatchBuffer,dest=0,tag=...)
25:PendingRequests.append(\(r\)), BatchBuffer.clear()
26:iflen(PendingRequests) \(\geq\) 32 then
27:MPI.Request.Waitall(PendingRequests), PendingRequests.clear()
28:endif
29:endif
30:endwhile
31:ifBatchBuffer not empty then
32:MPI.isend(BatchBuffer,...), PendingRequests.append()
33:endif
34:MPI.Request.Waitall(PendingRequests)
```  
**Algorithm 1** Overlapped AES encryption and subset transfer in slave node. As shown in the algorithm, the SlaveProcess function initializes the current file position and subset index **(Line 2)**.