Polarization-selective unidirectional and bidirectional diffractive neural networks for information security and sharing
  • SJ_Zhang
  • Jun. 9, 2025

Abstract

Information security aims to protect confidentiality and prevent information leakage, which inherently conflicts with the goal of information sharing. Balancing these competing requirements is especially challenging in all-optical systems, where efficient data transmission and rigorous security are essential. Here we propose and experimentally demonstrate a metasurface-based approach that integrates phase manipulation, polarization conversion, as well as direction- and polarization-selective functionalities into all-optical diffractive neural networks (DNNs). This approach enables a polarization-controllable switch between unidirectional and bidirectional DNNs, thus simultaneously realizing information security and sharing. A cascaded terahertz metasurface comprising quarter-wave plates and metallic gratings is designed to function as a polarization-selective unidirectional-bidirectional classifier and imager. By introducing half-wave plates into a cascade metasurface, we achieve a polarization-controlled transition in unidirectional-bidirectional-unidirectional modes for classification and imaging. Furthermore, we demonstrate a high-security data exchange framework based on these polarization-selective DNNs. The proposed DNNs with polarization-switchable unidirectional/bidirectional capabilities offer significant potential for privacy protection, encryption, communications, and data exchange.

Introduction

With the rapid development of information technology, communication networks demand higher bandwidths and greater capabilities in information processing1,2,3. All-optical information processing, recognized as the optimal solution, offers broadband characteristics and high efficiency for information transmission and processing4,5,6. Beyond this, data security and sharing have become two key topics in accelerating numerous applications, such as the digital economy and secure communication. However, these two concepts generally represent opposing sides of the same coin with computational systems7. Information security aims to prevent unauthorized access and protect confidentiality, thereby minimizing information leakage8. Conversely, information sharing, the opposite aspect of information security, primarily focuses on disseminating information, optimizing resource allocation, and reducing costs associated with data storage. While sharing data can enhance utilization and lower storage demands, it also introduces the risk of partial data exposure or unintended disclosure in an information-driven world. Therefore, balancing these opposite aspects—information security and data sharing—remains a significant challenge9,10,11.

All-optical diffractive neural networks (DNNs) have demonstrated unprecedented capabilities in processing large volumes of information at the speed of light, accelerating the development of all-optical information processing and artificial intelligence12,13,14,15. For instance, an all-optical DNN composed of multiple diffractive surface layers can classify images of handwritten digits and fashion products by leveraging supervised inference across its hidden layers16. In addition to image classification, DNNs have found applications in logic operations17 and image processors18,19. Benefiting from their ultrafast operation and low power consumption, DNNs are further optimized for integrated, multiple tasks, such as multi-wavelength complex-field imaging20, multispectral all-optical information processing21, and multi-target/task processing22. Moreover, the wave propagation direction constitutes a fundamental property of light that can be considered as a pivotal degree of freedom (DoF) for novel applications in information security, specifically, unidirectional information transmission that only permits propagation along one direction23. Recently, unidirectional DNNs have been proposed for diffractive unidirectional imaging, which can perform polarization-independent imaging in the forward direction while blocking imaging in the reverse direction24. A pyramid-structured DNN was also introduced to achieve directional image magnification and demagnification25. Despite these achievements, current techniques (e.g., three-dimensional (3D) printed diffractive surfaces) face challenges in realizing unidirectional-bidirectional-switchable DNNs with polarization-selective functionalities, which could address unidirectional information security and bidirectional information sharing simultaneously.

Metasurfaces, consisting of planer microstructures with various shapes and orientations, provide a versatile platform for controlling the wavefront of electromagnetic (EM) waves26,27,28,29,30. By delicately designing these microstructures, one can achieve independent wavefront manipulation for diverse applications, including generalized Snell’s law of refraction/reflection31,32, metalenses33,34,35, holograms36,37,38, spin-Hall effect39, quantum sources40,41,42, and polarization converters43,44. Beyond these applications, metasurface-enabled optical analog computation and imaging have significantly enhanced the capacity for advanced optical information processing45,46. Leveraging these extraordinary properties, metasurfaces have been employed to mimic DNNs with unique functionalities, such as all-optical linear neural networks47, matrix diffractive deep neural networks48, and angle-dependent diffractive deep neural networks49. Quantum logic operations based on metasurfaces have also been realized with high fidelity, paving the way for scalable optical quantum computing50. Unlike 3D-printed diffractive surfaces that predominantly manipulate amplitude and phase with limited DoFs, metasurfaces facilitate more flexible control over amplitude, phase, and polarization of EM waves51,52,53,54,55, which provide an ultracompact, versatile platform with an additional DoF (i.e., polarization) to design DNNs with advanced functionalities.

