Equations of the form ∑iaixi=0 where the xi’s are integer unknowns are called linear Diophantine equations.
Their integer solutions can be computed using greatest common denominator (GCD) tricks.
In this post, we go over a few basic types of such equations and their integer solutions.
ax+by=t
Theorem: This equation has an integer solution ⇔gcd(a,b)∣t.
Proof (“⇒”): Assume an integer solution (x0,y0) exists when gcd(a,b)∤t.
Since gcd(a,b) divides both a and b, it divides any linear combination of them, including ax0+by0=t, which implies it divides t.
Contradiction.
Proof (“⇒”):
If gcd(a,b)=1, then an integer solution x0,y0 can be obtained using the Extended Eucliden algorithm, which finds (u,v) such that au+bv=gcd(a,b).
The solution is:
x0y0=u⋅t/gcd(a,b)=v⋅t/gcd(a,b)
This is because ax0+ay0=(au+bv)gcd(a,b)t=gcd(a,b)gcd(a,b)t=t.
Theorem: When gcd(a,b)∣t, if (x0,y0) is an integer solution to such an equation, then all integer solutions can be characterized as:
\begin{align}
x &= x_0 - k b/\gcd(a,b)\ y &= y_0 + k a/\gcd(a,b)
\end{align}
Here, k is an arbitrary integer and either a=0 or b=0 (since otherwise gcd(a,b)=0 and gcd(a,b)∣t implies t=0, which means all integers (x,y) are solutions).
Proof: First, one can easily verify that the proposed (x,y) are indeed solutions that satisfy ax+by=t:
The more difficult part is to argue that every solution has this form!
Assume a=0 since the other b=0 case is symmetric.
Assume (x,y) to be an integer solution and note that, since (x0,y0) is a solution, this means:
Note that since a=0, we are allowed to divide by a above.
ax+by=0
In this case, since x0=0 and y0=0 is one integer solution, all integer solutions are of the form:
xy=−kb/gcd(a,b)=ka/gcd(a,b)
ax+by+cz=t
Theorem: This equation has an integer solution ⇔gcd(a,b,c)∣t.
Proof (“⇒”):
Proceeds analogously to the ax+by=t case before.
Proof (“⇐”):
We will generalize the proof from the ax+by=t case before.
gcd(a,b,c)∣t⇒gcd(a,gcd(b,c))∣t⇒ax+gcd(b,c)w=t has an integer solution (x0,w0).
Let gcd(b,c)=d.
We know ∃(y0,z0) such that:
In a Catalano-Fiore vector commitment (VC)[^CF13e] of size n=3, collision resistance is implied by the fact that the following equation with (ℓ+1)-bit primes e1,e2,e3 does not have any ℓ-bit integer solutions:
e2e3v1+e1e3v2+e1e2v3=0
The only integer solutions given by the formula above are at least ℓ+1 bit wide:
The “⇐” direction proceeds by induction.
The statement P(n) being proved by induction is:
∀ai∈Z,gcd(a1,…,an)∣t⇒i∈[n]∑aixi=thas an integer solution.
We prove P(n) is true for all n≥2.
First, P(2) is clearly true as we’ve shown before.
Second, we must show P(n)⇒P(n+1).
This we do analogously to the proof for n=3 from before.
Let d=gcd(a1,…,an).
We know that gcd(a1,…,an+1)=gcd(d,an+1).
Since d∣t (because P(n) is true), this implies ∃ integers s0,w0 such that:
ds0+an+1w0=t⇔
Since P(n) is true, we know there exist integers s1,…,sn such that:
i∈[n]∑aisi=d
Replacing d in the previous equation, we get:
ds0+an+1w0i∈[n]∑aisis0+an+1w0=t⇔=t
Thus, a solution can be found by setting xi=s0si,∀i∈[n] and xn+1=w0.
[^Heff03]: Elementary Number Theory, by Jim Hefferson and W. Edwin Clark, 2004, [URL]
[^Cohe07]: Number Theory: Volume I: Tools and Diophantine Equations, by Cohen, H., 2007, [URL]
[^CF13e]: Vector Commitments and their Applications, by Dario Catalano and Dario Fiore, in Cryptology ePrint Archive, Report 2011/495, 2011, [URL]