I'm trying to understand the ROCA attack on RSA from Matus Nemec et al. but I'm stuck on how they goes from the constraint they have expressed has: $$f(x) = x ∗ M' + (65537^{a'} \mod M') \pmod p$$
To the real polynomial they feed to Coppersmith: $$f(x) = x + (M'^{-1} \mod N) * (65537^{a'} \mod M') \pmod N $$
Specifically how we can go from a polynomial on $\Bbb{Z}/p\Bbb{Z}$ to a polynomial on $\Bbb{Z}/N\Bbb{Z}$ ?
If we try with some real values and we don't use $M'$ but keep $M$: $ M = P_{39}\# \\ a = 1675986788854043070, k = 26617369843\\ \begin{align} p = & k * M + (65537^a\mod M) \\ = & 256311276376047921060658369130455899807 \\ & 39897944295144398331573049960294370089 \end{align} $
$q$ computed in the same way:
$ \begin{align} q = & 143831813798290446194046706419144504095 \\ & 59736324729154061604353910339692872653 \end{align} $
$k$ is obviously a root for
$f(x) = x ∗ M + (65537^{a} \mod M) \pmod p$
but, as far as I understand it's not for
$f(x) = x + (M^{-1} \mod N) * (65537^{a} \mod M) \pmod N $
With: $ \begin{align} M^{-1} \mod N = & 352742121330634029642965446346501378229514125041483823729 \\ & 9285302994689783984115678100687263685016509742529377 \\ & 76329363423355363257168553996151098868709524 \end{align} $
Where am I wrong on this?