Here, we propose and experimentally demonstrate an approach that integrates phase manipulation, polarization conversion, and direction- and polarization-selective functionalities into a cascaded metasurface, which enables polarization-controllable switching between unidirectional and bidirectional DNNs, thereby emulating information security and sharing at the same time. Combining a quarter-wave plate (QWP) array with metallic gratings, we first achieve switchable unidirectional-bidirectional DNNs for digit classification and non-destructive letter imaging. Then, we demonstrate a more advanced unidirectional–bidirectional–unidirectional switching capability using a cascaded metasurface consisting of a half-wave plate (HWP) array and metallic gratings. Additionally, we implement a high-security information transmission/exchange method based on the polarization-selective DNNs. The polarization-switchable unidirectional-bidirectional functionality provides a versatile DNN framework for information security and sharing, offering promising applications in data transmission, privacy protection, and communication networks.

Results

The polarization-selective DNN (PS-DNN) comprising a HWP array for applications in information sharing and security are schematically shown in Fig. 1. The PS-DNN consists of two main components: a metallic pattern and a cascade metasurface, functioning as the input and hidden layers of a DNN, respectively. The metallic pattern generates spatially distributed light, such as handwritten letters, while the metasurface—consisting of cascaded meta-atoms and metallic gratings—modulates both the polarization and phase of the input optical field, which behaves analogously to the neuron in a DNN. As depicted, when the incident terahertz (THz) wave is x-polarized (y-polarized) from the forward (backward) direction, the PS-DNN recognizes the letter by diffracting the THz wave into a prescribed region in the detection plane. However, the incidence with the same polarization from the opposite direction is blocked, demonstrating the unidirectional operation of the PS-DNN. Under 45°-linearly-polarized (45°-LP) incidence, the PS-DNN can work for both forward and backward directions by detecting the x-polarized (y-polarized) diffractive fields in the output plane, leading to the bidirectional operation. As such, this polarization-switchable property grants our PS-DNN the versatility to operate in either a unidirectional (information security) mode or a bidirectional (information sharing) mode. For instance, secure data transmission could be achieved by encrypting data as a time sequence of polarization states; only the correct polarization state (e.g. x- or y-polarized) and forward/backward propagation direction would reveal the actual information. Conversely, data can be shared in both directions using a 45°-LP incidence, fulfilling an information-sharing function.\\

 

Fig. 1: Schematic illustration of HWPs-based polarization-selective unidirectional and bidirectional DNN.

 

figure 1

When x- or y-polarized THz waves are incident, the system operates as a unidirectional classifier in the forward or backward direction, respectively. Under 45°-LP waves, the system functions bidirectionally, allowing classification in both forward and backward directions. The top-right inset depicts the concept of polarization-selective DNN for THz waves incident from either the forward or backward direction with specific polarization states. The bottom-left inset shows the DNN architecture used to map the designed metasurfaces.

PS-DNNs design

To realize the above-mentioned functions, the polarization-selective information sharing and security model can be deduced as follows (detailed discussion can be obtained in Supplementary Note 1): Supposing an optical system consists of the waveplate with the main axis along the 45° direction whose Jones matrix is defined as 12(1+???1−???1−???1+???), where ?≠0 denotes the phase difference between the x- and y-polarized light modulated by the waveplate, and the polarizer based on the meta-grating can be described as (0001). Therefore, the forward and backward transmission with the LP incidence can be derived as:

For the forward transmission mode, there is only the y-polarized output, and the critical condition for closing the forward channels is:

