Is this expansion a legal step?
$12^8\mod15 = 2^8 * 2 ^ 8 * 3 ^ 8\mod15$
Is this expansion a legal step?
$12^8\mod15 = 2^8 * 2 ^ 8 * 3 ^ 8\mod15$
On
A short justification is simply the canonical map: $\,\begin{aligned}[t]\mathbf Z &\to\mathbf Z/15\mathbf Z\\n&\mapsto n+15\mathbf Z\end{aligned}$ is a ring homomrphism.
More generally, for any commutative ring $R$ and any ideal $I\subset R$, the canonical map: $$\begin{align*}R &\to R/I\\x&\mapsto x+I\end{align*}$$ is a ring homomorphism.
For any integer $n$,
$$(xy)^n = x^n y^n$$
Because they are equal, they are the same number. Anytime you see one side of the equation it can be replaced with the other, because both sides are the same object.
Since $12 = 2\cdot2\cdot3$, $12^8 = (2\cdot2\cdot3)^8 = 2^8 \cdot 3^8 \cdot 3^8$
That is, "$12$" and "$2^8 \cdot 3^8 \cdot 3^8$" are two names for the same object, and as such the expressions can be used interchangeably in any context.