About yhe fist interrogative sentence of the question:
why does it have to be negative?
read literally and with "it" relative to the quantities $A_i$ and $B_i$.
The second set of equations really is (or can be changed to) $k_i+{A_i}\,d+B_i\equiv0\pmod n$ where $A_i=-s_i^{-1}\,r_i\bmod n$ and $B_i=-s_i^{-1}\,H(m)\bmod n$. The $\bmod n$ are implied. Therefore, in this $A_i$ and $B_i$ are non-negative.
That's by definition of the $\bmod$ operator:
- $x\bmod n$ is the $z$ in range $[0,n)$ with $x\equiv z\pmod n$.
- $x^{-1}\bmod n$ is the $z$ in range $[0,n)$ with $x\,z\equiv1\pmod n$
- $-x^{-1}\,y\bmod n$ is the $z$ in range $[0,n)$ with $x\,z\equiv-y\pmod n$
Recall that $x\equiv z\pmod n$ is defined to mean that $x-z$ is a multiple of $n$.
We can rewrite the first equation as $s_i^{-1}\,r_i+s_i^{-1}\,H(m)\equiv k_i\pmod n$. The concept of lattice attack should still hold: If the lattice vector is small, basis reduction algorithm should generate the answer. What have I got wrong?
I vaguely conjecture the problem is that the lattice reduction code used wants an input in matrix form. We can match this by rewriting the equation as $s_i^{-1}\,r_i+s_i^{-1}\,H(m)+k'_i\equiv 0\pmod n$ with $k'_i=n-k_i$. But recall that the attack revolves around the feasibility of selecting, by a timing attack, the $i$ such that $k_i$ is small. The same selection method won't yield small $k'_i$; and I'm not sure a suitable method is even possible.