while the backward channel will be blocked for the x-polarized incidence. By carefully selecting the working polarization state of the incidence, we can design it to operate in a unidirectional mode (e.g., when θ = 0°, only allowing the forward data transmission). This distinction in transmission properties between the forward and backward directions enhances the security of the data transmission by preventing unauthorized access through the direction-reversed channel. Moreover, the data-sharing process can be obtained for the 45°-LP incidence (θ = 45°) where both forward and backward transmission channels are transparent, achieving bidirectional transmission. Moreover, this model is applicable to other polarization states for the QWPs-based PS-DNN, with a detailed analysis provided in Supplementary Note 1.

To demonstrate the polarization-selective functionalities, we integrate metallic gratings and structured subwavelength silicon (Si) rods that function as quarter-wave plates (QWPs) or half-wave plates (HWPs) to form cascaded metasurfaces (Supplementary Notes 2 and 3). The cascaded metasurfaces have unprecedented functionalities in modulating the phase and polarization of the THz waves (for classification and imaging) and enabling polarization-switchable transmission properties (for information security and sharing).

According to the Huygens-Fresnel principle, the light emitted from each meta-atom can be considered as a secondary spherical source, and thus, the wavefront of light can be modulated by the engineered metasurface. The optical field distribution at a target plane located a distance z away can be numerically calculated using the Rayleigh-Sommerfeld diffraction theory. First, the diffraction from the input mask to the metasurface can be expressed as:

where ?1 and ?1 are the coordinates in the input plane, ?2 and ?2 denote the coordinates in the metasurface layer, and ??? is the electric field distribution at the input layer. Next, the diffraction from the metasurface to the detection plane can be achieved in a similar form:

Here, ?3 and ?3 denote the coordinates in the detection layer, ????? is the electric field distributed at the hidden layer (i.e., the cascaded metasurface), and h represents the impulse response function expressed as:

where ??=(??+1−??)2+(??+1−??)2+??2 is the Euclidean distance between two points (either between the input plane and the metasurface or between the metasurface and the output plane) and ? is the wavelength of the incident wave. When the distance between the detection plane and metasurface is fixed, the diffractive fields produced by the input pattern are further modulated by the meta-atoms with predesigned functions (e.g., digit classification or imaging). Here, the meta-atoms act as neurons in a DNN, where their phase retardances are to be optimized. By prescribing both the input (such as handwritten digits or letters) and the target profile ?(??,??), the loss function for this diffractive optical neural network can be modeled using a mean square error (MSE) criterion:

where m denotes the number of sampled points in the target plane. By minimizing this MSE, the optimal phase retardance for each meta-atom can be determined through a backpropagation algorithm that computes the gradients and updates the phase values accordingly, thereby fulfilling the targeted classification or imaging functionality.

Unidirectional-bidirectional classifier and imager

