$\newcommand{\b} {\mathbf}$
Assume two particle collied in 3D
the equations are
\begin{align*}
&m_1\,(\mathbf v_1-\mathbf u_1)=-\lambda\,\mathbf n\tag 1
\end{align*}
\begin{align*}
&m_2\,(\mathbf v_2-\mathbf u_2)=\lambda\,\mathbf n\tag 2
\end{align*}
\begin{align*}
&\left[(\mathbf v_2-\mathbf{v}_1)+\epsilon\,(\mathbf u_2-\mathbf u_1)\right]\cdot\mathbf n=0\tag 3
\end{align*}
you have 7 scalar equations for the 7 unknowns; the 6 components of the vectors $~\mathbf v_i~$ and $~\lambda$
Adding equation (1) and (2) you obtain the conservation of the linear momentum and for $~\epsilon=1~$ the conservation of the energy .
where
- $\b v_1~,\b v_2~$ velocity after the collision
- $\b u_1~,\b u_2~$ velocity bevor the collision
- $m_i~$ particle masses
- $\b n~$ collision direction vector $\quad,\b n\cdot\b n=1$
- $\epsilon~$ coefficient of restitution
$\quad,\epsilon=0~$ perfectly inelastic collision
$\quad,\epsilon=1~$ perfectly elastic collision
Theory
starting with Newton equation immediately after the collision
\begin{align*}
&m_i\,\frac{d\mathbf v'_i}{dt}= \pm\, F_c\,\mathbf n\quad\Rightarrow\\
&m_i\,\int_{\mathbf u_i}^{\mathbf v_i}\,d\b v'_i=\pm\int F_c\,\mathbf n\,dt=-\lambda\mathbf{n}
\end{align*}
\begin{align*}
&m_i\,(\mathbf v_i-\mathbf u_i)=\pm\lambda\,\mathbf n\quad i=1,2
\end{align*}
$~i=1~$ minus , $~i=2~$ plus
where $~ F_c~$ is the constraint force
Conservation of the energy
\begin{align*}
&E=\frac{1}{2}\left(m_1\,(\mathbf{v}_1)^2+m_2\,(\mathbf{v}_2)^2-
m_1\,(\mathbf{u}_1)^2-m_2\,(\mathbf{u}_2)^2\right)=0\\
&2\,E=\left(m_1\,\left [(\mathbf{v}_1)^2- (\mathbf{u}_1)^2\right]
+m_2\,\left[(\mathbf{v}_2)^2-
(\mathbf{u}_2)^2\right]\right)=0\\
&2\,E=\left(m_1\,\left [\mathbf{v}_1- \mathbf{u}_1\right]\cdot
\left [\mathbf{v}_1+ \mathbf{u}_1\right]
+m_2\,\left[\mathbf{v}_2-\mathbf{u}_2\right]
\cdot \left[\mathbf{v}_2+\mathbf{u}_2\right]\right)=0\\
&\text{with}\quad \mathbf{v}_1- \mathbf{u}_1=-\frac{\lambda}{m_1}\,\mathbf n
\quad, \mathbf{v}_2- \mathbf{u}_2=\frac{\lambda}{m_2}\,\mathbf n\\
&2\,E=\left(m_1\,\left [-\frac{\lambda}{m_1}\,\mathbf n\right]\cdot
\left [\mathbf{v}_1+ \mathbf{u}_1\right]
+m_2\,\left[\frac{\lambda}{m_2}\,\mathbf n\right]
\cdot \left[\mathbf{v}_2+\mathbf{u}_2\right]\right)=0\quad\Rightarrow\\
&2E=\left[(\mathbf v_2-\mathbf{v}_1)+(\mathbf u_2-\mathbf u_1)\right]\cdot\mathbf n=0
\end{align*}
and with the coefficient of restitution $~\epsilon~$
\begin{align*}
&\left[(\mathbf v_2-\mathbf{v}_1)+\epsilon\,(\mathbf u_2-\mathbf u_1)\right]\cdot\mathbf n=0
\end{align*}
thus for $~\epsilon=1~$ you obtain the conservation of the energy
Example
assume one dimensional
$$\b u_1=[u,0,0]^T~,\b u_2=[0,0,0]^T~,\b n=[1,0,0]^T$$
you obtain
$$\b v_1=\left[{\frac {u \left( m_{{1}}+m_{{2}}\epsilon \right) }{m_{{2}}+m_{{1}}}}~,0~,0]\right]^T$$
$$\b v_2=\left[-{\frac {m_{{1}}u \left( -1+\epsilon \right) }{m_{{2}}+m_{{1}}}}~,0~,0\right]^T$$
$$\lambda=-{\frac {m_{{2}}m_{{1}}u \left( -1+\epsilon \right) }{m_{{2}}+m_{{1}}
}}
$$
$$2\,E={\frac {m_{{1}}{u}^{2}m_{{2}} \left( -1+{\epsilon }^{2} \right) }{m_{{
2}}+m_{{1}}}}
$$