Quantum state heralding using photonic integrated circuits with free electrons

Recently, integrated photonic circuits have brought new capabilities to electron microscopy and been used to demonstrate efficient electron phase modulation and electron-photon correlations. Here, we quantitatively analyze the feasibility of high fidelity and high purity quantum state heralding using a free electron and a photonic integrated circuit with parametric coupling, and propose schemes to shape useful electron and photonic states in different application scenarios. Adopting a dissipative quantum electrodynamics treatment, we formulate a framework for the coupling of free electrons to waveguide spatial-temporal modes. To avoid multimode-coupling induced state decoherence, we show that with proper waveguide design, the interaction can be reduced to a single-mode coupling to a quasi-TM00 mode. In the single-mode coupling limit, we go beyond the conventional state ladder treatment, and show that the electron-photon energy correlations within the ladder subspace can still lead to a fundamental purity and fidelity limit on complex optical and electron state preparations through heralding schemes. We propose applications that use this underlying correlation to their advantage, but also show that the imposed limitations for general applications can be overcome by using photonic integrated circuits with an experimentally feasible interaction length, showing its promise as a platform for free-electron quantum optics.

Quantum coherent coupling between distinct physical systems harnesses the advantages and strengths of the different systems in order to better explore new phenomena and potentially develop novel quantum technologies [1,2].Photonic links [3] are most commonly used to connect different systems due to the potential for longrange transmission through optical fibers and robustness to decoherence from thermal environments, and have been realized in systems ranging from superconducting qubits [4,5], solid state spins [6,7], ultra coherent mechanics [8,9], and atomic systems [10][11][12][13][14], where each offers unique features and advantages to be utilized in a hybrid quantum system.One key aspect of all these systems is the ability to enact high-fidelity quantum control of the interaction with well-defined optical modes.
High-fidelity quantum control requires high coupling strength between free electrons and optical vacuum fields, and low dissipation to keep decoherence at a minimum.The interaction mechanisms and their coupling strengths differ substantially between different physical platforms, which can be categorized into metallic [18] and dielectric structures [20,26,30,38,39].For nanophotonic parti- * guanhao.huang@epfl.chcles, the short attosecond-long interaction time promotes the use of dissipative materials, such as plasmonic structures [40].The collective electronic response amplifies the interaction, while at the same time bringing retardation and dissipation, which is not ideal for quantum-coherent manipulation of electrons with optical states.On the other hand, transparent dielectrics, for which the coupling is enhanced by an extended interaction length, offer a paradigm shift in free-electron quantum optics due to their low optical dissipation and practically instant electronic response.Instead of enhancing the interaction by lossy media, optical modes supported by dielectric structures interact with the free electron by a geometric effect through the relativistic field retardation [41], which results in a purely parametric interaction ideally suited for high-fidelity quantum control.
Photonic integrated circuits have only entered the picture very recently [30,42], and have several advantages for free-electron quantum optical experiments.Firstly, integrated photonics enables exquisite control of the optical properties of waveguides [43,44].The nearly lossless guided modes [45] and high-efficiency output fiber coupling [46] facilitate coupling to both on-chip [6][7][8][9] and fiber-coupled quantum systems [4,[11][12][13][14].Additional capabilities are provided by well-established on-chip optical elements such as tunable beam splitters and phase shifters [47], spectral filters [48] and photon counters [49], which offer high-fidelity optical state manipulation and characterization [50].With the versatile on-chip structures and demonstrated efficient electron phase modulation [30] and electron-photon correlation [42], we propose heralding schemes to shape useful electron and optical states in various application scenarios with photonic integrated circuits.
To transfer the aforementioned advantages to the scenario of generating high-quality quantum states through electron-photon interaction, high-ideality coupling to a single well-defined optical mode [51] is required.However, due to the complex waveguide structures, parasitic couplings to auxiliary spatial modes cause decoherence of the system, see Fig. 1(a).We quantitatively investigate this limitation in a realistic experimental scenario, and show that with a single-mode waveguide, larger gap distance, and long interaction length, near-unity coupling ideality and strong coupling can be achieved to the waveguide quasi-TM 00 spatial-temporal mode.
Further, we show that even in the limit of singlemode interaction, there is still a state subspace correlation that imposes fundamental limit to the state fidelity and purity.To address the electron-photon interaction in the conventional quantum optics description, a synthetic ladder state space [32][33][34][35][36][37] is usually used, shown in Fig. 1(b).This treatment greatly eases the analysis of the interaction between two systems that are actually continuum systems.However, within the subspace of a ladder level, energy conservation enforces strong correlation between the electron energy loss and the frequency of the photon created.When one neglects the underlying correlation, information loss occurs.This process can be characterized by the state purity, that captures both the distance to a pure quantum state, and the degree of electron-photon entanglement through Rényi-2 entropy [52].Here, we propose applications that exploit this underlying correlation to their advantage, e.g.imprinting electron wavefunctions onto optical states, and later examine the state fidelity and purity in quantum state heralding schemes.We find that electrons in particle-like states with high purity are required to generate pure heralded states, and the purity limits are greatly reduced with experimentally feasible interaction length using photonic integrated circuits.
The manuscript is organized as follows: Section I establishes the theoretical formalism for describing electron-photon spontaneous scattering processes with dielectric media, different parameter regimes, and the underlying state correlations within the energy ladders.Section II studies the interaction in a photonic integrated circuit structure, defines the spatial-temporal modes and provides guidelines to achieve single-mode coupling.Section III investigates optical state heralding in wave-like and particle-like regimes, shows corresponding applications and quantitative analysis of the correlation-induced state heralding fidelity and purity limit.Section IV investigates electron state heralding schemes, optical mode matching and down-conversion schemes, and the state purity limit.Section V summaries the manuscript, discuss the theoretical limitations of our analysis and the experimental constraints.(a) Illustration of the electron-photon inelastic scattering process mediated by a dielectric waveguide.In an electron microscope, when the high-energy electron passes by a dielectric waveguide structure with a given dielectric permittivity distribution (x, y, z), the material dielectric dipoles exert a backaction field (force) on the electron, resulting in correlated electron energy loss and optical emission in both the guided waveguide modes and non-guided bulk modes.High-ideality coupling to a low-loss waveguide mode is required for high fidelity state preparation and interaction with other quantum systems through optical links.(b) Synthetic electron-photon state ladder of the pair state generation through Ŝe-ph .Within each ladder state, there is an underlying subspace that still maintains correlation between electron energy and photon frequencies.This correlation can lead to new types of applications, but generally leads to degradation of fidelity and purity of the interaction.

I. ELECTRON-PHOTON INTERACTIONS WITH DIELECTRIC MEDIA
The interaction between free electrons and optical modes at a dielectric surface can be understood in a microscopic picture as follows: When an electron passes near the surface of a dielectric structure, the electric field of the flying electron polarizes the dipoles in the structure (see Fig. 1(a)).As a result, these dipoles generate The electron and photon spatial waveforms as a function of T = t−z/ve, where z is the longitudinal coordinate, are shown in the upper panels, and the corresponding energy (frequency) domain picture is shown in the lower panels.The frequency bandwidth of the generated photon is determined by the phase-matching mechanism, and two of the frequency components are shown in red.(a) Wave-like regime where distinguishable electron states are generated from the emission of photons with the corresponding frequencies.This regime is accompanied by mixed optical ladder states ρ ph,N , and incoherent photon emission.(c) Particle-like regime where the photon emission at different frequencies generates indistinguishable electron states.This regime has pure optical ladder states ρ ph,N , where the synthetic electron-photon state ladder is a valid approximation.(c) Classical regime where different photon-sidebands of the electron overlap well, and classical optical field emission with non-zero Â is achieved.
oscillating electromagnetic fields that cause backaction Coulomb forces on the electron which change the electron energy.In the conventional quantum optical modal decomposition picture commonly used in the cavity quantum electrodynamics (QED) community, this can be interpreted as the interaction between the free electrons and the optical vacuum fields of the modes supported by the dielectric structure [53].
Here, we formulate the problem as the interaction between propagating free electrons and one single interaction-specific optical spatial mode Â(r, ω) (see Appendix A for the QED details and the field profile) at frequencies ω in the continuum, instead of pre-determined discrete optical modes of the dielectric structure (see Appendix C for its correspondence to modal decomposition), with the scattering matrix [33,51] in the interaction picture where the phase operator χ acts only on the electron degrees of freedom (ignored in the remaining discussion), and is associated with the Aharonov-Bohm effect of the vector potential [54].Continuum photon ladder operators âω and electron operators bω characterize the energy exchanges between the electron and the optical field at a given optical frequency ω in an energy-conserving manner.The interaction with the vacuum optical fields results in transitions into lower electron energy states with energy differences of ω.We define the electron-photon coupling strength at a given photon energy ω in terms of the vacuum coupling strength g ω as Γ(ω) = |g ω | 2 [16].
The phase matching condition gives the vacuum coupling strength a finite bandwidth.In the limit where Γ(ω) 1, Γ(ω) is equivalent to the electron energy loss probability per unit optical frequency of dielectric media measured in electron energy loss spectroscopy (EELS), and can be derived classically in a simplified picture (See Appendix B).To simplify the discussion here, we also assume a pointlike transverse distribution for the electron (see Appendix A for the discussion on the transverse effect), and the vacuum coupling strength g ω is derived at a corresponding transverse position R 0 .
The interaction with the optical continuum, as opposed to the conventional discrete energy-ladder levels illustrated in Fig. 1(b), results in a continuum electronphoton pair state where ψ(E) is the electron wavefunction in the energy domain.We show in Fig. 2 that depending on the size of the electron wave-packet, the electron-photon interaction can be categorized into three regimes.The classical regime has been explored, and is accessible through laser modulation schemes [32,36,[55][56][57][58].Some electronmicroscopes equipped with a monochromator fall into the wave-like regime [27,28,59], while others with longer interaction length [42] are in an intermediate wave-particlelike regime.The simplified electron-photon ladder picture is only partially valid in both cases.In the wave-particle-like regime, the ladder state |E |0 maintains a correlation between electron energies E and photon frequencies ω.To go back to the simplified ladder picture, one traces out e.g. the continuum electron states within each ladder as ρph,N = Tr E [|ψ e , ψ ph N ψ e , ψ ph | N ], which results in a degradation of the optical state purity P = Tr ρ2 ph,N .To reduce the degree of correlation and reach the particle-like regime, a narrower phase-matching bandwidth relative to the electron energy uncertainty is generally required.
We show in the latter half of this manuscript that in the case of photonic integrated circuits, the prolonged interaction length can help reduce the phase-matching bandwidth and lower the energy correlation for a single waveguide mode, pushing the system parameters well into the particle-like regime.However, the complex dielectric environment generally results in multimode electronphoton interactions, e.g., through parasitic coupling to other optical mode families and other non-guided spatial modes supported by open-ended dielectric substrates.The effective phase-matching bandwidth of the multimode coupling is generally large, and the corresponding electron-photon correlation can not be suppressed by a longer interaction length.Therefore, we first quantitatively analyze how to effectively constrain the interaction to the single-mode case.
It is generally hard to design and fabricate waveguide structures that achieves 100% spatial overlap between a waveguide mode and the electron optical emission over the full optical frequency range.Therefore, instead of mode-matching, our strategy to achieve single-mode interaction is to exploit a combination of effects which are results of the phase-matching mechanism.
To quantitatively account for the infinite number of interacting spatial optical modes, it is generally impractical to use the conventional modal decomposition method [18].Instead, as is mentioned before, we combine all the possible coupling contributions from different modes into one single interaction-specific spatial mode, following a three-dimensional QED treatment [60].This formalism, derived using the fluctuation-dissipation theorem, was previously used when analyzing electron energy loss probabilities with dissipative materials [16] that exhibit a delayed material response, which is the dominant contribution to the main electron energy loss channels.The dielectric materials we study here are transparent in the optical frequency bands of interest.In this sense, we can set Im{ (r, ω)} → 0, which corresponds to an instantaneous dielectric dipole response and further simplifies the analysis.For materials with sufficiently low absorption, which are used for integrated waveguides designed to guide optical fields, the interaction is purely contributed from the relativistic field retardation effect [41] and prohibits energy and momentum transfer to the material, avoiding loss of coherence.It is in this sense that the whole process of an electron interacting with dielectric waveguide is parametric in nature.

II. COUPLING IDEALITY
In this section, we show how to achieve ideal singlemode electron-photon coupling with photonic integrated circuits.As an example, here we quantitatively investigate the electron-photon coupling mediated by an integrated Si 3 N 4 waveguide embedded in a silica substrate without top cladding (the bottom silicon substrate is not considered), shown in Fig. 3(a).This type of structure has been used in recent investigations of both stimulated phase-matched interactions [30] and spontaneous inelastic scattering [42] between free electrons and the evanescent field of a photonic-chip-based optical microresonator, and features ultra-low material-limited loss of 0.15 dB/m [45].We calculate the electron-photon vacuum coupling strength (numerical details in Appendix D) and plot it in Fig. 3(b-c) as a function of electron velocity for optical wavelengths ranging from 780 nm to 2.5 µm (where all relevant material properties are well known), which covers most of the frequency bands that are of general interest.
Under the optimal phase-matching condition, the interaction strength of the waveguide transverse modes scales quadratically with respect to the interaction length since they co-propagate with the electron, in contrast to the linear relation of bulk modes.In reality, waveguidemode phase velocity differs at different optical frequencies.Through the phase-matching mechanism, linear chromatic dispersion limits the coupling bandwidths to scale inversely proportional to the interaction length.With prolonged interaction length, coupling strengths to different waveguide transverse mode families are isolated in optical frequencies, and exhibit peak features shown in Fig. 3(b-c).Dispersion-free systems are generally feasible in higher dimensions and have been realized in specially structured photonic lattices [61][62][63], where the optical modes of interest are generally unguided.In integrated photonics, advances in dispersion engineering have enabled waveguide designs that tailor the modal dispersion [44,64], promising dispersion-free quadratic coupling enhancement over a broad frequency range.In our study, we focus on translation-invariant straight waveguides which exhibit chromatic dispersion determined by the waveguide materials and geometry.
The waveguide mode families have finite coupling bandwidths and are well isolated from each other.We therefore define discrete spatial-temporal optical modes âm ∝ dωg m,ω âω associated with different waveguide mode families from the optical continuum based on the vacuum coupling strengths g m,ω of the interaction (details see Appendix C).The coupling strength of a given mode family âm , scales linearly with interaction length and inversely with chromatic dispersion.We quantitatively evaluate the coupling strengths |g m | 2 to different spatial-temporal modes âm based on the fitted interaction strength |g m,ω | 2 from the simulation results.As an example, for the quasi-TM 00 mode of the 800 nm wide waveguide shown in Fig. 3(c), for an electron-waveguide gap of 100 nm, a strong coupling strength of |g TM 00 | 2 ∼ 1 can be achieved with 100 µm of interaction length at an electron velocity of v e /c = 0.65 (a kinetic energy of 160 keV).The 100 nm gap distance and 100 µm e-beam propagation length are experimentally feasible and demonstrated in [42] with a gradient d|g TM 00 | 2 /dz ∼ 5 mm −1 .
Using the procedure described in the previous paragraph, we quantitatively investigate the influence of competing waveguide modes for a given waveguide configuration, and how one can approach unity coupling ideality by a proper choice of waveguide geometry and material, and electron beam positioning and velocity.Since the lowest order TM 00 mode is generally the most strongly coupled and is the most spectrally isolated mode, we target unity coupling ideality, defined by the coupling fraction to the TM 00 mode.
From the numerical result shown in Fig. 3(b-c), we find that reduced waveguide cross-section (to single-mode dimension) enhances the mode index contrast, and results in more spectrally isolated fundamental modes.With a better frequency isolation, the evanescent field of the coupled higher-order modes decay much faster than that of the fundamental mode in the near field, as a result of their higher optical frequencies.Therefore, one can enhance the ideality by increasing the gap distance to the waveguide surface, with 1 − I decreasing exponentially with gap distance (details in Appendix D).
In addition to coupling to higher-order waveguide mode families, one can also identify a rising background in the high velocity region.It can be attributed to strong coupling to the substrate modes in the Cherenkov regime (v 0.7c), where the charged particle velocity exceeds the phase velocity of light in dielectric media (here: silica).In Appendix E, we quantify the contribution of the substrate bulk modes.This contribution can be suppressed by either choosing an electron velocity well below the Cherenkov regime of the substrate, or by using a low index material as the substrate (e.g. by suspending the structure in vacuum).
Here, we quantitatively analyze the coupling idealities in different application scenarios, and show the results in Fig. 3(d).First, we consider state heralding applications e.g.heralded single photon sources by photon-energy loss selection with EELS.We assume an initial electron state with a fitted 0.6 eV Voigt zero-loss-peak (ZLP) profile, and show that by conditioning on the first energy-loss sideband, one can easily achieve more than 99 % conditional coupling ideality I * to the TM 00 mode outside the Cherenkov regime (v e 0.7c) with a single-mode waveguide and the electron beam positioned 100 nm above the surface (details in Appendix D).For a general application that is sensitive to the full optical spectrum, we show that more than 95 % non-conditional coupling ideality I can be achieved with the electron beam placed 300 nm above the surface, limited by the parasitic coupling to the higher-order waveguide modes.This is not a fundamental limitation, as one can always increase the gap distance from the waveguide surface to achieve higher ideality, at the expense of reduced coupling strength.This trade-off is also illustrated in Fig. 3(d), where the total coupling strength |g TM 00 | 2 is plotted against the coupling ideality.However, this effect can generally be compensated with longer interaction length L. As a result, given a fixed waveguide geometry and a target total coupling strength, the deviation from unity is given by 1 − I ∝ L −1 .
In the special case where the waveguide loops and forms a resonator, the result of the open-ended waveguide studied here can equally apply (see Appendix F).In most scenarios, where the electron longitudinal spatial wavefunction is shorter than the cavity round trip length, or in the frequency domain picture where the electron zero-loss-peak (ZLP) width is broader than the cavity free-spectral-range, there is no difference in terms of coupling ideality betweeen a straight waveguide and a resonator.The physical picture is that when the emitted optical pulse does not interact with the electron a second time, the emission is only determined by the local structure around the electron.In the case of a resonator, the pulse will circulate multiple times and exit the cavity as a pulse train, and exhibit in the frequency domain as a comb-structure, as was shown in [27,28,42].
Note that the experimentally measured ZLP width consists of a coherent energy spread of a single-electron wavefunction, e.g.inherited from the driving laser pulses in the cold field electron emission process, and also an incoherent broadening due to e.g. the statistical imprecision of the electron acceleration voltage and the measurement instrument.In this manuscript, we mostly use ZLP width to refer to the coherent energy width, unless otherwise specified.
Generally, residual coupling to the higher-order modes can be further mitigated with heralding schemes.As an example, one can place a bandpass spectral filter [48] around the frequency band of the target mode.Upon conditioning on photon-absence events at the dark port of the filter, one can further approach unity ideality, and be eventually limited by the background bulk contribution.As long as the velocity is far from the Cherenkov regime of the substrate material, we estimate this contribution to be far less than 1%.With near-unity coupling ideality, the fidelity and purity of the interaction will be limited to the correlation between electron energy and the optical frequency components of a single spatial-temporal optical mode within the ladder state space.In the following sections, we discuss this fundamental limitation in the cases of state heralding schemes.

III. SHAPING OPTICAL STATES FROM MEASUREMENT ON ELECTRON ENERGY
In this section, we consider the case of heralding a general optical state by measuring the electron energy.To simplify the discussion here and capture the main features of the physics considered, we assume coupling to a single spatial-temporal optical mode with I = 1, and a coherent electron wavefunction ψ(E) prepared before the interaction.The effect of electron sideband overlaps (with expression shown in Appendix G) is not considered since they can be efficiently eliminated experimentally and are thus not a fundamental limitation.
We first investigate the consequences of electronphoton correlation in the state subspace in some general state preparation schemes.We consider a projection M = |E c E c | on the electron's first photon sideband (general case in Appendix G).This results in a pure single-photon optical state with frequency components φ ω ∝ g * ω ψ(E c + ω), a product between the electron wavefunction and the vacuum coupling strength.This reflects the fact that the electron energy loss is intrinsically correlated with the frequency of the photon created.The strength of the correlation depends on the initial energy uncertainty of the electron, which determines how well the photon frequency components can be distinguished by measurements of the electron state.In a stark contrast, we will see in the next section that this is not the case for the electron state heralded by photon counting, since in the no-recoil limit the frequency of the photon created does not depend on the energy of the electron.In this section, we consider two regimes of interest: The wave-like regime (section A) that exploits the correlation to its advantage, and the particle-like regime (section B) that aims for high-purity state heralding.

A. Wave-like regime
In the wave-like regime, the electron ZLP width is much narrower than the phase-matching bandwidth, as shown in Fig. 4(a), where the electron behaves more wave-like to different optical frequency components.This regime exploits the strong correlation in the subspace between electron energy and optical frequency.This is compatible with the experimentally achieved [59] 4 meV ZLP width using a monochromator [28] combined with the recently demonstrated ∼100 meV phase-matching bandwidth [42].In this regime, we show the expression for the heralded single-photon Fock state as In this scenario, ignoring the waveguide dispersion during propagation, as well as electron energy dispersion, we effectively imprint the electron spatial wavefunction ψ(T = t − z/v e ) onto the optical waveform φ(T ) of the generated single-photon Fock state of spatial-temporal mode â ∝ dωψ * (E c + ω)â ω , with with a center frequency ω c = E c / matching the conditioned electron energy E c .Therefore, by shaping the electron wavefunction (e.g.pre-compression into THz Ŝe-ph 10 2 interaction length (µm) wave-like regime particle-like regime pulse trains) and conditioning on a specific sideband energy, one can transfer the arbitrarily shaped electron spatial wavefunction to the optical waveform at a desired optical frequency.As for higher-order conditional Fock states |N , they cannot be addressed into the Nphoton excitation of a single spatial-temporal mode (see Appendix G) because the optical frequency components are highly correlated, but in any photon counting scheme, the optical profile is still shaped as |φ(T )| 2 and contains N photons.We illustrate in Fig. 4(c) an application example in this regime.When an electron passes through two waveguides, and is then measured at the first photon sideband on the detector (single photon excitation), the measurement does not resolve in which waveguide the photons are created.In this scenario, the measurement creates a spatial entanglement of photon excitation in the two spatially separated waveguides, with naturally mode-matched waveform φ(T ) and a controlled phase depending on the effective delay ∆t from the electron trajectory, essential for generating path entangled NOON states [65].If we interfere the two entangled modes with a balanced beam splitter, there is coherent quantum inference between the two waveguide excitations (see Appendix J).In this way, we effectively constructed an optical interferometer with a non-classical optical state mediated by free electrons, with output differential photon flux Notice that due to the nature of broadband optical coupling, when conditioning on different electron energy E c , we are effectively scanning the probing optical frequency of the interferometer ω c , enabling accurate extraction of the time imbalance ∆t to the order of only a few optical cycles.When sweeping the optical path length difference to induce mode-mismatch, one can also retrieve electron spectra density based on interference visibility, similar to what was realized in matter interferometers [66].The electron wavefunction can also be reconstructed through spectral shearing interferometry [67], answering an important question that is both fundamental and practical: how much of the measured electron energy uncertainty is quantum coherent [68].

B. Particle-like regime
In the particle-like regime, typically associated with a long interaction length, the phase-matching bandwidth is very narrow compared to the electron energy uncertainty and the coupling strength becomes large, as shown in Fig. 4(b).Without on-chip electron guiding structures [31,69], we expect the longest interaction length to be limited to 1 mm with |g TM00 | 2 ∼ 5 given beam divergence angle ∼ 0.2 mrad [70] with a 100 nm gap.The electron behaves more particle-like in this regime, and can hardly distinguish different optical frequency components, therefore, the spatial-temporal optical modes defined in Section II can be correctly applied.In this limit, the subspace correlation can be greatly suppressed.When conditioning on the N th energy sideband, we can simplify the state to photon excitations of an electron-measurement-independent spatialtemporal mode â ∝ dωg ω âω as where the optical waveform φ(T ) is connected to the Fourier transform of the optical mode profile U z (z, T ) = FT ω [U z (z, ω)] along the electron propagation trajectory, determined by waveguide routing, and is generally much longer than the spatial extent of the electron wavefunction.For the case that includes propagation dispersion see Appendix I. Since the electron travels in a straight path, by using a tailor-made waveguide structure with proper dispersion and routing, most types of optical waveforms can be generated.The center frequency of the optical excitation is not determined by the conditioned electron energy, but can be easily tuned by selecting the appropriate electron velocity, evident in the results shown in Fig. 3(b-c).
In the following, we restrict ourselves to the regime of long interaction length, since it is most versatile for heralding more complex optical states with higher photon numbers, and the ladder subspace correlation is weaker due to narrow phase-matching bandwidth.We show an example on how to generate highly complex optical states, with the scheme shown in Fig. 4(d).The scheme consists of two stages, the first stage entangles the free electron with the waveguide mode, and the second stage selects the effective measurement basis for the electron energy.Specifically, the first stage of the interaction is the same pair-state generation [42] discussed in previous sections.While direct conditioning on the electron energy measurement generates optical Fock states, in order to generate more general optical states, one can select a more general measurement basis by having a second stage to apply a unitary transformation Û on the electron state before the measurement.Starting from the physical measurement basis M |, with the correct unitary transformation Û , the desired measurement basis M | Û can be generated.If an arbitrary measurement basis can be constructed, an arbitrary quantum state can be heralded.Such a scheme exploits the time-reversal symmetry in quantum mechanics, and has been used to demonstrate optical super-resolving phase measurement using only classical lasers [71].
In the illustrated case, shown in Fig. 4(d), we apply a standard photon-induced near-field electron-microscopy (PINEM) operation [30] at the same optical frequency (served as the phase reference for any follow-up optical state characterization) before detection, which effectively transforms the measurement basis from Upon heralding, the generated optical state is with coefficients modified by the selected electron measurement basis.Following this scheme, if at the second stage we select a more general measurement basis by modulating the electron with an optical waveform consisting of multiple harmonics [72] of the base optical frequency Ŝ = n ŜPINEM (g n , nω), one can in principle generate any general optical state e.g.Cat and GKP state [37].Note that in the no-recoil limit, any operation on the electron wavefunction commutes with the entangling operation Ŝe-ph .Therefore, it does not matter if the operation is applied post-entanglement or preentanglement.
Until here, we restricted ourselves to state generation in the ideal scenario where electron and photon are completely dis-entangled in the subspace of the synthetic electron-photon energy ladder.However, as is discussed in the theory section, there are still correlations between electron energy and optical frequency within the subspace.When tracing out the subspace continuum states, this leads to a degradation of state purity P = Tr ρ2 and fidelity 2 of the synthesized quantum state ρ.We analyze these effects in our state heralding scheme (expressions for P and F derived in Appendix G, calculated using Monte Carlo sampling due to high dimensionality).We first stress that when conditioning on an electron energy with perfect energy resolution, the purity of the state is always unity, and we define the state fidelity in that limit.However, the relative heralding bandwidth γ = ∆E/∆E ZLP determines the heralding rate, and is lower-bounded by the experimental energy resolution.At finite bandwidth, it always results in finite purity of the state.We illustrate this effect at different relative heralding bandwidths in Appendix G.
We assume a ZLP width ∆E ZLP = 0.6 eV with fitted Voigt lineshape from experimental data [42].Given a relative heralding bandwidth γ = 1, we show in Fig. 4(e-f) both the purity P of the state and the fidelity F compared to the target state.As the purity is only a function of the occupancy at different Fock state components, we only plot the scheme/state independent purity at these components.Due to more scrambled correlations between electron energy and photon frequency at higher ladder state subspace |ψ e , N , their purity is lower, with impurity 1 − P ∝ √ N .We also see that fidelity and purity increase with longer interaction distance L, with 1 − F ∝ L −4 and 1 − P ∝ L −2 .This scaling is expected from the narrower phase-matching bandwidth at longer interaction length, and aligns well with the prolonged interaction targeted by the photonic integrated circuits.To help the readers grasp the inverse quadratic scaling to interaction length, we point out that for relatively short interaction length at 10 µm [30],the state purity is < 90% for Fock state components |3 and above, but for an interaction length at 100 µm [42], the state purity > 98% even for |10 , with fidelity exceeding 99.9%.
Note that any contribution from the experimental uncertainty of electron energy will lead to degradation of the electron state purity, and also increase the relative heralding bandwidth.Therefore, the experimentally measured ZLP width ∼0.6 eV [73] can only serve as the upper bound of the quantum coherent energy uncertainty.Experimentally, the coherent energy uncertainty can be at least lower bounded at ∼0.1 eV by the measured single-electron pulse duration [74] which is in fact still far from the Fourier limit.In the limiting case when the electron energy density matrix is completely incoherent, P → 0. Furthermore, as the experimentally measured purity of the heralded optical state through Wigner tomography [75] scales as 1 − P ∝ ∆E −2 coherent , the purity characterization can also serve as a probe of the coherence property of the free electron.Even though the coherent electron energy width is hard to determine experimentally, it is fundamentally determined by the electron field-emission mechanism that generates the electron pulse.We can conclude that in order to be quantum coherent, the frequency spread of the heralded optical state must be much smaller than that of the laser pulses used in the electron field-emission.

IV. SHAPING ELECTRON STATES FROM OPTICAL DETECTION
Here we consider the reciprocal operation of the previous section which is to generate complex electron energy superposition state by conditioning on photon counting.This procedure enables generation of a much broader set of electron states not accessible by conventional PINEM- type phase modulation, e.g.direct amplitude modulation of electron wavefunction.Note that with the no-recoil approximation, here the heralded spatial-temporal electron wavefunction is not shaped by the optical detection and maintains the original waveform, in sharp contrast to heralding optical state by measuring electron energy.Therefore, the fidelity F of the heralded electron wavefunction does not depend on interaction length, but the state purity still does.In Fig. 5(a) we illustrate a similar scheme to that shown in the previous section to generate complex electron states with multiple stages of operations but on the optical side.The principle is the same, a pair-state is generated, then we select an effective measurement basis on the optical side to project the electron state into the desired form.As an example, before the detection, one can use a displacement operation D(α), realized by a high-ratio on-chip beam splitter [76], to modify the effective photon number counting [77] Based on a photon counting record, a conditional electron state is prepared at In the special case of the coherent state measure-ment basis α|, which can also be constructed by simultaneously detecting both orthogonal optical quadratures in a homodyne setting, the heralding operation is equivalent to applying a direct density modulation exp(2|αg| cos( ω v z + θ α )) on the electron wavefunction.In the limit of large modulation depth |αg| 1, the width of the electron wavefunction is compressed down to ∆z ∼ 1.7v ω √ |αg| .The magnitude of pulse compression is similar to what is possible with PINEM-type interaction, but without the additional dispersive propagation with modulation-depth-dependent distance [18].
The projection into a sharply density modulated electron wavefunction by measuring in the basis of optical coherent states can be understood intuitively.Since classical coherent optical excitation can only be generated by point-like electrons, the measurement of coherent states serves as a position measurement of the electrons, projecting them into the possible periodic positions that would give the correct classical phase of the measured optical coherent state.But since the coherent states are not completely orthogonal to each other, the uncertainty of the projected electron position is determined by the magnitude of the measured field amplitude |α|.
One can also prepare even parity electron energy state to halve the spatial modulation period, useful for generating coherent second harmonic optical emission [58], by applying conditional optical parity operation P (P ) using two-level systems [6,78,79] or photon-number-resolving counting [80] which modifies the measurement basis to cat states cat α | ∝ α| + −α|.Higher harmonic spatial modulation can be generated by detecting in higher-order cat state basis.
On the optical side, most unitary operations or state characterizations require mode matching to a reference spatial-temporal optical mode, which is difficult to achieve for the emitted THz broad optical pulses.Here we discuss two options that are experimentally feasible.The first option is to re-shape the emitted optical spatialtemporal profile through frequency filtering e.g. using an on-chip photonic crystal filter cavity [6].When the frequency width is narrow enough to be resolved by the detector, one can choose a continuous wave local oscillator and gate on the detector time sequence [81] synchronized with the electron pulses.To prevent any lossof-information that may lead to the degradation of state purity, one needs to collect all the optical excitations rejected from the filter and condition on a zero-count event from the dark port.At a single-photon level of optical emission, the relative heralding rate is determined by the filtered optical bandwidth vs. the original optical phasematching bandwidth.Therefore, such a frequency filtering scheme does limit the heralding rate significantly due to the large phase-matching bandwidth (e.g. 1 THz width at 1 cm interaction length).The second option is to directly mode-match with a specifically shaped reference optical pulse.Such pulse shaping with individual control at all the frequency components is generally hard in straight waveguides, and therefore requires the use of optical resonators in place of waveguides as was recently demonstrated [42].The reference optical mode can then be generated in an identical resonator [82] e.g. as a dissipative Kerr soliton [83] or an electro-optic frequency comb [84] with control over each individual frequency component [64,85].The time gating resolution required on the optical detection would then be relaxed to the optical cavity life time, which can be achieved at the level of 20 ns [45] for materials and structures studied in the current manuscript.In integrated photonics, cavity life time approaching 1 µs is also demonstrated [86][87][88].
Optical resonators offer the unique advantage of the concentrated optical density of states due to their narrow optical linewidth.We show a frequency conversion example in Fig. 5(b) (details of the scheme see Appendix K) to exploit this advantage of optical resonators to convert the THz-broad optical excitation from the electronphoton interaction to a MHz-broad microwave excitation using a χ 2 optical-to-microwave converter [89,90].Using a structured local oscillator pump field, the conversion effectively serves as a multi-mode demodulation of the entangled photons.The frequency width of the microwave photon is determined by the linewidth of the optical cavity mediating the electron-photon interaction.Compared to the original THz-broad optical excitation, this frequency conversion is particularly useful to bridge interactions of eV-broad free electrons with quantum systems at GHz frequencies, e.g.superconducting qubits, electron spin qubits and mechanical oscillators.Generally, with the coupling to well-controlled two-level systems in the strong coupling regime, any photon measurement basis can be constructed [91].As arbitrary quantum state synthesis of microwave photons was experimentally demonstrated in superconducting qubit systems [92], we can construct an arbitrary measurement basis ψ| = 0| Û by applying the unitary operation Û on the converted microwave field and then conditioning on the microwave ground state 0| with photon-number resolving measurement [93] using a superconducting qubit, promising arbitrary electron state generation.Optical-to-microwave converters and superconducting qubits mostly require mK temperatures due to their GHz-frequencies, and usually operate in a dilution refrigerator.Therefore, optical excitations need to be guided out of the electron microscope through optical fibers, stressing the importance of high efficiency fiber-to-chip couplings [46].
Note that due to multiple stages, usually the optical measurement event will occur after the electron detection due to the high electron velocity.However, a delayed measurement on the optics side does not impair our scheme, as the measurement operators on the two parties commute [94].Therefore, no real-time action is required.
Here, we show the full bandwidth state purity (expressions derived in Appendix H) as a function of interaction length in Fig. 5(c).As expected, it follows the same 1 − P ∝ L −2 √ N scaling, and favors longer interaction length.We point out again that for a relatively short in-teraction length at 10 µm, the electron ladder |10 state purity is 50%, but for an interaction length at 200 µm, the state purity reaches 99%.Note that the state purity is completely determined by the electron-photon interaction, and does not depend on specific schemes e.g.optical-to-microwave conversion.
Here, a lower purity of the initial electron state will also result in purity degradation of the heralded electron wavefunction, similar to the case of heralded optical state discussed in the previous section.However, effects like heralded density modulation is robust as the electron position projections are always valid given optical measurement records even with mixed electron states.

V. DISCUSSION
We analyzed fundamental limits of integrated photonic circuits as a platform for synthesizing high-quality quantum states with free electrons.We show that near-unity coupling ideality to the target TM 00 spatial-temporal waveguide mode can be achieved by suppressing parasitic couplings through the control of electron beam positioning, velocity, and waveguide design.We also investigate the underlying correlation between electron energy and photon frequency in the energy ladder subspace, and the induced fundamental limitation as a trade-off between heralding rate and state purity.We found that particlelike electrons with coherent energy uncertainty are required to generate pure heralded states, and the purity limit can be greatly relaxed with experimentally feasible interaction length with integrated waveguides.We also show that these correlations can be exploited to shape the optical waveforms, e.g. to map the electron wavefunction to optical domain and construct an effective optical interferometer mediated by free electrons.However, the spatial sensitivity of such an interferometer remains at the optical-wavelength scale, and does not inherit the superior spatial sensitivity of electron waves.It is still an open question whether phase-objectinduced electron phases can be transferred to the optical domain, accumulate and be detected optically, which is relevant for quantum-enhanced phase-object imaging applications [95,96].We also anticipate that the maximum feasible coupling strength |g TM00 | 2 can be further enhanced through waveguide dispersion engineering [44], with the trade-off of lower state purity due to larger phase-matching bandwidth.
Note that in our discussion we omit detailed analysis on some experimental limitations e.g.finite detection efficiencies, primarily on the optical side.The heralded optical state is robust given the high energy of the electrons, but the heralded electron state purity is therefore most sensitive to the optical detector efficiencies and other limiting factors such as optical mode-matching.We anticipate that there are schemes or parameter regimes that are less prone to detection inefficiencies.We also restrict our discussion mostly to the interaction picture, except that the electron and optical waveforms are defined in the Schrödinger picture.We remind the reader that in the Schrödinger picture, though not the main focus of the paper, long distance propagation significantly modifies the electron and optical density profile | ψ(T )| 2 and |φ(T )| 2 , leading to effects like electron [32,[55][56][57]97] and optical [98] pulse compression.Moreover, in the no-recoil limit, all the electron operations commute with each other.This approximation, though practically valid for few-photon single-chip interactions, limits the controllable degrees of freedom of the heralded optical states to the order of the harmonics of the PINEM field used to shape the electron wavefunction [72].In the platform of Si 3 N 4 microresonators, efficient generation of second [99] and third [100,101] harmonics are supported with estimated maximum |g 2 | ∼ 100 and |g 3 | ∼ 10, offering a total of 8 degrees of freedom on the heralded optical state.The Si 3 N 4 integrated photonics platform also provides an ultra-wide transparency window from 400 nm to 4.5 µm [102], supporting at most ten harmonic components with an externally driven optical source.Beyond the no-recoil limit [97], electron energy transitions significantly modifies the velocity due to energy dispersion.When interaction regions are far apart, the recoil effect results in an energy-dependent phase accumulation between different stages (details see Appendix L).The recoil effect can be safely neglected in the discussion of fewphoton single-chip interaction, but could be important for a wider range of experimental schemes [32,36,58], e.g. when multiple chips are involved with significant separation distance.Furthermore, our analysis is purely in the framework of macroscopic QED [60], where electrons interacts with the medium-assisted electromagnetic fields.In optical media like the Si 3 N 4 material we discuss here, optical phonons typically exist and result in Raman scattering of optical fields [103].But, due to their short spatial extent and low energy [104,105], we do not consider their contribution in long-distance phasematched interaction with the high-energy free electrons.The same reasoning also excludes higher electron energy loss process e.g.valence and inner-shell ionization around 50 eV [106].
Our analysis and results indicate that the photonic integrated circuit platform is ideal for free-electron quantum optics with manageable limitations, and promises a pathway to high-fidelity and high-purity quantum state heralding, entanglement of free electrons with other quantum systems, and quantum-enhanced sensing and imaging.
the Young Faculty Award from the National Quantum Science and Technology program of the Israeli Planning and Budgeting Committee.

Appendix A: QED details
We consider an electron beam with a narrow momentum spread around wavevector k 0 and assume that the photon energies involved in the interaction are much smaller than the electron relativistic energy E 0 = c c 2 m 2 + 2 k 2 0 (i.e. the no-recoil regime).In the velocity gauge, the Hamiltonian is described as [58,107] where we defined the electron current operator Ĵ(r) = (−ev/V ) k,q e iq•r ĉ † k ĉk+q using the Fermionic ladder operators ĉk and the relativistic electron group velocity v = c 2 k 0 /E 0 , and a linear electron energy dispersion is assumed.The vector potential Â(r, t) = dω 2π Â(r, ω)e iωt + h.c. is associated with the noise current operator ĵnoise (r, ω) through the quantized threedimensional Maxwell equation [60] and has a formal solution where G(r, r , ω) is the dyadic Green function (Green tensor) of the classical problem satisfying the equation which describes the field response at r to a point current excitation at r .Since we are dealing with non-magnetic materials, we assume a relative permeability µ(r) = 1.The noise operator is bosonic and was chosen to be in order to satisfy the fluctuation-dissipation theorem due to dissipative material, with bosonic ladder operators f (r, ω) satisfying commutation relation fi (r, ω), f i (r , ω ) = δ i,i δ(r − r )δ(ω − ω ).Note that in the limiting case of a dispersive material (assumed in this study, characterized by its instantaneous electronic response) Im{ (r, ω)} → 0. However, this imposes no problem for our formalism which is shown to correctly reduce to the mode decomposition method used in the quantized vacuum field [108] due to Kramers-Kronig relations.
When projecting to the direction of the electron trajectory ẑ with transverse coordinate R 0 , the scattering matrix is shown to be where q ⊥ is the transverse component of the exchanged electron wave vector.We can further simplify the expression by disregarding the phase operator χ and assuming a point electron distribution over the transverse direction, and obtain where continuum photon and electron operators are introduced with vacuum coupling strength g ω associated with the electron energy loss (EELS) probability studied in this manuscript The operators are defined in this way so that the quantum optical commutation relations are preserved [â ω , â † ω ] = δ(ω − ω ), and can be easily proven using the identity ω)}.Note that âω contains contributions from all the spatial modes at ω, and is not a specific pre-defined spatial mode âω,m which is frequently used in cavity QED systems.
To find the spatial mode function of âω , we use the following relations [109] for an arbitrary set of orthogonal basis âi,ω âi,ω = d 3 rV i (r, ω) • f (r, ω) where the weight functions obeys the following normalization condition From here, we can re-express the field operator in terms of the set of orthogonal basis as Â(r, ω) = −4πω d 3 r 0 Im{ (r , ω)}G(r, r , ω) By choosing one of the spatial modes âi=0,ω as our mode of interest âω with the weight function we can find the mode function of this optical mode as which is a mode specifically defined for this interaction.This mode construction corresponds to a linear transformation of the original structure-supported optical spatial modes, such that only this specific optical mode is involved in the interaction, while all the other transformed modes are dark and invisible to the electron.It is in this way advantageous to use this formalism to account for the infinite number of spatial modes of the optical structure that the electron couples to.In the limit of unity coupling ideality, this mode function converges to the one of the waveguide modes.If the electron transverse spread is significant, the EELS probability is shown [110] to be an average over the transverse electron wavefunction However, this type of averaging is not quantum coherent.At different transverse positions, the coupling coefficients are different.Therefore, we have to modify the scattering matrix to If the part of the longitudinal optical field that overlaps with the electron transverse wavefunction has considerably inhomogeneity, then the different transverse position components of the electron will be entangled with different longitudinal electron-photon pair states, characterized by their different coupling strengths.Therefore, information loss occurs when tracing out the transverse degrees of freedom of the electron, leading to state purity degradation.Since nm-scale electron beam focuses are routinely used in electron microscopes, this is not a significant limitation for near-field coupling to optical waveguides which have a typical decay length of ∼100 nm.
Appendix B: Equivalence to the classical result The electron energy loss at a dielectric surface can be interpreted classically in a microscopic picture [111], see Fig. 1: if an electron passes near the surface of a dielectric structure, the dipoles in the structures are polarized (equivalently classical current), induced by the electric field from the flying electron, and generates a backaction field E(r e (t), t) to the electron at r e (t) that induces electron energy loss.The total energy loss can be expressed in time domain and frequency domain as where the frequency domain energy loss function Γ(ω) is expressed as which can be easily verified if one plugs it back into the energy loss expression and the correct time integral is retrieved.Notice that here E(r e (t), ω) is not the direct Fourier transform of E(r e (t), t).The Fourier transform applies only on the time dependence of the electric field function not explicitly depending on the electron trajectory function r e (t).The frequency domain components depends explicitly on the current induced from a given electron trajectory, but do not take into account the sampling of the field at different position r e (t) at different time t.This ensures that the total energy loss is consistent, but renders the formalism non-local.This treatment is consistent with the quantum formalism when the electron is decomposed into perfect momentum states where the wavepacket length is infinite, as one could see from the fact that even though the electron only interacts with the structure locally, the resulting energy loss spectrum will show e.g.discrete mode structure (a non-local property).This is the result of this particular Fourier expansion procedure, but when considering the electron in terms of wave packets this treatment is valid.It has been shown [110] that a full quantum treatment gives exactly the same EELS result.
Using the no-recoil approximation, which assumes that the radiation of electron into the surrounding substrates does not change the trajectory r e (t) of the electron significantly, we can directly calculate the induced electric field E(r e (t), t) from the electron current j(r, t) through the Green tensor of the whole dielectric structure, where the Green tensor G(r, r , ω) is the elementary solution of the full Maxwell equation with a point current at position r in frequency domain.
A flying electron is equivalent to a broadband evanescent source, and here we consider an electron beam at ẑ direction at transverse coordinate R 0 , for which the frequency domain electron current density is From here, one can express the frequency domain loss rate in terms of Green function as which coincides with the result from a full QED treatment.One should keep in mind that the Green tensor here has two contributions, one from vacuum G 0 when there is no structure around, and the other component from the backaction field G ind that is induced from the dielectric dipoles.Only the backaction field G ind contributes to electron energy loss, because electron does not emit in vacuum so the contribution from the vacuum G 0 vanishes in the integral.