As a guiding demonstration, we design a cascaded metasurface that consists of a QWP array and metallic gratings to mimic a PS-DNN with both unidirectional and bidirectional recognition capabilities, as shown in Fig. 2. The dielectric meta-atoms are selected from the QWP set to construct a 100 × 100 neuron array, operating at 0.6 THz. Trained on handwritten digits from the Modified National Institute of Standards and Technology (MNIST) dataset, the resulting phase profiles are extracted from the DNN and encoded into the meta-atoms, with the distances between input/hidden and hidden/output layers each set to 10 mm. Under x- or y-polarized forward incidence, the THz waves first pass through the QWP array, converting into the left- or right-handed circularly-polarized (LCP or RCP) waves. Then the metallic gratings filter out the y-polarized component (Fig. 2a). For the backward incidence, the x-polarized THz waves are reflected completely by the metallic gratings, while the y-polarized THz waves can be transmitted from the metallic gratings and converted into RCP THz waves after the QWP array, as shown in Fig. 2b. As such, we can achieve unidirectional recognition for x-polarized waves and bidirectional recognition for y-polarized waves. For a forward-incidence digit “2” (from the MNIST dataset, Fig. 2c), the x-polarized diffractive fields are converted to LCP fields by the QWP array and then filtered out with the y-polarized component by the metallic gratings, leading to the diffractive fields located at the top-left corner in the output plane, as shown in Fig. 2d. The measured output-energy distributions in Fig. 2i match well with the diffractive fields. Here, the energy distribution is defined as ?sub?/?total, where ?sub? is the sum of the energy in the ?th recognition region, and ?total is the total energy across all recognition regions (Supplementary Note 4). The measured confusion matrix exhibits a recognition accuracy of 90.0% (Fig. 2m). In contrast, when the sample digit “2” (Fig. 2f) is illuminated by x-polarized waves from the backward direction, no focused field is observed in the detection plane (Fig. 2g), confirming unidirectional recognition in the forward direction. Similarly, the digits “3”, “6”, and “7” (Fig. 2c) are recognized in the forward direction, producing focused y-polarized beams at the top-right, bottom-left, and bottom-right corners, respectively (Fig. 2d). The measured output-energy distributions are shown in Fig. 2j–l. However, for the backward incidence of x-polarized THz waves with the input patterns of “3”, “6”, and “7” (Fig. 2f), the incident waves are reflected completely without the recognized function in the backward direction (Fig. 2d). For the forward incidence of y-polarized waves, input digits “2”, “3”, “6”, and “7” are also recognized by our designed PS-DNN, with the y-polarized diffractive fields focused on the top-left, top-right, bottom-left, and bottom-right corners, as demonstrated in Fig. 2e. Under backward y-polarized incidence, the same digits are successfully recognized (Fig. 2h), demonstrating the bidirectional operation. Therefore, the designed PS-DNN realizes unidirectional classification for the x-polarized incidence and bidirectional digit recognition for the y-polarized incidence. Additional measured output-energy maps for forward y-polarized and backward x- or y-polarized incidences are provided in Supplementary Note 5. Numerical demonstrations of the polarization-selective unidirectional/bidirectional recognition functions are included in Supplementary Notes 6 and 7, while recognition of all ten handwritten digits is discussed in Supplementary Note 8. A guide rail is designed for the alignment of input digits and the metasurface (Supplementary Note 2), ensuring the optimal performance of the PS-DNN. A detailed discussion on the impact of alignment errors on the PS-DNN is provided in Supplementary Note 9.

 

Fig. 2: Experimental demonstration of the unidirectional-bidirectional DNN digit classifier.

 

figure 2

ab Schematic of the working principle of the unidirectional-bidirectional DNN under x- and y-polarized THz illumination from the forward (a) and backward (b) directions. ce Digit patterns and corresponding measured electric-field intensity distributions in the output plane under the forward incidence of x- and y-polarized THz waves. fh Digit patterns and corresponding measured electric-field intensity distributions in the output plane under the backward incidence of x- and y-polarized THz waves. il Measured output-energy distribution maps for the x-polarized forward incidence. m Measured confusion matrix for the x-polarized forward incidence.

In addition to polarization-selective directional digit recognition, this approach can be extended to unidirectional and bidirectional imaging, yielding a polarization-controllable imager with unidirectional-bidirectional capabilities. For example, under forward illumination of x-polarized THz waves and an input digit “2”, the measured diffractive field distributions in the output plane form a y-polarized image of “2”, as shown in Fig. 3a, b. Here, the input diffractive field (after the pattern of “2”) is processed by the hidden layer, which rotates the polarization and reconstructs the image in the detection plane. However, no image of “2” is observed for the incidence of x-polarized THz waves from the backward direction (Fig. 3d, e). When the input digit switches to “3”, “6”, or “7”, x-polarized forward incidence generates images of these digits in the output plane (Fig. 3a, b), while no corresponding images appear under backward incidence (Fig. 3d, e). In comparison with Fig. 3b, e, a unidirectional imager can be achieved by our PS-DNN under the illumination of x-polarized THz waves from the forward direction. By switching the incident polarization to y-polarization, both forward and backward incidences can produce reconstructed images of “2”, “3”, “6” and “7” (Fig. 3c, f), demonstrating the bidirectional imaging capability under y-polarized excitation. Thus, merely altering the incident polarization allows the cascaded metasurface to function as either a unidirectional or bidirectional imager, supporting applications in information security (one-way transmission) and information sharing (two-way transmission). Further numerical demonstrations of the polarization-selective unidirectional–bidirectional imager can be found in Supplementary Note 10.

 

Fig. 3: Experimental demonstration of the unidirectional-bidirectional DNN imager.

figure 3

