Recently significant progress has been made in $(2+1)$-dimensional conformal field theories without supersymmetry. In particular, it was realized that different Lagrangians may be related by hidden dualities, i.e., seemingly different field theories may actually be identical in the infrared limit. Among all the proposed dualities, one has attracted particular interest in the field of strongly-correlated quantum-matter systems: the one relating the easy-plane noncompact CP$^1$ model (NCCP$^1$) and noncompact quantum electrodynamics (QED) with two flavors ($N = 2$) of massless two-component Dirac fermions. The easy-plane NCCP$^1$ model is the field theory of the putative deconfined quantum-critical point separating a planar (XY) antiferromagnet and a dimerized (valence-bond solid) ground state, while $N=2$ noncompact QED is the theory for the transition between a bosonic symmetry-protected topological phase and a trivial Mott insulator. In this work we present strong numerical support for the proposed duality. We realize the $N=2$ noncompact QED at a critical point of an interacting fermion model on the bilayer honeycomb lattice and study it using determinant quantum Monte Carlo (QMC) simulations. Using stochastic series expansion QMC, we study a planar version of the $S=1/2$ $J$-$Q$ spin Hamiltonian (a quantum XY-model with additional multi-spin couplings) and show that it hosts a continuous transition between the XY magnet and the valence-bond solid. The duality between the two systems, following from a mapping of their phase diagrams extending from their respective critical points, is supported by the good agreement between the critical exponents according to the proposed duality relationships.