Appendix C: Correspondence to modal decomposition
The correspondence between the 3D macroscopic quantization method in a dispersive material with the conventional quantum optics quantization procedure using modal decomposition has been demonstrated for the 1D case [108].Here, we show the correspondence with the quantum optical formalism used in [30].To account for all the spatial modes at a given frequency ω, the quantization of vector potential was chosen as to fulfill the canonical field commutation relations.However, in vacuum or lossless media, the modal decomposition method [112] is often used instead, with where the profile function U m (r) of each mode defined in a frequency window ∆ω m satisfies the wave equation with normalization condition From here, one can easily find the correspondence between the spatial mode ladder operators âω,m and the bosonic ladder operators f (r , ω) as âωm,m = −4π with their vacuum coupling strength to the electron as [42] g ωm,m (R 0 ) = −i e 2 2 0 ω m dze −iωmz/ve U m,z (R 0 , z).
In this formalism, we can rewrite the scattering matrix in its modal decomposition form where the optical mode operators âωm,m are no longer continuum mode operators and now satisfy [â ωm,m , â † ωn,n ] = δ m,n .In the case of an optical cavity, the optical modes are well-defined bosonic modes.As long as the electron energy resolution does not resolve frequency components of the optical mode, the treatment is valid.For an open waveguide, the modes that are coupled to the electron are instead travelling modes in a continuum [113].This is the most general case and can include the open cavity modes as well.The vacuum coupling strength of a continuum frequency mode in a spatial mode family is where the profile function Ũm (r, ω) satisfies the wave equation as well, but with normalization condition Index m here represents different spatial mode families.However, when the electron energy resolution does not resolve the frequency structure of the coupling strength to any given mode family, as in the weak correlation regime discussed in the manuscript, one can still define the corresponding non-continuous operators for different mode families, where φ m (ω) is the Fourier component of the temporal field profile functions [114,115] of the defined mode families.It is a complete orthogonal set of functions on ω, found through Gramm-Schmit orthonormalization procedure, such that the commutation relation [â m , â † n ] = δ m,n is satisfied for these field operators in the context of quantum field theory, introduced to avoid using operatorvalued distributions.One can therefore rewrite the scattering matrix in the new mode family field operator basis where g m = dωg ω φ m (ω).The total coupling strength would be Here, when the frequency bands of different mode families with non-negligible coupling strength g ω are sufficiently separated, we choose the profile function φ m (ω) = I ω∈∆ωm g * ω /g * m , where ∆ω m is the frequency window within which we define the field operator for the corresponding mode family, and |g m | 2 = ∆ωm dω|g ω | 2 .Note that when the coupling to bulk modes is significant, one has to use the coupling strength g ω,m from the conventional modal decomposition method instead of the Green function method to quantitatively isolate the coupling to a mode family from background bulk mode contributions.
The cavity mode decomposition is actually the narrowband approximation of the Gramm-Schmit orthonormalization procedure, where φ m (ω) is strongly peaked around the mode center frequency, since all optical modes, though narrow, still have a finite linewidth due to the coupling to outside channels (e.g.bus waveguide and cavity losses).The profile function can be found through the input-output formalism [116] of an optical cavity âm , assuming unity coupling efficiency to the bus waveguide mode âout with coupling rate κ, which results in a profile function of φ m (ω) , where the bus waveguide is part of the resonator and forms the continuum modes in frequency domain.