ac Input patterns and corresponding measured electric-field intensity distributions in the output plane under the forward incidence of x- and y-polarized THz waves. df Input patterns and corresponding measured electric-field intensity distributions in the output plane under the backward incidence of x- and y-polarized THz waves.

Unidirectional-bidirectional-unidirectional classifier and imager

To enable a unidirectional channel in the backward direction, a cascaded metasurface consisting of a HWP array and metallic gratings is designed and experimentally demonstrated to realize polarization-controllable unidirectional-bidirectional-unidirectional DNN, as shown in Fig. 4. As shown in Fig. 4a, b for x-polarized THz waves incident from the forward direction, the HWP array transforms the incident waves into y-polarized waves, which then fully transmit through the metallic gratings. Conversely, x-polarized waves are completely reflected when impinging from the backward side, leading to unidirectional transmission in the forward direction. Meanwhile, y-polarized incidence achieves unidirectional transmission in the backward direction, and 45°-LP waves allow bidirectional transmission. In the experiment, we use the letters “C”, “O”, “S”, and “V” as input under x-polarized forward incidence. The measured diffractive fields appear at the top-left, top-right, bottom-left, and bottom-right regions (Fig. 4c, d). As expected, the corresponding output-energy distribution maps (Fig. 4k–n) match well with the measured electric-field distributions, and the confusion matrix (Fig. 4o) indicates a classification accuracy of about 92.5%. In contrast, the same input letters under x-polarized backward incidence produce no detectable diffractive fields in the detection plane (Fig. 4g, h), indicating the unidirectional recognition in the forward direction. When the incidence is 45°-LP, both forward and backward excitations allow diffractive fields to be focused into the predesigned regions (Fig. 4e, i), thereby achieving a bidirectional recognition mode. Once the incidence is switched into y-polarized waves, the forward incidence is entirely reflected by the metallic gratings (Fig. 4f), while the backward incidence can transmit through the metallic gratings and undergo modulation by the HWP array, finally forming diffractive fields at the top-left, top-right, bottom-left, and bottom-right corners (Fig. 4j), which confirms the unidirectional recognition in the backward channel. Overall, these results establish unidirectional-bidirectional-unidirectional DNN that support information security (unidirectional information transmission in forward or backward directions) and sharing (bidirectional information transmission in opposite directions). Additional measured output-energy maps under various polarization/incidence combinations are given in Supplementary Note 11, while numerical demonstrations of the polarization-controllable unidirectional-bidirectional-unidirectional DNN are detailed in Supplementary Note 12. The simulated output-energy maps for 45°-LP forward incidence and 45°-LP/y-polarized backward incidence are presented in Supplementary Note 13, while the recognition of ten handwritten letters is discussed in Supplementary Note 14. Although the experiments were conducted under normal incidence, our proposed PS-DNN exhibits robust performance under oblique incidence. Moreover, owing to the inherent resilience of DNNs, our PS-DNN operates effectively over a broad bandwidth. Detailed discussions on these aspects are provided in Supplementary Notes 15 and 16.

 

Fig. 4: Experimental demonstration of the unidirectional-bidirectional-unidirectional DNN letter classifier.

figure 4

ab Schematic of the working principle of the unidirectional-bidirectional-unidirectional DNN under x-, 45°-, and y-polarized THz illumination from the forward (a) and backward (b) directions. cf Letter patterns and corresponding measured electric-field intensity distributions in the output plane under the forward incidence of x-, 45°-, and y-polarized THz waves. gj Letter patterns and corresponding measured electric-field intensity distributions in the output plane under the backward incidence of x-, 45°-, and y-polarized THz waves. kn Measured output-energy distribution maps for the x-polarized forward incidence. o Measured confusion matrix for the x-polarized forward incidence.

Capitalizing on the unidirectional-bidirectional-unidirectional DNN, a polarization-selective directional imaging system can be implemented, as illustrated in Fig. 5 and Supplementary Note 17. Here, the cascaded metasurface, modeled as a PS-DNN, is trained to realize directional imaging for the input letters “C”, “O”, “S”, and “V”. When illuminated by x-polarized THz waves in the forward direction, the images of “C”, “O”, “S” and “V” can be clearly observed in the output plane, as demonstrated in Fig. 5, A and B (in comparison with Fig. 5e, f). For the incidence of 45°-LP THz waves, the imaging function activates in both forward and backward directions, enabling bidirectional imaging capability (Fig. 5c, g). When y-polarized waves are used, only the backward channel supports image formation (Fig. 5d, h).

 

