Prove $4\sin^{2}\frac{\pi}{9}-2\sqrt{3}\sin\frac{\pi}{9}+1=\frac{1}{4}\sec^{2}\frac{\pi}{9}$. While attempting to algebraically solve a trigonometry problem in (Question 3535106), I came across the interesting equation

$$
4\sin^{2}\frac{\pi}{9}-2\sqrt{3}\sin\frac{\pi}{9}+1=\frac{1}{4}\sec^{2}\frac{\pi}{9}
$$

which arose from the deduction that $\frac{1}{4}\sqrt{\frac{256\sin^{4}40^{\circ}-80\sin^{2}40^{\circ}+12-\ 8\sqrt{3}\sin40^{\circ}}{\left(16\sin^{4}40^{\circ}-4\sin^{2}40^{\circ}+1\right)}}=\cos50^{\circ}$. Despite the apparent simplicity of the relationship, it seems quite tricky to prove. I managed to prove it by solving the equation as a quadratic in $(\sin\frac{\pi}{9})$ and then using the identity $\sqrt{\sec^2 x-1}=|\tan x|$, the double angle formulae and finally that $\frac{\sqrt{3}}{2}\cos x-\frac{1}{2}\sin x$ can be written in the form $\sin\left(x+\frac{2\pi}{3}\right)$.
But it seems like quite a neat problem. So, does anyone have a better way of proving it?

Using
$$\sin \frac{\pi}{3}=\frac{\sqrt 3}{2},~\cos \frac{\pi}{3}=\frac{1}{2},~\sec \frac{\pi}{3}=\frac{1}{\cos \frac{\pi}{3}}=2$$
see this.
and the triple angle forumla for $\sec$
$$2=\frac{\sec^3\frac{\pi}{9}}{4-3\sec^2\frac{\pi}{9}}=\frac{\sec\frac{\pi}{9}}{4\cos^2\frac{\pi}{9}-3}$$
$$\Leftrightarrow 2\left(4\cos^2\frac{\pi}{9}-3\right) = \sec\frac{\pi}{9}$$
squaring both sides and dividing by $4$
$$\Leftrightarrow \left(4\cos^2\frac{\pi}{9}-3\right)^2 = \\ 1-8\sin^2\frac{\pi}{9}+16\sin^4\frac{\pi}{9} = \frac{1}{4}\sec^2\frac{\pi}{9}$$
then using the triple angle formula for $\sin$
$$1-8\sin^2\frac{\pi}{9}+4\sin\frac{\pi}{9}\left(3\sin\frac{\pi}{9}-\sin\frac{\pi}{3}\right) = \\ 4\sin^2\frac{\pi}{9}-4\sin\frac{\pi}{3}\sin\frac{\pi}{9}+1 = \frac{1}{4}\sec^2\frac{\pi}{9}$$
$$\Leftrightarrow 4\sin^2\frac{\pi}{9}-2\sqrt 3\sin\frac{\pi}{9}+1 = \frac{1}{4}\sec^2\frac{\pi}{9}$$
