Sure it is legal. At least if the example just provided by Supreme Court Justice Scalia, who just spent a week hunting Pheasants with the Defendant in a case he has to decide, The defendant is also a long time friend who benefitted big time from another decision he(Scalia) was a part of several years ago.
How can something like a project that has ties to your public office possibly be construed as a conflict of interest?