Appendix D: COMSOL simulation details
Since all the physical quantities we are interested in can be related to the Green tensor of the classical Maxwell equation given the dielectric structure of interest, we numerically solved the relevant Green tensor component G zz (r, r , ω) of an infinitely long optical waveguide with finite element method (FEM).The spatial map of the imaginary part of the Green function is illustrated in Fig. D.1.The Green function can be understood intuitively as the Fourier component of the optical field at frequency ω that is excited at position r by the propagating electron at position r , whereas the phase-matching condition determines whether this field constructively or destructively builds up at a given electron velocity.
The Green tensor solution of Maxwell equation is not directly supported in COMSOL, but can be retrieved by Frequency domain study with the radio frequency (RF) module.The waveguide is an air cladded Si 3 N 4 slab embedded in SiO2 substrate with different geometries mentioned in the main text.Perfect matching layers at boundaries are used to prevent boundary reflections and in turn allow us to simulate an infinitely long waveguide.In order to solve for the Green function G(r, r , ω), a point oscillating electric current dipole J(ω) = p(ω)δ(r − r 0 ) is placed above the waveguide surface at position r 0 (typically 100 nm or 300 nm).COM-SOL solves for the electric field which relates to the Green tensor as and thus if one wishes to retrieve G zz component one needs to orient the electric dipole p = pẑ along the z direction ẑ, and look at the electric field z component E z , such that The results are illustrated in Fig. D.1.The imaginary part of the Green function can be thought of as the spatial pattern of electron emission in the waveguide (or surrounding substrates) before the application of phasematching condition.Given the electron velocity, the application of phase-matching With the optimal phase-matching condition, the coupling strength at a given optical frequency (or a discrete cavity mode) scales quadratically with the interaction length, a unique feature of guided modes co-propagating with the flying electron.For the spatial modes in the substrate bulk, the excited field is localized around the electron position.Without the benefit of constructive interference from co-propagation with the flying electron,  ), the effective mode index difference between the fundamental mode and higher-order modes is relatively weak at the same optical frequency, which leads to multimode electron-photon interaction within a given frequency band.When the waveguide cross-section is reduced (referred to as single-mode waveguide), shown in Fig. D.3(c), one can enhance the mode index contrast.As a result, the mode frequency spacing is increased, such that the coupled fundamental modes are better isolated.Since most transmission electron microscopes (TEMs) have an energy resolution around 0.5 eV (120 THz in optical frequency), it is important to create a large frequency spacing between the phase-matched optical modes so that the interaction with individual modes can be energy resolved.
The difference between multimode and single-mode waveguides in fiber optics is usually quantified by a Vnumber, a normalized frequency parameter which determines the number of modes of a step-index fiber, as where r is the radial size of the core, n 1 is the core material index and n 2 is the cladding material index.For our single-mode waveguide dimension, the single-mode guiding criteria V < 2.4 is satisfied.When used in the fiber-optic applications, such a criterion is very important for single-mode guiding.Here, our design goal is to increase the mode frequency spacing between mode families.Therefore, we only use it as a guiding principle, not as a strict criterion.
The evanescent field of the coupled higher-order modes decay faster than that of the coupled fundamental mode, as a result of the higher optical frequency.In Fig. D.3(d), we show that one can further enhance the coupling contrast between fundamental mode and higher-order modes by placing the electron beam further away (200 nm) from the waveguide surface.In this way, the interaction exponentially favors the fundamental mode, at the expense of weaker interaction strength |g TM 00 | 2 which can be compensated for with a longer interaction length (5 times longer for the shown example).
As discussed in the main text, the Cherenkov radiation contributes as a rising background in the high velocity region.In Appendix E, we isolate the contribution of the substrate bulk modes.
We now quantitatively evaluate the coupling ideality to the TM 00 mode as a function of electron velocity.We fit the coupling spectra with Gaussian functions, illustrated in