Fig. 5: Experimental demonstration of the unidirectional-bidirectional-unidirectional DNN imager.

figure 5

ad Input patterns and corresponding measured electric-field intensity distributions in the output plane under the forward incidence of x-, 45°-, and y-polarized THz waves. eh Input patterns and corresponding measured electric-field intensity distributions in the output plane under the backward incidence of x-, 45°-, and y-polarized THz waves.

Discussion

By leveraging polarization-selective unidirectional-bidirectional-unidirectional DNN, one can design an information transmission system that integrates both data sharing and security for high-security data exchange. As illustrated in Fig. 6a, information is compiled into a sequence of LP images consisting of letters “C”, “S”, “O”, and “V” with predesigned polarizations. These polarization-dependent images are then securely transmitted to multiple agents, each potentially decoding different information depending on three keys: transmission direction (forward or backward), polarization state (e.g., 0°, 45°, and 90° LP), and detection position (e.g., a specific corner or region in the output plane). As shown in Fig. 6b, c, for the forward transmission, only the patterns with the polarization of 0° and 45° LP can be processed by the DNN, whereas 90° and 45° LP patterns can transmit through the cascaded metasurface in the backward direction. Since the diffractive fields in the output plane are focused in the predesigned recognition areas, the signal is only detected in the correct region if the transmission direction, polarization state, and detection position match the key. The decoded codes are then defined in the binary form of “1” and “0” (“1” for a match, “0” otherwise). To reinforce the security of information processing, each receiver only detects and combines signals from two discrete positions (e.g., the top-left and top-right corners of the detection plane), which enhances both channel capacity and decoding complexity. Consequently, the same message from one sender can yield distinct decoded outputs for different receivers, owing to the combined security and sharing capability of the proposed DNN (i.e., each receiver uses its own unique set of keys). Meanwhile, unauthorized interception of the polarization-dependent images—without knowledge of the correct decoding keys—defaults to “1” in each transmitted data sequence, thus resulting in incorrect information.

 

Fig. 6: PS-DNN-based high-security data transmission/exchange system.

figure 6

a Schematic of the incident Letters with predesigned polarizations. bc Schematic illustration of the decoding process performed by a PS-DNN letter classifier with three discrete keys. dg Experimental results for the detected signals and decoded binary codes at 0.6 THz, measured at the top-left and top-right corners under forward and backward transmission. The same polarized-image sequence is used as the input, demonstrating shared and confidential data decoding.

To validate the proposed system, we performed an experimental demonstration with different decryption keys for Agents “Alice” and “Bob” (Fig. 6d–g). For “Alice”, the transmission direction key is forward, the polarization key is 0° and 45°, and the position key is the recognized region corresponding to handwritten letters “C” and “O”. For “Bob”, the three keys are backward direction, 90° and 45° LP, and recognized region corresponding to letters “C” and “O”, respectively. We compile the digital data into a polarization-related image sequence (i.e., “SCSVOCCOOVCO”) with carefully predesigned polarization states to mimic both information sharing and security scenarios, as shown in Fig. 6a. For Agent “Alice” with a forward key, the measured signal in the detection plane appears at the top-left corner (Fig. 6d) when the 45°-LP sequence “SCSVOC” is directed onto the DNN. Decoding this signal yields a binary string “010001,” where “1” implies the normalized intensity in the designated region exceeds 0.5, and “0” indicates it is below 0.5. The experimental setup and data processing methods are provided in Supplementary Note 2. Meanwhile, for the probe placed at the top-right corner (Fig. 6e), the decoded result is “000010.” After combining these two strings, “Alice” finally receives the message “010011”. Under the same 45°-LP sequence “SCSVOC”, Agent “Bob” can also decode the signals as “010001” (Fig. 6f) from one probe location and “000010” (Fig. 6g) from the other location. Thus, both “Alice” and “Bob” share this partial data “010011,” illustrating the information-sharing aspect. For the polarization-coded image sequence “COOVCO” with polarization angles of 0°, 90°, 90°, 0°, 90°, and 0°, the decoded data at the top-left corner is “100000” (Fig. 6d), while the top-right corner decodes “000001” (Fig. 6e) as the PS-DNN in the forward direction only allows the 0°-polarized component to pass through, leaving the combined data “100001”. However, “Bob” receives different information because only the 90°-polarized wave is allowed for backward propagation. The combined decoded result for “Bob” is “011010,” (Fig. 6f, g) which differs from “Alice’s” decoded data “100001”. Consequently, for the same input sequence, “Alice” receives “010011100001” (partial sharing + confidential data), while Agent “Bob” receives “010011011010” (they share “010011” but differ in the remaining bits). This outcome demonstrates how the polarization-selective DNN can simultaneously provide information security (confidential data that differ between “Alice” and “Bob”) and information sharing (matching portions of the transmitted data). The performance of the information transmission system under oblique incidence, which integrates both data sharing and security for high-security data exchange, is discussed in Supplementary Note 18. Furthermore, the design of such an information transmission system leveraging polarization-selective unidirectional-bidirectional DNN is provided in Supplementary Note 19.

