Jointly Establishing a Shared Random String for NIZK proofs of knowledge
I'm not sure the solution you have given works.

However, it can be adapted to work -- both for NIZK proofs and proofs of knowledge -- by using a coin-tossing protocol where "secure" here means in the sense of general secure two-party computation. This can be done based on one-way functions in polynomially many rounds, or based on stronger assumptions in constant rounds.

A good reference is Lindell's paper on coin tossing.