Appendix E: Substrate and thin film losses
Though not discussed in the main text, there are different scaling of Γ(ω) for bulk substrate (∝ L), thin film (∝ L log L), and guided modes (∝ L 2 ).We show their coupling spectrum characteristics in Fig. E.1 with an electron 100 nm above the dielectric surface.It is shown that for a given frequency component ω, the quadratic scaling of a guided mode will dominate the interaction.However, for a waveguide structure with linear dispersion (e.g. the one shown in Fig. E.1(a)), the phase-matching condition will enforce a linear scaling of the total deposited quanta into one particular waveguide mode.But due to relatively weak dispersion of the waveguide modes, the cou-pling contribution from the waveguide modes dominates over substrate losses, where the latter accounts for far less than 1% of the total coupling strength over a 0.6 eV band with electron velocity v e /c ≤ 0.6.For unpatterned thin films, the total photon emission is 70% lower than for a waveguide, and the emission is less structured and hard to Note that due to the presence of chromatic dispersion, the total coupling strengths of different spatial-temporal modes are linearly dependent on distance.Therefore, the ratio of different coupling contributions is distance independent, and only depends on waveguide dispersion and routing, and e-beam positioning.

Appendix F: Interaction with optical resonators
We only discussed results for open ended waveguides so far.However, there have been experiments [30,42] that uses optical resonators with a discrete set of welldefined frequency modes instead of a continuum of frequency modes in the case of a waveguide.These welldefined modes in state of the art resonators typically have optical linewidths of tens of MHz [45], and it is therefore difficult to resolve their Green functions by sweeping the optical frequencies in FEM simulations.Nonetheless, their Green functions can be easily related to the one of open ended optical waveguides by their optical susceptibility function χ(ω) = and multiplying the resonance susceptibilities For a closed loop resonator structure, the resulting interaction strength Γ(ω) will have a narrow-linewidth comb-like structure [42] instead in frequency space, compared to the continuum case of an open ended waveguide, with the peak intensity enhanced by a factor of 2F π .A comparison between a waveguide and a resonator coupling to free electrons ( Γ and Γ r respectively) is illustrated in Fig. F.1.The comb-like structure in the electron energy loss spectrum results from the spectral property of the resonator that is non-local with respect to the interaction region, and is only accessible since the interaction is analyzed in the electron energy basis, whose state is also non-local in nature.However, in order to access these comb-like features in an EELS experiment, the electron-cavity characteristic interaction time (determined by the measured electron ZLP) has to be longer than the round trip time of the resonator, thus satisfying the energy-time uncertainty principle.Nonetheless, the comb-like structure can always be accessed from the optical side with a measurement time longer than the round trip time, as was shown in [42].
There is also no difference in the total coupling strength in a given mode family for the open waveguide case and the resonator case, as long as the the phasematching bandwidth ∆ν is much larger than ∆ν FSR .The total interaction strength |g m | 2 of a mode family will be considerably altered by the resonator structure when the phase-matching bandwidth ∆ν is on the frequency scale of one FSR.The minimum number of modes inside the phase-matching bandwidth can be estimated with N ∼ 1 |ng−n eff | (for common dielectric materials ∼ 5 − 20), so in order to access the regime where the phase-matching bandwidth is smaller than the FSR, one requires |n g − n eff | > 1, which is generally very difficult to achieve with structures using only dielectric materials.However, with common dielectric structures and careful mode dispersion engineering, the regime N = O(1) where the resonance structure has a small impact is accessible.
The motivation of using a resonator instead of an open waveguide is that the optical resonance frequencies are more passively stable, and the wavepackets generated from each resonator mode are generally much longer than the optical pulse length enforced by the phase-matching bandwidth from an open waveguide, and have energy density enhanced by the cavity finesse at resonant frequencies.Therefore, resonators have advantages in experiments where optical excitation needs to interfere with a reference local oscillator, and good mode-matching is required.Resonators also provide advantages in experiments where optical frequency filtering is required, since the optical density of the excitation is concentrated in frequency.We show a frequency conversion example in Appendix K to exploit this advantage of optical resonators to convert THz broad optical excitation to MHz broad optical or microwave excitation, useful to bridge interactions with superconducting qubits, mechanical oscillators and long-life-time optical qubits.

