Gauge invariant derivation of zeroth and first laws of black hole thermodynamics