Section 5. (a) A former state employee who knowingly acts as agent or attorney for, or receives compensation directly or indirectly from anyone other than the commonwealth or a state agency, in connection with any particular matter in which the commonwealth or a state agency is a party or has a direct and substantial interest and in which he participated as a state employee while so employed, or (