Appendix G: Purity and Fidelity of heralded optical quantum states
In this section, we derive the heralded optical states by measuring electron energy, and calculate the state fidelity and purity.The optical state generated when there is no sideband overlap (not a fundamental limit), and when conditioning on a narrow bandwidth around an energy slice E c ∼ N ω is As one can see, the coefficient is a product between the electron wavefunction and the coupling coefficient.This Electron energy loss spectrum for a 50 µm interaction distance with (a) waveguides, (b) silica substrate, and (c) Si3N4thin film on silica substrate.Notice that for a waveguide the scaling is quadratic with respect to distance and more structured, whereas for substrate and thin film the scaling is mostly linear the emission is more broadband.The interaction with the waveguide mode will prevail over substrate and thin film over an interaction length just a few wavelengths.The dashed gray lines are a guide to the eye showing Cherenkov regime boundaries for silica and Si3N4.
Comparison between free electron coupling to waveguides vs. resonators.(a) Illustration of electron-photon interaction mediated by an optical cavity.An optical pulse is first generated inside the cavity.Then the pulse circulates inside the cavity and couples out as a pulse train with repetition rate of FSR an exponential decaying envelope.
Coupling spectrum for the pulse inside the resonator, indistinguishable to the one generated inside a waveguide with the same geometry.(c) Coupling spectrum for the out-coupled pulse trains, now exhibits a comb-like feature with frequency spacing matching the resonator FSR, peak width matching the pulse train envelope, and comb envelope matching the spectral components of each individual pulse.
reflects on the fact that the electron energy distribution is correlated with the frequency at which the photon is created.One will see later that this is not the case for conditional electron states, since in the no-recoil limit the frequency of the photon does not depend on the energy of the electron.
In the first limit when electron ZLP is much narrower than phase-matching bandwidth, we can simplify the expression to .
for single-photon states.The frequency components of the generated state are directly linked to φ(ω) ∝ ψ(E c + ω).Ignoring the waveguide dispersion during propagation, we have the optical waveform where it has a center frequency determined by the conditional electron energy, and an envelope profile that is exactly the time domain electron spatial profile ψ(T ).Therefore, by shaping electron wavefunctions and conditioning on the selected sideband energy, one can transfer the electron spatial wavefunction to the optical waveform of the photonic state at a desired optical frequency.For readers familiar with optical spontaneous parametric down conversion, a similar technique is also used in heralded single photon sources [117] to imprint the waveform of the pump field onto the signal field.
For conditional multi-photon optical states, as one can imediately see from the expression, since the electron wavefunction generally can not be factorized to N components ψ(E + ( k ω k ) = k F (E, ω k ), the conditional state can not be addressed into a Fock state of a well defined spatial-temporal mode, but since high phase-matching bandwidth usually comes with low g, we restrict ourselves to single-photon states in this limit.
We defined the fidelity of the heralded single-photon state as For the case of long propagation, we usually end up with very narrow phase-matching bandwidth and high interaction g.In this case, when conditioning on the Nth energy sideband, we can simplify the expression to where it is a well defined N -photon Fock state with mode profile φ(t) (see Appendix I), which is determined by both the waveguide routing and the material dispersion.To this end, one can adapt the electron positioning and velocity to shape the optical waveform.
We defined the fidelity to state as With more electron operations stages, we can select the electron measurement basis.After the pair-state generation, if we pass the electron through e.g. a PINEM interaction stage characterized by the scattering matrix S(α), by conditioning on the energy sideband |E , we are effectively measuring under the basis S † (α Formally, we write down the conditional optical state as where |g| 2 = dω|g ω | 2 .This effectively projects the optical state into a more general state other than Fock states if one directly measures the electron energy after the pair-state preparation.For these general states, the corresponding heralded state fidelity is an average of all the involved Fock states with a correct weight and the same kind of weighted averaging needs to be applied to the heralded state purity as well.
The single-photon state purity can be degraded by two main effects.First, spectral overlap between different sideband orders.Second, relative bandwidth ratio between ZLP and phase-matching bandwidth.For higher-order Fock states, it's further affected by the spectral distribution of the other optical mode families as well, e.g. the electron might not be able to distinguish between a two-photon transition of the fundamental optical mode, and a single-photon transition of a higher order mode.Here, we categorize this case into the spectral overlap between electron sidebands.
First, let us investigate the purity degradation of the conditional photonic Fock state due to the sideband spectral overlap.In the limit of narrow phase-matching bandwidth, the optical density matrix after detection at electron energy band ∆E electron energy event, is The purity of this state is Then we investigate the effect of finite phase-matching bandwidth, and in the limit where there is no photon sideband overlaps, the conditional single-photon Fock state is ρph = 1 In the limit of perfect electron energy resolution ∆E → 0, Tr ρ2 ph → 1.However, experimentally, either the ZLP consists of a statistical uncertainty, or the conditioning window can not be set arbitrarily small, due to its effect on the heralding rate.As a result, the purity is limited by both the phase-matching bandwidth, and the relative heralding bandwidth.
For a general N -photon Fock state, the density matrix of the heralded state is ρph = 1 with the corresponding state purity To illustrate the impact of relative heralding bandwidth on state purity, we show the overall scaling of 1 − P ∝ γ 2  where P N is the purity of the N th Fock state component, P N,N is the purity of the off-diagonal terms, and ω is the center frequency of the optical state.
Appendix H: Purity of heralded electron state In this section, we consider heralding schemes that generate complex electron states, and derive the expression of purity of the heralded electron state by the optical measurement.With multiple single-photon detectors, if one conditions on a N -photon counting event, one projects the electron into a corresponding energy state that loses a equal amount of energy.However, these types of photon counting measurements can not project the electron into a coherent superposition of multiple sideband states.This is the result of the chosen measurement operator a † a, whose eigenstates are Fock states.However, one can select a measurement basis to project the electron onto a more general state.These operations require high detection efficiencies (no information loss), which has to be considered carefully when applying optical elements e.g.spectral filters.The first simple method to change the measurement basis would be to combine the signal with a strong local oscillator through a high aspect ratio beam splitter.This modifies the detection from photon-number detection to field detection in the basis of displaced Fock states.With the ability to mode-match to an optical reference field, homodyne types of detection can also be realized.In the setting where the signal field is split and detected by two homodyne in orthogonal quadratures, the measurement is effectively under the coherent state basis.More sophisticated operation can be done with an atomic system to provide arbitrary measurement basis.
In the special case of measuring in coherent state basis |α , we can derive the effective modulation applied on the electron wavefunction as which is effectively a direct density modulation of Now, we consider a general heralded electron state, with the N th sideband density matrix component as ρe = 1 Note that for each sideband component, the corresponding electron wavefunction is not shaped by the optical detection and maintains the original shape.This is in sharp contrast to heralding optical state by measuring electron energies.The difference is that the electron energy loss heavily depend on optical frequency, but the optical frequency does not depend on electron energy under the no-recoil approximation.Therefore, any measurement on the frequency of the created photons simply translates the original electron energy state down by a corresponding photon energy.Because of that, we do not define the fidelity of the electron wavefunction in the limit of perfect photon frequency resolution.
We proceed to calculate the state purity of the N th electron sideband component as where the same weighted average needs to be applied for a general state with weights |c N | 2 , similar to the case of heralded optical states.
Appendix I: Optical waveform generated from the electron-photon interaction In this section, we derive the waveform of the conditional optical state when considering the waveguide dispersion.
The composite quantum state after the electronphoton interaction is when conditioned on the nth energy sideband of the electron state (with electron ZLP much wider than the coupling bandwidth to the optical modes), the heralded optical state is When the interaction is dominated by the coupling to a single optical mode family, one can generate Fock state of a well-defined spatial-temporal mode as From these results, one can derive the temporal field profile function of this spatial-temporal mode, as it may concern experiments that require waveform shaping.Straight from the definition, one gets φ m (r, t) ∝ dzdωe iω(z/ve−t) Ũ * m,z (R 0 , z, ω) Ũm (r, ω).
When chromatic dispersion of the frequency modes is ignored, one retrieves the waveform shown in the main text.When dispersion is considered, one can further remove the frequency dependence of the mode profile functions by assuming an open waveguide (e.g.no sharp frequency response in the phase-matched region) and up to second order dispersion β, Ũm (r, ω) ≈ Ũm (r, ω m )e i(ω−ωm)r /vg e iβ(ω−ωm) 2 r /vg , where ω m is the center frequency of the pulse, selected so that the phase velocity at ω m matches the electron velocity v, v g v is the corresponding group velocity, and r is the longitudinal coordinate along the waveguide trajectory.One can then rewrite the expression as where r ≡ r − v g t is the waveform coordinate in the optical pulse frame with group velocity v g .Ũ * m,z (R 0 , z, ω m ) is the mode envelope profile at wave vector ω m /v.The integral kernel represents a phase scrambling around the waveform coordinate r with a bandwidth of ∼ |β(r )v 2 /v g |, due to the presence of second order dispersion.One can get physical intuition of the waveform in the limit of weak dispersion (β → 0), where one can approximate the integral kernel with a Dirac delta function, where z i (r, t) : zi v − 1 vg (R (z i ) − r ) = 0 are the spatial z coordinates where the vacuum field contributes the most through the phase-matching condition to the generated field at r coordinate at time t.Therefore, the excited optical profile in the time domain is easily connected to the envelope of the optical mode field profile Ũm,z (R 0 , z, ω m ) along the electron propagation direction, when the mode dispersion is sufficiently weak.In the exact limit β = 0, there can be unphysical scenarios when |R ∂z (z i ) − vg v | = 0, which corresponds to the infinite phase-matching bandwidth.However, in physical materials, the phase-matching bandwidth is always finite.
The mode dispersion during pulse propagation will cause pulse shortening or broadening by shifting the phase of different frequency components and leaving the amplitude unchanged.This can be easily corrected and is not a fundamental limit to construct an arbitrary waveform.Therefore, one can structure any desired optical waveform φ(r, t) by positioning the electron beam trajectory on an optical waveguide with a tailor-made waveguide structure.

Appendix J: Imprinting electron wavefunction onto the optical waveform in an interferometric fashion
In the regime where the electron energy spread is much narrower than the phase-matching bandwidth, the spatial-temporal mode is defined completely by the electron wavefunction, see Appendix G, with a phase contri-bution from the coupling coefficient g ωc=−Ec/(N ) , where N is the sideband order.Whenever an electron interacts with an optical mode, and measured on the N th electron energy sideband at the energy E c , it's equivalent to apply an operator Ŝ ∝ ψ(E c + ω) e iθg â † ω N onto the optical state.When the electron interacts with two waveguides in sequential manner (identical geometry), the operator is where a i is the spatial-temporal mode on waveguide i = 1, 2, and the phase is determined by the the reference point from both the optical side and the electron side.When the two interaction regimes (positions of waveguides) are separated by a spatial distance that correspond to an electron propagation time ∆t, we have the following phase relation of the coupling coefficients where Ĥ0 is the electron free evolution Hamiltonian.If we assume the optical phase references are set to 0, we can rewrite the scattering as

N
As one can see, this interaction projects the optical state into a quantum coherent spatial superposition state of two spatially separated waveguides.In the case that the two waveguide are connected to a 50:50 beam splitter to form an interferometer, the photon flux difference f (t) can be expressed as which forms an effective optical interferometer of the time delay the electron experiences between two interaction stages, but can also be induced by an external potential.Here, to extract the delay time, one can simply look at the photon counting record at different electron energy records E c which determines ω c .Therefore, compared to conventional optical interferometry where one has to scan the laser frequencny over a very broad range to resolve length difference to the order of a few wavelengths, here, we exploit the very wide electron emission bandwidth to get an accurate length difference, just by looking at different electron energy records.Note that here the imprinted electron wavefunction only provides a profile function with an effective optical delay (convenient for automatic mode matching between the two arms), with its original fast evolving phase unobservable.Therefore, for a phase object positioned between the two waveguides, the interferometer sensitivity is on the optical wavelength scale, not on the scale of the de Broglie wavelength of the electrons.
Appendix K: Frequency conversion using resonator structures As discussed in the previous section, optical resonators provide unique advantages over straight waveguides in terms of the concentrated optical density.Here we show an example scheme to use on-chip ring resonator structures to convert the THz-broad optical excitation from the electron-photon interaction to a MHz-broad optical/electrical excitation, limited by the optical resonator linewidth.Here we define the spatial-temporal mode for the optical excitation of a resonator as â † = dω i φ i (ω)â † ω , where each φ i (ω) is a Lorentzian centered around ω i + ω m with ω i the pump center frequency.We also define the microwave excitation as ĉ † ∝ dωφ(ω)ĉ † ω , centered around ω m .In the ideal case that all the optical azimuthal modes are identical in their frequency components, we have φ i (ω + ω i ) = φ(ω).
Near-unity efficiency optical to microwave conversion was demonstrated in χ 2 type materials [89,90].We assume a ring structure optical resonator (conversion ring) with a strong χ 2 nonlinearity and a relatively high optical quality factor, with identical cavity azimuthal modes of two orthogonal polarizations (e.g.TE and TM fundamental modes) with approximately the same FSR, and a frequency spacing ∼ ω m between these two mode families that matches the microwave mode frequency ω m .Practically, the frequency matching is only required between a few optical resonances, since the electron-photon optical excitation from a ring resonator can occupy only 5-20 azimuthal modes.We use this resonator for frequency down conversion of the broadband photon excitation â † at frequencies ω i + ω m from the electron-photon interaction, with a specially structured local oscillator pump at frequencies ω i .We further assume that there are two more rings on the chip, with matched optical frequencies of the modes of interest.We use one of the rings for electron-photon interaction, where the photon excitation is generated on the TM polarization at frequencies ω i + ω m (signal field).This ring should be designed with the highest quality factor possible, since its linewidth determines the microwave linewidth φ(ω), and should be narrower than the linewidth of the conversion ring.We use the other ring for generating or filtering a structured continuous wave (CW) optical pump on the TE polarization with frequencies ω i (LO field).We combine LO and signal field through a polarization beam splitter, and send them into the conversion ring for frequency down conversion.
In principle, the signal field and LO field does not have to be orthogonal in polarization to enable efficient and low-noise frequency conversion.The orthogonal polarizations considered here are intended to prevent spectral leakage of the LO field to the signal mode, even though they can be sufficiently separated in frequency.
When the conversion ring is pumped by the LO field with cooperativity C = 1 in each pump-field mode pairs, the signal frequency component φ i (ω) at the azimuthal mode at frequency ω i + ω m is converted to a microwave photon at frequency ω m with frequency component φ(ω) and conversion efficiency η = 100%.When all the azimuthal modes of the conversion ring convert their signal field components down to the same microwave frequency ω m with unity efficiencies, the original signal pulse with THz-broad frequency components from the electron-photon interaction will be converted to a single microwave mode excitation at frequency ω m with frequency width down to MHz with a unity efficiency, and at the same time generate a pump field photon with THzbroad frequency component due to the energy conservation.
Here, we formally analyze this conversion process.We define the scattering matrix of the conversion process with a multi-mode three-wave mixing operator ŜTWM = e i βi(ω,ωi)âω+ω i ĉ † where ω i is the frequency of each CW pump comb tooth, and β i the coupling constant amplified by the pump field.The coupling constant β i (ω, ω i ) contains the conversion frequency response of each pump-signal mode pair, including effects e.g.phase-matching, cavity responses of the signal and pump field , and microwave cavity response.The operators are the signal field annihilation âω , the microwave field creation operator ĉ † ω , and the pump field operator d † ωi = Nω i |N ωi + 1 N ωi | which is specially defined high-up in the photon ladder, similar to the electron ladder operator in the no-recoil limit, that represents the addition of a photon to the classical coherent pump field |α i with frequency ω i .In the single mode conversion case, d † can be ignored.However, in the multi-mode conversion considered here, neglecting d † leads to non-unitary operations.Under such an operation, the state of the system changes to where â † = dω i φ i (ω)â † ω is used, θ i = arg[β i (ω, ω i )], and also |ψ ph = F (â † )|0 a .In the ideal case where φ i (ω + ω i ) = φ(ω)G i is separated to the cavity density of states φ(ω) and the electron-photon phase-matching coefficient G i at signal mode i, with unity cooperativity β i (ω, ω i ) = π/2 at every pump-signal mode pair over the frequency components of interest, the state is simplified to e iθi b † ωi Since the pump field is a strong coherent field and maintains a unity overlap with a photon-added state, we can trace out the pump field state space, and arrive at where the state of the signal field |ψ ph = F (â † )|0 a is transferred to the microwave field, with frequency com-ponents limited by the signal cavity density of states ∝ φ(ω).
Practically, the amplitude and frequency components of the LO field has to be specifically shaped, but since the optical excitation from the electron-photon interaction can occupy only 5-20 optical modes with the maximum interaction length achievable with a racetrack resonator geometry, it is possible to shape a reasonably accurate LO field with a soliton [83] or an electro-optic comb [84] source and a frequency shaper [85].
There are currently two types of main-stream opticalto-microwave converters [3].One type uses χ 2 optical nonlinearity to directly convert signals from the optical domain to the microwave domain, as is considered here.The other type [118] uses a mechanical oscillator as an intermediate stage to first convert the optical signal to a mechanical signal using optomechanical couplings, and then from the mechanical signal to a microwave signal using electro-mechanical couplings.Both types of systems have shown near-unity conversion efficiency and low added noise, but the mechanical one suffers from the low conversion bandwidth typically at kHz level (not possible to achieve β i (ω, ω i ) ∼ π/2 over the cavity bandwidth ∼MHz), limited by the electro-mechanical and optomechanical coupling rates.Therefore, we only consider χ 2 -type optical-to-microwave converters for our scheme since they offer broadband transductions, essential to convert all the frequency components of the optical excitation to the microwave domain.For a realistic lithium niobate ring resonators with 50 µm radius, the microwave frequency at 4 GHz, with optical and microwave cavity linewidths at κ ph/m /2π ∼ 10 MHz, the estimated required pump power to reach C i = 1 is reasonable at P i ∼ 100 µW [119].
Similar types of schemes can also down-convert the signal to an optical excitation with MHz linewidth.But generally, a relatively uniform mode spacing over multiple azimuthal modes at optical frequency scale is harder to design for triply resonant schemes.
Appendix L: Beyond no-recoil approximation In the no-recoil limit, the coupling coefficient g ω is not energy dependent, as is the case for the scenarios we discussed in the current study.However, the recoil effect will be significant with multi-stage operations with sufficient spatial separation, where the effect of electron energymomentum dispersion kicks in.
Here, we consider two stages separated by distance ∆L, with near-point-like interaction regions.The coupling coefficient for the first stage is where U 1,z (z) is the optical mode function along ẑ direction.At the first stage the recoil effect does not play a significant role yet.However, at the second stage that's ∆L away, the electron energy dispersion k = E 2 /c 2 − m 2 c 2 changes the phase-matching integral of the off-diagonal element |E E + ω| to where now the coupling coefficient accumulates an energy-dependent phase e i2π( 2∆E ω +1) ∆L z T .Here z T = 4πmv 3 γ 3 / ω 2 is the Talbot distance and γ is the Lorentz factor.∆E is the distance to the original center electron energy E 0 , which is the reference point of the dispersion quadratic expansion.In the case of v/c ∼ 0.65 and ω ∼ 2π • 2 × 10 14 Hz, z T ∼ 1 m.For the largest photon number |N = 10 discussed in the current manuscript, and a typical photonic chip length ∆L ∼ 5 mm, the phase accumulation is θ = 0.1 • 2π, therefore negligible in our discussion.We anticipate the effect to dominate, e.g. when two photonic chips are involved and with sufficient separation ∆L ∼ 1 m.When that is indeed the case, we can still use the scattering matrix with the no-recoil approximation (used in the current manuscript) at the second stage, but add a propagation matrix Ŝprop = dE exp −i2π∆L(E − E 0 ) 2 4π mv 3 γ 3 |E E|, to account for the recoil-induced phase accumulation of different energy components when arriving at the second stage.The phases accumulate differently between different energy components due to their different group velocities, and therefore there is an effective timing difference of their arrival at the second stage which is treated as a point interaction with no-recoil approximation.This is consistent with literature that uses Schrödinger equations to solve for the wavefunction evolution between two interaction stages [36], and can also explain effects observed in double-PINEM-type experiment [32].However, our assumption of point-like interaction will break down when a single interaction is sufficiently long e.g.L > 10 cm, and with transitions involving Fock states |N > 10 .Then a single scattering matrix including the recoil effect has to be used to account for the dispersive phase accumulation during the interaction, as Ŝe-ph = exp dωg ω b † ω âω − h.c.
where the modified electron energy lowering operator is bω = dE|E E + ω| dze and the no-recoil coupling coefficient g ω is used.For non-guided electron beam with divergence angle around 0.2 mrad, and an electron-surface gap 100 nm, the longest propagation on chip is restricted to about 1 mm.To achieve long enough distance such that recoil effect kicks in, an on-chip electron guiding structure [31,69] is required.
FIG. 1. (a)Illustration of the electron-photon inelastic scattering process mediated by a dielectric waveguide.In an electron microscope, when the high-energy electron passes by a dielectric waveguide structure with a given dielectric permittivity distribution (x, y, z), the material dielectric dipoles exert a backaction field (force) on the electron, resulting in correlated electron energy loss and optical emission in both the guided waveguide modes and non-guided bulk modes.High-ideality coupling to a low-loss waveguide mode is required for high fidelity state preparation and interaction with other quantum systems through optical links.(b) Synthetic electron-photon state ladder of the pair state generation through Ŝe-ph .Within each ladder state, there is an underlying subspace that still maintains correlation between electron energy and photon frequencies.This correlation can lead to new types of applications, but generally leads to degradation of fidelity and purity of the interaction.

IG. 2 .
Illustration of different parameter regimes of electron-photon interactions.

FIG. 3 .
FIG. 3. (a) Illustration of the waveguide structure studied, consisting of a Si3N4 waveguide embedded in a silica substrate.The free electron passes by the top surface of the waveguide and generates correlated optical emission.(b-c) Electron-photon coupling strength Γ(ω) spectrum for different waveguide geometries and electron positioning.The coupling spectrum is plotted as a function of both electron velocity ve and optical frequency ω.The waveguides have a thickness of 650 nm, and widths of (b) 2.1 µm and (c) 800 nm.Coupling to different waveguide mode families appears as multiple coupling bands, and their phasematching bandwidth is kept constant for better visualization.(d) Total coupling strength of TM00 mode vs. non-conditional and conditional coupling idealities (I and I * respectively), as a function of gap distance between the electron beam and the waveguide surface, with 800 nm waveguide width, 100 µm interaction length and ve/c = 0.65 electron velocity.

FIG. 5 .
FIG. 5. (a) Scheme for heralding an arbitrary electron state by optical detection, consisting of one stage for pair state preparation with Ŝe-ph and one stage for measurement basis selection with on-chip optical operations.(b) Scheme to convert the original THz-broad optical excitation to a MHzbroad microwave excitation, with frequency width limited by the linewidth of the optical cavity, using a χ2 optical-tomicrowave transducer.The narrow-linewidth down-converted microwave excitation is useful for interacting with GHzfrequency quantum systems at low temperatures.(c) Investigation of subspace correlation induced degradation of purity of different electron ladder state components |N as a function of interaction length.
retrieves the field function of the excited optical mode.The Green function along the electron trajectory is shown in Fig.D.2(a), where one can clearly see the bulk mode contribution near the dipole position, and spatial beatings of different waveguide modes under some conditions.

FIG. D. 1 .
FIG. D.1.Spatial pattern of Im[Gzz(r, r0, ω)] for the case of a Si3N4waveguide embedded in a silica substrate.In addition to emission into the substrate and free space, some guided modes in the waveguide are also excited by the oscillating electric current dipole, and forms a beating spatial pattern amongst guided modes along the waveguide direction.
FIG. D.2.(a) Examples of the Green function Im[Gzz(r, r0, ω)] along the trajectory of the electron at different optical frequencies, and (b) the corresponding vacuum coupling strength at different electron velocities, for a 50 µm interaction length.The spatial beating of many mode families is visible in the Green functions, and also in the coupling strength.The coupling to different mode families is phase-matched at different electron velocities at a given optical frequency.When the electron velocity is in the Cherenkov regime (v 0.7c), the energy loss is eventually dominated by the substrate loss.

2FIG. D. 3 .
FIG. D.3.Electron-photon coupling with 50 µm interaction length for different waveguide geometries and electron positioning.The coupling spectrum is plotted as a function of both electron velocity ve and optical frequency ω.The waveguides have a thickness of 650 nm, and widths of (a-b) 2.1 µm and (c-d) 800 nm, and are embedded in a silica substrate.Coupling to different waveguide mode families appears as multiple coupling bands.Coupling ideality to the target TM00 mode is improved by changing the electron beam transverse position from waveguide edge (100 nm from surface) (a) to waveguide center (b), from multimode waveguide (b) to single mode waveguide (c), and moving further away (300 nm from surface) (d) from the waveguide surface.The waveguide widths and the relative positions of the electron beam are also labeled at the lower right corner of the panels.
Fig.D.4(a), and calculate the conditional and non-conditional idealities as a function of electron velocities, shown in Fig.D.4(b-c).

2
−ω0) 2 /κ 2 enforced by the resonator periodic boundary conditions, describing an optical resonance with center frequency ω and Finesse F = ∆νFSR κ , where the cavity free-spectral-range (FSR) is used.One can retrieve the resonator Green function G(ω) by separating the open waveguide Green function into contributions from different cavity modes (with mode field function U m (r), details see Appendix C) FIG. E.1.Electron energy loss spectrum for a 50 µm interaction distance with (a) waveguides, (b) silica substrate, and (c) Si3N4thin film on silica substrate.Notice that for a waveguide the scaling is quadratic with respect to distance and more structured, whereas for substrate and thin film the scaling is mostly linear the emission is more broadband.The interaction with the waveguide mode will prevail over substrate and thin film over an interaction length just a few wavelengths.The dashed gray lines are a guide to the eye showing Cherenkov regime boundaries for silica and Si3N4.
in the limit of small heralding bandwidth in Fig. G.1.For a general state |ψ ph = c N |N , which consists of a coherent superposition of different Fock states |N , as discussed before in the state fidelity calculation, the purity is a |c N | 2 weighted average of each individual Fock state component, shown as Tr ρ2 ph = N |c N | 4 P N + N,N |c N | 2 |c N | 2 P N,N

FIG. G. 1 .
FIG. G.1.Heralded optical state purity vs relative heralding bandwidth at different Fock state basis.Here we assume 20 µm interaction length.