GMM time-series regression factor model with factors that are not returns

Factor models with factors that are not returns are usually estimated and tested by cross-sectional regressions. However, there is a way to use time-series regression to estimate and test the model. The time-series regression is given by: $$R_t^{ei} = a_i + \beta_i f_t + \varepsilon_t^i \ \ ; \ \ t = 1, 2, \cdots, T \ \text{for each } i$$ where $R_t^{ei} = R_t^i - R_t^f$, i.e., the excess return of asset $i$, $f_t$ is a single factor, and the error term $\varepsilon$ is i.i.d. over time, homoskedastic, and independent of the factors. Furthermore, the above asset pricing model does not leave $a_i$ free, instead they must satisfy $a_i = \beta_i(\lambda - E(f))$ where $\lambda$ is the factor risk premium.

Question: Using GMM, write down a set of moment conditions that you can use to estimate this model and test the restriction on the $a_i$. How would you estimate the parameters and what formula would you use to compute a test? [You can use the already known results of the famous GMM formulas].

The hint is to start with the moments for unrestricted OLS time-series regressions, then impose the constraint between $a$ and $\lambda$, then estimate the restricted model.

For anyone that's interested, this question comes from John Cochrane's Asset Pricing (2005 revised edition) book, chapter 12 question 5.