In summary, we have proposed and experimentally demonstrated PS-DNNs that unify both information sharing and security within an all-optical framework. By integrating meta-gratings with QWP or HWP arrays, our approach enables direction-dependent classification and imaging functionalities. Specifically, we first realized unidirectional and bidirectional modes for digit recognition and imaging, and then extended these capabilities to unidirectional–bidirectional–unidirectional modes for letter recognition and imaging. Furthermore, we designed a polarization-selective transmission system to blend high-security data exchange with shared information processing. This compact, polarization-dependent DNNs architecture addresses the longstanding challenge of balancing data sharing and data security in photonic systems. Compared to conventional polarization-selective metasurfaces, the proposed PS-DNNs offer higher processing capacity by handling versatile optical inputs, adaptive functionality through deep learning-based optimization, and enhanced information security via polarization-selective classification. Although the proposed PS-DNNs operate in the THz frequency, the designing method and underlying mechanism can be extended to the infrared and optical frequencies by scaling the meta-atom dimensions and optimizing the structural parameters. We envision that the presented design and methodology will open new avenues for modern all-optical computation, communication, and privacy protection, offering a promising route toward advanced, multifunctional photonic devices.

Methods

Numerical calculations

Full-wave simulations are performed using the finite-difference time-domain (FDTD) method. To optimize the unit structure, periodic boundary conditions are applied in the x and y directions, while perfectly matched layers (PMLs) are used along the z direction. For digit/letter classification and imaging, PMLs are applied in all directions. The metallic gratings and input patterns are carved gold films with a thickness of 150 nm. The Si substrate is 500 μm thick, with a dielectric constant of ε=3.45. In the simulation, a plane wave normally illuminates the metasurface, and a 2D monitor is used to detect the electric field distribution in the output plane.

Training

A single-layer DNN is designed using Python (v3.9.16) and TensorFlow (v2.6.0, Google Inc.) on a Windows 10 system (Microsoft) equipped with an Intel(R) Core (TM) CPU i7−12700H @ 2.20 GHz central processing unit (CPU, Intel Inc.), 128 GB RAM, and a GeForce RTX 3060 Ti graphics processing unit (GPU, Nvidia Inc.). The MNIST and EMNIST datasets are used for training with a batch size of 8 over 50 epochs, and the learning rate is 0.01. The mean square error is employed as the loss function, and the desired phase of the hidden layer for network training is updated using the stochastic gradient descent algorithm.

Experimental setup

A near-field scanning terahertz time-domain spectroscopy microscopy system (NSTDSM) is constructed to measure the diffraction light field distribution after the metasurface samples. A femtosecond laser with a central wavelength of 1560 nm is divided into two beams. One beam is guided into a photoconductive antenna emitter to generate THz waves for sample characterization. The other beam passes through a periodically polarized lithium niobate (PPLN) crystal, generating a 780 nm laser beam that is then coupled into a single-mode fiber and focused onto the THz tip. Mounted on a 3D translation stage, the THz tip enables precise 3D scanning of the diffraction light field distribution behind the metasurface samples.