Modular arithmetic : Subtraction and Simplification

I reading a book on the 2 of n escrow protocol. The mathematical algorithm continues as follows:

Given two equations

$x_2k_1 = (x_2(a x_1) + K)$ mod p

$x_1k_2 = (x_1(a x_2) + K)$ mod p

The book says by subtracting one from the other I end up with

$x_2k_1-x_1k_2=x_2K - x_1K$ mod p

I'm new to modular arithmetic and I'm seemingly doing something wrong somewhere. When I try this I end up cancelling everything out since however I manipulate it I end up with 0.

I've tried using the formula :

(A - B) mod C = (A mod C - B mod C) mod C

However I struggle to see how it applies exactly to this one since what's happening is essentially

(A + B) mod C - (A + B) mod C = 0

Any help would be appreciated.

• Are you sure it's $x_2(ax_1) + K$? It seems like it should be $x_2(ax_1 + K)$. – Michael Albanese Nov 23 '15 at 3:20
• @MichaelAlbanese Hi, yes that's correct. The algorithm in the University study program book is wrong. Thanks for that. – user3168961 Nov 28 '15 at 14:46
• Please edit your question to include this information. – Michael Albanese Nov 28 '15 at 14:47
• that is the answer to my question – user3168961 Nov 28 '15 at 17:56